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.

Ozean12GooglePubSubExtension   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 7

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 7
dl 0
loc 58
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B load() 0 46 3
1
<?php
2
3
namespace Ozean12\GooglePubSubBundle\DependencyInjection;
4
5
use Ozean12\GooglePubSubBundle\Service\Publisher\Publisher;
6
use Symfony\Component\DependencyInjection\ContainerBuilder;
7
use Symfony\Component\Config\FileLocator;
8
use Symfony\Component\DependencyInjection\Reference;
9
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
10
use Symfony\Component\DependencyInjection\Loader;
11
12
/**
13
 * {@inheritdoc}
14
 */
15
class Ozean12GooglePubSubExtension extends Extension
16
{
17
    const PUBSUB_CLIENT_SERVICE_DEFINITION = 'ozean12_google_pubsub.pubsub_client.service';
18
    const CLIENT_SERVICE_DEFINITION = 'ozean12_google_pubsub.client.service';
19
    const PUBLISHER_SERVICE_DEFINITION = 'ozean12_google_pubsub.publisher.';
20
    const SUBSCRIBER_MANAGER_SERVICE_DEFINITION = 'ozean12_google_pubsub.push_subscriber_manager.service';
21
    const TAG_NAME = 'ozean12_pub_sub_service';
22
23
    /**
24
     * {@inheritdoc}
25
     */
26
    public function load(array $configs, ContainerBuilder $container)
27
    {
28
        $configuration = new Configuration();
29
        $config = $this->processConfiguration($configuration, $configs);
30
31
        $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
32
        $loader->load('services.yml');
33
34
        $definitions = [];
35
        $clientConfig = [
36
            'projectId' => $config['project_id'],
37
            'keyFilePath' => $config['key_file_path'],
38
        ];
39
40
        $pubSubDefinition = $container
41
            ->getDefinition(self::PUBSUB_CLIENT_SERVICE_DEFINITION)
42
            ->replaceArgument(0, $clientConfig)
43
        ;
44
45
        $baseDefinition = $container->getDefinition(self::CLIENT_SERVICE_DEFINITION);
46
47
        foreach ($config['topics'] as $topic) {
48
            $definitions[self::PUBLISHER_SERVICE_DEFINITION.$topic] = (clone $baseDefinition)
49
                ->replaceArgument(0, $topic)
50
                ->replaceArgument(1, $pubSubDefinition)
51
                ->replaceArgument(3, $config['topic_suffix'] ?? '')
52
                ->setClass(Publisher::class)
53
                ->setPublic(true)
54
                ->addTag(self::TAG_NAME)
55
            ;
56
        }
57
58
        $subscriberManager = $container
59
            ->getDefinition(self::SUBSCRIBER_MANAGER_SERVICE_DEFINITION)
60
            ->replaceArgument(0, $config['project_id'])
61
            ->addTag(self::TAG_NAME)
62
        ;
63
64
        foreach ($config['push_subscriptions'] as $subscriptionName => $subscriberServiceName) {
65
            $subscriberManager
66
                ->addMethodCall('addSubscriber', [$subscriptionName, new Reference($subscriberServiceName)])
67
            ;
68
        }
69
70
        $container->addDefinitions($definitions);
71
    }
72
}
73