X-Git-Url: https://git.mxchange.org/?p=core.git;a=blobdiff_plain;f=framework%2Fmain%2Fclasses%2Fcriteria%2Fclass_BaseCriteria.php;h=de4cd3ee278b09bcbc1adc0650e533ab46db6800;hp=e38926cf2e928fd3486b2518ca9930c664e30c08;hb=08a0c865dd2c8ee0b6dbf96f4f07e9ee0ce0f02b;hpb=fea88c89d790fd1cc5101744e675a99db097d0a8 diff --git a/framework/main/classes/criteria/class_BaseCriteria.php b/framework/main/classes/criteria/class_BaseCriteria.php index e38926cf..de4cd3ee 100644 --- a/framework/main/classes/criteria/class_BaseCriteria.php +++ b/framework/main/classes/criteria/class_BaseCriteria.php @@ -6,14 +6,14 @@ namespace Org\Mxchange\CoreFramework\Criteria; use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap; use Org\Mxchange\CoreFramework\Criteria\Search\SearchCriteria; use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem; -use Org\Mxchange\CoreFramework\Utils\String\StringUtils; +use Org\Mxchange\CoreFramework\Utils\Strings\StringUtils; /** * A general crtieria class * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2021 Core Developer Team * @license GNU GPL 3.0 or any newer version * @link http://www.shipsimu.org * @@ -50,7 +50,7 @@ abstract class BaseCriteria extends BaseFrameworkSystem implements Criteria { foreach (array('default', 'choice', 'exclude') as $criteriaType) { // Init it $this->initGenericArrayKey('criteria', $criteriaType, 'entries'); - } // END - foreach + } } /** @@ -169,7 +169,7 @@ abstract class BaseCriteria extends BaseFrameworkSystem implements Criteria { foreach ($this->getGenericArray('criteria') as $criteriaType => $dummy) { // Remove it $this->unsetGenericArrayElement('criteria', $criteriaType, 'entries', $criteriaKey); - } // END - foreach + } } /** @@ -236,10 +236,8 @@ abstract class BaseCriteria extends BaseFrameworkSystem implements Criteria { // Make sure no 'my-' or 'my_' passes this point assert((strpos($criteriaKey, 'my-') === false) && (strpos($criteriaKey, 'my_') === false) && (!is_bool($criteriaValue))); - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($criteriaType) . '(' . $this->__toString() . ')-CRITERIA: criteriaKey=' . $criteriaKey . ',criteriaValue=' . $criteriaValue); - // Add it + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($criteriaType) . '(' . $this->__toString() . ')-CRITERIA: criteriaKey=' . $criteriaKey . ',criteriaValue=' . $criteriaValue); $this->pushValueToGenericArrayElement('criteria', 'choice', 'entries', StringUtils::convertDashesToUnderscores($criteriaKey), (string) $criteriaValue); } @@ -264,7 +262,7 @@ abstract class BaseCriteria extends BaseFrameworkSystem implements Criteria { * @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude' * @return void */ - public final function addConfiguredCriteria ($criteriaKey, $configEntry, string $criteriaType = 'default') { + public final function addConfiguredCriteria (string $criteriaKey, string $configEntry, string $criteriaType = 'default') { // Add the configuration entry as a criteria $value = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry($configEntry); $this->addCriteria($criteriaKey, $value, $criteriaType); @@ -277,32 +275,26 @@ abstract class BaseCriteria extends BaseFrameworkSystem implements Criteria { * @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude' * @return $value Whether the value of the critera or false */ - public function getCriteriaElemnent ($criteriaKey, string $criteriaType = 'default') { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($criteriaType) . '-CRITERIA: criteriaKey=' . $criteriaKey . ',criteriaType=' . $criteriaType . ' - CALLED!'); - + public function getCriteriaElemnent (string $criteriaKey, string $criteriaType = 'default') { // Make sure no 'my-' or 'my_' passes this point + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($criteriaType) . '-CRITERIA: criteriaKey=' . $criteriaKey . ',criteriaType=' . $criteriaType . ' - CALLED!'); assert((strpos($criteriaKey, 'my-') === false) && (strpos($criteriaKey, 'my_') === false)); // Convert dashes to underscore $criteriaKey = StringUtils::convertDashesToUnderscores($criteriaKey); - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($criteriaType) . '-CRITERIA: criteriaKey=' . $criteriaKey . ',criteria()=' . $this->countGenericArrayGroup('criteria', $criteriaType)); - // Default is not found + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($criteriaType) . '-CRITERIA: criteriaKey=' . $criteriaKey . ',criteria()=' . $this->countGenericArrayGroup('criteria', $criteriaType)); $value = false; // Is the criteria there? if ($this->isKeySet($criteriaType, $criteriaKey)) { // Then use it $value = $this->getGenericArrayElement('criteria', $criteriaType, 'entries', $criteriaKey); - } // END - if - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($criteriaType) . '-CRITERIA: value=' . $value . ' - EXIT!'); + } // Return the value + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($criteriaType) . '-CRITERIA: value=' . $value . ' - EXIT!'); return $value; } @@ -360,9 +352,9 @@ abstract class BaseCriteria extends BaseFrameworkSystem implements Criteria { if (($key == $criteriaKey) && ($criteriaValue == $entry)) { // Then count this one up $counted++; - } // END - if - } // END - foreach - } // END - foreach + } + } + } // Now check if expected criteria counts match $matches = ($counted == $this->countGenericArrayGroup('criteria', $criteriaType)); @@ -428,8 +420,8 @@ abstract class BaseCriteria extends BaseFrameworkSystem implements Criteria { $criteriaKey, urlencode($criteriaValue) ); - } // END - if - } // END - foreach + } + } // Remove last semicolon $cacheKey = substr($cacheKey, 0, -1); @@ -443,8 +435,8 @@ abstract class BaseCriteria extends BaseFrameworkSystem implements Criteria { $this->getLimit(), $this->getSkip() ); - } // END - if - } // END - if + } + } // Return the cache key return $cacheKey;