TYPO3 CMS  TYPO3_6-2
TYPO3\CMS\Core\Utility\MathUtility Class Reference
Inheritance diagram for TYPO3\CMS\Core\Utility\MathUtility:
t3lib_utility_Math

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

This file is part of the TYPO3 CMS project.

It is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, either version 2 of the License, or any later version.

For the full copyright and license information, please read the LICENSE.txt file that was distributed with this source code.

The TYPO3 project - inspiring people to share! Class with helper functions for mathematical calculations

Author
Susanne Moog typo3.nosp@m.@sus.nosp@m.anne-.nosp@m.moog.nosp@m..de

Definition at line 21 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
integer Calculated value. Or error string.
See also
calculateWithPriorityToAdditionAndSubtraction(), ::stdWrap()

Definition at line 166 of file MathUtility.php.

Referenced by TYPO3\CMS\Core\Tests\Unit\Utility\MathUtilityTest\calculateWithParenthesesCorrectlyCalculatesExpression(), and 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
integer Calculated value. Or error string.
See also
::calculateWithParentheses()

Definition at line 108 of file MathUtility.php.

Referenced by TYPO3\CMS\Core\Tests\Unit\Utility\MathUtilityTest\calculateWithPriorityToAdditionAndSubtractionCorrectlyCalculatesExpression().

◆ 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
boolean Returns TRUE if string is a float

Definition at line 88 of file MathUtility.php.

Referenced by TYPO3\CMS\Core\Tests\Unit\Utility\MathUtilityTest\canBeInterpretedAsFloatReturnsFalse(), and TYPO3\CMS\Core\Tests\Unit\Utility\MathUtilityTest\canBeInterpretedAsFloatReturnsTrue().

◆ 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
boolean Returns TRUE if string is an integer

Definition at line 72 of file MathUtility.php.

Referenced by TYPO3\CMS\Core\Resource\ResourceCompressor\__construct(), TYPO3\CMS\Frontend\ContentObject\SearchResultContentObject\__construct(), TYPO3\CMS\Core\DataHandling\DataHandler\applyFiltersToValues(), TYPO3\CMS\Core\Utility\GeneralUtility\array2xml(), TYPO3\CMS\Core\Tests\Unit\Utility\MathUtilityTest\canBeInterpretedAsIntegerReturnsFalse(), TYPO3\CMS\Core\Tests\Unit\Utility\MathUtilityTest\canBeInterpretedAsIntegerReturnsTrue(), TYPO3\CMS\Backend\Form\Element\InlineElement\checkAccess(), TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController\checkAndSetAlias(), TYPO3\CMS\Core\Resource\Security\FileMetadataPermissionsAspect\checkModifyAccessList(), TYPO3\CMS\Core\DataHandling\DataHandler\checkValue_inline(), TYPO3\CMS\Core\DataHandling\DataHandler\clear_cacheCmd(), TYPO3\CMS\Core\Html\HtmlParser\compileTagAttribs(), TYPO3\CMS\Core\Database\RelationHandler\convertPosNeg(), TYPO3\CMS\Scheduler\CronCommand\NormalizeCommand\convertRangeToListOfValues(), TYPO3\CMS\Backend\Toolbar\ShortcutToolbarItem\createAjaxShortcut(), TYPO3\CMS\Backend\Form\Element\InlineElement\createNewRecord(), TYPO3\CMS\Core\DataHandling\DataHandler\dbAnalysisStoreExec(), TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController\determineIdIsHiddenPage(), TYPO3\CMS\Core\DataHandling\DataHandler\doesRecordExist(), TYPO3\CMS\Feedit\FrontendEditPanel\editPanelLinkWrap(), TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher\evaluateConditionCommon(), TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer\fillInMarkerArray(), TYPO3\CMS\Core\Resource\FileRepository\findBySha1Hash(), TYPO3\CMS\Core\Resource\AbstractRepository\findByUid(), TYPO3\CMS\Core\Resource\FileRepository\findFileReferenceByUid(), TYPO3\CMS\Backend\Form\FormEngine\getAvailableLanguages(), TYPO3\CMS\Backend\Controller\EditDocumentController\getButtons(), TYPO3\CMS\Backend\Controller\PageLayoutController\getButtons(), TYPO3\CMS\Core\DataHandling\DataHandler\getCheckModifyAccessListHookObjects(), TYPO3\CMS\Core\Resource\AbstractFile\getCombinedIdentifier(), TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer\getData(), TYPO3\CMS\Backend\Form\FormEngine\getExcludeElements(), TYPO3\CMS\Backend\Utility\BackendUtility\getFlexFormDS(), TYPO3\CMS\Extbase\Service\ImageService\getImageFromSourceString(), TYPO3\CMS\CssStyledContent\Controller\CssStyledContentController\getImgColumnWidths(), TYPO3\CMS\Backend\Form\Element\InlineElement\getNewRecordPid(), TYPO3\CMS\Backend\Utility\BackendUtility\getNoRecordTitle(), TYPO3\CMS\Core\Resource\ResourceFactory\getObjectFromCombinedIdentifier(), TYPO3\CMS\Backend\Utility\BackendUtility\getPidForModTSconfig(), TYPO3\CMS\Extbase\Reflection\ObjectAccess\getPropertyInternal(), TYPO3\CMS\Backend\Search\LiveSearch\LiveSearch\getRecordTitlePrep(), TYPO3\CMS\Backend\Utility\BackendUtility\getRecordTitlePrep(), TYPO3\CMS\Backend\Form\Element\InlineElement\getSingleField_typeInline(), TYPO3\CMS\Backend\Utility\BackendUtility\getTSconfig_pidValue(), TYPO3\CMS\Install\Controller\Action\Tool\CleanUp\getTypo3TempStatistics(), TYPO3\CMS\Core\Database\SoftReferenceIndex\getTypoLinkParts(), TYPO3\CMS\Backend\Controller\BackendController\handlePageEditing(), TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer\imageLinkWrap(), TYPO3\CMS\Backend\Controller\Wizard\AddController\init(), TYPO3\CMS\Frontend\Controller\ShowImageController\init(), TYPO3\CMS\Backend\Clipboard\Clipboard\initializeClipboard(), TYPO3\CMS\Core\Core\Bootstrap\initializeOutputCompression(), TYPO3\CMS\Backend\Toolbar\ShortcutToolbarItem\initShortcuts(), TYPO3\CMS\Core\DataHandling\DataHandler\insertNewCopyVersion(), TYPO3\CMS\Core\DataHandling\DataHandler\insertUpdateDB_preprocessBasedOnFieldType(), TYPO3\CMS\Backend\Form\FormEngine\isNewRecord(), TYPO3\CMS\Core\Database\RelationHandler\isOnSymmetricSide(), TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer\listNum(), TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer\mailto_makelinks(), TYPO3\CMS\Backend\Controller\Wizard\EditController\main(), TYPO3\CMS\Backend\Controller\PageLayoutController\main(), TYPO3\CMS\Backend\Search\LiveSearch\LiveSearch\makeQuerySearchByTable(), TYPO3\CMS\Frontend\ContentObject\Menu\AbstractMenuContentObject\menuTypoLink(), TYPO3\CMS\Core\DataHandling\DataHandler\moveL10nOverlayRecords(), TYPO3\CMS\Scheduler\CronCommand\NormalizeCommand\normalizeIntegerField(), TYPO3\CMS\Core\Database\RelationHandler\readList(), TYPO3\CMS\Scheduler\CronCommand\NormalizeCommand\reduceListOfValuesByStepValue(), TYPO3\CMS\Frontend\ContentObject\MediaContentObject\render(), TYPO3\CMS\Frontend\ContentObject\ImageTextContentObject\render(), TYPO3\CMS\Frontend\ContentObject\FormContentObject\render(), TYPO3\CMS\Fluid\ViewHelpers\Format\DateViewHelper\render(), TYPO3\CMS\Backend\Form\Element\InlineElement\renderForeignRecord(), TYPO3\CMS\Backend\Form\Element\InlineElement\renderForeignRecordHeaderControl(), TYPO3\CMS\Backend\Form\Element\SuggestElement\renderSuggestSelector(), TYPO3\CMS\Backend\Form\FormEngine\renderWizards(), TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer\replacement(), TYPO3\CMS\Core\Resource\ResourceFactory\retrieveFileOrFolderObject(), TYPO3\CMS\Recycler\Domain\Model\DeletedRecords\setData(), TYPO3\CMS\Core\DataHandling\DataHandler\setTSconfigPermissions(), TYPO3\CMS\Core\Database\SoftReferenceIndex\setTypoLinkPartsElement(), TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer\splitObj(), TYPO3\CMS\Frontend\ContentObject\Menu\AbstractMenuContentObject\start(), TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer\TCAlookup(), 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\Core\Database\RelationHandler\writeForeignField(), and TYPO3\CMS\Core\Utility\GeneralUtility\xml2arrayProcess().

◆ convertToPositiveInteger()

static TYPO3\CMS\Core\Utility\MathUtility::convertToPositiveInteger (   $theInt)
static

◆ 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
integer$theIntInput value
integer$minLower limit
integer$maxHigher limit
integer$defaultValueDefault value if input is FALSE.
Returns
integer The input value forced into the boundaries of $min and $max

Definition at line 32 of file MathUtility.php.

Referenced by TYPO3\CMS\Reports\Status\__construct(), TYPO3\CMS\Frontend\ContentObject\SearchResultContentObject\__construct(), TYPO3\CMS\Impexp\Controller\ImportExportController\addRecordsForPid(), TYPO3\CMS\IndexedSearch\Indexer\bodyDescription(), TYPO3\CMS\Core\Html\HtmlParser\checkTagTypeCounts(), TYPO3\CMS\Recordlist\RecordList\clearCache(), 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\Backend\Form\FormEngine\dbFileIcons(), TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository\doSearch(), TYPO3\CMS\Impexp\Controller\ImportExportController\exportData(), TYPO3\CMS\Core\TypoScript\ExtendedTemplateService\ext_procesInput(), TYPO3\CMS\IndexedSearch\FileContentParser\fileContentParts(), TYPO3\CMS\Core\Tests\Unit\Utility\MathUtilityTest\forceIntegerInRangeForcesIntegerIntoDefaultBoundaries(), TYPO3\CMS\Core\Tests\Unit\Utility\MathUtilityTest\forceIntegerInRangeSetsDefaultValueIfZeroValueIsGiven(), TYPO3\CMS\Backend\Form\FormEngine\formatValue(), TYPO3\CMS\IndexedSearch\Hook\CrawlerHook\generateNextIndexingTime(), TYPO3\CMS\IndexedSearch\Controller\SearchFormController\getDisplayResults(), TYPO3\CMS\Backend\Form\FormEngine\getExcludeElements(), TYPO3\CMS\CssStyledContent\Controller\CssStyledContentController\getImgColumnWidths(), TYPO3\CMS\Core\Utility\VersionNumberUtility\getNumericTypo3Version(), TYPO3\CMS\IndexedSearch\Controller\SearchFormController\getResultRows(), TYPO3\CMS\Backend\Form\Element\InlineElement\getSingleField_typeInline(), TYPO3\CMS\Backend\Form\FormEngine\getSingleField_typeSelect(), TYPO3\CMS\Backend\Form\FormEngine\getSingleField_typeSelect_multiple(), TYPO3\CMS\Backend\Form\FormEngine\getSingleField_typeSelect_singlebox(), TYPO3\CMS\Core\Imaging\GraphicalFunctions\getTextScalFactor(), TYPO3\CMS\Core\Imaging\GraphicalFunctions\IMparams(), TYPO3\CMS\Core\Imaging\GraphicalFunctions\IMreduceColors(), TYPO3\CMS\Backend\Controller\ClickMenuController\init(), 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\Backend\Controller\EditDocumentController\init(), TYPO3\CMS\IndexedSearch\Controller\SearchController\initialize(), TYPO3\CMS\IndexedSearch\Controller\SearchFormController\initialize(), TYPO3\CMS\Backend\Clipboard\Clipboard\initializeClipboard(), 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\Lowlevel\CleanFlexformCommand\main(), TYPO3\CMS\Lowlevel\DeletedRecordsCommand\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\Core\Imaging\GraphicalFunctions\makeShadow(), TYPO3\CMS\Core\Imaging\GraphicalFunctions\makeText(), TYPO3\CMS\IndexedSearch\Controller\SearchController\markupSWpartsOfString(), TYPO3\CMS\Filelist\Controller\FileListController\menuConfig(), TYPO3\CMS\Core\Utility\GeneralUtility\modifyHTMLColor(), TYPO3\CMS\Core\Imaging\GraphicalFunctions\output(), TYPO3\CMS\Core\Imaging\GraphicalFunctions\outputLevels(), TYPO3\CMS\Frontend\Page\PageGenerator\pagegenInit(), TYPO3\CMS\IndexedSearch\Controller\SearchFormController\pi_list_browseresults(), TYPO3\CMS\Core\Resource\Processing\LocalPreviewHelper\process(), TYPO3\CMS\Version\Hook\DataHandlerHook\processCmdmap(), TYPO3\CMS\Frontend\Controller\ShowImageController\processImage(), TYPO3\CMS\Core\Utility\VersionNumberUtility\raiseVersionNumber(), TYPO3\CMS\Frontend\ContentObject\ImageTextContentObject\render(), TYPO3\CMS\Frontend\ContentObject\ColumnsContentObject\render(), TYPO3\CMS\Frontend\ContentObject\HorizontalRulerContentObject\render(), TYPO3\CMS\IndexedSearch\ViewHelpers\PageBrowsingViewHelper\render(), TYPO3\CMS\Frontend\ContentObject\FormContentObject\render(), TYPO3\CMS\CssStyledContent\Controller\CssStyledContentController\render_table(), TYPO3\CMS\Form\PostProcess\MailPostProcessor\setPriority(), TYPO3\CMS\Core\Messaging\AbstractMessage\setSeverity(), TYPO3\CMS\Frontend\Imaging\GifBuilder\start(), TYPO3\CMS\Frontend\ContentObject\Menu\AbstractMenuContentObject\start(), TYPO3\CMS\Recordlist\RecordList\AbstractDatabaseRecordList\start(), TYPO3\CMS\Core\Html\RteHtmlParser\TS_transform_rte(), TYPO3\CMS\Core\Imaging\GraphicalFunctions\v5_blur(), TYPO3\CMS\Core\Imaging\GraphicalFunctions\v5_sharpen(), TYPO3\CMS\Core\TypoScript\TemplateService\versionOL(), TYPO3\CMS\SysAction\ActionTask\viewRecordList(), and TYPO3\CMS\Frontend\ContentObject\Menu\JavaScriptMenuContentObject\writeMenu().

◆ isIntegerInRange()