Completed
Push — master ( ca7ebd...ffd42a )
by Nikolas
03:40
created

Template::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
namespace rtens\domin\delivery\web\resources;
3
4
class Template {
5
6
    /** @var string */
7
    private $file;
8
9
    /**
10
     * @param string $file
11
     */
12
    public function __construct($file) {
13
        $this->file = $file;
14
    }
15
16
    public function render($viewModel) {
17
        global $model;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
18
        $model = $viewModel;
19
20
        ob_start();
21
        include $this->file;
22
        return ob_get_clean();
23
    }
24
}