Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
5 / 5 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
| HydeSmartDocsFacade | |
100.00% |
5 / 5 |
|
100.00% |
3 / 3 |
6 | |
100.00% |
1 / 1 |
| create | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| hasTorchlight | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
2 | |||
| canRenderSourceLink | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
3 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace Hyde\Framework\Concerns\FacadeHelpers; |
| 4 | |
| 5 | use Hyde\Framework\Helpers\Features; |
| 6 | use Hyde\Framework\Models\DocumentationPage; |
| 7 | |
| 8 | /** |
| 9 | * Provide static facade methods, and instance helpers for HydeSmartDocs. |
| 10 | * |
| 11 | * @see \Hyde\Framework\Services\HydeSmartDocs |
| 12 | */ |
| 13 | trait HydeSmartDocsFacade |
| 14 | { |
| 15 | public static function create(DocumentationPage $page, string $html): static |
| 16 | { |
| 17 | return (new static($page, $html))->process(); |
| 18 | } |
| 19 | |
| 20 | public function hasTorchlight(): bool |
| 21 | { |
| 22 | return Features::hasTorchlight() && str_contains($this->html, 'Syntax highlighted by torchlight.dev'); |
| 23 | } |
| 24 | |
| 25 | protected function canRenderSourceLink(string $inPosition): bool |
| 26 | { |
| 27 | $config = config('docs.edit_source_link_position', 'both'); |
| 28 | $positions = $config === 'both' ? ['header', 'footer'] : [$config]; |
| 29 | |
| 30 | return ($this->page->getOnlineSourcePath() !== false) && in_array($inPosition, $positions); |
| 31 | } |
| 32 | } |