SeriesApi   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 45
Duplicated Lines 15.56 %

Coupling/Cohesion

Components 1
Dependencies 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 1
cbo 6
dl 7
loc 45
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A find() 7 7 1
A get() 0 12 2
A getFollowers() 0 10 1

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
 * This is part of the webuni/srazy-api-client.
5
 *
6
 * (c) Martin Hasoň <[email protected]>
7
 * (c) Webuni s.r.o. <[email protected]>
8
 *
9
 * For the full copyright and license information, please view the LICENSE
10
 * file that was distributed with this source code.
11
 */
12
13
namespace Webuni\Srazy\Api;
14
15
use Doctrine\Common\Collections\ArrayCollection;
16
use Webuni\Srazy\Model\Series;
17
use Webuni\Srazy\Page\CommunityPage;
18
use Webuni\Srazy\Page\SearchPage;
19
use Webuni\Srazy\Page\SeriesPage;
20
21
class SeriesApi extends AbstractApi
22
{
23
    /**
24
     * @return Series[]|ArrayCollection
25
     */
26 View Code Duplication
    public function find($series)
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...
27
    {
28
        $crawler = $this->client->get(sprintf('/hledat/?s=%s', urlencode($series)));
29
        $page = new SearchPage($crawler, $this->client);
30
31
        return $page->getSeries();
32
    }
33
34
    public function get($series)
35
    {
36
        $url = $series;
37
        if ($series instanceof Series) {
38
            $url = $series->getUri();
39
        }
40
41
        $crawler = $this->client->get($url.'/terminy');
42
        $page = new SeriesPage($crawler, $this->client);
43
44
        return $page->getSeries();
45
    }
46
47
    public function getFollowers(Series $series)
48
    {
49
        $crawler = $this->client->get($series->getUri().'/komunita');
50
        $page = new CommunityPage($crawler, $this->client);
51
52
        $followers = $page->getUsers();
53
        $series->setFollowers($followers);
54
55
        return $followers;
56
    }
57
58
    /*public function getEvents(Series $series)
0 ignored issues
show
Unused Code Comprehensibility introduced by
57% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
59
    {
60
        $crawler = $this->client->get($series->getUri().'/terminy');
61
        $page = new SeriesPage($crawler, $this->client);
62
63
        return $page->getEvents($series);
64
    }*/
65
}
66