Passed
Push — main ( ec6948...9b9c4a )
by Michael
04:01
created

ClassString   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 5
eloc 6
c 1
b 0
f 1
dl 0
loc 44
ccs 9
cts 9
cp 1
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 2 1
A interfaceExists() 0 3 1
A classExists() 0 3 1
A value() 0 3 1
A __toString() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace MichaelRubel\ValueObjects\Complex;
6
7
use Illuminate\Support\Traits\Conditionable;
8
use Illuminate\Support\Traits\Macroable;
9
use MichaelRubel\ValueObjects\ValueObject;
10
11
/**
12
 * @method make(string $classString)
13
 */
14
class ClassString extends ValueObject
15
{
16
    use Macroable, Conditionable;
0 ignored issues
show
Bug introduced by
The trait Illuminate\Support\Traits\Macroable requires the property $name which is not provided by MichaelRubel\ValueObjects\Complex\ClassString.
Loading history...
17
18
    /**
19
     * @param  string|null  $classString
20
     */
21 11
    public function __construct(protected ?string $classString)
22
    {
23
        //
24
    }
25
26
    /**
27
     * @return bool
28
     */
29 5
    public function classExists(): bool
30
    {
31 5
        return class_exists($this->value());
32
    }
33
34
    /**
35
     * @return bool
36
     */
37 4
    public function interfaceExists(): bool
38
    {
39 4
        return interface_exists($this->value());
40
    }
41
42
    /**
43
     * @return string
44
     */
45 9
    public function value(): string
46
    {
47 9
        return (string) $this->classString;
48
    }
49
50
    /**
51
     * Get string representation of the value object.
52
     *
53
     * @return string
54
     */
55 2
    public function __toString(): string
56
    {
57 2
        return $this->value();
58
    }
59
}
60