Completed
Pull Request — develop (#2)
by Sebastian
02:16
created

HeaderKey::asString()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 4
Ratio 100 %

Importance

Changes 0
Metric Value
dl 4
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
namespace DjThossi\SmokeTestingPhp\ValueObject;
3
4
use DjThossi\Ensure\EnsureIsNotEmptyTrait;
5
use DjThossi\Ensure\EnsureIsStringTrait;
6
7 View Code Duplication
class HeaderKey
1 ignored issue
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
8
{
9
    use EnsureIsStringTrait;
10
    use EnsureIsNotEmptyTrait;
11
12
    const KEY_IS_NOT_A_STRING = 1;
13
    const KEY_IS_EMPTY = 2;
14
15
    /**
16
     * @var string
17
     */
18
    private $key;
19
20
    /**
21
     * @param string $key
22
     */
23
    public function __construct($key)
24
    {
25
        $this->ensureKey($key);
26
27
        $this->key = $key;
28
    }
29
30
    /**
31
     * @return string
32
     */
33
    public function asString()
34
    {
35
        return $this->key;
36
    }
37
38
    /**
39
     * @param mixed $key
40
     */
41
    private function ensureKey($key)
42
    {
43
        $this->ensureIsString('Key', $key, self::KEY_IS_NOT_A_STRING);
44
        $this->ensureIsNotEmpty('Key', $key, self::KEY_IS_EMPTY);
45
    }
46
}
47