Completed
Push — master ( a8b0ff...93e3c3 )
by Dennis
8s
created

src/Parser/JusticeSpolecnikPersonParser.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace Defr\Parser;
4
5
use Defr\Parser\Helper\StringHelper;
6
use Defr\ValueObject\Person;
7
use Symfony\Component\DomCrawler\Crawler;
8
9 View Code Duplication
final class JusticeSpolecnikPersonParser
0 ignored issues
show
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
10
{
11
    /**
12
     * @param Crawler $crawler
13
     * @return Person
14
     */
15
    public static function parseFromDomCrawler(Crawler $crawler)
16
    {
17
        $content = $crawler->text();
18
        $content = StringHelper::removeEmptyLines($content);
19
20
        $contentItems = explode("\n", $content);
21
        $contentItems = array_map('trim', $contentItems);
22
        $name = trim(explode(',', $contentItems[1])[0]);
23
24
        $birthday = DateTimeParser::parseFromCzechDateString($contentItems[2]);
25
26
        return new Person($name, $birthday, $contentItems[3]);
27
    }
28
}
29