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

View   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 75%

Importance

Changes 0
Metric Value
wmc 6
dl 0
loc 27
ccs 9
cts 12
cp 0.75
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A assign() 0 3 1
A view() 0 7 3
A render() 0 3 1
A config() 0 3 1
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