From: Roland Häder Date: Tue, 24 Nov 2020 02:07:26 +0000 (+0100) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=3b3b3bc253fa9c4020022edba682db85326ff039;p=core.git Continued: - moved $updateInstance and getter/setter to proper BaseDatabaseResult class - renamed $class to $className - removed __CLASS__ as default value from any abstract class' constructor Signed-off-by: Roland Häder --- diff --git a/framework/main/classes/class_BaseFrameworkSystem.php b/framework/main/classes/class_BaseFrameworkSystem.php index 26d93920..0cfc19bb 100644 --- a/framework/main/classes/class_BaseFrameworkSystem.php +++ b/framework/main/classes/class_BaseFrameworkSystem.php @@ -6,7 +6,6 @@ namespace Org\Mxchange\CoreFramework\Object; use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap; use Org\Mxchange\CoreFramework\Criteria\Criteria; use Org\Mxchange\CoreFramework\Criteria\Local\LocalSearchCriteria; -use Org\Mxchange\CoreFramework\Criteria\Local\LocalUpdateCriteria; use Org\Mxchange\CoreFramework\Crypto\Cryptable; use Org\Mxchange\CoreFramework\Database\Frontend\DatabaseWrapper; use Org\Mxchange\CoreFramework\EntryPoint\ApplicationEntryPoint; @@ -83,11 +82,6 @@ abstract class BaseFrameworkSystem extends stdClass implements FrameworkInterfac */ private $searchInstance = NULL; - /** - * Update criteria instance - */ - private $updateInstance = NULL; - /** * Database result instance */ @@ -503,25 +497,6 @@ abstract class BaseFrameworkSystem extends stdClass implements FrameworkInterfac return $this->searchInstance; } - /** - * Setter for update instance - * - * @param $updateInstance An instance of a LocalUpdateCriteria clase - * @return void - */ - public final function setUpdateInstance (LocalUpdateCriteria $updateInstance) { - $this->updateInstance = $updateInstance; - } - - /** - * Getter for update instance - * - * @return $updateInstance Updateable criteria instance - */ - public final function getUpdateInstance () { - return $this->updateInstance; - } - /** * Setter for debug instance * diff --git a/framework/main/classes/database/class_BaseDatabaseResult.php b/framework/main/classes/database/class_BaseDatabaseResult.php index 74b5d228..2b30e9e1 100644 --- a/framework/main/classes/database/class_BaseDatabaseResult.php +++ b/framework/main/classes/database/class_BaseDatabaseResult.php @@ -3,6 +3,7 @@ namespace Org\Mxchange\CoreFramework\Result\Database; // Import framework stuff +use Org\Mxchange\CoreFramework\Criteria\Local\LocalUpdateCriteria; use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem; /** @@ -29,14 +30,38 @@ use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem; * along with this program. If not, see . */ abstract class BaseDatabaseResult extends BaseFrameworkSystem { + /** + * Update criteria instance + */ + private $updateInstance = NULL; + /** * Protected constructor * * @return void */ - protected function __construct($class = __CLASS__) { + protected function __construct (string $className) { // Call parent constructor - parent::__construct($class); + parent::__construct($className); + } + + /** + * Setter for update instance + * + * @param $updateInstance An instance of a LocalUpdateCriteria clase + * @return void + */ + public final function setUpdateInstance (LocalUpdateCriteria $updateInstance) { + $this->updateInstance = $updateInstance; + } + + /** + * Getter for update instance + * + * @return $updateInstance Updateable criteria instance + */ + public final function getUpdateInstance () { + return $this->updateInstance; } } diff --git a/framework/main/classes/database/migration/class_BaseDatabaseMigration.php b/framework/main/classes/database/migration/class_BaseDatabaseMigration.php index ba23a172..3f2acf07 100644 --- a/framework/main/classes/database/migration/class_BaseDatabaseMigration.php +++ b/framework/main/classes/database/migration/class_BaseDatabaseMigration.php @@ -33,9 +33,9 @@ abstract class BaseDatabaseMigration extends BaseFrameworkSystem { * * @return void */ - protected function __construct($class = __CLASS__) { + protected function __construct (string $className) { // Call parent constructor - parent::__construct($class); + parent::__construct($className); } } diff --git a/framework/main/classes/database/migration/format_upgrade/class_BaseFormatUpgrade.php b/framework/main/classes/database/migration/format_upgrade/class_BaseFormatUpgrade.php index b5e1932a..e7c2e4ef 100644 --- a/framework/main/classes/database/migration/format_upgrade/class_BaseFormatUpgrade.php +++ b/framework/main/classes/database/migration/format_upgrade/class_BaseFormatUpgrade.php @@ -34,9 +34,9 @@ abstract class BaseFormatUpgrade extends BaseDatabaseMigration implements Migrat * * @return void */ - protected function __construct($class = __CLASS__) { + protected function __construct (string $className) { // Call parent constructor - parent::__construct($class); + parent::__construct($className); } } diff --git a/framework/main/classes/database/result/class_CachedDatabaseResult.php b/framework/main/classes/database/result/class_CachedDatabaseResult.php index 7f54df53..9f08757b 100644 --- a/framework/main/classes/database/result/class_CachedDatabaseResult.php +++ b/framework/main/classes/database/result/class_CachedDatabaseResult.php @@ -139,7 +139,7 @@ class CachedDatabaseResult extends BaseDatabaseResult implements SearchableResul // Mark it as out-dated $this->outDated[$criteriaKey] = 1; - } // END - foreach + } } /** @@ -158,7 +158,7 @@ class CachedDatabaseResult extends BaseDatabaseResult implements SearchableResul $this->currentPos++; $this->currentRow = $this->resultArray[BaseDatabaseBackend::RESULT_INDEX_ROWS][$this->currentPos]; $nextValid = true; - } // END - if + } // Return the result return $nextValid; @@ -178,7 +178,7 @@ class CachedDatabaseResult extends BaseDatabaseResult implements SearchableResul while (($this->currentPos < $index) && ($this->valid())) { // Continue on $this->next(); - } // END - while + } } /** @@ -194,7 +194,7 @@ class CachedDatabaseResult extends BaseDatabaseResult implements SearchableResul if (isset($this->resultArray[BaseDatabaseBackend::RESULT_INDEX_ROWS][$this->currentPos])) { // Then get it $current = $this->resultArray[BaseDatabaseBackend::RESULT_INDEX_ROWS][$this->currentPos]; - } // END - if + } // Return the result return $current; @@ -216,7 +216,7 @@ class CachedDatabaseResult extends BaseDatabaseResult implements SearchableResul if (($this->ifStatusIsOkay()) && (isset($this->resultArray[BaseDatabaseBackend::RESULT_INDEX_ROWS][($this->currentPos + 1)])) && (isset($this->resultArray[BaseDatabaseBackend::RESULT_INDEX_ROWS][0]))) { // All fine! $isValid = true; - } // END - if + } // Return the result return $isValid; @@ -289,7 +289,7 @@ class CachedDatabaseResult extends BaseDatabaseResult implements SearchableResul $searchInstance = $criteriaInstance->getSearchInstance(); // And start looking for the result - $foundEntries = 0; + $foundEntries = $this->getAffectedRows(); while (($this->valid()) && ($foundEntries < $searchInstance->getLimit())) { // Get next entry $this->next(); @@ -302,14 +302,14 @@ class CachedDatabaseResult extends BaseDatabaseResult implements SearchableResul // Count one up $foundEntries++; - } // END - if - } // END - while + } + } // If no entry is found/updated throw an exception if ($foundEntries == 0) { // Throw an exception here throw new ResultUpdateException($this, self::EXCEPTION_RESULT_UPDATE_FAILED); - } // END - if + } // Set affected rows $this->setAffectedRows($foundEntries); @@ -324,7 +324,7 @@ class CachedDatabaseResult extends BaseDatabaseResult implements SearchableResul * @param $rows Number of affected rows * @return void */ - public final function setAffectedRows ($rows) { + public final function setAffectedRows (int $rows) { $this->affectedRows = $rows; } @@ -370,8 +370,8 @@ class CachedDatabaseResult extends BaseDatabaseResult implements SearchableResul if ($this->find($key)) { // Then update it $criteriaInstance->addCriteria($key, $this->getFoundValue()); - } // END - if - } // END - foreach + } + } } /** @@ -405,8 +405,8 @@ class CachedDatabaseResult extends BaseDatabaseResult implements SearchableResul // And stop searching break; - } // END - if - } // END - while + } + } // Return the result return $found; diff --git a/framework/main/exceptions/main/class_NullPointerException.php b/framework/main/exceptions/main/class_NullPointerException.php index c3a1d02d..e2e08781 100644 --- a/framework/main/exceptions/main/class_NullPointerException.php +++ b/framework/main/exceptions/main/class_NullPointerException.php @@ -36,7 +36,7 @@ class NullPointerException extends FrameworkException { * @param $code Code number for the exception * @return void */ - public function __construct (FrameworkInterface $class = NULL, $code) { + public function __construct (FrameworkInterface $class = NULL, int $code) { // Is the instance set? if (is_null($class)) { // Add a message around the missing class