Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
85.71% covered (warning)
85.71%
6 / 7
50.00% covered (danger)
50.00%
1 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
Icons
85.71% covered (warning)
85.71%
6 / 7
50.00% covered (danger)
50.00%
1 / 2
5.07
0.00% covered (danger)
0.00%
0 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 strings
83.33% covered (warning)
83.33%
5 / 6
0.00% covered (danger)
0.00%
0 / 1
4.07
1<?php
2
3declare(strict_types=1);
4
5namespace Cosray\Config;
6
7final class Icons
8{
9    /** @var list<non-empty-string>|null */
10    private ?array $localPathsCache = null;
11
12    private ?Iconify $iconifyCache = null;
13
14    public function __construct(
15        private readonly \Cosray\Config $config,
16    ) {}
17
18    /** @var list<non-empty-string> */
19    public array $localPaths {
20        get => $this->localPathsCache ??= self::strings($this->config->get('icons.local.paths'));
21    }
22
23    public Iconify $iconify {
24        get => $this->iconifyCache ??= new Iconify($this->config);
25    }
26
27    /** @return list<non-empty-string> */
28    private static function strings(mixed $value): array
29    {
30        if ($value === null) {
31            return [];
32        }
33
34        if (is_string($value)) {
35            $value = trim($value);
36
37            return $value === '' ? [] : [$value];
38        }
39
40        return array_values($value);
41    }
42}