| Total Complexity | 10 |
| Total Lines | 50 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 7 | class BooleanColumn extends DataColumn |
||
| 8 | { |
||
| 9 | protected $trueValue = 'Yes'; |
||
| 10 | protected $falseValue = 'No'; |
||
| 11 | |||
| 12 | public function getCellContent($entity) |
||
| 13 | { |
||
| 14 | if (is_callable($this->value)) { |
||
| 15 | $result = call_user_func_array($this->value, [$entity]); |
||
| 16 | } elseif ($this->value !== null) { |
||
| 17 | $result = $this->value ? $this->trueValue : $this->falseValue; |
||
| 18 | } else { |
||
| 19 | |||
| 20 | $result = $entity->{$this->attribute} |
||
| 21 | ? $this->trueValue |
||
| 22 | : $this->falseValue; |
||
| 23 | } |
||
| 24 | return $this->format == 'html' ? $result : htmlspecialchars($result); |
||
| 25 | } |
||
| 26 | |||
| 27 | /** |
||
| 28 | * @return string |
||
| 29 | */ |
||
| 30 | public function getTrueValue(): string |
||
| 31 | { |
||
| 32 | return $this->trueValue; |
||
| 33 | } |
||
| 34 | |||
| 35 | /** |
||
| 36 | * @param string $trueValue |
||
| 37 | */ |
||
| 38 | protected function setTrueValue(string $trueValue): void |
||
| 41 | } |
||
| 42 | |||
| 43 | /** |
||
| 44 | * @return string |
||
| 45 | */ |
||
| 46 | public function getFalseValue(): string |
||
| 49 | } |
||
| 50 | |||
| 51 | /** |
||
| 52 | * @param string $falseValue |
||
| 53 | */ |
||
| 54 | protected function setFalseValue(string $falseValue): void |
||
| 59 |