Skip to content

Commit 1af7ab9

Browse files
committed
Remove deprecated ConfigKeys indirection
1 parent 430e2d1 commit 1af7ab9

File tree

7 files changed

+30
-91
lines changed

7 files changed

+30
-91
lines changed

src/Support/CodeHighlighter.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class CodeHighlighter
2020
*/
2121
public function highlight(string $code, string $language, ?string $highlightTheme = null, ?string $presentationTheme = null, ?string $font = null, ?string $size = null): HtmlString
2222
{
23-
if (! config(ConfigKeys::SLIDES_HIGHLIGHT_ENABLED, true)) {
23+
if (! config('slidewire.slides.highlight.enabled', true)) {
2424
return $this->fallback($code, $language, $font, $size);
2525
}
2626

@@ -45,7 +45,7 @@ public function resolveHighlightTheme(?string $highlightTheme = null, ?string $p
4545
}
4646

4747
if ($presentationTheme !== null && $presentationTheme !== '') {
48-
$themeConfig = config(ConfigKeys::THEMES, [])[$presentationTheme] ?? null;
48+
$themeConfig = config('slidewire.themes', [])[$presentationTheme] ?? null;
4949

5050
if ($themeConfig instanceof ThemeConfig && $themeConfig->highlightTheme !== '') {
5151
return $themeConfig->highlightTheme;
@@ -60,7 +60,7 @@ public function resolveHighlightTheme(?string $highlightTheme = null, ?string $p
6060
}
6161
}
6262

63-
return (string) config(ConfigKeys::SLIDES_HIGHLIGHT_THEME, 'github-dark');
63+
return (string) config('slidewire.slides.highlight.theme', 'github-dark');
6464
}
6565

6666
/**
@@ -123,8 +123,8 @@ protected function applyCodeStyles(string $html, ?string $font = null, ?string $
123123

124124
protected function styleAttribute(?string $font = null, ?string $size = null): string
125125
{
126-
$font = trim((string) ($font ?? config(ConfigKeys::SLIDES_HIGHLIGHT_FONT, '')));
127-
$size = trim((string) ($size ?? config(ConfigKeys::SLIDES_HIGHLIGHT_FONT_SIZE, 'md')));
126+
$font = trim((string) ($font ?? config('slidewire.slides.highlight.font', '')));
127+
$size = trim((string) ($size ?? config('slidewire.slides.highlight.font_size', 'md')));
128128

129129
$styles = [];
130130

src/Support/ConfigKeys.php

Lines changed: 0 additions & 65 deletions
This file was deleted.

src/Support/ConfigValidator.php

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,16 @@
1212
*/
1313
class ConfigValidator
1414
{
15+
/**
16+
* @var list<string>
17+
*/
18+
private const array THEME_REQUIRED_KEYS = ['background', 'highlight_theme', 'title', 'text'];
19+
20+
/**
21+
* @var list<string>
22+
*/
23+
private const array TYPOGRAPHY_REQUIRED_KEYS = ['font', 'color', 'size'];
24+
1525
/**
1626
* Validate the themes configuration.
1727
*
@@ -32,11 +42,11 @@ public function validateThemes(array $themes): void
3242
if (! is_array($theme)) {
3343
throw new InvalidArgumentException(
3444
"SlideWire theme [{$name}] must be an array or ThemeConfig with keys: "
35-
. implode(', ', ConfigKeys::THEME_REQUIRED_KEYS) . '.'
45+
. implode(', ', self::THEME_REQUIRED_KEYS) . '.'
3646
);
3747
}
3848

39-
foreach (ConfigKeys::THEME_REQUIRED_KEYS as $key) {
49+
foreach (self::THEME_REQUIRED_KEYS as $key) {
4050
if (! array_key_exists($key, $theme)) {
4151
throw new InvalidArgumentException(
4252
"SlideWire theme [{$name}] is missing required key [{$key}]."
@@ -54,11 +64,11 @@ public function validateThemes(array $themes): void
5464
if (! is_array($theme[$typo])) {
5565
throw new InvalidArgumentException(
5666
"SlideWire theme [{$name}] key [{$typo}] must be an array or ThemeFont with keys: "
57-
. implode(', ', ConfigKeys::TYPOGRAPHY_REQUIRED_KEYS) . '.'
67+
. implode(', ', self::TYPOGRAPHY_REQUIRED_KEYS) . '.'
5868
);
5969
}
6070

61-
foreach (ConfigKeys::TYPOGRAPHY_REQUIRED_KEYS as $key) {
71+
foreach (self::TYPOGRAPHY_REQUIRED_KEYS as $key) {
6272
if (! array_key_exists($key, $theme[$typo])) {
6373
throw new InvalidArgumentException(
6474
"SlideWire theme [{$name}] typography [{$typo}] is missing required key [{$key}]."
@@ -149,14 +159,14 @@ public function validateSlides(array $slides): void
149159
*/
150160
public function validate(): void
151161
{
152-
$this->validateThemes(config(ConfigKeys::THEMES, []));
153-
$this->validateFonts(config(ConfigKeys::FONTS, []));
154-
$this->validateSlides(config(ConfigKeys::SLIDES, []));
162+
$this->validateThemes(config('slidewire.themes', []));
163+
$this->validateFonts(config('slidewire.fonts', []));
164+
$this->validateSlides(config('slidewire.slides', []));
155165
}
156166

157167
protected function validateThemeTypography(string $themeName, ThemeFont $font, string $key): void
158168
{
159-
foreach (ConfigKeys::TYPOGRAPHY_REQUIRED_KEYS as $requiredKey) {
169+
foreach (self::TYPOGRAPHY_REQUIRED_KEYS as $requiredKey) {
160170
if ($font->{$requiredKey} === '') {
161171
throw new InvalidArgumentException(
162172
"SlideWire theme [{$themeName}] typography [{$key}] is missing required key [{$requiredKey}]."

src/Support/EffectiveSettingsResolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class EffectiveSettingsResolver
3838
*/
3939
public function resolve(array $slides, array $deckMeta): array
4040
{
41-
$slidesConfig = config(ConfigKeys::SLIDES, []);
41+
$slidesConfig = config('slidewire.slides', []);
4242

4343
return array_values(array_map(
4444
fn (array $slide): array => $this->resolveSlide($slide, $deckMeta, $slidesConfig),

src/Support/ThemeResolver.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class ThemeResolver
1717
*/
1818
public function backgroundClassMap(): array
1919
{
20-
return collect(config(ConfigKeys::THEMES, []))
20+
return collect(config('slidewire.themes', []))
2121
->map(function (mixed $theme): string {
2222
if ($theme instanceof ThemeConfig) {
2323
return (string) $theme;
@@ -39,7 +39,7 @@ public function backgroundClassMap(): array
3939
*/
4040
public function typographyClassMap(): array
4141
{
42-
return collect(config(ConfigKeys::THEMES, []))
42+
return collect(config('slidewire.themes', []))
4343
->map(function (mixed $theme): array {
4444
if ($theme instanceof ThemeConfig) {
4545
return [
@@ -76,8 +76,8 @@ public function typographyClassMap(): array
7676
*/
7777
public function codeFontFamily(): string
7878
{
79-
$font = (string) config(ConfigKeys::SLIDES_HIGHLIGHT_FONT, '');
80-
$fonts = config(ConfigKeys::FONTS, []);
79+
$font = (string) config('slidewire.slides.highlight.font', '');
80+
$fonts = config('slidewire.fonts', []);
8181

8282
if ($font === '' || ! array_key_exists($font, $fonts)) {
8383
return $this->resolveFontStack();
@@ -91,7 +91,7 @@ public function codeFontFamily(): string
9191
*/
9292
public function googleFontsUrl(): ?string
9393
{
94-
$fontConfig = config(ConfigKeys::FONTS, []);
94+
$fontConfig = config('slidewire.fonts', []);
9595

9696
$googleFontFamilies = collect($fontConfig)
9797
->filter(fn (mixed $config): bool => $config instanceof FontConfig || (is_array($config) && (($config['source'] ?? 'system') === FontSource::Google->value)))

src/View/Components/Slide.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use Closure;
88
use Illuminate\Contracts\View\View;
99
use Illuminate\View\Component;
10-
use WendellAdriel\SlideWire\Support\ConfigKeys;
1110
use WendellAdriel\SlideWire\Support\SlideContext;
1211

1312
class Slide extends Component
@@ -32,7 +31,7 @@ public function __construct(
3231
public ?string $autoSlide = null,
3332
public ?string $theme = null,
3433
) {
35-
$this->transition ??= (string) config(ConfigKeys::SLIDES_TRANSITION, 'slide');
34+
$this->transition ??= (string) config('slidewire.slides.transition', 'slide');
3635
$this->context->setSlide($this->theme);
3736
}
3837

tests/Unit/ArchitectureTest.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,6 @@
3131
->expect('WendellAdriel\SlideWire\Support')
3232
->not->toUse('WendellAdriel\SlideWire\Commands');
3333

34-
arch('ConfigKeys is a final class with no dependencies')
35-
->expect(WendellAdriel\SlideWire\Support\ConfigKeys::class)
36-
->toBeFinal()
37-
->not->toUse('Illuminate');
38-
3934
arch('all source files use strict types')
4035
->expect('WendellAdriel\SlideWire')
4136
->toUseStrictTypes();

0 commit comments

Comments
 (0)