Conditions | 2 |
Paths | 2 |
Total Lines | 13 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
47 | protected function takeScreenshot($caption = null) |
||
48 | { |
||
49 | $data = $this->screenshot(); |
||
50 | if (empty($data)) { |
||
51 | return $this; |
||
52 | } |
||
53 | |||
54 | $path = sys_get_temp_dir() . '/' . md5(__METHOD__) . '.png'; |
||
55 | file_put_contents($path, $data); |
||
56 | $this->addAttachment($path, $caption, 'image/png'); |
||
57 | |||
58 | return $this; |
||
59 | } |
||
60 | |||
72 |
In PHP traits cannot be used for type-hinting as they do not define a well-defined structure. This is because any class that uses a trait can rename that trait’s methods.
If you would like to return an object that has a guaranteed set of methods, you could create a companion interface that lists these methods explicitly.