diff --git a/.php_cs b/.php_cs index 12229a2..42fded2 100644 --- a/.php_cs +++ b/.php_cs @@ -1,13 +1,14 @@ in([ - __DIR__ . DIRECTORY_SEPARATOR . 'benchmarks', - __DIR__ . DIRECTORY_SEPARATOR . 'src', - __DIR__ . DIRECTORY_SEPARATOR . 'tests', + __DIR__ . '/src', + __DIR__ . '/tests', ]); -return Symfony\CS\Config\Config::create() - ->level(\Symfony\CS\FixerInterface::PSR2_LEVEL) - ->fixers(['short_array_syntax']) - ->finder($finder); \ No newline at end of file +return PhpCsFixer\Config::create() + ->setRules([ + '@PSR2' => true, + 'array_syntax' => ['syntax' => 'short'], + ]) + ->setFinder($finder); diff --git a/src/Factory/WzClassificationFactory.php b/src/Factory/WzClassificationFactory.php index fad9e18..20464a4 100644 --- a/src/Factory/WzClassificationFactory.php +++ b/src/Factory/WzClassificationFactory.php @@ -43,7 +43,8 @@ public static function buildFromFile($xmlFile) if (!$xml) { throw new InvalidArgumentException( - sprintf("Invalid XML file `%s`.", $xmlFile)); + sprintf("Invalid XML file `%s`.", $xmlFile) + ); } return self::buildFromXml($xml); @@ -87,7 +88,8 @@ private static function buildItems(SimpleXMLElement $xml) $itemId, self::buildLabels($xmlItem), $itemLevel, - $parent); + $parent + ); $items[] = $current; $levels[$itemLevel] = $current; diff --git a/src/WzClassification.php b/src/WzClassification.php index b69db04..e57118f 100644 --- a/src/WzClassification.php +++ b/src/WzClassification.php @@ -28,7 +28,8 @@ public function __construct(array $items) if (!$item instanceof WzItemInterface) { throw new InvalidArgumentException(sprintf( 'Only `%s` objects are allowed.', - WzItemInterface::class)); + WzItemInterface::class + )); } $this->items[$item->getId()] = $item; @@ -62,7 +63,9 @@ public function getItemsByLevel($level) $this->items, function (WzItemInterface $item) use ($level) { return $item->getLevel() == $level; - })); + } + ) + ); } /** diff --git a/src/WzItem.php b/src/WzItem.php index 27b0b0c..6ef07e0 100644 --- a/src/WzItem.php +++ b/src/WzItem.php @@ -81,7 +81,8 @@ public function getLabel($langCode) throw new InvalidArgumentException(sprintf( 'Unsupported language code `%s`. Supported codes: `%s`.', $langCode, - implode(',', array_keys($this->labels)))); + implode(',', array_keys($this->labels)) + )); } /** @@ -140,7 +141,8 @@ public function addChild(WzItemInterface $child) "The parent of `%s` is invalid. Expected `%s` but got `%s`.", $child->getId(), $this->getId(), - $child->getParent() ? $child->getParent()->getId() : '')); + $child->getParent() ? $child->getParent()->getId() : '' + )); } $this->children[] = $child; diff --git a/tests/Factory/WzClassificationFactoryTest.php b/tests/Factory/WzClassificationFactoryTest.php index 68eb479..b084670 100644 --- a/tests/Factory/WzClassificationFactoryTest.php +++ b/tests/Factory/WzClassificationFactoryTest.php @@ -43,7 +43,8 @@ public function testDefaultClassification() { $this->assertInstanceOf( WzClassificationInterface::class, - WzClassificationFactory::build()); + WzClassificationFactory::build() + ); } public function testDefaultClassification_Count() @@ -92,7 +93,8 @@ public function testDefaultClassification_Children() $this->assertSame( $item->getChildren(), - $item->getChildrenByLevel($item::LEVEL_SUBCLASS)); + $item->getChildrenByLevel($item::LEVEL_SUBCLASS) + ); $this->assertSame('74.10.1', $item->getChildren()[0]->getId()); $this->assertSame('74.10.2', $item->getChildren()[1]->getId()); @@ -125,7 +127,8 @@ public function testDefaultClassification_Parents() $this->assertSame(4, $parent->getLevel()); $this->assertSame( 'Ateliers für Textil-, Schmuck-, Grafik- u. ä. Design', - $parent->getLabel('de')); + $parent->getLabel('de') + ); $parent = $item->getParentByLevel(WzItemInterface::LEVEL_GROUP); @@ -133,7 +136,8 @@ public function testDefaultClassification_Parents() $this->assertSame(3, $parent->getLevel()); $this->assertSame( 'Ateliers für Textil-, Schmuck-, Grafik- u. ä. Design', - $parent->getLabel('de')); + $parent->getLabel('de') + ); $parent = $item->getParentByLevel(WzItemInterface::LEVEL_DIVISION); @@ -141,7 +145,8 @@ public function testDefaultClassification_Parents() $this->assertSame(2, $parent->getLevel()); $this->assertSame( 'Sonstige freiberufliche, wissenschaftliche und technische Tätigkeiten', - $parent->getLabel('de')); + $parent->getLabel('de') + ); $parent = $item->getParentByLevel(WzItemInterface::LEVEL_SECTION); @@ -149,6 +154,7 @@ public function testDefaultClassification_Parents() $this->assertSame(1, $parent->getLevel()); $this->assertSame( 'Erbringung von freiberuflichen, wissenschaftlichen und technischen Dienstleistungen', - $parent->getLabel('de')); + $parent->getLabel('de') + ); } } diff --git a/tests/WzClassificationTest.php b/tests/WzClassificationTest.php index 59d3ce1..1709936 100644 --- a/tests/WzClassificationTest.php +++ b/tests/WzClassificationTest.php @@ -68,7 +68,8 @@ public function testInvalidInput() } catch (InvalidArgumentException $e) { $this->assertSame( sprintf('Only `%s` objects are allowed.', WzItemInterface::class), - $e->getMessage()); + $e->getMessage() + ); } } } diff --git a/tests/WzItemTest.php b/tests/WzItemTest.php index c0b46bf..6a4be12 100644 --- a/tests/WzItemTest.php +++ b/tests/WzItemTest.php @@ -109,20 +109,23 @@ public function testParentFunctions(array $map) $this->assertSame( $map['01.11'], $map['01.11.0'] - ->getParent()); + ->getParent() + ); $this->assertSame( $map['01.1'], $map['01.11.0'] ->getParent() - ->getParent()); + ->getParent() + ); $this->assertSame( $map['01'], $map['01.11.0'] ->getParent() ->getParent() - ->getParent()); + ->getParent() + ); $this->assertSame( $map['A'], @@ -130,7 +133,8 @@ public function testParentFunctions(array $map) ->getParent() ->getParent() ->getParent() - ->getParent()); + ->getParent() + ); } /** @@ -153,27 +157,31 @@ public function testChildrenFunctions(array $map) [ $map['01'], ], - $map['A']->getChildrenByLevel(2)); + $map['A']->getChildrenByLevel(2) + ); $this->assertSame( [ $map['01.1'], ], - $map['A']->getChildrenByLevel(3)); + $map['A']->getChildrenByLevel(3) + ); $this->assertSame( [ $map['01.11'], $map['01.12'], ], - $map['A']->getChildrenByLevel(4)); + $map['A']->getChildrenByLevel(4) + ); $this->assertSame( [ $map['01.11.0'], $map['01.12.0'], ], - $map['A']->getChildrenByLevel(5)); + $map['A']->getChildrenByLevel(5) + ); } public function testChildrenOutOfBounds() @@ -263,7 +271,8 @@ public function testLabel() } catch (InvalidArgumentException $e) { $this->assertSame( 'Unsupported language code `fr`. Supported codes: `de,en`.', - $e->getMessage()); + $e->getMessage() + ); } } @@ -300,7 +309,8 @@ public function testAddChild() } catch (InvalidParentException $e) { $this->assertSame( 'The parent of `P` is invalid. Expected `P` but got ``.', - $e->getMessage()); + $e->getMessage() + ); } try { @@ -309,7 +319,8 @@ public function testAddChild() } catch (InvalidParentException $e) { $this->assertSame( 'The parent of `B` is invalid. Expected `A` but got `P`.', - $e->getMessage()); + $e->getMessage() + ); } } }