Skip to content

Commit

Permalink
Merge pull request #3 from lucascherifi/analysis-XNAvPe
Browse files Browse the repository at this point in the history
Applied fixes from StyleCI
  • Loading branch information
Lucas CHERIFI committed Apr 10, 2016
2 parents 27222bb + e7b47fd commit a931393
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 23 deletions.
2 changes: 1 addition & 1 deletion DependencyInjection/PdfParserExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function load(array $configs, ContainerBuilder $container)
{
$loader = new YamlFileLoader(
$container,
new FileLocator(__DIR__ . '/../Resources/config')
new FileLocator(__DIR__.'/../Resources/config')
);
$loader->load('services.yml');
}
Expand Down
16 changes: 8 additions & 8 deletions PdfParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ private function doParse($data)

$endPos = $this->findPosition($data, $this->processorConfiguration['endConditions']);
if (is_null($endPos)) {
throw new Exception('End condition not reached at the ' . (count($blocks) + 1) . 'nth loop of block.');
throw new Exception('End condition not reached at the '.(count($blocks) + 1).'nth loop of block.');
} else {
$blockData = substr($data, 0, $endPos);
$data = substr($data, $endPos);
Expand Down Expand Up @@ -330,7 +330,7 @@ private function findSpaceGroups($rawRows)
}

// clean "false positive" space groups
$spaceGroups = array_filter($spaceGroups, function($spaceGroup) {
$spaceGroups = array_filter($spaceGroups, function ($spaceGroup) {
return $spaceGroup['end'] - $spaceGroup['start'] > 1;
});

Expand All @@ -347,7 +347,7 @@ private function mergeRows($row, $newRow)
{
foreach ($newRow as $newRowColumnIndex => $newRowColumnValue) {
if (strlen($newRowColumnValue)) {
$row[$newRowColumnIndex] = trim($row[$newRowColumnIndex] . "\n" . $newRowColumnValue);
$row[$newRowColumnIndex] = trim($row[$newRowColumnIndex]."\n".$newRowColumnValue);
}
}

Expand All @@ -361,14 +361,14 @@ private function mergeRows($row, $newRow)
*/
private function getTextVersion($filePath)
{
$tmpPath = $this->temporaryDirectoryPath . '/' . rand(0, 10000) . '.txt';
$process = new Process('/usr/bin/pdftotext -layout ' . $filePath . ' ' . $tmpPath);
$tmpPath = $this->temporaryDirectoryPath.'/'.rand(0, 10000).'.txt';
$process = new Process('/usr/bin/pdftotext -layout '.$filePath.' '.$tmpPath);
$this->logger->info('Execute Pdftotext', ['file' => $filePath]);
$process->run(function($type, $buffer) {
$process->run(function ($type, $buffer) {
if (Process::ERR === $type) {
echo 'ERR > ' . $buffer;
echo 'ERR > '.$buffer;
} else {
echo 'OUT > ' . $buffer;
echo 'OUT > '.$buffer;
}
});

Expand Down
6 changes: 3 additions & 3 deletions Processor/BfbProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class BfbProcessor extends Processor implements ProcessorInterface
*/
public function format(ArrayCollection $data)
{
$data = $data->map(function($item) {
$data = $data->map(function ($item) {
// Date
$dateRaw = $item[1];
$date = new \DateTime();
Expand All @@ -35,10 +35,10 @@ public function format(ArrayCollection $data)

// Value
if (strlen($item[3])) {
$value = abs((float)str_replace(',', '.', str_replace(' ', '', $item[3])));
$value = abs((float) str_replace(',', '.', str_replace(' ', '', $item[3])));
$debit = true;
} else {
$value = (float)str_replace(',', '.', str_replace(' ', '', $item[4]));
$value = (float) str_replace(',', '.', str_replace(' ', '', $item[4]));
$debit = false;
}

Expand Down
8 changes: 4 additions & 4 deletions Processor/LclProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,20 @@ class LclProcessor extends Processor implements ProcessorInterface
*/
public function format(ArrayCollection $data)
{
$data = $data->map(function($item) {
$data = $data->map(function ($item) {
// Date
$dateRaw = $item[2];
$date = new \DateTime();
$date->setDate(2000 + (int)substr($dateRaw, 6, 2), (int)substr($dateRaw, 3, 2), (int)substr($dateRaw, 0, 2));
$date->setDate(2000 + (int) substr($dateRaw, 6, 2), (int) substr($dateRaw, 3, 2), (int) substr($dateRaw, 0, 2));
$date->setTime(12, 0, 0);
// Value
$debitRaw = $item[3];
if (strlen($debitRaw)) {
$value = abs((float)str_replace(',', '.', str_replace(' ', '', $debitRaw)));
$value = abs((float) str_replace(',', '.', str_replace(' ', '', $debitRaw)));
$debit = true;
} else {
$creditRaw = $item[4];
$value = (float)str_replace(',', '.', str_replace(' ', '', $creditRaw));
$value = (float) str_replace(',', '.', str_replace(' ', '', $creditRaw));
$debit = false;
}

Expand Down
2 changes: 1 addition & 1 deletion Processor/Processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function getConfiguration()

public function __toString()
{
return (string)$this->configuration['name'];
return (string) $this->configuration['name'];
}

public function frenchDateFormatter($raw)
Expand Down
10 changes: 5 additions & 5 deletions Processor/SgProProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,27 +28,27 @@ class SgProProcessor extends Processor implements ProcessorInterface
*/
public function format(ArrayCollection $data)
{
$data = $data->map(function($item) {
$data = $data->map(function ($item) {
// Date
$dateRaw = $item[0];
$date = new \DateTime();
$date->setDate((int)substr($dateRaw, 6, 4), (int)substr($dateRaw, 3, 2), (int)substr($dateRaw, 0, 2));
$date->setDate((int) substr($dateRaw, 6, 4), (int) substr($dateRaw, 3, 2), (int) substr($dateRaw, 0, 2));
$date->setTime(12, 0, 0);

// Value Date
$dateRaw = $item[1];
$valueDate = new \DateTime();
$valueDate->setDate((int)substr($dateRaw, 6, 4), (int)substr($dateRaw, 3, 2), (int)substr($dateRaw, 0, 2));
$valueDate->setDate((int) substr($dateRaw, 6, 4), (int) substr($dateRaw, 3, 2), (int) substr($dateRaw, 0, 2));
$valueDate->setTime(12, 0, 0);

// Value
$debitRaw = $item[3];
if (strlen($debitRaw)) {
$value = abs((float)str_replace(',', '.', str_replace('.', '', $debitRaw)));
$value = abs((float) str_replace(',', '.', str_replace('.', '', $debitRaw)));
$debit = true;
} else {
$creditRaw = $item[4];
$value = (float)str_replace(',', '.', str_replace('.', '', $creditRaw));
$value = (float) str_replace(',', '.', str_replace('.', '', $creditRaw));
$debit = false;
}

Expand Down
2 changes: 1 addition & 1 deletion Tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
if (!($loader = @include __DIR__ . '/../vendor/autoload.php')) {
if (!($loader = @include __DIR__.'/../vendor/autoload.php')) {
echo <<<'EOT'
You need to install the project dependencies using Composer:
$ wget http://getcomposer.org/composer.phar
Expand Down

0 comments on commit a931393

Please sign in to comment.