Completed
Push — master ( 815380...5d2ba3 )
by Sergey
02:13
created

AsciiChar::getChar()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
/**
3
 * @author: Viskov Sergey
4
 * @date: 3/18/16
5
 * @time: 11:18 AM
6
 */
7
8
namespace LTDBeget\ascii;
9
10
11
use MabeEnum\Enum;
12
13
/**
14
 * Class AsciiChar
15
 * @package LTDBeget\ascii
16
 */
17
abstract class AsciiChar extends Enum
18
{
19
    /**
20
     * ascii table symbol as char
21
     * @return string
22
     */
23
    public function __toString()
24
    {
25
        return $this->getChar();
26
    }
27
28
    /**
29
     * @return string
30
     */
31
    public function getChar() : string
32
    {
33
        return chr($this->getValue());
34
    }
35
36
    /**
37
     * @return int
38
     */
39
    public function getDec() : int
40
    {
41
        return $this->getValue();
42
    }
43
44
    /**
45
     * @return string
46
     */
47
    public function getHex() : string
48
    {
49
        return dechex($this->getValue());
50
    }
51
52
    /**
53
     * @return bool
54
     */
55
    public function isControlChar() : bool
56
    {
57
        return $this->getValue() >= 0 && $this->getValue() <= 31;
58
    }
59
60
    /**
61
     * @return bool
62
     */
63
    public function isPrintableChar() : bool
64
    {
65
        return $this->getValue() >= 32 && $this->getValue() <= 127;
66
    }
67
}