diff --git a/Creational/AbstractFactory/AbstractFactory.php b/Creational/AbstractFactory/AbstractFactory.php deleted file mode 100644 index 85bd878..0000000 --- a/Creational/AbstractFactory/AbstractFactory.php +++ /dev/null @@ -1,12 +0,0 @@ -skipHeaderLine = $skipHeaderLine; + } + + public function parse(string $input): array + { + $headerWasParsed = false; + $parsedLines = []; + + foreach (explode(PHP_EOL, $input) as $line) { + if (!$headerWasParsed && $this->skipHeaderLine === self::OPTION_CONTAINS_HEADER) { + continue; + } + + $parsedLines[] = str_getcsv($line); + } + + return $parsedLines; + } +} diff --git a/Creational/AbstractFactory/HtmlFactory.php b/Creational/AbstractFactory/HtmlFactory.php deleted file mode 100644 index ba44216..0000000 --- a/Creational/AbstractFactory/HtmlFactory.php +++ /dev/null @@ -1,11 +0,0 @@ -createText('foobar'); + $factory = new ParserFactory(); + $parser = $factory->createCsvParser(CsvParser::OPTION_CONTAINS_HEADER); - $this->assertInstanceOf(HtmlText::class, $text); + $this->assertInstanceOf(CsvParser::class, $parser); } - public function testCanCreateJsonText() + public function testCanCreateJsonParser() { - $factory = new JsonFactory(); - $text = $factory->createText('foobar'); + $factory = new ParserFactory(); + $parser = $factory->createJsonParser(); - $this->assertInstanceOf(JsonText::class, $text); + $this->assertInstanceOf(JsonParser::class, $parser); } } diff --git a/Creational/AbstractFactory/Text.php b/Creational/AbstractFactory/Text.php deleted file mode 100644 index 3573801..0000000 --- a/Creational/AbstractFactory/Text.php +++ /dev/null @@ -1,16 +0,0 @@ -text = $text; - } -} diff --git a/Creational/AbstractFactory/uml/AbstractFactory.uml b/Creational/AbstractFactory/uml/AbstractFactory.uml index 224cc06..bcd4efb 100644 --- a/Creational/AbstractFactory/uml/AbstractFactory.uml +++ b/Creational/AbstractFactory/uml/AbstractFactory.uml @@ -1,50 +1,35 @@ PHP - \DesignPatterns\Creational\AbstractFactory\AbstractFactory + \DesignPatterns\Creational\AbstractFactory\CsvParser - \DesignPatterns\Creational\AbstractFactory\JsonFactory - \DesignPatterns\Creational\AbstractFactory\AbstractFactory - \DesignPatterns\Creational\AbstractFactory\HtmlFactory - \DesignPatterns\Creational\AbstractFactory\JsonText - \DesignPatterns\Creational\AbstractFactory\HtmlText - \DesignPatterns\Creational\AbstractFactory\Text + \DesignPatterns\Creational\AbstractFactory\Parser + \DesignPatterns\Creational\AbstractFactory\ParserFactory + \DesignPatterns\Creational\AbstractFactory\JsonParser + \DesignPatterns\Creational\AbstractFactory\CsvParser - - - - - + + + + + - - - - - - - + - - - - - - - - - + + + - - - \DesignPatterns\Creational\AbstractFactory\AbstractFactory - + + - Methods - Constants Fields + Constants + Constructors + Methods private diff --git a/Creational/AbstractFactory/uml/uml.png b/Creational/AbstractFactory/uml/uml.png index 68d3a8b..fc1db5d 100644 Binary files a/Creational/AbstractFactory/uml/uml.png and b/Creational/AbstractFactory/uml/uml.png differ diff --git a/Creational/AbstractFactory/uml/uml.svg b/Creational/AbstractFactory/uml/uml.svg index e7eff24..ecd8021 100644 --- a/Creational/AbstractFactory/uml/uml.svg +++ b/Creational/AbstractFactory/uml/uml.svg @@ -1,560 +1,82 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + - + - + - + - + - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + - + - - + + - - + + - - + + - - + + - - + + - - + + - - - createText(content) + + - - + + - - - + + - - - - - JsonFactory - - - JsonFactory - - - - - - - - - - - - - - - - - - - - - - createText(content) - - - - - - - - - - - - - JsonFactory - - - JsonFactory - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - createText(content) - - - - - - - - - - - - - AbstractFactory - - - AbstractFactory - - - - - - - - - - - - - - - - - - - - - - createText(content) - - - - - - - - - - - - - AbstractFactory - - - AbstractFactory - - - - - - - - - - - - - - - - - - - - - - createText(content) - - - - - - - - - - - - - HtmlFactory - - - HtmlFactory - - - - - - - - - - - - - - - - - - - - - - createText(content) - - - - - - - - - - - - - HtmlFactory - - - HtmlFactory - - - - - - - - - - - - - - - - JsonText - - - JsonText - - - - - - - - - - - - - JsonText - - - JsonText - - - - - - - - - - - - - - - - HtmlText - - - HtmlText - - - - - - - - - - - - - HtmlText - - - HtmlText - - - - - - - - - - - - - - - - - - - - - - - - - text - - - - - - - - - - - - - Text - - - Text - - - - - - - - - - - - - - - - - - - - - - text - - - - - - - - - - - - - Text - - - Text - - - - - - - - - - - - + + + +