NameField   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 28
rs 10
c 0
b 0
f 0
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 2
A slugify() 0 5 1
A fromString() 0 3 1
A getValue() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the G.L.S.R. Apps package.
7
 *
8
 * (c) Dev-Int Création <[email protected]>.
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Core\Domain\Common\Model\VO;
15
16
use Cocur\Slugify\Slugify;
0 ignored issues
show
Bug introduced by
The type Cocur\Slugify\Slugify was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
17
use Core\Domain\Common\Model\Exception\StringExceeds255Characters;
18
19
final class NameField
20
{
21
    private string $name;
22
23
    public function __construct(string $name)
24
    {
25
        if (\strlen($name) > 255) {
26
            throw new StringExceeds255Characters();
27
        }
28
29
        $this->name = $name;
30
    }
31
32
    public static function fromString(string $name): self
33
    {
34
        return new self($name);
35
    }
36
37
    public function getValue(): string
38
    {
39
        return $this->name;
40
    }
41
42
    public function slugify(): string
43
    {
44
        $slugify = new Slugify();
45
46
        return $slugify->slugify($this->name);
47
    }
48
}
49