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.
Passed
Push — master ( 890c9c...35b399 )
by
unknown
02:03
created

Page::getPresets()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 0
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * This file is part of the O2System Framework package.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 *
8
 * @author         Steeve Andrian Salim
9
 * @copyright      Copyright (c) Steeve Andrian Salim
10
 */
11
12
// ------------------------------------------------------------------------
13
14
namespace O2System\Framework\Http\Presenter;
15
16
// ------------------------------------------------------------------------
17
18
use O2System\Framework\Libraries\Ui\Components\Breadcrumb;
19
use O2System\Framework\Libraries\Ui\Contents\Link;
20
use O2System\Kernel\Http\Message\Uri;
21
use O2System\Psr\Patterns\Structural\Repository\AbstractRepository;
22
use O2System\Spl\DataStructures\SplArrayObject;
23
use O2System\Spl\Info\SplFileInfo;
24
25
/**
26
 * Class Page
27
 *
28
 * @package App\DataStructures
29
 */
30
class Page extends AbstractRepository
31
{
32
    /**
33
     * Page::$file
34
     *
35
     * @var \O2System\Spl\Info\SplFileInfo
36
     */
37
    public $file;
38
39
    /**
40
     * Page Variables
41
     *
42
     * @var array
43
     */
44
    private $vars = [];
45
46
    /**
47
     * Page Presets
48
     *
49
     * @var SplArrayObject
50
     */
51
    private $presets;
52
53
    // ------------------------------------------------------------------------
54
55
    /**
56
     * Page::__construct
57
     */
58
    public function __construct()
59
    {
60
        // Create Page breadcrumbs
61
        $breadcrumb = new Breadcrumb();
62
        $breadcrumb->createList(new Link(language()->getLine('HOME'), base_url()));
63
        $this->store('breadcrumb', $breadcrumb);
64
65
        // Store Page Uri
66
        $uri = new Uri();
67
        $this->store('uri', $uri);
68
    }
69
70
    // ------------------------------------------------------------------------
71
72
    /**
73
     * Page::setVars
74
     *
75
     * @param array $vars
76
     *
77
     * @return static
78
     */
79
    public function setVars(array $vars)
80
    {
81
        $this->vars = $vars;
82
83
        return $this;
84
    }
85
86
    // ------------------------------------------------------------------------
87
88
    /**
89
     * Page::getVars
90
     *
91
     * Gets page variables.
92
     *
93
     * @return array
94
     */
95
    public function getVars()
96
    {
97
        return $this->vars;
98
    }
99
100
    // ------------------------------------------------------------------------
101
102
    /**
103
     * Page::setPresets
104
     *
105
     * @param \O2System\Spl\DataStructures\SplArrayObject $presets
106
     *
107
     * @return static
108
     */
109
    public function setPresets(SplArrayObject $presets)
110
    {
111
        $this->presets = $presets;
112
113
        return $this;
114
    }
115
116
    // ------------------------------------------------------------------------
117
118
    /**
119
     * Page::getPresets
120
     *
121
     * Gets page presets.
122
     *
123
     * @return bool|\O2System\Spl\DataStructures\SplArrayObject
124
     */
125
    public function getPresets()
126
    {
127
        if ($this->presets instanceof SplArrayObject) {
0 ignored issues
show
introduced by
$this->presets is always a sub-type of O2System\Spl\DataStructures\SplArrayObject.
Loading history...
128
            return $this->presets;
129
        }
130
131
        return false;
132
    }
133
134
    // ------------------------------------------------------------------------
135
136
    /**
137
     * Page::setFile
138
     *
139
     * @param $filePath
140
     *
141
     * @return static
142
     */
143
    public function setFile($filePath)
144
    {
145
        if (is_file($filePath)) {
146
            $this->file = new SplFileInfo($filePath);
147
148
            if (file_exists(
149
                $propertiesFilePath = $this->file->getPath() . DIRECTORY_SEPARATOR . str_replace(
150
                        '.phtml',
151
                        '.json',
152
                        strtolower($this->file->getBasename())
153
                    )
154
            )) {
155
                $properties = file_get_contents($propertiesFilePath);
156
                $properties = json_decode($properties, true);
157
158
                if (isset($properties[ 'vars' ])) {
159
                    $this->vars = $properties[ 'vars' ];
160
                }
161
162
                if (isset($properties[ 'presets' ])) {
163
                    $this->presets = new SplArrayObject($properties[ 'presets' ]);
164
                }
165
            }
166
        }
167
168
        return $this;
169
    }
170
171
    // ------------------------------------------------------------------------
172
173
    /**
174
     * Page::setHeader
175
     *
176
     * @param string $header
177
     *
178
     * @return static
179
     */
180
    public function setHeader($header)
181
    {
182
        $header = trim($header);
183
        $this->store('header', $header);
184
        presenter()->meta->offsetSet('subtitle', $header);
185
        presenter()->meta->title->append($header);
186
187
        return $this;
188
    }
189
190
    // ------------------------------------------------------------------------
191
192
    /**
193
     * Page::setSubHeader
194
     *
195
     * @param string $subHeader
196
     *
197
     * @return static
198
     */
199
    public function setSubHeader($subHeader)
200
    {
201
        $this->store('subHeader', trim($subHeader));
202
203
        return $this;
204
    }
205
206
    // ------------------------------------------------------------------------
207
208
    /**
209
     * Page::setDescription
210
     *
211
     * @param string $description
212
     *
213
     * @return static
214
     */
215
    public function setDescription($description)
216
    {
217
        $description = trim($description);
218
        $this->store('description', $description);
219
220
        return $this;
221
    }
222
223
    // ------------------------------------------------------------------------
224
225
    /**
226
     * Page::setContent
227
     *
228
     * @param string $content
229
     *
230
     * @return static
231
     */
232
    public function setContent($content)
233
    {
234
        if ( ! empty($content)) {
235
            presenter()->partials->offsetSet('content', $content);
236
        }
237
238
        return $this;
239
    }
240
}