@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | { |
54 | 54 | // Scan the source directory, and directories therein, for files that match the model's file extension. |
55 | 55 | foreach (glob($this->kernel->path($pageClass::sourcePath('{*,**/*}')), GLOB_BRACE) as $filepath) { |
56 | - if (! str_starts_with(basename((string) $filepath), '_')) { |
|
56 | + if (!str_starts_with(basename((string) $filepath), '_')) { |
|
57 | 57 | $this->addFile(SourceFile::make($filepath, $pageClass)); |
58 | 58 | } |
59 | 59 | } |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | */ |
71 | 71 | public function getFiles(?string $pageClass = null): FileCollection |
72 | 72 | { |
73 | - return $pageClass ? $this->filter(function (SourceFile $file) use ($pageClass): bool { |
|
73 | + return $pageClass ? $this->filter(function(SourceFile $file) use ($pageClass) : bool { |
|
74 | 74 | return $file->model === $pageClass; |
75 | 75 | }) : $this; |
76 | 76 | } |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | |
33 | 33 | protected function runDiscovery(): void |
34 | 34 | { |
35 | - $this->kernel->pages()->each(function (HydePage $page): void { |
|
35 | + $this->kernel->pages()->each(function(HydePage $page): void { |
|
36 | 36 | $this->addRoute(new Route($page)); |
37 | 37 | }); |
38 | 38 | } |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | */ |
56 | 56 | public function getRoutes(?string $pageClass = null): RouteCollection |
57 | 57 | { |
58 | - return $pageClass ? $this->filter(function (Route $route) use ($pageClass): bool { |
|
58 | + return $pageClass ? $this->filter(function(Route $route) use ($pageClass) : bool { |
|
59 | 59 | return $route->getPage() instanceof $pageClass; |
60 | 60 | }) : $this; |
61 | 61 | } |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | |
56 | 56 | public function getContentLength(): int |
57 | 57 | { |
58 | - if (! is_file($this->getAbsolutePath())) { |
|
58 | + if (!is_file($this->getAbsolutePath())) { |
|
59 | 59 | throw new FileNotFoundException($this->path); |
60 | 60 | } |
61 | 61 | |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | |
97 | 97 | protected static function discoverMediaAssetFiles(): array |
98 | 98 | { |
99 | - return collect(static::getMediaAssetFiles())->mapWithKeys(function (string $filepath): array { |
|
99 | + return collect(static::getMediaAssetFiles())->mapWithKeys(function(string $filepath): array { |
|
100 | 100 | $file = static::make($filepath); |
101 | 101 | |
102 | 102 | return [$file->getIdentifier() => $file]; |
@@ -11,13 +11,13 @@ discard block |
||
11 | 11 | |
12 | 12 | define('BASE_PATH', realpath(__DIR__.'/../../../')); |
13 | 13 | |
14 | -if (BASE_PATH === false || ! file_exists(BASE_PATH.'/hyde')) { |
|
14 | +if (BASE_PATH === false || !file_exists(BASE_PATH.'/hyde')) { |
|
15 | 15 | throw new InvalidArgumentException('This test suite must be run from the root of the hydephp/develop monorepo.'); |
16 | 16 | } |
17 | 17 | |
18 | 18 | ob_start(); |
19 | 19 | |
20 | -test('handle routes index page', function () { |
|
20 | +test('handle routes index page', function() { |
|
21 | 21 | putenv('SERVER_DASHBOARD=false'); |
22 | 22 | mockRoute(''); |
23 | 23 | |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | Filesystem::unlink('_site/index.html'); |
37 | 37 | }); |
38 | 38 | |
39 | -test('handle routes custom pages', function () { |
|
39 | +test('handle routes custom pages', function() { |
|
40 | 40 | mockRoute('foo'); |
41 | 41 | |
42 | 42 | Filesystem::put('_pages/foo.md', '# Hello World!'); |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | Filesystem::unlink('_site/foo.html'); |
55 | 55 | }); |
56 | 56 | |
57 | -test('handle routes pages with .html extension', function () { |
|
57 | +test('handle routes pages with .html extension', function() { |
|
58 | 58 | mockRoute('foo.html'); |
59 | 59 | |
60 | 60 | Filesystem::put('_pages/foo.md', '# Hello World!'); |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | Filesystem::unlink('_site/foo.html'); |
73 | 73 | }); |
74 | 74 | |
75 | -test('handle routes static assets', function () { |
|
75 | +test('handle routes static assets', function() { |
|
76 | 76 | mockRoute('media/app.css'); |
77 | 77 | |
78 | 78 | $kernel = new HttpKernel(); |
@@ -85,14 +85,14 @@ discard block |
||
85 | 85 | expect($response->body)->toContain('/*! HydeFront v2.0.0'); |
86 | 86 | }); |
87 | 87 | |
88 | -test('handle throws route not found exception for missing route', function () { |
|
88 | +test('handle throws route not found exception for missing route', function() { |
|
89 | 89 | mockRoute('missing'); |
90 | 90 | |
91 | 91 | $kernel = new HttpKernel(); |
92 | 92 | $kernel->handle(new Request()); |
93 | 93 | })->throws(RouteNotFoundException::class, 'Route [missing] not found'); |
94 | 94 | |
95 | -test('handle sends 404 error response for missing asset', function () { |
|
95 | +test('handle sends 404 error response for missing asset', function() { |
|
96 | 96 | mockRoute('missing.css'); |
97 | 97 | |
98 | 98 | $kernel = new HttpKernel(); |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | // Filesystem::unlink('_site/foo.html'); |
124 | 124 | //})->skip('Underlying framework does not buffer headers (yet)'); |
125 | 125 | |
126 | -test('trailing slashes are normalized from route', function () { |
|
126 | +test('trailing slashes are normalized from route', function() { |
|
127 | 127 | mockRoute('foo/'); |
128 | 128 | |
129 | 129 | Filesystem::put('_pages/foo.md', '# Hello World!'); |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | Filesystem::unlink('_site/foo.html'); |
142 | 142 | }); |
143 | 143 | |
144 | -test('docs uri path is rerouted to docs/index', function () { |
|
144 | +test('docs uri path is rerouted to docs/index', function() { |
|
145 | 145 | mockRoute('docs'); |
146 | 146 | |
147 | 147 | Filesystem::put('_docs/index.md', '# Hello World!'); |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | Filesystem::unlink('_site/docs/index.html'); |
160 | 160 | }); |
161 | 161 | |
162 | -test('docs/search renders search page', function () { |
|
162 | +test('docs/search renders search page', function() { |
|
163 | 163 | mockRoute('docs/search'); |
164 | 164 | |
165 | 165 | $kernel = new HttpKernel(); |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | Filesystem::unlink('_site/docs/search.html'); |
175 | 175 | }); |
176 | 176 | |
177 | -test('ping route returns ping response', function () { |
|
177 | +test('ping route returns ping response', function() { |
|
178 | 178 | mockRoute('ping'); |
179 | 179 | |
180 | 180 | $kernel = new HttpKernel(); |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | ->and($response->statusMessage)->toBe('OK'); |
186 | 186 | }); |
187 | 187 | |
188 | -test('exception handling', function () { |
|
188 | +test('exception handling', function() { |
|
189 | 189 | $exception = new Exception('foo'); |
190 | 190 | $response = ExceptionHandler::handle($exception); |
191 | 191 |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | */ |
119 | 119 | public static function files(): array |
120 | 120 | { |
121 | - return Files::getFiles(static::class)->map(function (SourceFile $file): string { |
|
121 | + return Files::getFiles(static::class)->map(function(SourceFile $file): string { |
|
122 | 122 | return static::pathToIdentifier($file->getPath()); |
123 | 123 | })->values()->toArray(); |
124 | 124 | } |
@@ -338,7 +338,7 @@ discard block |
||
338 | 338 | |
339 | 339 | public function showInNavigation(): bool |
340 | 340 | { |
341 | - return ! $this->navigation['hidden']; |
|
341 | + return !$this->navigation['hidden']; |
|
342 | 342 | } |
343 | 343 | |
344 | 344 | public function navigationMenuPriority(): int |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | |
33 | 33 | protected function runDiscovery(): void |
34 | 34 | { |
35 | - $this->kernel->files()->each(function (SourceFile $file): void { |
|
35 | + $this->kernel->files()->each(function(SourceFile $file): void { |
|
36 | 36 | $this->addPage($file->model::parse( |
37 | 37 | $file->model::pathToIdentifier($file->getPath()) |
38 | 38 | )); |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | */ |
59 | 59 | public function getPages(?string $pageClass = null): PageCollection |
60 | 60 | { |
61 | - return $pageClass ? $this->filter(function (HydePage $page) use ($pageClass): bool { |
|
61 | + return $pageClass ? $this->filter(function(HydePage $page) use ($pageClass) : bool { |
|
62 | 62 | return $page instanceof $pageClass; |
63 | 63 | }) : $this; |
64 | 64 | } |
@@ -89,11 +89,11 @@ |
||
89 | 89 | Hyde::pathToRelative(Hyde::getDocumentationPagePath()), |
90 | 90 | ]; |
91 | 91 | |
92 | - if (! in_array($directory, $directories)) { |
|
92 | + if (!in_array($directory, $directories)) { |
|
93 | 93 | throw new Exception("Path [$this->path] is not in a valid source directory.", 400); |
94 | 94 | } |
95 | 95 | |
96 | - if (! file_exists(Hyde::path($this->path))) { |
|
96 | + if (!file_exists(Hyde::path($this->path))) { |
|
97 | 97 | throw new Exception("File [$this->path] not found.", 404); |
98 | 98 | } |
99 | 99 | } |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | { |
20 | 20 | protected function generate(): void |
21 | 21 | { |
22 | - Routes::getRoutes(DocumentationPage::class)->each(function (Route $route): void { |
|
22 | + Routes::getRoutes(DocumentationPage::class)->each(function(Route $route): void { |
|
23 | 23 | if ($this->canAddRoute($route)) { |
24 | 24 | $this->items->put($route->getRouteKey(), NavItem::fromRoute($route)); |
25 | 25 | } |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | /** @return array<string> */ |
35 | 35 | public function getGroups(): array |
36 | 36 | { |
37 | - return $this->items->map(function (NavItem $item): string { |
|
37 | + return $this->items->map(function(NavItem $item): string { |
|
38 | 38 | return $item->getGroup(); |
39 | 39 | })->unique()->toArray(); |
40 | 40 | } |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | /** @return Collection<\Hyde\Framework\Features\Navigation\NavItem> */ |
43 | 43 | public function getItemsInGroup(?string $group): Collection |
44 | 44 | { |
45 | - return $this->items->filter(function (NavItem $item) use ($group): bool { |
|
45 | + return $this->items->filter(function(NavItem $item) use ($group) : bool { |
|
46 | 46 | return ($item->getGroup() === $group) || ($item->getGroup() === Str::slug($group)); |
47 | 47 | })->sortBy('navigation.priority')->values(); |
48 | 48 | } |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | |
56 | 56 | protected function canAddRoute(Route $route): bool |
57 | 57 | { |
58 | - return parent::canAddRoute($route) && ! $route->is(DocumentationPage::homeRouteName()); |
|
58 | + return parent::canAddRoute($route) && !$route->is(DocumentationPage::homeRouteName()); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | private function isPageIndexPage(): bool |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | |
26 | 26 | public function hasDropdowns(): bool |
27 | 27 | { |
28 | - if (! $this->dropdownsEnabled()) { |
|
28 | + if (!$this->dropdownsEnabled()) { |
|
29 | 29 | return false; |
30 | 30 | } |
31 | 31 | |
@@ -35,11 +35,11 @@ discard block |
||
35 | 35 | /** @return array<string, DropdownNavItem> */ |
36 | 36 | public function getDropdowns(): array |
37 | 37 | { |
38 | - if (! $this->dropdownsEnabled()) { |
|
38 | + if (!$this->dropdownsEnabled()) { |
|
39 | 39 | throw new BadMethodCallException('Dropdowns are not enabled. Enable it by setting `hyde.navigation.subdirectories` to `dropdown`.'); |
40 | 40 | } |
41 | 41 | |
42 | - return $this->items->filter(function (NavItem $item): bool { |
|
42 | + return $this->items->filter(function(NavItem $item): bool { |
|
43 | 43 | return $item instanceof DropdownNavItem; |
44 | 44 | })->values()->all(); |
45 | 45 | } |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | |
68 | 68 | protected function canAddRoute(Route $route): bool |
69 | 69 | { |
70 | - return parent::canAddRoute($route) && (! $route->getPage() instanceof DocumentationPage || $route->is(DocumentationPage::homeRouteName())); |
|
70 | + return parent::canAddRoute($route) && (!$route->getPage() instanceof DocumentationPage || $route->is(DocumentationPage::homeRouteName())); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | protected function canAddItemToDropdown(NavItem $item): bool |