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

AsciiChar   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1
Metric Value
wmc 8
lcom 1
cbo 1
dl 0
loc 51
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __toString() 0 4 1
A getChar() 0 4 1
A getDec() 0 4 1
A getHex() 0 4 1
A isControlChar() 0 4 2
A isPrintableChar() 0 4 2
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
}