| Total Complexity | 14 |
| Total Lines | 97 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 9 | class StylesRenderer |
||
| 10 | { |
||
| 11 | /** |
||
| 12 | * @var StyleCollection |
||
| 13 | */ |
||
| 14 | private $collection; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * @var StyleOptions |
||
| 18 | */ |
||
| 19 | private $options; |
||
| 20 | |||
| 21 | public function __construct(StyleCollection $collection) |
||
| 22 | { |
||
| 23 | $this->collection = $collection; |
||
| 24 | $this->options = $collection->getOptions(); |
||
| 25 | } |
||
| 26 | |||
| 27 | public function render() : string |
||
| 28 | { |
||
| 29 | if($this->collection->hasStyles()) |
||
| 30 | { |
||
| 31 | return implode( |
||
| 32 | $this->resolveSeparator(), |
||
| 33 | $this->renderLines() |
||
| 34 | ).$this->resolveSuffix(); |
||
| 35 | } |
||
| 36 | |||
| 37 | return ''; |
||
| 38 | } |
||
| 39 | |||
| 40 | private function resolveSuffix() : string |
||
| 48 | } |
||
| 49 | |||
| 50 | private function resolveSeparator() : string |
||
| 51 | { |
||
| 52 | if($this->options->isNewlineEnabled()) |
||
| 53 | { |
||
| 54 | return ';'.PHP_EOL; |
||
| 55 | } |
||
| 56 | |||
| 57 | return ';'; |
||
| 58 | } |
||
| 59 | |||
| 60 | private function resolveIndent() : string |
||
| 61 | { |
||
| 62 | $indentLevel = $this->options->getIndentLevel(); |
||
| 63 | |||
| 64 | if($indentLevel > 0) |
||
| 65 | { |
||
| 66 | return str_repeat($this->options->getIndentChar(), $indentLevel); |
||
| 67 | } |
||
| 68 | |||
| 69 | return ''; |
||
| 70 | } |
||
| 71 | |||
| 72 | private function resolveValueSpace() : string |
||
| 80 | } |
||
| 81 | |||
| 82 | private function renderLines() : array |
||
| 106 | } |
||
| 107 | } |
||
| 108 |