Completed
Push — master ( d05011...b5c800 )
by Edson
01:28
created

View::assign()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 3
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 2
crap 2
1
<?php
2
3
namespace Bonfim\Component\View;
4
5
class View
6
{
7
    private static $view = null;
8
    private static $data = [];
9
10 2
    private static function view(): Tpl
0 ignored issues
show
Coding Style Best Practice introduced by
Please use __construct() instead of a PHP4-style constructor that is named after the class.
Loading history...
11
    {
12 2
        if (!isset(self::$view) || is_null(self::$view)) {
13 2
            self::$view = new Tpl;
14
        }
15
16 2
        return self::$view;
17
    }
18
19 2
    public static function config(array $config): void
20
    {
21 2
        self::view()->config($config);
22 2
    }
23
24
    public static function assign(string $key, $value): void
25
    {
26
        self::$data[$key] = $value;
27
    }
28
29 2
    public static function render(string $view, array $data = null): string
0 ignored issues
show
Unused Code introduced by
The parameter $data is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

29
    public static function render(string $view, /** @scrutinizer ignore-unused */ array $data = null): string

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
30
    {
31 2
        return self::view()->render($view, self::$data);
32
    }
33
}
34