ThemeState   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 4
c 1
b 0
f 0
dl 0
loc 27
ccs 7
cts 7
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A getTheme() 0 3 1
A setTheme() 0 5 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
     */
24 1
    public function setTheme(?Theme $theme): self
25
    {
26 1
        $this->theme = $theme;
27
28 1
        return $this;
29
    }
30
31
    /**
32
     * Gets the theme instance, or `null` if no theme has been set.
33
     *
34
     * @return Theme|null The theme instance, or `null` if no theme has been set.
35
     */
36 65
    public function getTheme(): ?Theme
37
    {
38 65
        return $this->theme;
39
    }
40
}
41