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 ( 0e1ebf...76891d )
by Sebastian
01:12
created

YamlFrontMatterSpec   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 50
Duplicated Lines 58 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 2
dl 29
loc 50
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A it_is_initializable() 0 4 1
A it_can_parse_valid_front_matter() 14 14 1
A it_falls_back_to_empty_front_matter_with_the_original_as_body() 15 15 1
A getMatchers() 0 11 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace spec\Spatie\YamlFrontMatter;
4
5
use PhpSpec\ObjectBehavior;
6
use Spatie\YamlFrontMatter\Document;
7
use Spatie\YamlFrontMatter\YamlFrontMatter;
8
9
class YamlFrontMatterSpec extends ObjectBehavior
10
{
11
    public function it_is_initializable()
12
    {
13
        $this->shouldHaveType(YamlFrontMatter::class);
14
    }
15
16 View Code Duplication
    public function it_can_parse_valid_front_matter()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
17
    {
18
        $contents = "
19
        ---
20
        foo: bar
21
        ---
22
23
        Lorem ipsum.
24
        ";
25
26
        $this->parse($contents)->shouldHaveType(Document::class);
27
        $this->parse($contents)->shouldHaveFrontMatter(['foo' => 'bar']);
28
        $this->parse($contents)->shouldHaveBodyContaining('Lorem ipsum.');
29
    }
30
31 View Code Duplication
    public function it_falls_back_to_empty_front_matter_with_the_original_as_body()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
32
    {
33
        $contents = "
34
        ---
35
        foo: bar
36
        --
37
38
        Lorem ipsum.
39
        ";
40
41
        $this->parse($contents)->shouldHaveType(Document::class);
42
        $this->parse($contents)->shouldHaveFrontMatter([]);
43
        $this->parse($contents)->shouldHaveBodyContaining('foo: bar');
44
        $this->parse($contents)->shouldHaveBodyContaining('Lorem ipsum.');
45
    }
46
47
    public function getMatchers() : array
48
    {
49
        return [
50
            'haveFrontMatter' => function (Document $subject, $value) {
51
                return $subject->matter() === $value;
52
            },
53
            'haveBodyContaining' => function (Document $subject, $value) {
54
                return str_contains($subject->body(), $value);
55
            },
56
        ];
57
    }
58
}
59