Skip to content

Commit

Permalink
Merge pull request #7 from rapidwebltd/analysis-qoOAvK
Browse files Browse the repository at this point in the history
Apply fixes from StyleCI
  • Loading branch information
DivineOmega authored Mar 28, 2018
2 parents 48559e3 + 336da5d commit 4c2d26b
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 6 deletions.
2 changes: 2 additions & 0 deletions src/Interfaces/SourceInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
interface SourceInterface
{
public function getDataRows($page = 1, $fieldsToRetrieve = []);

public function countDataRows();

public function getFields();
}
6 changes: 3 additions & 3 deletions src/Objects/Migrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
namespace RapidWeb\uxdm\Objects;

use Psr\Cache\CacheItemPoolInterface;
use RapidWeb\CliProgressBar\ProgressBar;
use RapidWeb\uxdm\Interfaces\DestinationInterface;
use RapidWeb\uxdm\Interfaces\SourceInterface;
use RapidWeb\uxdm\Objects\Exceptions\MissingFieldToMigrateException;
use RapidWeb\uxdm\Objects\Exceptions\NoDestinationException;
use RapidWeb\uxdm\Objects\Exceptions\NoSourceException;
use RapidWeb\CliProgressBar\ProgressBar;

class Migrator
{
Expand Down Expand Up @@ -102,6 +102,7 @@ public function setSourceCache(CacheItemPoolInterface $sourceCachePool, $sourceC
public function withProgressBar()
{
$this->showProgressBar = true;

return $this;
}

Expand Down Expand Up @@ -163,7 +164,6 @@ public function migrate()
}

for ($page = 1; $page < PHP_INT_MAX; $page++) {

$dataRows = $this->getSourceDataRows($page);

if (!$dataRows) {
Expand Down Expand Up @@ -224,7 +224,7 @@ public function migrate()
private function advanceProgressBar($amount)
{
if ($this->showProgressBar) {
for ($i=0; $i < $amount; $i++) {
for ($i = 0; $i < $amount; $i++) {
$this->progressBar->advance()->display();
}
}
Expand Down
1 change: 1 addition & 0 deletions src/Objects/Sources/CSVSource.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public function countDataRows()
{
$file = new \SplFileObject($this->file, 'r');
$file->seek(PHP_INT_MAX);

return $file->key();
}
}
2 changes: 1 addition & 1 deletion src/Objects/Sources/PDOSource.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public function countDataRows()
$sql = $this->getSQL([]);
$fromPos = strpos($sql, 'from');
$limitPos = strrpos($sql, 'limit');
$sqlSuffix = substr($sql, $fromPos, $limitPos-$fromPos);
$sqlSuffix = substr($sql, $fromPos, $limitPos - $fromPos);

$sql = 'select count(*) as countDataRows '.$sqlSuffix;

Expand Down
2 changes: 1 addition & 1 deletion src/Objects/Sources/WordPressPostSource.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public function countDataRows()
$sql = $this->getPostSQL([]);
$fromPos = strpos($sql, 'from');
$limitPos = strrpos($sql, 'limit');
$sqlSuffix = substr($sql, $fromPos, $limitPos-$fromPos);
$sqlSuffix = substr($sql, $fromPos, $limitPos - $fromPos);

$sql = 'count (*) '.$sqlSuffix;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Objects/Sources/WordPressUserSource.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public function countDataRows()
$sql = $this->getUserSQL([]);
$fromPos = strpos($sql, 'from');
$limitPos = strrpos($sql, 'limit');
$sqlSuffix = substr($sql, $fromPos, $limitPos-$fromPos);
$sqlSuffix = substr($sql, $fromPos, $limitPos - $fromPos);

$sql = 'count (*) '.$sqlSuffix;
}
Expand Down
1 change: 1 addition & 0 deletions src/Objects/Sources/XMLSource.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ public function getFields()
public function countDataRows()
{
$domNodeList = $this->xpath->query($this->xpathQuery);

return $domNodeList->length;
}
}

0 comments on commit 4c2d26b

Please sign in to comment.