AbstractKeyboard   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 26
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getKey() 0 6 2
A getKeyList() 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\Keyboard;
10
11
use SerhiiMe\Typos\Exception\KeyNotFoundException;
12
13
/**
14
 * Class AbstractKeyboard
15
 * @package SerhiiMe\Typos\Keyboard
16
 */
17
abstract class AbstractKeyboard
18
{
19
    /**
20
     * Array of possible wrong keys.
21
     * @var array
22
     */
23
    protected $keys = [
24
25
    ];
26
27
    public function getKeyList(): array
28
    {
29
        return array_keys($this->keys);
30
    }
31
32
    /**
33
     * @param string $key
34
     * @return array
35
     * @throws KeyNotFoundException
36
     */
37
    public function getKey(string $key): array
38
    {
39
        if(!array_key_exists($key, $this->keys)) {
40
            throw new KeyNotFoundException($key);
41
        }
42
        return $this->keys[$key];
43
    }
44
}