/core/CronArchive/FixedSiteIds.php
PHP | 68 lines | 38 code | 13 blank | 17 comment | 3 complexity | dbbb847c1dff811c833b3d1836e4f475 MD5 | raw file
Possible License(s): LGPL-3.0, JSON, MIT, GPL-3.0, LGPL-2.1, GPL-2.0, AGPL-1.0, BSD-2-Clause, BSD-3-Clause
- <?php
- /**
- * Piwik - free/libre analytics platform
- *
- * @link http://piwik.org
- * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
- *
- */
- namespace Piwik\CronArchive;
- use Piwik\CronArchive;
- class FixedSiteIds
- {
- private $siteIds = array();
- private $index = -1;
- public function __construct($websiteIds)
- {
- if (!empty($websiteIds)) {
- $this->siteIds = $websiteIds;
- }
- }
- public function getInitialSiteIds()
- {
- return $this->siteIds;
- }
- /**
- * Get the number of total websites that needs to be processed.
- *
- * @return int
- */
- public function getNumSites()
- {
- return count($this->siteIds);
- }
- /**
- * Get the number of already processed websites. All websites were processed by the current archiver.
- *
- * @return int
- */
- public function getNumProcessedWebsites()
- {
- $numProcessed = $this->index + 1;
- if ($numProcessed > $this->getNumSites()) {
- return $this->getNumSites();
- }
- return $numProcessed;
- }
- public function getNextSiteId()
- {
- $this->index++;
- if (!empty($this->siteIds[$this->index])) {
- return $this->siteIds[$this->index];
- }
- return null;
- }
- }