TYPO3CMS  8
 All Classes Namespaces Files Functions Variables Pages
MathUtility Class Reference

Static Public Member Functions

static forceIntegerInRange ($theInt, $min, $max=2000000000, $defaultValue=0)
 
static convertToPositiveInteger ($theInt)
 
static canBeInterpretedAsInteger ($var)
 
static canBeInterpretedAsFloat ($var)
 
static calculateWithPriorityToAdditionAndSubtraction ($string)
 
static calculateWithParentheses ($string)
 
static isIntegerInRange ($value, $minimum, $maximum)
 

Detailed Description

Class with helper functions for mathematical calculations

Definition at line 20 of file MathUtility.php.

Member Function Documentation

static calculateWithParentheses (   $string)
static

Calculates the input with parenthesis levels

Parameters
string$stringInput string, eg "(123 + 456) / 789 - 4
Returns
int Calculated value. Or error string.
See also
calculateWithPriorityToAdditionAndSubtraction(), ::stdWrap()

Definition at line 170 of file MathUtility.php.

Referenced by ContentObjectRenderer\stdWrap_prioriCalc().

static calculateWithPriorityToAdditionAndSubtraction (   $string)
static

Calculates the input by +,-,*,/,%,^ with priority to + and -

Parameters
string$stringInput string, eg "123 + 456 / 789 - 4
Returns
int Calculated value. Or error string.
See also
::calculateWithParentheses()

Definition at line 111 of file MathUtility.php.

static canBeInterpretedAsFloat (   $var)
static

Tests if the input can be interpreted as float.

Note: Float casting from objects or arrays is considered undefined and thus will return false.

See also
http://www.php.net/manual/en/language.types.float.php, section "Formally" for the notation
Parameters
mixed$varAny input variable to test
Returns
bool Returns TRUE if string is a float

Definition at line 90 of file MathUtility.php.

static canBeInterpretedAsInteger (   $var)
static

Tests if the input can be interpreted as integer.

Note: Integer casting from objects or arrays is considered undefined and thus will return false.

See also
http://php.net/manual/en/language.types.integer.php#language.types.integer.casting.from-other
Parameters
mixed$varAny input variable to test
Returns
bool Returns TRUE if string is an integer

Definition at line 73 of file MathUtility.php.

Referenced by ResourceCompressor\__construct(), TcaInlineIsOnSymmetricSide\addData(), DatabaseRecordTypeValue\addData(), Import\addSingle(), GeneralUtility\array2xml(), TableController\changeFunc(), TypoScriptFrontendController\checkAndSetAlias(), FileMetadataPermissionsAspect\checkModifyAccessList(), DataHandler\checkValueForInline(), DataHandler\clear_cacheCmd(), Typo3DbBackend\clearPageCache(), NormalizeCommand\convertRangeToListOfValues(), DataHandler\dbAnalysisStoreExec(), TypoScriptFrontendController\determineIdIsHiddenPage(), DataHandler\doesRecordExist(), FrontendEditPanel\editPanelLinkWrap(), DeletedRecordsCommand\execute(), CleanFlexFormsCommand\execute(), ExtendedTemplateService\ext_getObjTree(), ExtendedTemplateService\ext_getTSCE_config(), ArrayUtility\filterAndSortByNumericKeys(), AbstractRepository\findByUid(), FileRepository\findFileReferenceByUid(), SplitStorage\get(), EditDocumentController\getButtons(), AbstractFile\getCombinedIdentifier(), FlexFormTools\getDataStructureIdentifierFromRecord(), ImageManipulationElement\getFile(), BackendUtility\getFlexFormDS(), ImageService\getImageFromSourceString(), FormInlineAjaxController\getInlineExpandCollapseStateArrayForTableUid(), InfoPageTyposcriptConfigController\getList(), StagesService\getNextStage(), BackendUtility\getPidForModTSconfig(), StagesService\getPrevStage(), StagesService\getPropertyOfCurrentWorkspaceStage(), PageLinkHandler\getRecordsOnExpandedPage(), LiveSearch\getRecordTitlePrep(), BackendUtility\getRecordTitlePrep(), BackendUtility\getTSconfig_pidValue(), CleanUp\getTypo3TempStatistics(), SoftReferenceIndex\getTypoLinkParts(), ImageManipulationWizard\getWizardAction(), RemoteServer\getWorkspaceInfos(), BackendController\handlePageEditing(), ContentObjectRenderer\imageLinkWrap(), AddController\init(), ShowImageController\initialize(), Clipboard\initializeClipboard(), RequestHandler\initializeOutputCompression(), Bootstrap\initializeOutputCompression(), ShortcutToolbarItem\initShortcuts(), DataHandler\insertUpdateDB_preprocessBasedOnFieldType(), PageGenerator\isAllowedLinkVarValue(), RelationHandler\isOnSymmetricSide(), TemplateService\linkData(), ContentObjectRenderer\listNum(), PageLayoutController\makeButtons(), LiveSearch\makeQuerySearchByTable(), AbstractMenuContentObject\menuTypoLink(), NormalizeCommand\normalizeIntegerField(), AbstractPlugin\pi_getFFvalueFromSheetArray(), AbstractPlugin\pi_isOnlyFields(), AbstractMenuContentObject\prepareMenuItemsForKeywordsMenu(), AbstractMenuContentObject\prepareMenuItemsForRootlineMenu(), AbstractMenuContentObject\prepareMenuItemsForUpdatedMenu(), AbstractItemProvider\processForeignTableClause(), Import\processSoftReferences_substTokens(), SplitStorage\put(), RelationHandler\readList(), NormalizeCommand\reduceListOfValuesByStepValue(), InputTextElement\render(), TypoScriptTemplateModuleController\renderList(), DateViewHelper\renderStatic(), ContentObjectRenderer\replacement(), LegacyLinkNotationConverter\resolve(), LegacyLinkNotationConverter\resolvePageRelatedParameters(), ResourceFactory\retrieveFileOrFolderObject(), ActionHandler\saveLanguageSelection(), SuggestWizardController\searchAction(), WorkspaceService\selectAllVersionsFromPages(), ActionHandler\sentCollectionToStage(), DeletedRecords\setData(), DatabaseRowInitializeNew\setPid(), DataHandler\setTSconfigPermissions(), SoftReferenceIndex\setTypoLinkPartsElement(), ContentObjectRenderer\splitObj(), FileLinkHandlerTest\splitParametersToUnifiedIdentifierForFiles(), RteHtmlParser\TS_links_rte(), DataHandler\updateFlexFormData(), ProcessedFile\updateProperties(), FileStorageIndexingAdditionalFieldProvider\validateAdditionalFields(), FileStorageExtractionAdditionalFieldProvider\validateAdditionalFields(), AbstractHandler\validateLanguageParameter(), RelationHandler\writeForeignField(), Import\writeRecords_records_order(), and GeneralUtility\xml2arrayProcess().

static convertToPositiveInteger (   $theInt)
static

Returns $theInt if it is greater than zero, otherwise returns zero.

Parameters
int$theIntInteger string to process
Returns
int

Definition at line 55 of file MathUtility.php.

Referenced by EditDocumentController\generatePreviewCode(), LiveSearch\setLimitCount(), and LiveSearch\setStartCount().

static forceIntegerInRange (   $theInt,
  $min,
  $max = 2000000000,
  $defaultValue = 0 
)
static

Forces the integer $theInt into the boundaries of $min and $max. If the $theInt is FALSE then the $defaultValue is applied.

Parameters
int$theIntInput value
int$minLower limit
int$maxHigher limit
int$defaultValueDefault value if input is FALSE.
Returns
int The input value forced into the boundaries of $min and $max

Definition at line 31 of file MathUtility.php.

Referenced by Status\__construct(), BackendController\__construct(), FileList\__construct(), AbstractItemProvider\addItemsFromFolder(), ImportExportController\addRecordsForPid(), Indexer\bodyDescription(), CleanerCommand\cli_printInfo(), GraphicalFunctions\convertColor(), VersionNumberUtility\convertVersionsStringToVersionNumbers(), VersionNumberUtility\convertVersionStringToArray(), GraphicalFunctions\copyGifOntoGif(), CrawlerHook\crawler_execute_type1(), MagicImageService\createMagicImage(), IndexSearchRepository\doSearch(), DeletedRecordsCommand\execute(), CleanFlexFormsCommand\execute(), ExtendedTemplateService\ext_procesInput(), FileContentParser\fileContentParts(), NoneElement\formatValue(), CrawlerHook\generateNextIndexingTime(), SearchFormController\getDisplayResults(), VersionNumberUtility\getNumericTypo3Version(), SearchFormController\getResultRows(), GraphicalFunctions\getTextScalFactor(), GraphicalFunctions\IMparams(), GraphicalFunctions\IMreduceColors(), TableController\init(), SimpleDataHandlerController\init(), GraphicalFunctions\init(), Indexer\init(), SearchFormController\initialize(), Clipboard\initializeClipboard(), TcaInlineConfiguration\initializeMinMaxItems(), FileContentParser\initParser(), GeneralUtility\initSysLog(), GraphicalFunctions\inputLevels(), AbstractUserAuthentication\ipLockClause_remoteIPNumber(), SearchController\loadSettings(), SearchFormController\loadSettings(), VersionsCommand\main(), CreateFolderController\main(), GraphicalFunctions\makeBox(), GraphicalFunctions\makeOutline(), SearchController\makeRating(), SearchFormController\makeRating(), GraphicalFunctions\makeShadow(), GraphicalFunctions\makeText(), SearchController\markupSWpartsOfString(), SearchFormController\markupSWpartsOfString(), TypoScriptParser\modifyHTMLColor(), GraphicalFunctions\output(), GraphicalFunctions\outputLevels(), AbstractPlugin\pi_exec_query(), AbstractPlugin\pi_getPidList(), AbstractPlugin\pi_list_browseresults(), AbstractMenuContentObject\prepareMenuItemsForKeywordsMenu(), AbstractMenuContentObject\prepareMenuItemsForUpdatedMenu(), PagePositionMap\printRecordMap(), LocalPreviewHelper\process(), ShowImageController\processImage(), VersionNumberUtility\raiseVersionNumber(), TcaTypesShowitem\removeFieldsByBitmaskExcludeBits(), NoneElement\render(), InputColorPickerElement\render(), FilesContentObject\render(), RsaInputElement\render(), InputTextElement\render(), SelectMultipleSideBySideElement\render(), TextElement\render(), T3editorElement\render(), CssStyledContentController\render_table(), SearchFormController\renderPagination(), InlineControlContainer\renderPossibleRecordsSelectorTypeSelect(), SelectSingleBoxElement\renderSelectElement(), PageBrowsingViewHelper\renderStatic(), AbstractMessage\setSeverity(), GraphicalFunctions\v5_blur(), GraphicalFunctions\v5_sharpen(), ActionTask\viewRecordList(), and JavaScriptMenuContentObject\writeMenu().

static isIntegerInRange (   $value,
  $minimum,
  $maximum 
)
static

Checks whether the given number $value is an integer in the range [$minimum;$maximum]

Parameters
int$valueInteger value to check
int$minimumLower boundary of the range
int$maximumUpper boundary of the range
Returns
bool

Definition at line 200 of file MathUtility.php.

Referenced by Typo3DependencyViewHelper\isVersionSuitable(), InfoboxViewHelper\renderStatic(), and FileStorageExtractionAdditionalFieldProvider\validateAdditionalFields().