Passed
Push — master ( 79c4f7...80a53d )
by Guillaume
12:18
created

BaseDocset::specificPages()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace App\Docsets;
4
5
use App\Contracts\Docset;
6
use Illuminate\Support\Collection;
7
use Illuminate\Support\Facades\Storage;
8
9
abstract class BaseDocset implements Docset
10
{
11
    public const CODE = self::CODE;
12
    public const NAME = self::NAME;
13
    public const URL = self::URL;
14
    public const INDEX = self::INDEX;
15
    public const PLAYGROUND = self::PLAYGROUND;
16
    public const ICON_16 = self::ICON_16;
17
    public const ICON_32 = self::ICON_32;
18
    public const EXTERNAL_DOMAINS = self::EXTERNAL_DOMAINS;
19
20
21 3
    final public function code(): string
22
    {
23 3
        return static::CODE;
24
    }
25
26 2
    final public function name(): string
27
    {
28 2
        return static::NAME;
29
    }
30
31 2
    final public function url(): string
32
    {
33 2
        return static::URL;
34
    }
35
36 2
    final public function index(): string
37
    {
38 2
        return static::INDEX;
39
    }
40
41 2
    final public function playground(): string
42
    {
43 2
        return static::PLAYGROUND;
44
    }
45
46 2
    final public function icon16(): string
47
    {
48 2
        return static::ICON_16;
49
    }
50
51 2
    final public function icon32(): string
52
    {
53 2
        return static::ICON_32;
54
    }
55
56 1
    final public function externalDomains(): string
57
    {
58 1
        return implode(
59 1
            ',',
60 1
            array_merge((array) static::URL, (array) static::EXTERNAL_DOMAINS)
61
        );
62
    }
63
64 34
    final public function file(): string
65
    {
66 34
        return static::CODE . '/' . static::CODE . '.docset';
67
    }
68
69 25
    final public function innerDirectory(): string
70
    {
71 25
        return self::file() . '/Contents/Resources/Documents';
0 ignored issues
show
Bug Best Practice introduced by
The method App\Docsets\BaseDocset::file() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

71
        return self::/** @scrutinizer ignore-call */ file() . '/Contents/Resources/Documents';
Loading history...
72
    }
73
74 21
    final public function innerIndex(): string
75
    {
76 21
        return self::innerDirectory() . '/' . static::INDEX;
0 ignored issues
show
Bug Best Practice introduced by
The method App\Docsets\BaseDocset::innerDirectory() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

76
        return self::/** @scrutinizer ignore-call */ innerDirectory() . '/' . static::INDEX;
Loading history...
77
    }
78
79 35
    final public function downloadedDirectory(): string
80
    {
81 35
        return static::CODE . '/docs/' . static::URL;
82
    }
83
84 21
    final public function downloadedIndex(): string
85
    {
86 21
        return self::downloadedDirectory() . '/' . static::INDEX;
0 ignored issues
show
Bug Best Practice introduced by
The method App\Docsets\BaseDocset::downloadedDirectory() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

86
        return self::/** @scrutinizer ignore-call */ downloadedDirectory() . '/' . static::INDEX;
Loading history...
87
    }
88
89 3
    final public function infoPlistFile(): string
90
    {
91 3
        return self::file() . '/Contents/Info.plist';
0 ignored issues
show
Bug Best Practice introduced by
The method App\Docsets\BaseDocset::file() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

91
        return self::/** @scrutinizer ignore-call */ file() . '/Contents/Info.plist';
Loading history...
92
    }
93
94 8
    final public function databaseFile(): string
95
    {
96 8
        return self::file() . '/Contents/Resources/docSet.dsidx';
0 ignored issues
show
Bug Best Practice introduced by
The method App\Docsets\BaseDocset::file() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

96
        return self::/** @scrutinizer ignore-call */ file() . '/Contents/Resources/docSet.dsidx';
Loading history...
97
    }
98
99 2
    final public function htmlFiles(): Collection
100
    {
101 2
        $files = Storage::allFiles(
102 2
            self::innerDirectory()
0 ignored issues
show
Bug Best Practice introduced by
The method App\Docsets\BaseDocset::innerDirectory() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

102
            self::/** @scrutinizer ignore-call */ 
103
                  innerDirectory()
Loading history...
103
        );
104
105
        return collect($files)->reject(static function ($file) {
106 2
            return substr($file, -5) !== '.html';
107 2
        });
108
    }
109
110
    abstract public function entries(string $html): Collection;
111
112
    abstract public function format(string $html): string;
113
}
114