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.

TimelineWidget   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 5
dl 0
loc 60
ccs 17
cts 17
cp 1
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getName() 0 4 1
A renderWidget() 0 11 3
A getOneTimeWidgetJs() 0 4 1
A getFunctions() 0 8 1
1
<?php
2
/*
3
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
4
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
5
 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
6
 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
7
 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
8
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
9
 */
10
11
namespace TwitterWidgetBundle\Extension;
12
13
use InvalidArgumentException;
14
use TwitterWidgets\Assets\OneTimeJsProvider;
15
use TwitterWidgets\Options\WidgetOptions;
16
use TwitterWidgets\Options\WidgetOptionsInterface;
17
use TwitterWidgets\Timeline\TimelineBuilderInterface;
18
19
class TimelineWidget extends \Twig_Extension
20
{
21
    protected $widgetOptions;
22
    protected $timeline;
23
24
    /**
25
     * @param WidgetOptions            $widgetOptions
26
     * @param TimelineBuilderInterface $timeline
27
     */
28 6
    public function __construct(WidgetOptions $widgetOptions, TimelineBuilderInterface $timeline)
29
    {
30 6
        $this->widgetOptions = $widgetOptions;
31 6
        $this->timeline      = $timeline;
32 6
    }
33
34
    /**
35
     * @return array
36
     */
37 1
    public function getFunctions()
38
    {
39
        return [
40 1
            new \Twig_SimpleFunction('tw', [$this, 'renderWidget'], ['is_safe' => ['html']]),
41 1
            new \Twig_SimpleFunction('twJs', [$this, 'getOneTimeWidgetJs'], ['is_safe' => ['html']]),
42
43
        ];
44
    }
45
46
    /**
47
     * @return string
48
     */
49 1
    public function getName()
50
    {
51 1
        return 'timelinewidgetextensions';
52
    }
53
54
    /**
55
     * @param  array|WidgetOptionsInterface $options
56
     * @param  bool                         $addJs
57
     * @return string
58
     */
59 2
    public function renderWidget($options, $addJs = true)
60
    {
61 2
        if (!is_array($options) && !($options instanceof WidgetOptionsInterface)) {
62 1
            throw new InvalidArgumentException(
63 1
                '"options" must be an array or an implementation of WidgetOptionsInterface'
64
            );
65
        }
66 1
        $this->widgetOptions->setFromArray($options);
0 ignored issues
show
Bug introduced by
It seems like $options defined by parameter $options on line 59 can also be of type object<TwitterWidgets\Op...WidgetOptionsInterface>; however, Zend\Stdlib\AbstractOptions::setFromArray() does only seem to accept array|object<Traversable...Stdlib\AbstractOptions>, maybe add an additional type check?

This check looks at variables that have been passed in as parameters and are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
67
68 1
        return $this->timeline->renderWidget($addJs);
69
    }
70
71
    /**
72
     * @return mixed
73
     */
74 1
    public function getOneTimeWidgetJs()
75
    {
76 1
        return (new OneTimeJsProvider())->getOneTimeWidgetJs();
77
    }
78
}
79