IgnitionConfig::getRemoteSitesPath()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Facade\Ignition;
4
5
use Illuminate\Contracts\Support\Arrayable;
6
use Illuminate\Support\Arr;
7
8
class IgnitionConfig implements Arrayable
9
{
10
    /** @var array */
11
    protected $options;
12
13
    public function __construct(array $options = [])
14
    {
15
        $this->options = $this->mergeWithDefaultConfig($options);
16
    }
17
18
    public function getEditor(): ?string
19
    {
20
        return Arr::get($this->options, 'editor');
21
    }
22
23
    public function getRemoteSitesPath(): ?string
24
    {
25
        return Arr::get($this->options, 'remote_sites_path');
26
    }
27
28
    public function getLocalSitesPath(): ?string
29
    {
30
        return Arr::get($this->options, 'local_sites_path');
31
    }
32
33
    public function getTheme(): ?string
34
    {
35
        return Arr::get($this->options, 'theme');
36
    }
37
38
    public function getEnableShareButton(): bool
39
    {
40
        if (! app()->isBooted()) {
41
            return false;
42
        }
43
44
        return Arr::get($this->options, 'enable_share_button', true);
45
    }
46
47
    public function getEnableRunnableSolutions(): bool
48
    {
49
        $enabled = Arr::get($this->options, 'enable_runnable_solutions', null);
50
51
        if ($enabled === null) {
52
            $enabled = config('app.debug');
53
        }
54
55
        return $enabled ?? false;
56
    }
57
58
    public function toArray(): array
59
    {
60
        return [
61
            'editor' => $this->getEditor(),
62
            'remoteSitesPath' => $this->getRemoteSitesPath(),
63
            'localSitesPath' => $this->getLocalSitesPath(),
64
            'theme' => $this->getTheme(),
65
            'enableShareButton' => $this->getEnableShareButton(),
66
            'enableRunnableSolutions' => $this->getEnableRunnableSolutions(),
67
            'directorySeparator' => DIRECTORY_SEPARATOR,
68
        ];
69
    }
70
71
    protected function mergeWithDefaultConfig(array $options = []): array
72
    {
73
        return array_merge(config('ignition') ?: include __DIR__.'/../config/ignition.php', $options);
74
    }
75
}
76