Passed
Pull Request — master (#243)
by Sergei
03:13
created

ThemeState::setTheme()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 5
ccs 3
cts 3
cp 1
rs 10
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\View\State;
6
7
use Yiisoft\View\Theme;
8
9
/**
10
 * @internal
11
 */
12
final class ThemeState
13
{
14 130
    public function __construct(
15
        private ?Theme $theme = null
16
    ) {
17 130
    }
18
19
    /**
20
     * Set the specified view theme.
21
     *
22
     * @param Theme|null $theme $theme The theme instance or `null` for reset theme.
23
     * @return $this
24
     */
25 1
    public function setTheme(?Theme $theme): self
26
    {
27 1
        $this->theme = $theme;
28
29 1
        return $this;
30
    }
31
32
    /**
33
     * Gets the theme instance, or `null` if no theme has been set.
34
     *
35
     * @return Theme|null The theme instance, or `null` if no theme has been set.
36
     */
37 65
    public function getTheme(): ?Theme
38
    {
39 65
        return $this->theme;
40
    }
41
}
42