1 | <?php |
||
2 | /** |
||
3 | * This file is part of the sauls/widget package. |
||
4 | * |
||
5 | * @author Saulius Vaičeliūnas <[email protected]> |
||
6 | * @link http://saulius.vaiceliunas.lt |
||
7 | * @copyright 2018 |
||
8 | * |
||
9 | * For the full copyright and license information, please view the LICENSE |
||
10 | * file that was distributed with this source code. |
||
11 | */ |
||
12 | |||
13 | namespace Sauls\Component\Widget\View; |
||
14 | |||
15 | |||
16 | class StringView implements ViewInterface |
||
17 | { |
||
18 | /** |
||
19 | * @param string $viewFile |
||
20 | * @param array $viewData |
||
21 | * |
||
22 | * @return string |
||
23 | * |
||
24 | */ |
||
25 | 6 | public function render(string $viewFile, array $viewData = []): string |
|
26 | { |
||
27 | 6 | return strtr( |
|
28 | 6 | $viewFile, |
|
29 | 6 | array_combine( |
|
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
30 | 6 | array_map( |
|
31 | 6 | function ($key) { |
|
32 | 6 | return '{'.$key.'}'; |
|
33 | 6 | }, |
|
34 | 6 | array_keys($viewData) |
|
35 | ), |
||
36 | 6 | array_values($viewData) |
|
37 | ) |
||
38 | ); |
||
39 | } |
||
40 | |||
41 | 19 | public function getName(): string |
|
42 | { |
||
43 | 19 | return 'string'; |
|
44 | } |
||
45 | } |
||
46 |