HookController::fetchGuilds()   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\Entity\Setting;
7
use App\Handler\ApiHandler;
8
use App\Utils\AbstractCrawler;
9
use App\Utils\CharacterCrawler;
10
use App\Utils\GuildCrawler;
11
use FOS\RestBundle\Controller\FOSRestController;
12
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
13
use Nelmio\ApiDocBundle\Annotation\Model;
14
use Swagger\Annotations as SWG;
15
use Symfony\Component\HttpFoundation\JsonResponse;
16
17
/**
18
 * @Route("/api/hook")
19
 */
20
class HookController extends FOSRestController
21
{
22
    /**
23
     * @Route("/fetch-guild", name="api_guild_collect_users")
24
     */
25 View Code Duplication
    public function fetchGuilds(GuildCrawler $crawler)
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...
26
    {
27
        $guilds = $this->getDoctrine()->getRepository(Guild::class)->findAll();
28
        foreach ($guilds as $guild) {
29
            $crawler->crawl($guild);
30
        }
31
32
        return JsonResponse::create(['success']);
33
    }
34
    /**
35
     * @Route("/fetch-characters", name="api_collect_characters")
36
     */
37
    public function fetchCharacters(CharacterCrawler $crawler)
38
    {
39
        $settings = $this->getDoctrine()->getRepository(Setting::class)->findOneByCode('swgoh');
0 ignored issues
show
Bug introduced by
The method findOneByCode() does not exist on Doctrine\Common\Persistence\ObjectRepository. Did you maybe mean findOneBy()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
40
        $crawler->crawl($settings);
41
42
        return JsonResponse::create(['success']);
43
    }
44
}
45