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 <webmaster@shipsimu.org>
* @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
*
foreach (array('default', 'choice', 'exclude') as $criteriaType) {
// Init it
$this->initGenericArrayKey('criteria', $criteriaType, 'entries');
- } // END - foreach
+ }
}
/**
foreach ($this->getGenericArray('criteria') as $criteriaType => $dummy) {
// Remove it
$this->unsetGenericArrayElement('criteria', $criteriaType, 'entries', $criteriaKey);
- } // END - foreach
+ }
}
/**
// 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);
}
* @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);
* @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;
}
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));
$criteriaKey,
urlencode($criteriaValue)
);
- } // END - if
- } // END - foreach
+ }
+ }
// Remove last semicolon
$cacheKey = substr($cacheKey, 0, -1);
$this->getLimit(),
$this->getSkip()
);
- } // END - if
- } // END - if
+ }
+ }
// Return the cache key
return $cacheKey;