Completed
Push — master ( 76c18a...59b186 )
by Thomas
24s
created

setWatchHooksImplementationsOptions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 2
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the ekino Drupal Debug project.
7
 *
8
 * (c) ekino
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Ekino\Drupal\Debug\Option;
15
16
use Ekino\Drupal\Debug\Action\DisplayPrettyExceptions\DisplayPrettyExceptionsOptions;
17
use Ekino\Drupal\Debug\Action\DisplayPrettyExceptionsASAP\DisplayPrettyExceptionsASAPOptions;
18
use Ekino\Drupal\Debug\Action\ThrowErrorsAsExceptions\ThrowErrorsAsExceptionsOptions;
19
use Ekino\Drupal\Debug\Action\WatchContainerDefinitions\WatchContainerDefinitionsOptions;
20
use Ekino\Drupal\Debug\Action\WatchModulesHooksImplementations\WatchModulesHooksImplementationsOptions;
21
use Ekino\Drupal\Debug\Action\WatchRoutingDefinitions\WatchRoutingDefinitionsOptions;
22
use Ekino\Drupal\Debug\Resource\Model\ResourcesCollection;
23
use Psr\Log\LoggerInterface;
24
25
class OptionsStackBuilder
26
{
27
    /**
28
     * @var OptionsInterface[]
29
     */
30
    private $options;
31
32 11
    private function __construct()
33
    {
34 11
        $this->options = array();
35 11
    }
36
37
    /**
38
     * @return OptionsStackBuilder
39
     */
40 11
    public static function create(): self
41
    {
42 11
        return new self();
43
    }
44
45
    /**
46
     * @return OptionsStack
47
     */
48 1
    public function getOptionsStack(): OptionsStack
49
    {
50 1
        return OptionsStack::create($this->options);
51
    }
52
53
    /**
54
     * @param string|null          $charset
55
     * @param string|null          $fileLinkFormat
56
     * @param LoggerInterface|null $logger
57
     */
58 2
    public function setDisplayPrettyExceptionsOptions(?string $charset, ?string $fileLinkFormat, ?LoggerInterface $logger): self
59
    {
60 2
        return $this->set(new DisplayPrettyExceptionsOptions($charset, $fileLinkFormat, $logger));
61
    }
62
63
    /**
64
     * @param string|null $charset
65
     * @param string|null $fileLinkFormat
66
     */
67 2
    public function setDisplayPrettyExceptionsASAPOptions(?string $charset, ?string $fileLinkFormat): self
68
    {
69 2
        return $this->set(new DisplayPrettyExceptionsASAPOptions($charset, $fileLinkFormat));
70
    }
71
72
    /**
73
     * @param int                  $levels
74
     * @param LoggerInterface|null $logger
75
     */
76 2
    public function setThrowErrorsAsExceptionsOptions(int $levels, ?LoggerInterface $logger): self
77
    {
78 2
        return $this->set(new ThrowErrorsAsExceptionsOptions($levels, $logger));
79
    }
80
81
    /**
82
     * @param string              $cacheFilePath
83
     * @param ResourcesCollection $resourcesCollection
84
     */
85 1
    public function setWatchContainerDefinitionsOptions(string $cacheFilePath, ResourcesCollection $resourcesCollection): self
86
    {
87 1
        return $this->set(new WatchContainerDefinitionsOptions($cacheFilePath, $resourcesCollection));
88
    }
89
90
    /**
91
     * @param string              $cacheFilePath
92
     * @param ResourcesCollection $resourcesCollection
93
     */
94 1
    public function setWatchModulesHooksImplementationsOptions(string $cacheFilePath, ResourcesCollection $resourcesCollection): self
95
    {
96 1
        return $this->set(new WatchModulesHooksImplementationsOptions($cacheFilePath, $resourcesCollection));
97
    }
98
99
    /**
100
     * @param string              $cacheFilePath
101
     * @param ResourcesCollection $resourcesCollection
102
     */
103 1
    public function setWatchRoutingDefinitionsOptions(string $cacheFilePath, ResourcesCollection $resourcesCollection): self
104
    {
105 1
        return $this->set(new WatchRoutingDefinitionsOptions($cacheFilePath, $resourcesCollection));
106
    }
107
108
    /**
109
     * @param OptionsInterface $options
110
     */
111 9
    private function set(OptionsInterface $options): self
112
    {
113 9
        $this->options[\get_class($options)] = $options;
114
115 9
        return $this;
116
    }
117
}
118