Passed
Push — develop ( c3bda6...364e1b )
by Guillaume
03:34
created

Alfred4::format()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
c 0
b 0
f 0
dl 0
loc 10
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
namespace App\Docsets;
4
5
use Godbout\DashDocsetBuilder\Docsets\BaseDocset;
6
use Illuminate\Support\Collection;
7
use Illuminate\Support\Facades\Storage;
8
use Wa72\HtmlPageDom\HtmlPageCrawler;
9
10
class Alfred4 extends BaseDocset
11
{
12
    public const CODE = 'alfred-4';
13
    public const NAME = 'Alfred 4';
14
    public const URL = 'alfred-4.com';
15
    public const INDEX = 'index.html';
16
    public const PLAYGROUND = '';
17
    public const ICON_16 = 'favicon-16x16.png';
18
    public const ICON_32 = 'favicon-32x32.png';
19
    public const EXTERNAL_DOMAINS = [
20
        '',
21
    ];
22
23
    public function entries(string $file): Collection
24
    {
25
        $crawler = HtmlPageCrawler::create(Storage::get($file));
26
27
        $crawler->filter('h1')->each(function (HtmlPageCrawler $node) use ($entries) {
0 ignored issues
show
Unused Code introduced by
The parameter $node is not used and could be removed. ( Ignorable by Annotation )

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

27
        $crawler->filter('h1')->each(function (/** @scrutinizer ignore-unused */ HtmlPageCrawler $node) use ($entries) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Comprehensibility Best Practice introduced by
The variable $entries seems to be never defined.
Loading history...
28
            $entries->push([
29
                'name' => 'What Shows up in Dash',
30
                'type' => 'One of the Million of Dash Entry Type',
31
                'path' => 'The Path to the File',
32
            ]);
33
        });
34
35
        return $entries;
36
    }
37
38
    public function format(string $file): string
39
    {
40
        $crawler = HtmlPageCrawler::create(Storage::get($file));
41
42
        /**
43
         * This is equivalent to murder
44
         */
45
        $crawler->filter('body')->remove();
46
47
        return $crawler->saveHTML();
48
    }
49
}
50