| Code Coverage | ||||||||||
| Lines | Functions and Methods | Classes and Traits | ||||||||
| Total |  | 100.00% | 25 / 25 |  | 100.00% | 15 / 15 | CRAP |  | 100.00% | 1 / 1 | 
| Features |  | 100.00% | 25 / 25 |  | 100.00% | 15 / 15 | 18 |  | 100.00% | 1 / 1 | 
| enabled |  | 100.00% | 8 / 8 |  | 100.00% | 1 / 1 | 1 | |||
| hasBlogPosts |  | 100.00% | 1 / 1 |  | 100.00% | 1 / 1 | 1 | |||
| hasBladePages |  | 100.00% | 1 / 1 |  | 100.00% | 1 / 1 | 1 | |||
| hasMarkdownPages |  | 100.00% | 1 / 1 |  | 100.00% | 1 / 1 | 1 | |||
| hasDocumentationPages |  | 100.00% | 1 / 1 |  | 100.00% | 1 / 1 | 1 | |||
| hasDocumentationSearch |  | 100.00% | 2 / 2 |  | 100.00% | 1 / 1 | 2 | |||
| hasDarkmode |  | 100.00% | 1 / 1 |  | 100.00% | 1 / 1 | 1 | |||
| hasTorchlight |  | 100.00% | 3 / 3 |  | 100.00% | 1 / 1 | 3 | |||
| blogPosts |  | 100.00% | 1 / 1 |  | 100.00% | 1 / 1 | 1 | |||
| bladePages |  | 100.00% | 1 / 1 |  | 100.00% | 1 / 1 | 1 | |||
| markdownPages |  | 100.00% | 1 / 1 |  | 100.00% | 1 / 1 | 1 | |||
| documentationPages |  | 100.00% | 1 / 1 |  | 100.00% | 1 / 1 | 1 | |||
| documentationSearch |  | 100.00% | 1 / 1 |  | 100.00% | 1 / 1 | 1 | |||
| darkmode |  | 100.00% | 1 / 1 |  | 100.00% | 1 / 1 | 1 | |||
| torchlight |  | 100.00% | 1 / 1 |  | 100.00% | 1 / 1 | 1 | |||
| 1 | <?php | 
| 2 | |
| 3 | namespace Hyde\Framework\Helpers; | 
| 4 | |
| 5 | /** | 
| 6 | * Allows features to be enabled and disabled in a simple object-oriented manner. | 
| 7 | * | 
| 8 | * Based entirely on Laravel Jetstream (License MIT) | 
| 9 | * | 
| 10 | * @see https://jetstream.laravel.com/ | 
| 11 | */ | 
| 12 | class Features | 
| 13 | { | 
| 14 | /** | 
| 15 | * Determine if the given specified is enabled. | 
| 16 | * | 
| 17 | * @param string $feature | 
| 18 | * @return bool | 
| 19 | */ | 
| 20 | public static function enabled(string $feature): bool | 
| 21 | { | 
| 22 | return in_array($feature, config('hyde.features', [ | 
| 23 | static::blogPosts(), | 
| 24 | static::bladePages(), | 
| 25 | static::markdownPages(), | 
| 26 | static::documentationPages(), | 
| 27 | static::documentationSearch(), | 
| 28 | static::darkmode(), | 
| 29 | static::torchlight(), | 
| 30 | ])); | 
| 31 | } | 
| 32 | |
| 33 | /** | 
| 34 | * ================================================ | 
| 35 | * Determine if a given feature is enabled. | 
| 36 | * ================================================. | 
| 37 | */ | 
| 38 | public static function hasBlogPosts(): bool | 
| 39 | { | 
| 40 | return static::enabled(static::blogPosts()); | 
| 41 | } | 
| 42 | |
| 43 | public static function hasBladePages(): bool | 
| 44 | { | 
| 45 | return static::enabled(static::bladePages()); | 
| 46 | } | 
| 47 | |
| 48 | public static function hasMarkdownPages(): bool | 
| 49 | { | 
| 50 | return static::enabled(static::markdownPages()); | 
| 51 | } | 
| 52 | |
| 53 | public static function hasDocumentationPages(): bool | 
| 54 | { | 
| 55 | return static::enabled(static::documentationPages()); | 
| 56 | } | 
| 57 | |
| 58 | public static function hasDocumentationSearch(): bool | 
| 59 | { | 
| 60 | return static::enabled(static::documentationSearch()) | 
| 61 | && static::hasDocumentationPages(); | 
| 62 | } | 
| 63 | |
| 64 | public static function hasDarkmode(): bool | 
| 65 | { | 
| 66 | return static::enabled(static::darkmode()); | 
| 67 | } | 
| 68 | |
| 69 | /** | 
| 70 | * Torchlight is by default enabled automatically when an API token | 
| 71 | * is set in the .env file but is disabled when running tests. | 
| 72 | */ | 
| 73 | public static function hasTorchlight(): bool | 
| 74 | { | 
| 75 | return static::enabled(static::torchlight()) | 
| 76 | && (config('torchlight.token') !== null) | 
| 77 | && (app('env') !== 'testing'); | 
| 78 | } | 
| 79 | |
| 80 | /** | 
| 81 | * ================================================ | 
| 82 | * Enable a given feature to be used in the config. | 
| 83 | * ================================================. | 
| 84 | */ | 
| 85 | public static function blogPosts(): string | 
| 86 | { | 
| 87 | return 'blog-posts'; | 
| 88 | } | 
| 89 | |
| 90 | public static function bladePages(): string | 
| 91 | { | 
| 92 | return 'blade-pages'; | 
| 93 | } | 
| 94 | |
| 95 | public static function markdownPages(): string | 
| 96 | { | 
| 97 | return 'markdown-pages'; | 
| 98 | } | 
| 99 | |
| 100 | public static function documentationPages(): string | 
| 101 | { | 
| 102 | return 'documentation-pages'; | 
| 103 | } | 
| 104 | |
| 105 | public static function documentationSearch(): string | 
| 106 | { | 
| 107 | return 'documentation-search'; | 
| 108 | } | 
| 109 | |
| 110 | public static function darkmode(): string | 
| 111 | { | 
| 112 | return 'darkmode'; | 
| 113 | } | 
| 114 | |
| 115 | public static function torchlight(): string | 
| 116 | { | 
| 117 | return 'torchlight'; | 
| 118 | } | 
| 119 | } |