1 | <?php |
||
17 | final class Provider implements ProviderContract |
||
18 | { |
||
19 | private const CACHE_TIMEOUT_SECONDS = 60 * 5; |
||
20 | private const PAGE_INDEX = 'index'; |
||
21 | private const FILE_EXTENSION = 'md'; |
||
22 | |||
23 | /** |
||
24 | * The cache implementation. |
||
25 | * |
||
26 | * @var Cache |
||
27 | */ |
||
28 | private $cache; |
||
29 | |||
30 | /** |
||
31 | * The cache key. |
||
32 | * |
||
33 | * @var string |
||
34 | */ |
||
35 | private $cacheKey; |
||
36 | |||
37 | /** |
||
38 | * Documentation resource directory. |
||
39 | * |
||
40 | * @var string |
||
41 | */ |
||
42 | private $documentationDirectory; |
||
43 | |||
44 | /** |
||
45 | * @var Filesystem |
||
46 | */ |
||
47 | private $filesystem; |
||
48 | |||
49 | /** |
||
50 | * @var ConfigProvider |
||
51 | */ |
||
52 | private $configProvider; |
||
53 | |||
54 | /** |
||
55 | * @var MarkdownParser |
||
56 | */ |
||
57 | private $markdownParser; |
||
58 | |||
59 | /** |
||
60 | * Create a new documentation instance. |
||
61 | * |
||
62 | * @param Filesystem $filesystem |
||
63 | * @param Cache $cache |
||
64 | * @param ConfigProvider $configProvider |
||
65 | * @param MarkdownParser $markdownParser |
||
66 | * |
||
67 | * @throws BadImplementation |
||
68 | */ |
||
69 | public function __construct( |
||
92 | |||
93 | /** |
||
94 | * @param Product $product |
||
95 | * @param string $version |
||
96 | * @param null|string $page |
||
97 | * |
||
98 | * @throws InvalidArgumentException |
||
99 | * @throws FileNotFoundException |
||
100 | * |
||
101 | * @return string |
||
102 | */ |
||
103 | public function getPage(Product $product, string $version, string $page = null): string |
||
118 | |||
119 | /** |
||
120 | * @param Product $product |
||
121 | * @param string $version |
||
122 | * @param string $content |
||
123 | * |
||
124 | * @return string |
||
125 | */ |
||
126 | public function replaceLinks(Product $product, string $version, string $content): string |
||
142 | |||
143 | /** |
||
144 | * @param Product $product |
||
145 | * @param string $version |
||
146 | * @param string $page |
||
147 | * |
||
148 | * @return bool |
||
149 | */ |
||
150 | public function sectionExists(Product $product, string $version, string $page): bool |
||
156 | |||
157 | /** |
||
158 | * @param Product $product |
||
159 | * @param string $version |
||
160 | * @param string $page |
||
161 | * |
||
162 | * @return string |
||
163 | */ |
||
164 | private function getFilePathForProductPage(Product $product, string $version, string $page): string |
||
171 | |||
172 | /** |
||
173 | * @param Product $product |
||
174 | * @param string $version |
||
175 | * @param string $page |
||
176 | * |
||
177 | * @throws FileNotFoundException |
||
178 | * |
||
179 | * @return string |
||
180 | */ |
||
181 | private function getPageContent(Product $product, string $version, string $page): string |
||
197 | } |
||
198 |