Conditions | 4 |
Paths | 4 |
Total Lines | 22 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
34 | public function render($value) { |
||
35 | if (method_exists($value, '__toString')) { |
||
36 | return (string)$value; |
||
37 | } |
||
38 | |||
39 | $output = [ |
||
40 | '### ' . (new \ReflectionClass($value))->getShortName() . ' ###', |
||
41 | ]; |
||
42 | |||
43 | $reader = new PropertyReader($this->types, $value); |
||
44 | foreach ($reader->readInterface($value) as $property) { |
||
45 | if (!$property->canGet()) { |
||
46 | continue; |
||
47 | } |
||
48 | $propertyValue = $property->get($value); |
||
49 | $rendered = $this->renderers->getRenderer($propertyValue)->render($propertyValue); |
||
50 | |||
51 | $output[] = ucfirst($property->name()) . ': ' . rtrim(str_replace(PHP_EOL, PHP_EOL . ' ', $rendered)); |
||
52 | } |
||
53 | |||
54 | return implode(PHP_EOL, $output) . PHP_EOL; |
||
55 | } |
||
56 | } |