Skip to content

Commit b68f0d9

Browse files
committed
Code cleanup
1 parent 1564adb commit b68f0d9

3 files changed

Lines changed: 70 additions & 39 deletions

File tree

app/repositories/AbstractCodexRepository.php

Lines changed: 59 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,46 @@
66
abstract class AbstractCodexRepository implements CodexRepositoryInterface
77
{
88
/**
9+
* The config implementation.
10+
*
911
* @var Config
1012
*/
1113
protected $config;
1214

1315
/**
16+
* The filesystem implementation.
17+
*
1418
* @var Filesystem
1519
*/
1620
protected $files;
1721

18-
public function __construct(Config $config, Filesyste $files)
22+
/**
23+
* Storage path.
24+
*
25+
* @var string
26+
*/
27+
protected $storagePath;
28+
29+
/**
30+
* Create a new AbstractCodexRepository instance.
31+
*
32+
* @param Config $config
33+
* @param Filesystem $files
34+
* @return void
35+
*/
36+
public function __construct(Config $config, Filesystem $files)
1937
{
2038
$this->config = $config;
2139
$this->files = $files;
40+
41+
$this->storagePath = $this->config->get('codex.storage_path');
2242
}
2343

44+
/**
45+
* Get the default manual.
46+
*
47+
* @return mixed
48+
*/
2449
public function getDefaultManual()
2550
{
2651
$manuals = $this->getManuals();
@@ -38,6 +63,12 @@ public function getDefaultManual()
3863
}
3964
}
4065

66+
/**
67+
* Get the default version for the given manual.
68+
*
69+
* @param string $manual
70+
* @return string
71+
*/
4172
public function getDefaultVersion($manual)
4273
{
4374
$versions = $this->getVersions($manual);
@@ -55,21 +86,21 @@ public function getDefaultVersion($manual)
5586
}
5687

5788
/**
58-
* Get all manuals from documentation directory.
59-
*
60-
* @return array
61-
*/
89+
* Get all manuals from documentation directory.
90+
*
91+
* @return array
92+
*/
6293
public function getManuals()
6394
{
6495
return $this->getDirectories($this->storagePath);
6596
}
6697

6798
/**
68-
* Get all versions for the given manual.
69-
*
70-
* @param string $manual
71-
* @return array
72-
*/
99+
* Get all versions for the given manual.
100+
*
101+
* @param string $manual
102+
* @return array
103+
*/
73104
public function getVersions($manual)
74105
{
75106
$manualDir = $this->storagePath.'/'.$manual;
@@ -78,11 +109,11 @@ public function getVersions($manual)
78109
}
79110

80111
/**
81-
* Return an array of folders within the supplied path.
82-
*
83-
* @param string $path
84-
* @return array
85-
*/
112+
* Return an array of folders within the supplied path.
113+
*
114+
* @param string $path
115+
* @return array
116+
*/
86117
public function getDirectories($path)
87118
{
88119
if ( ! $this->files->exists($path)) {
@@ -106,12 +137,12 @@ public function getDirectories($path)
106137
}
107138

108139
/**
109-
* Return the first line of the supplied page. This will (or rather should)
110-
* always be an <h1> tag.
111-
*
112-
* @param string $page
113-
* @return string
114-
*/
140+
* Return the first line of the supplied page. This will (or rather should)
141+
* always be an <h1> tag.
142+
*
143+
* @param string $page
144+
* @return string
145+
*/
115146
protected function getPageTitle($page)
116147
{
117148
$file = fopen($page, 'r');
@@ -123,13 +154,13 @@ protected function getPageTitle($page)
123154
}
124155

125156
/**
126-
* Gets the given documentation page modification time.
127-
*
128-
* @param string $manual
129-
* @param string $version
130-
* @param string $page
131-
* @return mixed
132-
*/
157+
* Gets the given documentation page modification time.
158+
*
159+
* @param string $manual
160+
* @param string $version
161+
* @param string $page
162+
* @return mixed
163+
*/
133164
public function getUpdatedTimestamp($manual, $version, $page)
134165
{
135166
$page = $this->storagePath.'/'.$manual.'/'.$version.'/'.$page.'.md';

app/repositories/CodexRepositoryFlat.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class CodexRepositoryFlat extends AbstractCodexRepository
2929
protected $storagePath;
3030

3131
/**
32-
* Create a new codex instance.
32+
* Create a new CodexRepositoryFlat instance.
3333
*
3434
* @param Config $config
3535
* @param Filesystem $files

app/repositories/CodexRepositoryGit.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ class CodexRepositoryGit extends AbstractCodexRepository
3838
protected $storagePath;
3939

4040
/**
41-
* Create a new codex instance.
41+
* Create a new CodexRepositoryGit instance.
4242
*
43-
* @param Cache $cache
44-
* @param Config $config
43+
* @param Cache $cache
44+
* @param Config $config
4545
* @param Filesystem $files
4646
* @param Git $git
4747
*/
@@ -151,13 +151,13 @@ public function search($manual, $version, $needle = '')
151151
}
152152

153153
/**
154-
* Gets the given documentation page modification time.
155-
*
156-
* @param string $manual
157-
* @param string $version
158-
* @param string $page
159-
* @return mixed
160-
*/
154+
* Gets the given documentation page modification time.
155+
*
156+
* @param string $manual
157+
* @param string $version
158+
* @param string $page
159+
* @return mixed
160+
*/
161161
public function getUpdatedTimestamp($manual, $version, $page)
162162
{
163163
$storagePath = $this->getStoragePath($manual, $version);

0 commit comments

Comments
 (0)