GuildController::collect()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 9
Ratio 100 %

Importance

Changes 0
Metric Value
dl 9
loc 9
rs 9.6666
c 0
b 0
f 0
cc 2
eloc 5
nc 2
nop 1
1
<?php
2
3
namespace App\Controller\API;
4
5
use App\Entity\Guild;
6
use App\Handler\ApiHandler;
7
use App\Utils\AbstractCrawler;
8
use App\Utils\GuildCrawler;
9
use FOS\RestBundle\Controller\FOSRestController;
10
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
11
use Nelmio\ApiDocBundle\Annotation\Model;
12
use Swagger\Annotations as SWG;
13
14
/**
15
 * @Route("/api/guild")
16
 */
17
class GuildController extends FOSRestController
18
{
19
    /**
20
     * @Route("/", name="api_guild")
21
     *
22
     * @SWG\Response(
23
     *     response=200,
24
     *     description="Returns the top 12 products from store",
25
     *     @SWG\Schema(
26
     *         type="array",
27
     *         @Model(type=Guild::class, groups={"users"})
28
     *     )
29
     * )
30
     * @SWG\Tag(name="guild")
31
     */
32
    public function cget()
33
    {
34
        return $this->getHandler()->collect(['guild']);
35
    }
36
37
    /**
38
     * @Route("/collect", name="api_guild_collect_users")
39
     *
40
     * @SWG\Response(
41
     *     response=200,
42
     *     description="Returns the top 12 products from store",
43
     *     @SWG\Schema(
44
     *         type="array",
45
     *         @Model(type=Guild::class, groups={"users"})
46
     *     )
47
     * )
48
     * @SWG\Tag(name="guild")
49
     */
50 View Code Duplication
    public function collect(GuildCrawler $guildCrawler)
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...
51
    {
52
        $guilds = $this->getDoctrine()->getRepository(Guild::class)->findAll();
53
54
        foreach ($guilds as $guild) {
55
            $guildCrawler->crawl($guild);
56
        }
57
        return $this->getHandler()->collect(['guild']);
58
    }
59
60
    public function getHandler()
61
    {
62
        return $this->get(ApiHandler::class)->init(Guild::class);
63
    }
64
}
65