Completed
Push — master ( 6a4efb...35b143 )
by Dennis
01:26
created

Icon::maybe()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 3
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace lloc\Msls\Component;
4
5
/**
6
 * Class Icon
7
 * @package lloc\Msls\Component
8
 */
9
abstract class Icon {
10
11
	/**
12
	 * @var array
13
	 */
14
	protected $map;
15
16
	/**
17
	 * Icon constructor
18
	 */
19
	public function __construct() {
20
		$this->map = include $this->path();
21
	}
22
23
	/**
24
	 * @param string $language
25
	 * @param string $prefix
26
	 * @param string $postfix
27
	 *
28
	 * @return string
29
	 */
30
	protected function maybe( string $language, string $prefix = '', string $postfix = '' ): string {
31
		if ( 5 == strlen( $language ) ) {
32
			$language = strtolower( substr( $language, - 2 ) );
33
		}
34
35
		return $prefix . $language . $postfix;
36
	}
37
38
	/**
39
	 * @return string
40
	 */
41
	abstract protected function path(): string;
42
43
	/**
44
	 * @param string $language
45
	 *
46
	 * @return string
47
	 */
48
	abstract public function get( string $language ): string;
49
50
}