ArrayTyposStorage   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 68
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 68
rs 10
c 0
b 0
f 0
wmc 7

7 Methods

Rating   Name   Duplication   Size   Complexity  
A getOriginalWord() 0 3 1
A addList() 0 3 1
A remove() 0 2 1
A addTypos() 0 4 1
A __construct() 0 4 1
A getList() 0 3 1
A getCount() 0 3 1
1
<?php
2
/**
3
 * @author Serhii Nekhaienko <[email protected]>
4
 * @license MIT
5
 * @copyright Serhii Nekhaienko (c) 2019
6
 * @version 1.0
7
 */
8
9
namespace SerhiiMe\Typos\Storage;
10
11
/**
12
 * Class ArrayTyposStorage
13
 * @package SerhiiMe\Typos\Storage
14
 */
15
final class ArrayTyposStorage implements ITyposStorage
16
{
17
    /**
18
     * @var array
19
     */
20
    private $list;
21
22
    /**
23
     * @var string
24
     */
25
    private $originalWord;
26
27
    /**
28
     * @return string
29
     */
30
    public function getOriginalWord(): string
31
    {
32
        return $this->originalWord;
33
    }
34
35
    public function __construct(string $originalWord)
36
    {
37
        $this->originalWord = $originalWord;
38
        $this->list = [];
39
    }
40
41
    /**
42
     * Add new typos to list
43
     * @param string $typos
44
     */
45
    public function addTypos(string $typos)
46
    {
47
        $this->list[] = $typos;
48
        $this->list = array_unique($this->list);
49
    }
50
51
    /**
52
     * Add list of typos to storage
53
     * @param array $typos
54
     */
55
    public function addList(array $typos) {
56
        $this->list = array_merge($this->list, $typos);
57
        $this->list = array_unique($this->list);
58
    }
59
60
    /**
61
     * Return list of typos in collection
62
     * @return array
63
     */
64
    public function getList(): array
65
    {
66
        return $this->list;
67
    }
68
69
    /**
70
     * Return count of typos in collection
71
     * @return int
72
     */
73
    public function getCount(): int
74
    {
75
        return count($this->list);
76
    }
77
78
    /**
79
     * Remove storage from memory
80
     */
81
    public function remove()
82
    {
83
        /** Not needed in this storage */
84
    }
85
}