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.
Completed
Pull Request — master (#206)
by Jeroen
02:07
created

AppEngineDriver::resolveEndpoint()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
rs 9.4285
cc 2
eloc 4
nc 2
nop 1
1
<?php
2
3
namespace Bernard\Driver;
4
5
use google\appengine\api\taskqueue\PushTask;
6
use Symfony\Component\OptionsResolver\OptionsResolver;
7
8
/**
9
 * Simple driver for google AppEngine. Many features are not supported.
10
 * It takes a list of array('name' => 'endpoint') to route messages to the
11
 * correct place.
12
 *
13
 * @package Bernard
14
 */
15
class AppEngineDriver extends AbstractDriver
16
{
17
    protected $queueMap;
18
19
    /**
20
     * @param array $queueMap
21
     */
22
    public function __construct(array $queueMap)
23
    {
24
        $this->queueMap = $queueMap;
25
    }
26
27
    /**
28
     * {@inheritdoc}
29
     */
30
    public function listQueues()
31
    {
32
        return array_flip($this->queueMap);
33
    }
34
35
    /**
36
     * {@inheritdoc}
37
     */
38
    public function createQueue($queueName, array $options = [])
39
    {
40
    }
41
42
    /**
43
     * {@inheritdoc}
44
     */
45
    public function countMessages($queueName)
46
    {
47
    }
48
49
    /**
50
     * {@inheritdoc}
51
     */
52
    public function pushMessage($queueName, $message, array $options = [])
53
    {
54
        $options = $this->validatePushOptions($options);
55
56
        $task = new PushTask($this->resolveEndpoint($queueName), compact('message'), $options);
57
        $task->add($queueName);
58
    }
59
60
    /**
61
     * {@inheritdoc}
62
     */
63
    public function popMessage($queueName, $duration = 5)
64
    {
65
    }
66
67
    /**
68
     * {@inheritdoc}
69
     */
70
    public function acknowledgeMessage($queueName, $receipt)
71
    {
72
    }
73
74
    /**
75
     * {@inheritdoc}
76
     */
77
    public function removeQueue($queueName)
78
    {
79
    }
80
81
    /**
82
     * {@inheritdoc}
83
     */
84
    public function peekQueue($queueName, $index = 0, $limit = 20)
85
    {
86
        return [];
87
    }
88
89
    /**
90
     * {@inheritdoc}
91
     */
92
    public function info()
93
    {
94
        return [];
95
    }
96
97
    /**
98
     * {@inheritdoc}
99
     */
100
    public function configurePushOptions(OptionsResolver $resolver)
101
    {
102
        //BC layer to support 2.3+ and 2.7+/3.0+ versions
103
        if (interface_exists('Symfony\Component\OptionsResolver\OptionsResolverInterface')) {
104
            //2.3+
105
            $resolver
0 ignored issues
show
Bug introduced by
The method setOptional() does not seem to exist on object<Symfony\Component...solver\OptionsResolver>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
106
                ->setOptional(array(
107
                    'method',
108
                    'name',
109
                    'delay_seconds',
110
                    'header',
111
                ))
112
                ->setAllowedValues(array(
113
                    'method' => array('POST', 'GET', 'HEAD', 'PUT', 'DELETE'),
114
                ))
115
            ;
116
        } else {
117
            //2.7+
118
            $resolver
119
                ->setDefined('method')
120
                ->setDefined('name')
121
                ->setDefined('delay_seconds')
122
                ->setDefined('header')
123
                ->setAllowedValues(
124
                    'method', array('POST', 'GET', 'HEAD', 'PUT', 'DELETE')
125
                )
126
            ;
127
        }
128
    }
129
130
    /**
131
     * @param string $queueName
132
     *
133
     * @throws InvalidArgumentException
134
     */
135
    protected function resolveEndpoint($queueName)
136
    {
137
        if (isset($this->queueMap[$queueName])) {
138
            return $this->queueMap[$queueName];
139
        }
140
141
        return '/_ah/queue/' . $queueName;
142
    }
143
}
144