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
Push — master ( eac52d...140efb )
by Sebastian
02:42
created

Document::__get()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 1
1
<?php
2
3
namespace Spatie\YamlFrontMatter;
4
5
use Illuminate\Support\Arr;
6
7
class Document
8
{
9
    protected $matter;
10
    protected $body;
11
12
    public function __construct(array $matter, string $body)
13
    {
14
        $this->matter = $matter;
15
        $this->body = $body;
16
    }
17
18
    public function matter(string $key = null, $default = null)
19
    {
20
        if ($key) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $key of type null|string is loosely compared to true; this is ambiguous if the string can be empty. You might want to explicitly use !== null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
21
            return Arr::get($this->matter, $key, $default);
22
        }
23
24
        return $this->matter;
25
    }
26
27
    public function body() : string
28
    {
29
        return $this->body;
30
    }
31
32
    public function __get($key)
33
    {
34
        if ($key === 'body') {
35
            return $this->body;
36
        }
37
38
        return $this->matter($key);
39
    }
40
}
41