Completed
Push — master ( d89681...8e123d )
by Andreas
20s
created

MainParser::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.9666
c 0
b 0
f 0
cc 1
nc 1
nop 3
1
<?php
2
3
/*
4
 * Copyright (c) Andreas Heigl<[email protected]
5
 *
6
 * Licensed under the MIT License. See LICENSE.md file in the project root
7
 * for full license information.
8
 */
9
10
namespace Callingallpapers\Parser\ConfsTech;
11
12
use DateTimeImmutable;
13
use GuzzleHttp\Client;
14
15
class MainParser
16
{
17
    private $yearParser;
18
19
    private $client;
20
21
    private $startYear;
22
23
    public function __construct(
24
        YearParser $yearParser,
25
        Client $client,
26
        string $startYear
27
    ) {
28
        $this->yearParser = $yearParser;
29
        $this->client     = $client;
30
        $this->startYear  = $startYear;
31
    }
32
33 View Code Duplication
    public function __invoke()
0 ignored issues
show
Duplication introduced by
This method 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...
34
    {
35
        $years = $this->client->request(
36
            'GET',
37
            'https://api.github.com/repos/tech-conferences/conference-data/contents/conferences'
38
        );
39
40
        $years = json_decode($years->getBody()->getContents(), true);
41
        foreach ($years as $year) {
42
            if ($year['name'] < $this->startYear) {
43
                continue;
44
            }
45
            ($this->yearParser)($year['url']);
46
        }
47
    }
48
}
49