Completed
Push — master ( d16aa7...8295b7 )
by Marcel
02:45 queued 01:17
created

IgnitionConfig   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 1
dl 0
loc 40
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getEditor() 0 4 1
A getTheme() 0 4 1
A getEnableShareButton() 0 4 1
A toArray() 0 9 1
A mergeWithDefaultConfig() 0 4 1
1
<?php
2
3
namespace Facade\Ignition;
4
5
use Illuminate\Support\Arr;
6
use Illuminate\Contracts\Support\Arrayable;
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 getTheme(): ?string
24
    {
25
        return Arr::get($this->options, 'theme');
26
    }
27
28
    public function getEnableShareButton(): bool
29
    {
30
        return Arr::get($this->options, 'enable_share_button', true);
31
    }
32
33
    public function toArray(): array
34
    {
35
        return [
36
            'editor' => $this->getEditor(),
37
            'theme' => $this->getTheme(),
38
            'enableShareButton' => $this->getEnableShareButton(),
39
            'directorySeparator' => DIRECTORY_SEPARATOR,
40
        ];
41
    }
42
43
    protected function mergeWithDefaultConfig(array $options = []): array
44
    {
45
        return array_merge(config('ignition'), $options);
46
    }
47
}
48