Concurrency::ensureConcurrency()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 15

Duplication

Lines 15
Ratio 100 %

Importance

Changes 0
Metric Value
dl 15
loc 15
rs 9.7666
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
namespace DjThossi\SmokeTestingPhp\ValueObject;
3
4
use DjThossi\Ensure\EnsureIsGreaterThanTrait;
5
use DjThossi\Ensure\EnsureIsIntegerTrait;
6
7 View Code Duplication
class Concurrency
8
{
9
    use EnsureIsIntegerTrait;
10
    use EnsureIsGreaterThanTrait;
11
12
    const CONCURRENCY_IS_NOT_AN_INTEGER = 1;
13
    const CONCURRENCY_IS_TOO_SMALL = 2;
14
15
    /**
16
     * @var int
17
     */
18
    private $concurrency;
19
20
    /**
21
     * @param int $concurrency
22
     */
23
    public function __construct($concurrency)
24
    {
25
        $this->ensureConcurrency($concurrency);
26
27
        $this->concurrency = $concurrency;
28
    }
29
30
    /**
31
     * @return int
32
     */
33
    public function asInteger()
34
    {
35
        return $this->concurrency;
36
    }
37
38
    /**
39
     * @param mixed $concurrency
40
     */
41
    private function ensureConcurrency($concurrency)
42
    {
43
        $this->ensureIsInteger(
44
            'Concurrency',
45
            $concurrency,
46
            self::CONCURRENCY_IS_NOT_AN_INTEGER
47
        );
48
49
        $this->ensureIsGreaterThan(
50
            'Concurrency',
51
            0,
52
            $concurrency,
53
            self::CONCURRENCY_IS_TOO_SMALL
54
        );
55
    }
56
}
57