SearchPage   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 86.67 %

Coupling/Cohesion

Components 1
Dependencies 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 1
cbo 6
dl 26
loc 30
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getSeries() 13 13 1
A getUsers() 13 13 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\Page;
14
15
use Doctrine\Common\Collections\ArrayCollection;
16
use Webuni\Srazy\Crawler;
17
use Webuni\Srazy\Model\Series;
18
use Webuni\Srazy\Model\User;
19
20
class SearchPage extends AbstractPage
21
{
22 View Code Duplication
    public function getSeries()
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...
23
    {
24
        $series = $this->crawler->filter('.body-default .span6:first-child h3 a')->each(function (Crawler $link) {
25
            $uri = $link->link()->getUri();
26
            $series = $this->client->model(Series::class, $uri);
27
            $series->setName($link->text());
28
            $series->setUri($uri);
29
30
            return $series;
31
        });
32
33
        return new ArrayCollection($series);
34
    }
35
36 View Code Duplication
    public function getUsers()
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...
37
    {
38
        $users = $this->crawler->filter('.body-default .span6 + .span6 h3 a')->each(function (Crawler $link) {
39
            $uri = $link->link()->getUri();
40
            $user = $this->client->model(User::class, $uri);
41
            $user->setName($link->text());
42
            $user->setUri($link->link()->getUri());
43
44
            return $user;
45
        });
46
47
        return new ArrayCollection($users);
48
    }
49
}
50