Lines 57.14% 4 / 7
Functions and Methods 50.00% 3 / 6
Classes and Traits 0.00% 0 / 1
Name Lines Functions and Methods CRAP Classes and Traits
RecordingExposedSelect 57.14% 4 / 7 50.00% 3 / 6 10.86 0.00% 0 / 1
 getConfig 0.00% 0 / 1 0.00% 0 / 1 2
 updateConfig 0.00% 0 / 1 0.00% 0 / 1 2
 getOption 100.00% 2 / 2 100.00% 1 / 1 2
 setOption 100.00% 1 / 1 100.00% 1 / 1 1
 watchCommands 0.00% 0 / 1 0.00% 0 / 1 2
 pushCommand 100.00% 1 / 1 100.00% 1 / 1 1
1<?php
2
3declare(strict_types=1);
4
5namespace Stewart\Testing\Exposure;
6
7use Stewart\Contracts\EventStream;
8use Stewart\Contracts\Exception\CommandException;
9use Stewart\Contracts\Exposure\Command\SelectCommand;
10use Stewart\Contracts\Exposure\ExposedSelect;
11use Stewart\Contracts\Exposure\ExposedState;
12use Stewart\Contracts\Exposure\ExposedStateChange;
13use Stewart\Contracts\Exposure\SelectConfig;
14
15/** @extends RecordingExposedEntity<SelectConfig> */
16final class RecordingExposedSelect extends RecordingExposedEntity implements ExposedSelect
17{
18    public function getConfig(): SelectConfig
19    {
20        return $this->config;
21    }
22
23    public function updateConfig(SelectConfig $config): void
24    {
25        $this->recordConfig($config);
26    }
27
28    public function getOption(): ?string
29    {
30        $value = $this->findStateValue();
31
32        return \is_string($value) ? $value : null;
33    }
34
35    public function setOption(?string $option, ?array $attributes = null): void
36    {
37        $this->recordChange(new ExposedStateChange(new ExposedState($option), $attributes));
38    }
39
40    public function watchCommands(): EventStream
41    {
42        /** @var EventStream<SelectCommand> */
43        return $this->watchPushedCommands();
44    }
45
46    /** @throws CommandException */
47    public function pushCommand(SelectCommand $command): void
48    {
49        $this->deliverCommand($command);
50    }
51}