SearchPage::getSeries()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 8

Duplication

Lines 13
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 13
loc 13
rs 9.4285
cc 1
eloc 8
nc 1
nop 0
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