SplInt::__invoke()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 4
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
/**
4
 * Part of SplTypes package.
5
 *
6
 * (c) Adrien Loyant <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace Ducks\Component\SplTypes;
15
16
/**
17
 * The SplInt class is used to enforce strong typing of the integer type.
18
 *
19
 * @extends SplType<int>
20
 *
21
 * @psalm-api
22
 */
23
class SplInt extends SplType
24
{
25
    /**
26
     * @var int
27
     *
28
     * @psalm-suppress InvalidClassConstantType
29
     */
30
    // phpcs:ignore Generic.NamingConventions.UpperCaseConstantName.ClassConstantNotUpperCase
31
    protected const __default = 0;
32
33
    /**
34
     * {@inheritdoc}
35
     *
36
     * @param int $initial_value
37
     *
38
     * @SuppressWarnings(PHPMD.CamelCaseParameterName)
39
     * @SuppressWarnings(PHPMD.CamelCaseVariableName)
40
     */
41 5
    public function __construct(int $initial_value = self::__default)
42
    {
43 5
        parent::__construct($initial_value);
44
    }
45
46 4
    final public function &__invoke(): int
47
    {
48
        /** @var int */
49 4
        return $this->__default;
50
    }
51
}
52