TYPO3 CMS  TYPO3_7-6
TYPO3\CMS\Core\Utility\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

◆ calculateWithParentheses()

static TYPO3\CMS\Core\Utility\MathUtility::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 TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer\stdWrap_prioriCalc().

◆ calculateWithPriorityToAdditionAndSubtraction()

static TYPO3\CMS\Core\Utility\MathUtility::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.

◆ canBeInterpretedAsFloat()

static TYPO3\CMS\Core\Utility\MathUtility::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.

◆ canBeInterpretedAsInteger()

static TYPO3\CMS\Core\Utility\MathUtility::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 TYPO3\CMS\Backend\Form\Container\InlineControlContainer\__construct(), TYPO3\CMS\Core\Resource\ResourceCompressor\__construct(), TYPO3\CMS\Backend\Form\FormDataProvider\TcaInlineIsOnSymmetricSide\addData(), TYPO3\CMS\Backend\Form\FormDataProvider\DatabaseRecordTypeValue\addData(), TYPO3\CMS\Impexp\Import\addSingle(), TYPO3\CMS\Core\DataHandling\DataHandler\applyFiltersToValues(), TYPO3\CMS\Core\Utility\GeneralUtility\array2xml(), TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer\calcAge(), TYPO3\CMS\Recordlist\LinkHandler\PageLinkHandler\canHandleLink(), TYPO3\CMS\Backend\Controller\Wizard\TableController\changeFunc(), TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController\checkAndSetAlias(), TYPO3\CMS\Version\Hook\PreviewHook\checkForPreview(), TYPO3\CMS\Core\Resource\Security\FileMetadataPermissionsAspect\checkModifyAccessList(), TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController\checkPageForShortcutRedirect(), TYPO3\CMS\Core\DataHandling\DataHandler\checkValueForInline(), TYPO3\CMS\Core\DataHandling\DataHandler\clear_cacheCmd(), TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbBackend\clearPageCache(), TYPO3\CMS\Core\Html\HtmlParser\compileTagAttribs(), TYPO3\CMS\Core\Database\RelationHandler\convertPosNeg(), TYPO3\CMS\Scheduler\CronCommand\NormalizeCommand\convertRangeToListOfValues(), TYPO3\CMS\Core\DataHandling\DataHandler\copyRecord_procBasedOnFieldType(), TYPO3\CMS\Core\Resource\FileRepository\createDomainObject(), TYPO3\CMS\Core\DataHandling\DataHandler\dbAnalysisStoreExec(), TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer\detectLinkTypeFromLinkParameter(), TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController\determineIdIsHiddenPage(), TYPO3\CMS\Core\DataHandling\DataHandler\doesRecordExist(), TYPO3\CMS\Backend\Controller\EditDocumentController\doProcessData(), TYPO3\CMS\Feedit\FrontendEditPanel\editPanelLinkWrap(), TYPO3\CMS\Recordlist\LinkHandler\PageLinkHandler\expandPage(), TYPO3\CMS\Core\TypoScript\ExtendedTemplateService\ext_getObjTree(), TYPO3\CMS\Core\TypoScript\ExtendedTemplateService\ext_getTSCE_config(), TYPO3\CMS\Core\Resource\AbstractRepository\findByUid(), TYPO3\CMS\Core\Resource\FileRepository\findFileReferenceByUid(), TYPO3\CMS\Rsaauth\Storage\SplitStorage\get(), TYPO3\CMS\Backend\Controller\EditDocumentController\getButtons(), TYPO3\CMS\Core\DataHandling\DataHandler\getCheckModifyAccessListHookObjects(), TYPO3\CMS\Core\Resource\AbstractFile\getCombinedIdentifier(), TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer\getData(), TYPO3\CMS\Backend\Form\Element\ImageManipulationElement\getFile(), TYPO3\CMS\Backend\Utility\BackendUtility\getFlexFormDS(), TYPO3\CMS\Extbase\Service\ImageService\getImageFromSourceString(), TYPO3\CMS\CssStyledContent\Controller\CssStyledContentController\getImgColumnWidths(), TYPO3\CMS\Backend\Controller\FormInlineAjaxController\getInlineExpandCollapseStateArrayForTableUid(), TYPO3\CMS\Workspaces\Service\StagesService\getNextStage(), TYPO3\CMS\Backend\Utility\BackendUtility\getNoRecordTitle(), TYPO3\CMS\Workspaces\Service\StagesService\getNotificationMode(), TYPO3\CMS\Core\Resource\ResourceFactory\getObjectFromCombinedIdentifier(), TYPO3\CMS\Backend\Utility\BackendUtility\getPidForModTSconfig(), TYPO3\CMS\Workspaces\Service\StagesService\getPrevStage(), TYPO3\CMS\Extbase\Reflection\ObjectAccess\getPropertyInternal(), TYPO3\CMS\Workspaces\Service\StagesService\getPropertyOfCurrentWorkspaceStage(), TYPO3\CMS\Backend\Search\LiveSearch\LiveSearch\getRecordTitlePrep(), TYPO3\CMS\Backend\Utility\BackendUtility\getRecordTitlePrep(), TYPO3\CMS\Backend\Utility\BackendUtility\getTSconfig_pidValue(), TYPO3\CMS\Install\Controller\Action\Tool\CleanUp\getTypo3TempStatistics(), TYPO3\CMS\Core\Database\SoftReferenceIndex\getTypoLinkParts(), TYPO3\CMS\Backend\Form\Wizard\ImageManipulationWizard\getWizardAction(), TYPO3\CMS\Backend\Controller\BackendController\handlePageEditing(), TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer\imageLinkWrap(), TYPO3\CMS\Backend\Controller\Wizard\AddController\init(), TYPO3\CMS\Frontend\Controller\ShowImageController\initialize(), TYPO3\CMS\Backend\Clipboard\Clipboard\initializeClipboard(), TYPO3\CMS\Frontend\Http\RequestHandler\initializeOutputCompression(), TYPO3\CMS\Core\Core\Bootstrap\initializeOutputCompression(), TYPO3\CMS\Backend\Backend\ToolbarItems\ShortcutToolbarItem\initShortcuts(), TYPO3\CMS\Core\DataHandling\DataHandler\insertUpdateDB_preprocessBasedOnFieldType(), TYPO3\CMS\Frontend\Page\PageGenerator\isAllowedLinkVarValue(), TYPO3\CMS\Backend\Http\BackendModuleRequestHandler\isDispatchedModule(), TYPO3\CMS\Core\Database\RelationHandler\isOnSymmetricSide(), TYPO3\CMS\Core\TypoScript\TemplateService\linkData(), TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer\listNum(), TYPO3\CMS\Scheduler\Scheduler\log(), TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer\mailto_makelinks(), TYPO3\CMS\Backend\Controller\PageLayoutController\main(), TYPO3\CMS\Backend\Controller\Wizard\EditController\mainAction(), TYPO3\CMS\Backend\Controller\PageLayoutController\makeButtons(), TYPO3\CMS\Backend\Search\LiveSearch\LiveSearch\makeQuerySearchByTable(), TYPO3\CMS\Frontend\ContentObject\Menu\AbstractMenuContentObject\menuTypoLink(), TYPO3\CMS\Form\Domain\Builder\ElementBuilder\moveAllOtherUserdefinedPropertiesToAdditionalArguments(), TYPO3\CMS\Core\DataHandling\DataHandler\moveL10nOverlayRecords(), TYPO3\CMS\Scheduler\CronCommand\NormalizeCommand\normalizeIntegerField(), TYPO3\CMS\Form\Domain\Builder\ElementBuilder\overlayUserdefinedHtmlAttributeValues(), TYPO3\CMS\Frontend\Plugin\AbstractPlugin\pi_getFFvalueFromSheetArray(), TYPO3\CMS\Frontend\Plugin\AbstractPlugin\pi_isOnlyFields(), TYPO3\CMS\Frontend\ContentObject\Menu\AbstractMenuContentObject\prepareMenuItemsForKeywordsMenu(), TYPO3\CMS\Frontend\ContentObject\Menu\AbstractMenuContentObject\prepareMenuItemsForRootlineMenu(), TYPO3\CMS\Frontend\ContentObject\Menu\AbstractMenuContentObject\prepareMenuItemsForUpdatedMenu(), TYPO3\CMS\Backend\Form\FormDataProvider\AbstractItemProvider\processForeignTableClause(), TYPO3\CMS\Impexp\Import\processSoftReferences_substTokens(), TYPO3\CMS\Rsaauth\Storage\SplitStorage\put(), TYPO3\CMS\Core\Database\RelationHandler\readList(), TYPO3\CMS\Scheduler\CronCommand\NormalizeCommand\reduceListOfValuesByStepValue(), TYPO3\CMS\Core\Resource\Rendering\YouTubeRenderer\render(), TYPO3\CMS\Backend\Form\Container\InlineRecordContainer\renderForeignRecordHeader(), TYPO3\CMS\InfoPagetsconfig\Controller\InfoPageTyposcriptConfigController\renderList(), TYPO3\CMS\Tstemplate\Controller\TypoScriptTemplateModuleController\renderList(), TYPO3\CMS\Fluid\ViewHelpers\Format\DateViewHelper\renderStatic(), TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer\replacement(), TYPO3\CMS\Core\Resource\ResourceFactory\retrieveFileOrFolderObject(), TYPO3\CMS\Workspaces\Service\WorkspaceService\selectAllVersionsFromPages(), TYPO3\CMS\Recycler\Domain\Model\DeletedRecords\setData(), TYPO3\CMS\Backend\Form\FormDataProvider\DatabaseRowInitializeNew\setPid(), TYPO3\CMS\Core\DataHandling\DataHandler\setTSconfigPermissions(), TYPO3\CMS\Core\Database\SoftReferenceIndex\setTypoLinkPartsElement(), TYPO3\CMS\Core\TypoScript\TemplateService\sortedKeyList(), TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer\splitObj(), TYPO3\CMS\Core\Html\RteHtmlParser\TS_links_rte(), TYPO3\CMS\Core\DataHandling\DataHandler\updateFlexFormData(), TYPO3\CMS\Core\Resource\ProcessedFile\updateProperties(), TYPO3\CMS\Scheduler\Task\FileStorageIndexingAdditionalFieldProvider\validateAdditionalFields(), TYPO3\CMS\Scheduler\Task\FileStorageExtractionAdditionalFieldProvider\validateAdditionalFields(), TYPO3\CMS\Tstemplate\Controller\TypoScriptTemplateObjectBrowserModuleFunctionController\verify_TSobjects(), TYPO3\CMS\Core\Database\RelationHandler\writeForeignField(), TYPO3\CMS\Impexp\Import\writeRecords_records_order(), and TYPO3\CMS\Core\Utility\GeneralUtility\xml2arrayProcess().

◆ convertToPositiveInteger()

static TYPO3\CMS\Core\Utility\MathUtility::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 TYPO3\CMS\Backend\Controller\EditDocumentController\generatePreviewCode(), TYPO3\CMS\Backend\Search\LiveSearch\LiveSearch\setLimitCount(), and TYPO3\CMS\Backend\Search\LiveSearch\LiveSearch\setStartCount().

◆ forceIntegerInRange()

static TYPO3\CMS\Core\Utility\MathUtility::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 TYPO3\CMS\Reports\Status\__construct(), TYPO3\CMS\Backend\Controller\BackendController\__construct(), TYPO3\CMS\Backend\Form\FormDataProvider\AbstractItemProvider\addItemsFromFolder(), TYPO3\CMS\Impexp\Controller\ImportExportController\addRecordsForPid(), TYPO3\CMS\IndexedSearch\Indexer\bodyDescription(), TYPO3\CMS\Core\Html\HtmlParser\checkTagTypeCounts(), TYPO3\CMS\Lowlevel\CleanerCommand\cli_printInfo(), TYPO3\CMS\Core\Imaging\GraphicalFunctions\convertColor(), TYPO3\CMS\Core\Utility\VersionNumberUtility\convertVersionsStringToVersionNumbers(), TYPO3\CMS\Core\Utility\VersionNumberUtility\convertVersionStringToArray(), TYPO3\CMS\Core\Imaging\GraphicalFunctions\copyGifOntoGif(), TYPO3\CMS\IndexedSearch\Hook\CrawlerHook\crawler_execute_type1(), TYPO3\CMS\Core\Resource\Service\MagicImageService\createMagicImage(), TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository\doSearch(), TYPO3\CMS\Core\TypoScript\ExtendedTemplateService\ext_procesInput(), TYPO3\CMS\IndexedSearch\FileContentParser\fileContentParts(), TYPO3\CMS\Backend\Form\Element\NoneElement\formatValue(), TYPO3\CMS\IndexedSearch\Hook\CrawlerHook\generateNextIndexingTime(), TYPO3\CMS\Impexp\Controller\ImportExportController\getButtons(), TYPO3\CMS\IndexedSearch\Controller\SearchFormController\getDisplayResults(), TYPO3\CMS\CssStyledContent\Controller\CssStyledContentController\getImgColumnWidths(), TYPO3\CMS\Core\Utility\VersionNumberUtility\getNumericTypo3Version(), TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer\getQuery(), TYPO3\CMS\IndexedSearch\Controller\SearchFormController\getResultRows(), TYPO3\CMS\Core\Imaging\GraphicalFunctions\getTextScalFactor(), TYPO3\CMS\Core\Imaging\GraphicalFunctions\IMparams(), TYPO3\CMS\Core\Imaging\GraphicalFunctions\IMreduceColors(), TYPO3\CMS\Backend\Controller\Wizard\TableController\init(), TYPO3\CMS\Backend\Controller\SimpleDataHandlerController\init(), TYPO3\CMS\Core\Imaging\GraphicalFunctions\init(), TYPO3\CMS\IndexedSearch\Indexer\init(), TYPO3\CMS\IndexedSearch\Controller\SearchController\initialize(), TYPO3\CMS\IndexedSearch\Controller\SearchFormController\initialize(), TYPO3\CMS\Backend\Clipboard\Clipboard\initializeClipboard(), TYPO3\CMS\Filelist\Controller\FileListController\initializeIndexAction(), TYPO3\CMS\Backend\Form\FormDataProvider\TcaInlineConfiguration\initializeMinMaxItems(), TYPO3\CMS\Backend\Controller\PageTreeNavigationController\initializeTemporaryDBmount(), TYPO3\CMS\IndexedSearch\FileContentParser\initParser(), TYPO3\CMS\Core\Utility\GeneralUtility\initSysLog(), TYPO3\CMS\Core\Imaging\GraphicalFunctions\inputLevels(), TYPO3\CMS\Core\Authentication\AbstractUserAuthentication\ipLockClause_remoteIPNumber(), TYPO3\CMS\IndexedSearch\Controller\SearchController\loadSettings(), TYPO3\CMS\IndexedSearch\Controller\SearchFormController\loadSettings(), TYPO3\CMS\Lowlevel\DeletedRecordsCommand\main(), TYPO3\CMS\Lowlevel\CleanFlexformCommand\main(), TYPO3\CMS\Lowlevel\VersionsCommand\main(), TYPO3\CMS\Backend\Controller\File\CreateFolderController\main(), TYPO3\CMS\Backend\View\ThumbnailView\main(), TYPO3\CMS\Backend\Controller\PageLayoutController\main(), TYPO3\CMS\Core\Imaging\GraphicalFunctions\makeBox(), TYPO3\CMS\Core\Imaging\GraphicalFunctions\makeOutline(), TYPO3\CMS\IndexedSearch\Controller\SearchController\makeRating(), TYPO3\CMS\IndexedSearch\Controller\SearchFormController\makeRating(), TYPO3\CMS\Core\Imaging\GraphicalFunctions\makeShadow(), TYPO3\CMS\Core\Imaging\GraphicalFunctions\makeText(), TYPO3\CMS\IndexedSearch\Controller\SearchController\markupSWpartsOfString(), TYPO3\CMS\IndexedSearch\Controller\SearchFormController\markupSWpartsOfString(), TYPO3\CMS\Core\Utility\GeneralUtility\modifyHTMLColor(), TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser\modifyHTMLColor(), TYPO3\CMS\Core\Imaging\GraphicalFunctions\output(), TYPO3\CMS\Core\Imaging\GraphicalFunctions\outputLevels(), TYPO3\CMS\Frontend\Plugin\AbstractPlugin\pi_exec_query(), TYPO3\CMS\Frontend\Plugin\AbstractPlugin\pi_getPidList(), TYPO3\CMS\Frontend\Plugin\AbstractPlugin\pi_list_browseresults(), TYPO3\CMS\Frontend\ContentObject\Menu\AbstractMenuContentObject\prepareMenuItemsForKeywordsMenu(), TYPO3\CMS\Frontend\ContentObject\Menu\AbstractMenuContentObject\prepareMenuItemsForUpdatedMenu(), TYPO3\CMS\Core\Resource\Processing\LocalPreviewHelper\preProcessConfiguration(), TYPO3\CMS\Backend\Tree\View\PagePositionMap\printRecordMap(), TYPO3\CMS\Version\Hook\DataHandlerHook\processCmdmap(), TYPO3\CMS\Frontend\Controller\ShowImageController\processImage(), TYPO3\CMS\Core\Utility\VersionNumberUtility\raiseVersionNumber(), TYPO3\CMS\Backend\Form\FormDataProvider\TcaTypesShowitem\removeFieldsByBitmaskExcludeBits(), TYPO3\CMS\Backend\Form\Element\NoneElement\render(), TYPO3\CMS\Frontend\ContentObject\FilesContentObject\render(), TYPO3\CMS\Rsaauth\Form\Element\RsaInputElement\render(), TYPO3\CMS\Backend\Form\Element\SelectMultipleSideBySideElement\render(), TYPO3\CMS\Backend\Form\Element\TextElement\render(), TYPO3\CMS\Core\Resource\Rendering\YouTubeRenderer\render(), TYPO3\CMS\T3editor\Form\Element\T3editorElement\render(), TYPO3\CMS\CssStyledContent\Controller\CssStyledContentController\render_table(), TYPO3\CMS\IndexedSearch\Controller\SearchFormController\renderPagination(), TYPO3\CMS\Backend\Form\Container\InlineControlContainer\renderPossibleRecordsSelectorTypeSelect(), TYPO3\CMS\Backend\Form\Element\SelectSingleBoxElement\renderSelectElement(), TYPO3\CMS\IndexedSearch\ViewHelpers\PageBrowsingViewHelper\renderStatic(), TYPO3\CMS\Form\PostProcess\MailPostProcessor\setPriority(), TYPO3\CMS\Core\Messaging\AbstractMessage\setSeverity(), TYPO3\CMS\Recordlist\Browser\DatabaseBrowser\setTemporaryDbMounts(), TYPO3\CMS\Core\Imaging\GraphicalFunctions\v5_blur(), TYPO3\CMS\Core\Imaging\GraphicalFunctions\v5_sharpen(), TYPO3\CMS\SysAction\ActionTask\viewRecordList(), and TYPO3\CMS\Frontend\ContentObject\Menu\JavaScriptMenuContentObject\writeMenu().

◆ isIntegerInRange()

static TYPO3\CMS\Core\Utility\MathUtility::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 TYPO3\CMS\Extensionmanager\ViewHelpers\Typo3DependencyViewHelper\isVersionSuitable(), TYPO3\CMS\Fluid\ViewHelpers\Be\InfoboxViewHelper\renderStatic(), and TYPO3\CMS\Scheduler\Task\FileStorageExtractionAdditionalFieldProvider\validateAdditionalFields().