• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ICanBoogie / View / 4139795252

pending completion
4139795252

push

github

Olivier Laviale
Add RenderTrait

10 of 10 new or added lines in 1 file covered. (100.0%)

68 of 99 relevant lines covered (68.69%)

1.12 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/lib/RenderTrait.php
1
<?php
2

3
namespace ICanBoogie\View;
4

5
use ICanBoogie\Routing\ControllerAbstract;
6

7
use function assert;
8

9
/**
10
 * A trait for {@link ControllerAbstract}.
11
 */
12
trait RenderTrait
13
{
14
    /**
15
     * Renders a template to a string and updates the response with it.
16
     *
17
     * The `template` and the `layout` are pre-determined by the view provider,
18
     * but can be overloaded.
19
     *
20
     * @param array<string, mixed>|null $locals
21
     */
22
    public function render(
23
        mixed $content = null,
24
        string $template = null,
25
        string $layout = null,
26
        array $locals = null,
27
    ): void {
28
        assert($this instanceof ControllerAbstract);
29
        assert(($this->view_provider ?? null) instanceof ViewProvider);
30

31
        $view = $this->view_provider->view_for_controller($this);
×
32

33
        if ($content !== null) {
×
34
            $view->content = $content;
×
35
        }
36
        if ($template !== null) {
×
37
            $view->template = $template;
×
38
        }
39
        if ($layout !== null) {
×
40
            $view->layout = $layout;
×
41
        }
42
        if ($locals !== null) {
×
43
            $view->assign($locals);
×
44
        }
45

46
        $this->response->body = $view->render();
×
47
    }
48
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc