Passed
Push — main ( 752a2b...79148c )
by Michael
03:17
created

ClassString::classExists()   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 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 0
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 Illuminate\Support\Traits\Tappable;
10
use MichaelRubel\ValueObjects\ValueObject;
11
12
class ClassString implements ValueObject
13
{
14
    use Macroable, Conditionable, Tappable;
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...
15
16
    /**
17
     * Create a new value object instance.
18
     *
19
     * @param  string|null  $classString
20
     */
21 10
    final public function __construct(public ?string $classString)
22
    {
23
        //
24
    }
25
26
    /**
27
     * Return a new instance of value object.
28
     *
29
     * @param  string|null  $classString
30
     *
31
     * @return static
32
     */
33 3
    public static function make(?string $classString): static
34
    {
35 3
        return new static($classString);
36
    }
37
38
    /**
39
     * @return bool
40
     */
41 5
    public function classExists(): bool
42
    {
43 5
        return class_exists($this->value());
44
    }
45
46
    /**
47
     * @return bool
48
     */
49 4
    public function interfaceExists(): bool
50
    {
51 4
        return interface_exists($this->value());
52
    }
53
54
    /**
55
     * Get the last name.
56
     *
57
     * @return string
58
     */
59 9
    public function value(): string
60
    {
61 9
        return (string) $this->classString;
62
    }
63
64
    /**
65
     * Return the first UUID if cast to string.
66
     *
67
     * @return string
68
     */
69 2
    public function __toString(): string
70
    {
71 2
        return $this->value();
72
    }
73
}
74