BsCount   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 3
c 1
b 0
f 1
dl 0
loc 32
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A increment() 0 3 1
A __construct() 0 8 1
A value() 0 3 1
1
<?php
2
3
namespace MaxGoryunov\SavingIterator\Src;
4
5
/**
6
 * Basic count implementation.
7
 */
8
final class BsCount implements Count
9
{
10
11
    /**
12
     * Ctor.
13
     * 
14
     * @param int $count how many times something happened.
15
     */
16
    public function __construct(
17
        /**
18
         * How many times something happened.
19
         *
20
         * @var int
21
         */
22
        private int $count = 0
23
    ) {
24
    }
25
26
    /**
27
     * {@inheritDoc}
28
     */
29
    public function increment(): Count
30
    {
31
        return new self($this->count + 1);
32
    }
33
34
    /**
35
     * {@inheritDoc}
36
     */
37
    public function value(): int
38
    {
39
        return $this->count;
40
    }
41
}
42