From f97f03a0885309b28942c91eec83383bb57fb3a9 Mon Sep 17 00:00:00 2001 From: Fonata Date: Sat, 23 Feb 2019 12:55:10 +0100 Subject: [PATCH] Only improved code formatting --- composer.json | 8 ++++---- examples/basic.php | 1 + examples/conditions.php | 1 + examples/download.php | 1 + examples/limit.php | 1 + src/enums/AbstractEnum.php | 12 +++++------- src/enums/FileProcessingModeEnum.php | 2 +- src/enums/SortEnum.php | 8 +++++--- src/extensions/DatatypeTrait.php | 8 ++++---- tests/methods/DatatypeTest.php | 14 +++++++------- tests/methods/ParseTest.php | 6 +++--- tests/methods/SaveTest.php | 4 ++-- tests/methods/UnparseTest.php | 4 ++-- tests/properties/OffsetTest.php | 1 + tests/properties/PublicPropertiesTest.php | 16 ++++++++-------- 15 files changed, 46 insertions(+), 41 deletions(-) diff --git a/composer.json b/composer.json index 4015f51..de3d7d7 100644 --- a/composer.json +++ b/composer.json @@ -20,14 +20,14 @@ "homepage": "https://github.com/Fonata" } ], - "autoload":{ - "psr-4":{ + "autoload": { + "psr-4": { "ParseCsv\\": "src", "ParseCsv\\extensions\\": "src\\extensions" } }, - "autoload-dev":{ - "psr-4":{ + "autoload-dev": { + "psr-4": { "ParseCsv\\tests\\": "tests" } }, diff --git a/examples/basic.php b/examples/basic.php index 66f1abc..7ed355a 100644 --- a/examples/basic.php +++ b/examples/basic.php @@ -3,6 +3,7 @@ # include parseCSV class. require __DIR__ . '/../vendor/autoload.php'; + use ParseCsv\Csv; diff --git a/examples/conditions.php b/examples/conditions.php index 547d43a..f085064 100644 --- a/examples/conditions.php +++ b/examples/conditions.php @@ -4,6 +4,7 @@ # include parseCSV class. require __DIR__ . '/../vendor/autoload.php'; + use ParseCsv\Csv; diff --git a/examples/download.php b/examples/download.php index 4a54d4f..9babb87 100644 --- a/examples/download.php +++ b/examples/download.php @@ -3,6 +3,7 @@ # include parseCSV class. require __DIR__ . '/../vendor/autoload.php'; + use ParseCsv\Csv; diff --git a/examples/limit.php b/examples/limit.php index 8734f77..4adeb0c 100644 --- a/examples/limit.php +++ b/examples/limit.php @@ -4,6 +4,7 @@ # include parseCSV class. require __DIR__ . '/../vendor/autoload.php'; + use ParseCsv\Csv; diff --git a/src/enums/AbstractEnum.php b/src/enums/AbstractEnum.php index aae78e1..19dae3f 100644 --- a/src/enums/AbstractEnum.php +++ b/src/enums/AbstractEnum.php @@ -1,9 +1,9 @@ isValid($value)) { throw new \UnexpectedValueException("Value '$value' is not part of the enum " . get_called_class()); } $this->value = $value; } - public static function getConstants(){ + public static function getConstants() { $class = get_called_class(); $reflection = new \ReflectionClass($class); @@ -33,8 +32,7 @@ abstract class AbstractEnum { * * @return bool */ - public static function isValid($value) - { + public static function isValid($value) { return in_array($value, static::getConstants(), true); } } diff --git a/src/enums/FileProcessingModeEnum.php b/src/enums/FileProcessingModeEnum.php index ab88055..b545c68 100644 --- a/src/enums/FileProcessingModeEnum.php +++ b/src/enums/FileProcessingModeEnum.php @@ -19,7 +19,7 @@ class FileProcessingModeEnum { const MODE_FILE_OVERWRITE = false; public static function getAppendMode($mode) { - if ($mode == self::MODE_FILE_APPEND){ + if ($mode == self::MODE_FILE_APPEND) { return 'ab'; } diff --git a/src/enums/SortEnum.php b/src/enums/SortEnum.php index 54c3040..fd1cb1e 100644 --- a/src/enums/SortEnum.php +++ b/src/enums/SortEnum.php @@ -1,8 +1,10 @@ SORT_REGULAR, self::SORT_TYPE_STRING => SORT_STRING, - self::SORT_TYPE_NUMERIC => SORT_NUMERIC + self::SORT_TYPE_NUMERIC => SORT_NUMERIC, ); - public static function getSorting($type){ - if (array_key_exists($type, self::$sorting)){ + public static function getSorting($type) { + if (array_key_exists($type, self::$sorting)) { return self::$sorting[$type]; } diff --git a/src/extensions/DatatypeTrait.php b/src/extensions/DatatypeTrait.php index 4e198cd..a939006 100644 --- a/src/extensions/DatatypeTrait.php +++ b/src/extensions/DatatypeTrait.php @@ -80,19 +80,19 @@ trait DatatypeTrait { * * @return bool */ - public function autoDetectFileHasHeading(){ - if (empty($this->data)){ + public function autoDetectFileHasHeading() { + if (empty($this->data)) { throw new \UnexpectedValueException('No data set yet.'); } - if ($this->heading){ + if ($this->heading) { $firstRow = $this->titles; } else { $firstRow = $this->data[0]; } $firstRow = array_filter($firstRow); - if (empty($firstRow)){ + if (empty($firstRow)) { return false; } diff --git a/tests/methods/DatatypeTest.php b/tests/methods/DatatypeTest.php index 35c7f9e..cd1cf95 100644 --- a/tests/methods/DatatypeTest.php +++ b/tests/methods/DatatypeTest.php @@ -8,12 +8,12 @@ namespace ParseCsv\tests\methods; -use PHPUnit\Framework\TestCase; use ParseCsv\enums\DatatypeEnum; +use PHPUnit\Framework\TestCase; -class DatatypeTest extends TestCase -{ - public function testSampleIsValidInteger(){ +class DatatypeTest extends TestCase { + + public function testSampleIsValidInteger() { $this->assertEquals(DatatypeEnum::TYPE_INT, DatatypeEnum::getValidTypeFromSample('1')); $this->assertEquals(DatatypeEnum::TYPE_INT, DatatypeEnum::getValidTypeFromSample('+1')); $this->assertEquals(DatatypeEnum::TYPE_INT, DatatypeEnum::getValidTypeFromSample('-1')); @@ -27,7 +27,7 @@ class DatatypeTest extends TestCase $this->assertNotEquals(DatatypeEnum::TYPE_INT, DatatypeEnum::getValidTypeFromSample('2018-02-19')); } - public function testSampleIsValidBool(){ + public function testSampleIsValidBool() { $this->assertEquals(DatatypeEnum::TYPE_BOOL, DatatypeEnum::getValidTypeFromSample('true')); $this->assertEquals(DatatypeEnum::TYPE_BOOL, DatatypeEnum::getValidTypeFromSample('TRUE')); $this->assertEquals(DatatypeEnum::TYPE_BOOL, DatatypeEnum::getValidTypeFromSample('false')); @@ -39,7 +39,7 @@ class DatatypeTest extends TestCase $this->assertNotEquals(DatatypeEnum::TYPE_BOOL, DatatypeEnum::getValidTypeFromSample('0.1')); } - public function testSampleIsValidFloat(){ + public function testSampleIsValidFloat() { $this->assertEquals(DatatypeEnum::TYPE_FLOAT, DatatypeEnum::getValidTypeFromSample('1.0')); $this->assertEquals(DatatypeEnum::TYPE_FLOAT, DatatypeEnum::getValidTypeFromSample('-1.1')); $this->assertEquals(DatatypeEnum::TYPE_FLOAT, DatatypeEnum::getValidTypeFromSample('+1,1')); @@ -54,7 +54,7 @@ class DatatypeTest extends TestCase $this->assertNotEquals(DatatypeEnum::TYPE_FLOAT, DatatypeEnum::getValidTypeFromSample('2018-02-19')); } - public function testSampleIsValidDate(){ + public function testSampleIsValidDate() { $this->assertEquals(DatatypeEnum::TYPE_DATE, DatatypeEnum::getValidTypeFromSample('2018-02-19')); $this->assertEquals(DatatypeEnum::TYPE_DATE, DatatypeEnum::getValidTypeFromSample('18-2-19')); $this->assertEquals(DatatypeEnum::TYPE_DATE, DatatypeEnum::getValidTypeFromSample('01.02.2018')); diff --git a/tests/methods/ParseTest.php b/tests/methods/ParseTest.php index 39cc3cd..4aa4bcd 100644 --- a/tests/methods/ParseTest.php +++ b/tests/methods/ParseTest.php @@ -238,9 +238,9 @@ class ParseTest extends TestCase { /** * Call protected/private method of a class. * - * @param object &$object Instantiated object that we will run method on. - * @param string $methodName Method name to call - * @param array $parameters Array of parameters to pass into method. + * @param object &$object Instantiated object that we will run method on. + * @param string $methodName Method name to call + * @param array $parameters Array of parameters to pass into method. * * @return mixed Method return. */ diff --git a/tests/methods/SaveTest.php b/tests/methods/SaveTest.php index 335844c..88d2fae 100644 --- a/tests/methods/SaveTest.php +++ b/tests/methods/SaveTest.php @@ -1,11 +1,11 @@ unparseAndCompare($expected, $fields); } - public function testUnparseDefaultFirstRowMissing(){ + public function testUnparseDefaultFirstRowMissing() { unset($this->csv->data[0]); $expected = "column1,column2\rvalue3,value4\r"; $this->unparseAndCompare($expected); } - public function testUnparseDefaultWithoutData(){ + public function testUnparseDefaultWithoutData() { unset($this->csv->data[0]); unset($this->csv->data[1]); $expected = "column1,column2\r"; diff --git a/tests/properties/OffsetTest.php b/tests/properties/OffsetTest.php index 728201c..3c9b2eb 100644 --- a/tests/properties/OffsetTest.php +++ b/tests/properties/OffsetTest.php @@ -6,6 +6,7 @@ namespace ParseCsv\tests\properties; * Tests related to the $offset property */ class OffsetTest extends BaseClass { + public function testOffsetOfOne() { $this->csv->offset = 1; $this->csv->auto(__DIR__ . '/../methods/fixtures/datatype.csv'); diff --git a/tests/properties/PublicPropertiesTest.php b/tests/properties/PublicPropertiesTest.php index ed49354..b90c32f 100644 --- a/tests/properties/PublicPropertiesTest.php +++ b/tests/properties/PublicPropertiesTest.php @@ -147,25 +147,25 @@ class PublicPropertiesTest extends TestCase { $this->assertCount($counter, $this->properties); } - public function testDefaultSortTypeIsRegular(){ - $this->assertEquals(SortEnum::SORT_TYPE_REGULAR, $this->csv->sort_type); + public function testDefaultSortTypeIsRegular() { + $this->assertEquals(SortEnum::SORT_TYPE_REGULAR, $this->csv->sort_type); } - public function testSetSortType(){ + public function testSetSortType() { $this->csv->sort_type = 'numeric'; - $this->assertEquals(SortEnum::SORT_TYPE_NUMERIC, $this->csv->sort_type); + $this->assertEquals(SortEnum::SORT_TYPE_NUMERIC, $this->csv->sort_type); $this->csv->sort_type = 'string'; - $this->assertEquals(SortEnum::SORT_TYPE_STRING, $this->csv->sort_type); + $this->assertEquals(SortEnum::SORT_TYPE_STRING, $this->csv->sort_type); } - public function testGetSorting(){ + public function testGetSorting() { $this->csv->sort_type = 'numeric'; $sorting = SortEnum::getSorting($this->csv->sort_type); - $this->assertEquals(SORT_NUMERIC, $sorting); + $this->assertEquals(SORT_NUMERIC, $sorting); $this->csv->sort_type = 'string'; $sorting = SortEnum::getSorting($this->csv->sort_type); - $this->assertEquals(SORT_STRING, $sorting); + $this->assertEquals(SORT_STRING, $sorting); } }