1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App\Services; |
4
|
|
|
|
5
|
|
|
use App\Contracts\Docset; |
6
|
|
|
use LaravelZero\Framework\Commands\Command; |
7
|
|
|
use Illuminate\Console\Command as LaravelCommand; |
8
|
|
|
|
9
|
|
|
class DocsetBuilder |
10
|
|
|
{ |
11
|
|
|
protected $docset; |
12
|
|
|
|
13
|
|
|
protected $grabber; |
14
|
|
|
protected $packager; |
15
|
|
|
protected $archiver; |
16
|
|
|
|
17
|
|
|
protected $command; |
18
|
|
|
|
19
|
|
|
|
20
|
25 |
|
public function __construct(Docset $docset, ?Command $command = null) |
21
|
|
|
{ |
22
|
25 |
|
$this->docset = $docset; |
23
|
|
|
|
24
|
25 |
|
$this->grabber = new DocsetGrabber($this->docset); |
25
|
25 |
|
$this->packager = new DocsetPackager($this->docset); |
26
|
25 |
|
$this->archiver = new DocsetArchiver($this->docset); |
27
|
|
|
|
28
|
25 |
|
$this->command = $command ?? new LaravelCommand(); |
29
|
25 |
|
} |
30
|
|
|
|
31
|
|
|
public function build() |
32
|
|
|
{ |
33
|
|
|
$this->grab(); |
34
|
|
|
$this->package(); |
35
|
|
|
$this->archive(); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
public function grab() |
39
|
|
|
{ |
40
|
|
|
if ($this->grabber->sitemapExists()) { |
41
|
|
|
return $this->grabFromSitemap(); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
return $this->grabFromIndex(); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
protected function grabFromSitemap() |
48
|
|
|
{ |
49
|
|
|
return $this->command->task(' - Downloading doc from sitemap', function () { |
50
|
|
|
return $this->grabber->grabFromSitemap(); |
51
|
|
|
}); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
protected function grabFromIndex() |
55
|
|
|
{ |
56
|
|
|
return $this->command->task(' - Downloading doc from index', function () { |
57
|
|
|
return $this->grabber->grabFromIndex(); |
58
|
|
|
}); |
59
|
|
|
} |
60
|
|
|
|
61
|
1 |
|
public function package() |
62
|
|
|
{ |
63
|
|
|
$this->command->task(' - Remove previous .docset', function () { |
64
|
1 |
|
return $this->packager->removePreviousDocsetFile(); |
|
|
|
|
65
|
1 |
|
}); |
66
|
|
|
|
67
|
|
|
$this->command->task(' - Create new .docset', function () { |
68
|
1 |
|
return $this->packager->createDocsetFile(); |
|
|
|
|
69
|
1 |
|
}); |
70
|
|
|
|
71
|
|
|
$this->command->task(' - Copy original doc files', function () { |
72
|
1 |
|
return $this->packager->copyDocFiles(); |
|
|
|
|
73
|
1 |
|
}); |
74
|
|
|
|
75
|
|
|
$this->command->task(' - Create Info.plist', function () { |
76
|
1 |
|
return $this->packager->createInfoPlist(); |
|
|
|
|
77
|
1 |
|
}); |
78
|
|
|
|
79
|
|
|
$this->command->task(' - Populate SQLiteIndex', function () { |
80
|
1 |
|
return $this->packager->createAndPopulateSQLiteIndex(); |
|
|
|
|
81
|
1 |
|
}); |
82
|
|
|
|
83
|
|
|
$this->command->task(' - Format doc files for Dash', function () { |
84
|
1 |
|
return $this->packager->formatDocFiles(); |
|
|
|
|
85
|
1 |
|
}); |
86
|
|
|
|
87
|
|
|
$this->command->task(' - Copy icons', function () { |
88
|
1 |
|
return $this->packager->copyIcons(); |
|
|
|
|
89
|
1 |
|
}); |
90
|
1 |
|
} |
91
|
|
|
|
92
|
1 |
|
public function archive() |
93
|
|
|
{ |
94
|
|
|
$this->command->task(' - Archiving package', function () { |
95
|
1 |
|
return $this->archiver->archive(); |
96
|
1 |
|
}); |
97
|
1 |
|
} |
98
|
|
|
} |
99
|
|
|
|
This check looks for function or method calls that always return null and whose return value is used.
The method
getObject()
can return nothing but null, so it makes no sense to use the return value.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.