GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

StoreSubscriber::postUpdate()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 2
eloc 3
c 1
b 0
f 1
nc 2
nop 1
dl 0
loc 6
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Odiseo\SyliusMailchimpPlugin\EventListener;
6
7
use Doctrine\Common\EventSubscriber;
8
use Doctrine\ORM\Event\LifecycleEventArgs;
9
use Odiseo\SyliusMailchimpPlugin\Handler\StoreRegisterHandlerInterface;
10
use Sylius\Component\Core\Model\ChannelInterface;
11
12
final class StoreSubscriber implements EventSubscriber
13
{
14
    /** @var StoreRegisterHandlerInterface */
15
    private $storeRegisterHandler;
16
17
    public function __construct(StoreRegisterHandlerInterface $storeRegisterHandler)
18
    {
19
        $this->storeRegisterHandler = $storeRegisterHandler;
20
    }
21
22
    /**
23
     * {@inheritdoc}
24
     */
25
    public function getSubscribedEvents(): array
26
    {
27
        return [
28
            'postPersist',
29
            'postUpdate',
30
            'postRemove',
31
        ];
32
    }
33
34
    /**
35
     * @param LifecycleEventArgs $args
36
     */
37
    public function postPersist(LifecycleEventArgs $args): void
38
    {
39
        $channel = $args->getEntity();
40
41
        if ($channel instanceof ChannelInterface) {
42
            $this->register($channel);
43
        }
44
    }
45
46
    /**
47
     * @param LifecycleEventArgs $args
48
     */
49
    public function postUpdate(LifecycleEventArgs $args): void
50
    {
51
        $channel = $args->getEntity();
52
53
        if ($channel instanceof ChannelInterface) {
54
            $this->register($channel);
55
        }
56
    }
57
58
    /**
59
     * @param LifecycleEventArgs $args
60
     */
61
    public function postRemove(LifecycleEventArgs $args): void
62
    {
63
        $channel = $args->getEntity();
64
65
        if ($channel instanceof ChannelInterface) {
66
            $this->unregister($channel);
67
        }
68
    }
69
70
    /**
71
     * @param ChannelInterface $channel
72
     */
73
    private function register(ChannelInterface $channel): void
74
    {
75
        $this->storeRegisterHandler->register($channel);
76
    }
77
78
    /**
79
     * @param ChannelInterface $channel
80
     */
81
    private function unregister(ChannelInterface $channel): void
82
    {
83
        $this->storeRegisterHandler->unregister($channel);
84
    }
85
}
86