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

YearParser   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 44.44 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 3
dl 12
loc 27
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A __invoke() 12 12 2

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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 GuzzleHttp\Client;
13
14
class YearParser
15
{
16
    private $client;
17
18
    private $parser;
19
20
    public function __construct(
21
        CategoryParser $parser,
22
        Client $client
23
    ) {
24
        $this->client = $client;
25
        $this->parser = $parser;
26
    }
27
28 View Code Duplication
    public function __invoke(string $url)
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...
29
    {
30
        $categories = $this->client->request('GET', $url);
31
32
        $categories = json_decode($categories->getBody()->getContents(), true);
33
        foreach ($categories as $category) {
34
            ($this->parser)(
35
                str_replace('.json', '', $category['name']),
36
                $category['git_url']
37
            );
38
        }
39
    }
40
}
41