1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Geezify\Converter; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* Converter class provide the base functionality |
7
|
|
|
* for the Ascii and Geez converters. |
8
|
|
|
* |
9
|
|
|
* @author Sam As End <4sam21{at}gmail.com> |
10
|
|
|
*/ |
11
|
|
|
abstract class Converter |
12
|
|
|
{ |
13
|
|
|
// i don't want readers to think it's a white |
14
|
|
|
// space, it's just an empty string |
15
|
|
|
const EMPTY_CHARACTER = ''; |
16
|
|
|
|
17
|
|
|
const GEEZ_NUMBERS = [ |
18
|
|
|
0 => '', '፩', '፪', '፫', '፬', '፭', '፮', '፯', '፰', '፱', '፲', |
19
|
|
|
20 => '፳', |
20
|
|
|
30 => '፴', |
21
|
|
|
40 => '፵', |
22
|
|
|
50 => '፶', |
23
|
|
|
60 => '፷', |
24
|
|
|
70 => '፸', |
25
|
|
|
80 => '፹', |
26
|
|
|
90 => '፺', |
27
|
|
|
100 => '፻', |
28
|
|
|
10000 => '፼', |
29
|
|
|
]; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Check if a number is strictly ZERO. |
33
|
|
|
* |
34
|
|
|
* @param int $number |
35
|
|
|
* |
36
|
|
|
* @return bool if true it's zero |
37
|
|
|
*/ |
38
|
172 |
|
public static function isZero($number) |
39
|
|
|
{ |
40
|
172 |
|
return $number === 0; |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
abstract public function convert($number); |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* Checks if the number is ፻. |
47
|
|
|
* |
48
|
|
|
* @param string $geez_number |
49
|
|
|
* |
50
|
|
|
* @return bool |
51
|
|
|
*/ |
52
|
91 |
|
protected function isGeezNumberHundred($geez_number) |
53
|
|
|
{ |
54
|
91 |
|
return $this->isGeezNumber($geez_number, 100); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Checks if the geez number character is equal to ascii number. |
59
|
|
|
* |
60
|
|
|
* @param string $geez_number |
61
|
|
|
* @param int $number |
62
|
|
|
* |
63
|
|
|
* @return bool |
64
|
|
|
*/ |
65
|
91 |
|
protected function isGeezNumber($geez_number, $number) |
66
|
|
|
{ |
67
|
91 |
|
return $geez_number === self::GEEZ_NUMBERS[$number]; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* Checks if the number is ፩. |
72
|
|
|
* |
73
|
|
|
* @param $geez_number |
74
|
|
|
* |
75
|
|
|
* @return bool |
76
|
|
|
*/ |
77
|
91 |
|
protected function isGeezNumberOne($geez_number) |
78
|
|
|
{ |
79
|
91 |
|
return $this->isGeezNumber($geez_number, 1); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* Checks if the number is ፼ |
84
|
|
|
* |
85
|
|
|
* @param $geez_number |
86
|
|
|
* |
87
|
|
|
* @return bool |
88
|
|
|
*/ |
89
|
25 |
|
protected function isGeezNumberTenThousand($geez_number) |
90
|
|
|
{ |
91
|
25 |
|
return $this->isGeezNumber($geez_number, 10000); |
92
|
|
|
} |
93
|
|
|
} |
94
|
|
|
|