MailingListUpdater   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A update() 0 20 2
1
<?php
2
namespace Tarioch\EveapiFetcherBundle\Component\EveApi\Char;
3
4
use JMS\DiExtraBundle\Annotation as DI;
5
use Tarioch\EveapiFetcherBundle\Entity\ApiCall;
6
use Pheal\Pheal;
7
use Tarioch\EveapiFetcherBundle\Entity\ApiKey;
8
use Tarioch\EveapiFetcherBundle\Entity\CharMailingList;
9
10
/**
11
 * @DI\Service("tarioch.eveapi.char.MailingLists")
12
 */
13
class MailingListUpdater extends AbstractCharUpdater
14
{
15
    /**
16
     * @inheritdoc
17
     */
18
    public function update(ApiCall $call, ApiKey $key, Pheal $pheal)
19
    {
20
        $charId = $call->getOwner()->getCharacterId();
21
22
        $query = 'delete from TariochEveapiFetcherBundle:CharMailingList c where c.ownerId=:ownerId';
23
        $this->entityManager
24
            ->createQuery($query)
25
            ->setParameter('ownerId', $charId)
26
            ->execute();
27
28
        $api = $pheal->charScope->MailingLists(array('characterID' => $charId));
29
30
        foreach ($api->mailingLists as $listApi) {
31
            $entity = new CharMailingList($charId, $listApi->listID);
32
            $entity->setDisplayName($listApi->displayName);
33
            $this->entityManager->persist($entity);
34
        }
35
36
        return $api->cached_until;
37
    }
38
}
39