1 | <?php |
||||||
2 | |||||||
3 | namespace SleepingOwl\Admin\Traits; |
||||||
4 | |||||||
5 | use Illuminate\View\View; |
||||||
6 | |||||||
7 | trait Renderable |
||||||
8 | { |
||||||
9 | /** |
||||||
10 | * @var string |
||||||
11 | */ |
||||||
12 | protected $viewPath; |
||||||
13 | |||||||
14 | /** |
||||||
15 | * @param string|View $view |
||||||
16 | * |
||||||
17 | * @return $this |
||||||
18 | */ |
||||||
19 | 4 | public function setView($view) |
|||||
20 | { |
||||||
21 | 4 | $this->viewPath = $view; |
|||||
22 | |||||||
23 | 4 | return $this; |
|||||
24 | } |
||||||
25 | |||||||
26 | /** |
||||||
27 | * @return View|string |
||||||
28 | */ |
||||||
29 | 12 | public function getView() |
|||||
30 | { |
||||||
31 | 12 | if (empty($this->viewPath) && property_exists($this, 'view')) { |
|||||
32 | 7 | return $this->view; |
|||||
33 | } |
||||||
34 | |||||||
35 | 7 | return $this->viewPath; |
|||||
36 | } |
||||||
37 | |||||||
38 | /** |
||||||
39 | * @return string |
||||||
40 | */ |
||||||
41 | 1 | public function __toString() |
|||||
42 | { |
||||||
43 | 1 | return (string) $this->render(); |
|||||
44 | } |
||||||
45 | |||||||
46 | /** |
||||||
47 | * @return \Illuminate\View\View|\Illuminate\Contracts\View\Factory |
||||||
48 | */ |
||||||
49 | 5 | public function render() |
|||||
50 | { |
||||||
51 | 5 | return app('sleeping_owl.template')->view( |
|||||
0 ignored issues
–
show
|
|||||||
52 | 5 | $this->getView(), |
|||||
53 | 5 | $this->toArray() |
|||||
0 ignored issues
–
show
It seems like
toArray() must be provided by classes using this trait. How about adding it as abstract method to this trait?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
54 | 5 | ); |
|||||
55 | } |
||||||
56 | } |
||||||
57 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.