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

APattern::getPattern()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
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