Passed
Push — master ( 823aee...b9b37f )
by Alec
13:15 queued 12s
created

APattern   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 7
c 2
b 0
f 0
dl 0
loc 27
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A pattern() 0 3 1
A getInterval() 0 4 1
A getPattern() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
// 10.03.23
5
6
namespace AlecRabbit\Spinner\Core\Pattern\A;
7
8
use AlecRabbit\Spinner\Contract\IInterval;
9
use AlecRabbit\Spinner\Core\Interval;
10
use AlecRabbit\Spinner\Core\Pattern\Contract\IPattern;
11
use ArrayObject;
12
use Traversable;
13
14
abstract class APattern implements IPattern
15
{
16
    /** @var int */
17
    protected const UPDATE_INTERVAL = 1000;
18
19
    /** @var array */
20
    protected const PATTERN = ['  ', ' u', 'un', 'nd', 'de', 'ef', 'fi', 'in', 'ne', 'ed', 'd ',];
21
22
    public function __construct(
23
        protected ?int $interval = null,
24
    ) {
25
    }
26
27
    public function getPattern(): Traversable
28
    {
29
        return $this->pattern();
30
    }
31
32
    protected function pattern(): Traversable
33
    {
34
        return new ArrayObject(static::PATTERN);
35
    }
36
37
    public function getInterval(): IInterval
38
    {
39
        return
40
            new Interval($this->interval ?? static::UPDATE_INTERVAL);
41
    }
42
}
43