Completed
Branch master (446cf6)
by Guillaume
04:16 queued 01:26
created

BaseDocset::databaseFile()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
c 0
b 0
f 0
rs 10
cc 1
nc 1
nop 0
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
    final public function code(): string
22
    {
23
        return static::CODE;
24
    }
25
26
    final public function name(): string
27
    {
28
        return static::NAME;
29
    }
30
31
    final public function url(): string
32
    {
33
        return static::URL;
34
    }
35
36
    final public function index(): string
37
    {
38
        return static::INDEX;
39
    }
40
41
    final public function playground(): string
42
    {
43
        return static::PLAYGROUND;
44
    }
45
46
    final public function icon16(): string
47
    {
48
        return static::ICON_16;
49
    }
50
51
    final public function icon32(): string
52
    {
53
        return static::ICON_32;
54
    }
55
56
    final public function externalDomains(): string
57
    {
58
        return implode(
59
            ',',
60
            array_merge((array) static::URL, (array) static::EXTERNAL_DOMAINS)
61
        );
62
    }
63
64
    final public function file(): string
65
    {
66
        return static::CODE . '/' . static::CODE . '.docset';
67
    }
68
69
    final public function innerDirectory(): string
70
    {
71
        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
    final public function innerIndex(): string
75
    {
76
        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
    final public function downloadedDirectory(): string
80
    {
81
        return static::CODE . '/docs/' . static::URL;
82
    }
83
84
    final public function downloadedIndex(): string
85
    {
86
        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
    final public function infoPlistFile(): string
90
    {
91
        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
    final public function databaseFile(): string
95
    {
96
        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
    final public function htmlFiles(): Collection
100
    {
101
        $files = Storage::allFiles(
102
            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
            return substr($file, -5) !== '.html';
107
        });
108
    }
109
110
    abstract public function entries(string $html): Collection;
111
112
    abstract public function format(string $html): string;
113
}
114