| Total Complexity | 10 |
| Total Lines | 77 |
| Duplicated Lines | 0 % |
| Changes | 5 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 7 | class Space |
||
| 8 | { |
||
| 9 | /** |
||
| 10 | * @var int This contains the amount of white spaces to be used |
||
| 11 | */ |
||
| 12 | protected $chars; |
||
| 13 | |||
| 14 | /** |
||
| 15 | * @var string This contains the type of space that is being returned. Accepts: space | escaped |
||
| 16 | */ |
||
| 17 | protected $kind; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * @var string this holds the actual spaces generated |
||
| 21 | */ |
||
| 22 | public $spaces; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * Constructor |
||
| 26 | * |
||
| 27 | * @param int $chars The number of space characters to display |
||
| 28 | * @param string $kind Determines the kind of space to return. Values: space | escaped |
||
| 29 | */ |
||
| 30 | |||
| 31 | public function __construct(int $chars = 1, string $kind = 'space') |
||
| 37 | } |
||
| 38 | |||
| 39 | private function generateSpace() |
||
| 40 | { |
||
| 41 | if ('space' == $this->kind) { |
||
| 42 | foreach ($this->whitesSpace($this->chars) as $space) { |
||
| 43 | $this->spaces .= $space; |
||
| 44 | } |
||
| 45 | } elseif ('escaped' == $this->kind) { |
||
| 46 | foreach ($this->whitesSpaceEscape($this->chars) as $space) { |
||
| 47 | $this->spaces .= $space; |
||
| 48 | } |
||
| 49 | } |
||
| 50 | |||
| 51 | } |
||
| 52 | |||
| 53 | /** |
||
| 54 | * Generator that produced a space ' ' |
||
| 55 | * |
||
| 56 | * This is a simple generator that returns a space in the form of a ' '. |
||
| 57 | * |
||
| 58 | * @param int $chars The number of of space characters to produce |
||
| 59 | * |
||
| 60 | * @return \Generator |
||
| 61 | */ |
||
| 62 | |||
| 63 | private function whitesSpace($chars) |
||
| 67 | } |
||
| 68 | } |
||
| 69 | |||
| 70 | /** |
||
| 71 | * Generator that produces an escaped space |
||
| 72 | * |
||
| 73 | * This is a simple generator that returns a space in the form of an escaped space. |
||
| 74 | * |
||
| 75 | * @param int $chars The number of of space characters to produce |
||
| 76 | * |
||
| 77 | * @return \Generator |
||
| 78 | */ |
||
| 79 | |||
| 80 | private function whitesSpaceEscape($chars) |
||
| 84 | } |
||
| 85 | } |
||
| 87 | } |