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.

DefaultAction::jsonSerialize()   B
last analyzed

Complexity

Conditions 5
Paths 8

Size

Total Lines 21
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 14
CRAP Score 5

Importance

Changes 0
Metric Value
dl 0
loc 21
c 0
b 0
f 0
ccs 14
cts 14
cp 1
rs 8.7624
cc 5
eloc 11
nc 8
nop 0
crap 5
1
<?php
2
3
namespace Tgallice\FBMessenger\Model;
4
5
class DefaultAction implements \JsonSerializable
6
{
7
    const HEIGHT_RATIO_FULL = 'full';
8
    const HEIGHT_RATIO_COMPACT = 'compact';
9
    const HEIGHT_RATIO_TALL = 'tall';
10
11
    /**
12
     * @var string
13
     */
14
    private $url;
15
16
    /**
17
     * @var string
18
     */
19
    private $webviewHeightRatio;
20
21
    /**
22
     * @var bool
23
     */
24
    private $messengerExtensions = false;
25
26
    /**
27
     * @var string|null
28
     */
29
    public $fallbackUrl;
30
31
    /**
32
     * @param string $url
33
     * @param string $webviewHeghtRatio
34
     * @param bool $messengerExtensions
35
     * @param null|string $fallbaclUrl
36
     */
37 7
    public function __construct($url, $webviewHeghtRatio = self::HEIGHT_RATIO_FULL, $messengerExtensions = false, $fallbaclUrl = null)
38
    {
39 7
        $this->url = $url;
40 7
        $this->webviewHeightRatio = $webviewHeghtRatio;
41 7
        $this->messengerExtensions = (bool) $messengerExtensions;
42 7
        $this->fallbackUrl = $fallbaclUrl;
43 7
    }
44
45
    /**
46
     * @return string
47
     */
48 1
    public function getUrl()
49
    {
50 1
        return $this->url;
51
    }
52
53
    /**
54
     * @return string|null
55
     */
56 1
    public function getWebviewHeightRatio()
57
    {
58 1
        return $this->webviewHeightRatio;
59
    }
60
61
    /**
62
     * @return string|null
63
     */
64 1
    public function getFallbackUrl()
65
    {
66 1
        return $this->fallbackUrl;
67
    }
68
69
    /**
70
     * @return bool
71
     */
72 1
    public function useMessengerExtensions()
73
    {
74 1
        return $this->messengerExtensions;
75
    }
76
77
    /**
78
     * @inheritdoc
79
     */
80 2
    public function jsonSerialize()
81
    {
82
        $json = [
83 2
            'type' => 'web_url',
84 2
            'url' => $this->url,
85 2
        ];
86
87 2
        if (!empty($this->webviewHeightRatio)) {
88 2
            $json['webview_height_ratio'] = $this->webviewHeightRatio;
89 2
        }
90
91 2
        if ($this->messengerExtensions) {
92 1
            $json['messenger_extensions'] = $this->messengerExtensions;
93 1
        }
94
95 2
        if ($this->messengerExtensions && !empty($this->fallbackUrl)) {
96 1
            $json['fallback_url'] = $this->fallbackUrl;
97 1
        }
98
99 2
        return $json;
100
    }
101
}
102