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

ClassString::make()   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 1
Bugs 0 Features 1
Metric Value
eloc 1
c 1
b 0
f 1
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 1
crap 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