Skip to content
This repository has been archived by the owner on Oct 1, 2024. It is now read-only.

Commit

Permalink
Ran php-cs-fixer
Browse files Browse the repository at this point in the history
  • Loading branch information
Rene de Kat committed Aug 26, 2016
1 parent 6eedaca commit 6fdea9c
Show file tree
Hide file tree
Showing 10 changed files with 440 additions and 421 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ $ composer require renedekat/blmreader
## Usage

``` php
use Renedekat\Blm\Drivers\Simple
use Renedekat\Blm\Drivers\Csv
use ReneDeKat\Blm\Drivers\Simple
use ReneDeKat\Blm\Drivers\Csvq

$simple = Simple::create()->loadFromFile("path/to/blmFile")
// OR
Expand Down
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
],
"require": {
"php": "~5.6|~7.0",
"friendsofphp/php-cs-fixer": "^1.12",
"renedekat/php-verbal-expressions": "^1.0",
"tightenco/collect": "^5.3"
},
Expand All @@ -28,12 +29,12 @@
},
"autoload": {
"psr-4": {
"Renedekat\\Blm\\": "src"
"ReneDeKat\\Blm\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"Renedekat\\Blm\\Test\\": "tests"
"ReneDeKat\\Blm\\Test\\": "tests"
}
},
"scripts": {
Expand Down
12 changes: 7 additions & 5 deletions src/Drivers/Csv.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<?php

namespace Renedekat\Blm\Drivers;
namespace ReneDeKat\Blm\Drivers;

use Renedekat\Blm\Reader;
use ReneDeKat\Blm\Reader;

class Csv extends Reader
{

/**
* Returns a string with CSV data
* Returns a string with CSV data.
*
* @return string
*/
public function getOutput()
Expand All @@ -29,8 +29,10 @@ public function getOutput()
}

/**
* Get CSV contents from file handle
* Get CSV contents from file handle.
*
* @param $handle
*
* @return string
*/
private function getCsvContentsFromHandle($handle)
Expand Down
10 changes: 5 additions & 5 deletions src/Drivers/Simple.php
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
<?php

namespace Renedekat\Blm\Drivers;
namespace ReneDeKat\Blm\Drivers;

use Renedekat\Blm\Reader;
use ReneDeKat\Blm\Reader;

class Simple extends Reader
{

/**
* Return the output as an array containing the keys: headers, definitions and data
* Return the output as an array containing the keys: headers, definitions and data.
*
* @return array
*/
public function getOutput()
{
return [
'headers' => $this->getHeaders()->toArray(),
'definitions' => $this->getDefinitions()->toArray(),
'data' => $this->getData()->toArray()
'data' => $this->getData()->toArray(),
];
}
}
3 changes: 1 addition & 2 deletions src/Exceptions/InvalidBlmFileException.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
<?php

namespace Renedekat\Blm\Exceptions;
namespace ReneDeKat\Blm\Exceptions;

use Exception;

class InvalidBlmFileException extends Exception
{

/**
* @param string $message Exception message to throw
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Exceptions/InvalidBlmStringException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Renedekat\Blm\Exceptions;
namespace ReneDeKat\Blm\Exceptions;

use Exception;

Expand Down
49 changes: 34 additions & 15 deletions src/Reader.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php

namespace Renedekat\Blm;
namespace ReneDeKat\Blm;

use Illuminate\Support\Collection;
use Renedekat\Blm\Exceptions\InvalidBlmFileException;
use Renedekat\Blm\Exceptions\InvalidBlmStringException;
use Renedekat\PHPVerbalExpressions\VerbalExpressions;
use ReneDeKat\Blm\Exceptions\InvalidBlmFileException;
use ReneDeKat\Blm\Exceptions\InvalidBlmStringException;
use ReneDeKat\PHPVerbalExpressions\VerbalExpressions;
use Symfony\Component\Filesystem\Exception\FileNotFoundException;

abstract class Reader
Expand Down Expand Up @@ -44,7 +44,9 @@ public static function create()

/**
* @param string $filePath Path to the BLM file
*
* @return $this
*
* @throws FileNotFoundException
* @throws InvalidBlmFileException
*/
Expand All @@ -65,7 +67,9 @@ final public function loadFromFile($filePath)

/**
* @param string $contents Contents of a BLM file
*
* @return Reader
*
* @throws InvalidBlmFileException
*/
final public function loadFromString($contents)
Expand All @@ -78,7 +82,8 @@ final public function loadFromString($contents)
}

/**
* Return the output in the drivers format
* Return the output in the drivers format.
*
* @return mixed
*/
abstract public function getOutput();
Expand Down Expand Up @@ -115,10 +120,11 @@ final protected function getData()
return $this->data;
}


/**
* Validates a string
* Validates a string.
*
* @param string $contents
*
* @return bool Returns true if content is valid
*/
final protected function containsValidBLM($contents)
Expand All @@ -133,8 +139,10 @@ final protected function containsValidBLM($contents)
}

/**
* Verifies if contents contain a headers sections
* Verifies if contents contain a headers sections.
*
* @param string $contents
*
* @return bool
*/
final protected function containsHeader($contents)
Expand All @@ -143,8 +151,10 @@ final protected function containsHeader($contents)
}

/**
* Verifies if contents contain a headers sections
* Verifies if contents contain a headers sections.
*
* @param string $contents
*
* @return bool
*/
final protected function containsDefinition($contents)
Expand All @@ -153,8 +163,10 @@ final protected function containsDefinition($contents)
}

/**
* Verifies if contents contain a headers sections
* Verifies if contents contain a headers sections.
*
* @param string $contents
*
* @return bool
*/
final protected function containsData($contents)
Expand All @@ -164,6 +176,7 @@ final protected function containsData($contents)

/**
* @param string $contents
*
* @return Reader
*/
final protected function parse($contents)
Expand All @@ -180,7 +193,8 @@ final protected function parse($contents)
}

/**
* Parses the #HEADER# section of the BLM file and stores it in $this->headers
* Parses the #HEADER# section of the BLM file and stores it in $this->headers.
*
* @param string $contents
*/
private function parseHeader($contents)
Expand All @@ -198,13 +212,14 @@ private function parseHeader($contents)
})->flatMap(function ($keyValuePairWithQuotes) {
return [
$keyValuePairWithQuotes[0] => preg_replace('/(^[\'"]|[\'"]$)/', '',
trim($keyValuePairWithQuotes[1]))
trim($keyValuePairWithQuotes[1])),
];
});
}

/**
* Parses the #DEFINITION# section of the BLM file and stores it in $this->definitions
* Parses the #DEFINITION# section of the BLM file and stores it in $this->definitions.
*
* @param string $contents
*/
private function parseDefinition($contents)
Expand All @@ -227,7 +242,8 @@ private function parseDefinition($contents)
}

/**
* Parses the #DATA# section of the BLM file and stores it in $this->data
* Parses the #DATA# section of the BLM file and stores it in $this->data.
*
* @param $contents
*/
private function parseData($contents)
Expand Down Expand Up @@ -255,11 +271,12 @@ private function parseData($contents)

/**
* @param $string
*
* @return VerbalExpressions
*/
private function getRegexFor($string)
{
return (new VerbalExpressions)
return (new VerbalExpressions())
->startOfLine()
->find($string)
->anythingBut('#')
Expand All @@ -268,6 +285,7 @@ private function getRegexFor($string)

/**
* @param $line
*
* @return bool
*/
private function isValidLineWithoutHash($line)
Expand All @@ -276,6 +294,7 @@ private function isValidLineWithoutHash($line)
}
/**
* @param array $record
*
* @return array
*/
private function mapRecordToDefinitionValue($record)
Expand Down
Loading

0 comments on commit 6fdea9c

Please sign in to comment.