Passed
Push — master ( a46ae4...dbf10f )
by Alain
02:41 queued 17s
created
config/defaults.php 1 patch
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -12,26 +12,26 @@
 block discarded – undo
12 12
 namespace BrightNucleus\View;
13 13
 
14 14
 $engineFinder = [
15
-    'ClassName'  => 'BrightNucleus\View\Engine\EngineFinder',
16
-    'Engines'    => [
17
-        'PHPEngine' => 'BrightNucleus\View\Engine\PHPEngine',
18
-    ],
19
-    'NullObject' => 'BrightNucleus\View\Engine\NullEngine',
15
+	'ClassName'  => 'BrightNucleus\View\Engine\EngineFinder',
16
+	'Engines'    => [
17
+		'PHPEngine' => 'BrightNucleus\View\Engine\PHPEngine',
18
+	],
19
+	'NullObject' => 'BrightNucleus\View\Engine\NullEngine',
20 20
 ];
21 21
 
22 22
 $viewFinder = [
23
-    'ClassName'  => 'BrightNucleus\View\View\ViewFinder',
24
-    'Views'      => [
25
-        'BaseView' => 'BrightNucleus\View\View\BaseView',
26
-    ],
27
-    'NullObject' => 'BrightNucleus\View\View\NullView',
23
+	'ClassName'  => 'BrightNucleus\View\View\ViewFinder',
24
+	'Views'      => [
25
+		'BaseView' => 'BrightNucleus\View\View\BaseView',
26
+	],
27
+	'NullObject' => 'BrightNucleus\View\View\NullView',
28 28
 ];
29 29
 
30 30
 return [
31
-    'BrightNucleus' => [
32
-        'View' => [
33
-            'EngineFinder' => $engineFinder,
34
-            'ViewFinder'   => $viewFinder,
35
-        ],
36
-    ],
31
+	'BrightNucleus' => [
32
+		'View' => [
33
+			'EngineFinder' => $engineFinder,
34
+			'ViewFinder'   => $viewFinder,
35
+		],
36
+	],
37 37
 ];
Please login to merge, or discard this patch.
src/View/Support/FinderInterface.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -22,14 +22,14 @@
 block discarded – undo
22 22
 interface FinderInterface
23 23
 {
24 24
 
25
-    /**
26
-     * Find a result based on a specific criteria.
27
-     *
28
-     * @since 0.1.0
29
-     *
30
-     * @param array $criteria Criteria to search for.
31
-     *
32
-     * @return mixed Result of the search.
33
-     */
34
-    public function find(array $criteria);
25
+	/**
26
+	 * Find a result based on a specific criteria.
27
+	 *
28
+	 * @since 0.1.0
29
+	 *
30
+	 * @param array $criteria Criteria to search for.
31
+	 *
32
+	 * @return mixed Result of the search.
33
+	 */
34
+	public function find(array $criteria);
35 35
 }
Please login to merge, or discard this patch.
src/View/Support/AbstractFinder.php 1 patch
Indentation   +90 added lines, -90 removed lines patch added patch discarded remove patch
@@ -26,102 +26,102 @@
 block discarded – undo
26 26
 abstract class AbstractFinder implements FinderInterface
27 27
 {
28 28
 
29
-    use ConfigTrait;
29
+	use ConfigTrait;
30 30
 
31
-    /**
32
-     * Array of Findables that the Finder can iterate through to find a match.
33
-     *
34
-     * @since 0.1.0
35
-     *
36
-     * @var Findable[]
37
-     */
38
-    protected $findables;
31
+	/**
32
+	 * Array of Findables that the Finder can iterate through to find a match.
33
+	 *
34
+	 * @since 0.1.0
35
+	 *
36
+	 * @var Findable[]
37
+	 */
38
+	protected $findables;
39 39
 
40
-    /**
41
-     * NullObject that is returned if the Finder could not find a match.
42
-     *
43
-     * @since 0.1.0
44
-     *
45
-     * @var NullObject
46
-     */
47
-    protected $nullObject;
40
+	/**
41
+	 * NullObject that is returned if the Finder could not find a match.
42
+	 *
43
+	 * @since 0.1.0
44
+	 *
45
+	 * @var NullObject
46
+	 */
47
+	protected $nullObject;
48 48
 
49
-    /**
50
-     * Instantiate an AbstractFinder object.
51
-     *
52
-     * @since 0.1.0
53
-     *
54
-     * @param ConfigInterface $config Configuration of the EngineFinder.
55
-     *
56
-     * @throws FailedToProcessConfigException If the config could not be processed.
57
-     */
58
-    public function __construct(ConfigInterface $config)
59
-    {
60
-        $this->processConfig($config);
61
-        $this->registerFindables($this->config);
62
-        $this->registerNullObject($this->config);
63
-    }
49
+	/**
50
+	 * Instantiate an AbstractFinder object.
51
+	 *
52
+	 * @since 0.1.0
53
+	 *
54
+	 * @param ConfigInterface $config Configuration of the EngineFinder.
55
+	 *
56
+	 * @throws FailedToProcessConfigException If the config could not be processed.
57
+	 */
58
+	public function __construct(ConfigInterface $config)
59
+	{
60
+		$this->processConfig($config);
61
+		$this->registerFindables($this->config);
62
+		$this->registerNullObject($this->config);
63
+	}
64 64
 
65
-    /**
66
-     * Register the Findables defined in the given configuration.
67
-     *
68
-     * @since 0.1.0
69
-     *
70
-     * @param ConfigInterface $config Configuration to register the Findables from.
71
-     */
72
-    public function registerFindables(ConfigInterface $config)
73
-    {
74
-        foreach ($config->getKey($this->getFindablesConfigKey()) as $findableKey => $findableObject) {
75
-            $this->registerFindable($findableKey, $findableObject);
76
-        }
77
-    }
65
+	/**
66
+	 * Register the Findables defined in the given configuration.
67
+	 *
68
+	 * @since 0.1.0
69
+	 *
70
+	 * @param ConfigInterface $config Configuration to register the Findables from.
71
+	 */
72
+	public function registerFindables(ConfigInterface $config)
73
+	{
74
+		foreach ($config->getKey($this->getFindablesConfigKey()) as $findableKey => $findableObject) {
75
+			$this->registerFindable($findableKey, $findableObject);
76
+		}
77
+	}
78 78
 
79
-    /**
80
-     * Register the NullObject defined in the given configuration.
81
-     *
82
-     * @since 0.1.0
83
-     *
84
-     * @param ConfigInterface $config Configuration to register the NullObject from.
85
-     */
86
-    public function registerNullObject(ConfigInterface $config)
87
-    {
88
-        $this->nullObject = $config->getKey($this->getNullObjectConfigKey());
89
-    }
79
+	/**
80
+	 * Register the NullObject defined in the given configuration.
81
+	 *
82
+	 * @since 0.1.0
83
+	 *
84
+	 * @param ConfigInterface $config Configuration to register the NullObject from.
85
+	 */
86
+	public function registerNullObject(ConfigInterface $config)
87
+	{
88
+		$this->nullObject = $config->getKey($this->getNullObjectConfigKey());
89
+	}
90 90
 
91
-    /**
92
-     * Register a single Findable.
93
-     *
94
-     * @since 0.1.0
95
-     *
96
-     * @param string $key      Key used to reference the Findable.
97
-     * @param mixed  $findable Findable as a FQCN, callable or object.
98
-     */
99
-    protected function registerFindable($key, $findable)
100
-    {
101
-        $this->findables[$key] = $findable;
102
-    }
91
+	/**
92
+	 * Register a single Findable.
93
+	 *
94
+	 * @since 0.1.0
95
+	 *
96
+	 * @param string $key      Key used to reference the Findable.
97
+	 * @param mixed  $findable Findable as a FQCN, callable or object.
98
+	 */
99
+	protected function registerFindable($key, $findable)
100
+	{
101
+		$this->findables[$key] = $findable;
102
+	}
103 103
 
104
-    /**
105
-     * Get the config key for the Findables definitions.
106
-     *
107
-     * @since 0.1.0
108
-     *
109
-     * @return string Config key use to define the Findables.
110
-     */
111
-    protected function getFindablesConfigKey()
112
-    {
113
-        return 'Findables';
114
-    }
104
+	/**
105
+	 * Get the config key for the Findables definitions.
106
+	 *
107
+	 * @since 0.1.0
108
+	 *
109
+	 * @return string Config key use to define the Findables.
110
+	 */
111
+	protected function getFindablesConfigKey()
112
+	{
113
+		return 'Findables';
114
+	}
115 115
 
116
-    /**
117
-     * Get the config key for the NullObject definitions.
118
-     *
119
-     * @since 0.1.0
120
-     *
121
-     * @return string Config key use to define the NullObject.
122
-     */
123
-    protected function getNullObjectConfigKey()
124
-    {
125
-        return 'NullObject';
126
-    }
116
+	/**
117
+	 * Get the config key for the NullObject definitions.
118
+	 *
119
+	 * @since 0.1.0
120
+	 *
121
+	 * @return string Config key use to define the NullObject.
122
+	 */
123
+	protected function getNullObjectConfigKey()
124
+	{
125
+		return 'NullObject';
126
+	}
127 127
 }
Please login to merge, or discard this patch.
src/View/View/AbstractView.php 1 patch
Indentation   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -25,55 +25,55 @@
 block discarded – undo
25 25
 abstract class AbstractView implements ViewInterface, Findable
26 26
 {
27 27
 
28
-    /**
29
-     * URI of the view.
30
-     *
31
-     * @since 0.1.0
32
-     *
33
-     * @var string
34
-     */
35
-    protected $uri;
28
+	/**
29
+	 * URI of the view.
30
+	 *
31
+	 * @since 0.1.0
32
+	 *
33
+	 * @var string
34
+	 */
35
+	protected $uri;
36 36
 
37
-    /**
38
-     * Engine to use for the view.
39
-     *
40
-     * @since 0.1.0
41
-     *
42
-     * @var EngineInterface
43
-     */
44
-    protected $engine;
37
+	/**
38
+	 * Engine to use for the view.
39
+	 *
40
+	 * @since 0.1.0
41
+	 *
42
+	 * @var EngineInterface
43
+	 */
44
+	protected $engine;
45 45
 
46
-    /**
47
-     * Instantiate an AbstractView object.
48
-     *
49
-     * @since 0.1.0
50
-     *
51
-     * @param string          $uri    URI for the view.
52
-     * @param EngineInterface $engine Engine to use for the view.
53
-     */
54
-    public function __construct($uri, EngineInterface $engine)
55
-    {
56
-        $this->uri    = $uri;
57
-        $this->engine = $engine;
58
-    }
46
+	/**
47
+	 * Instantiate an AbstractView object.
48
+	 *
49
+	 * @since 0.1.0
50
+	 *
51
+	 * @param string          $uri    URI for the view.
52
+	 * @param EngineInterface $engine Engine to use for the view.
53
+	 */
54
+	public function __construct($uri, EngineInterface $engine)
55
+	{
56
+		$this->uri    = $uri;
57
+		$this->engine = $engine;
58
+	}
59 59
 
60
-    /**
61
-     * Render the view.
62
-     *
63
-     * @since 0.1.0
64
-     *
65
-     * @param array $context Optional. The context in which to render the view.
66
-     * @param bool  $echo    Optional. Whether to echo the output immediately. Defaults to false.
67
-     *
68
-     * @return string|void Rendered HTML or nothing, depending on $echo argument.
69
-     */
70
-    public function render(array $context = [], $echo = false)
71
-    {
72
-        $output = $this->engine->render($this->uri, $context);
73
-        if ($echo) {
74
-            echo $output;
75
-        } else {
76
-            return $output;
77
-        }
78
-    }
60
+	/**
61
+	 * Render the view.
62
+	 *
63
+	 * @since 0.1.0
64
+	 *
65
+	 * @param array $context Optional. The context in which to render the view.
66
+	 * @param bool  $echo    Optional. Whether to echo the output immediately. Defaults to false.
67
+	 *
68
+	 * @return string|void Rendered HTML or nothing, depending on $echo argument.
69
+	 */
70
+	public function render(array $context = [], $echo = false)
71
+	{
72
+		$output = $this->engine->render($this->uri, $context);
73
+		if ($echo) {
74
+			echo $output;
75
+		} else {
76
+			return $output;
77
+		}
78
+	}
79 79
 }
Please login to merge, or discard this patch.
src/View/View/ViewFinderInterface.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -25,15 +25,15 @@
 block discarded – undo
25 25
 interface ViewFinderInterface extends FinderInterface
26 26
 {
27 27
 
28
-    /**
29
-     * Find a result based on a specific criteria.
30
-     *
31
-     * @since 0.1.0
32
-     *
33
-     * @param array           $criteria Criteria to search for.
34
-     * @param EngineInterface $engine   Optional. Engine to use with the view.
35
-     *
36
-     * @return ViewInterface View that was found.
37
-     */
38
-    public function find(array $criteria, EngineInterface $engine = null);
28
+	/**
29
+	 * Find a result based on a specific criteria.
30
+	 *
31
+	 * @since 0.1.0
32
+	 *
33
+	 * @param array           $criteria Criteria to search for.
34
+	 * @param EngineInterface $engine   Optional. Engine to use with the view.
35
+	 *
36
+	 * @return ViewInterface View that was found.
37
+	 */
38
+	public function find(array $criteria, EngineInterface $engine = null);
39 39
 }
Please login to merge, or discard this patch.
src/View/View/ViewInterface.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -22,14 +22,14 @@
 block discarded – undo
22 22
 interface ViewInterface
23 23
 {
24 24
 
25
-    /**
26
-     * Render the view.
27
-     *
28
-     * @since 0.1.0
29
-     *
30
-     * @param array $context Optional. The context in which to render the view.
31
-     *
32
-     * @return string Rendered HTML.
33
-     */
34
-    public function render(array $context = []);
25
+	/**
26
+	 * Render the view.
27
+	 *
28
+	 * @since 0.1.0
29
+	 *
30
+	 * @param array $context Optional. The context in which to render the view.
31
+	 *
32
+	 * @return string Rendered HTML.
33
+	 */
34
+	public function render(array $context = []);
35 35
 }
Please login to merge, or discard this patch.
src/View/View/NullView.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -24,16 +24,16 @@
 block discarded – undo
24 24
 class NullView implements ViewInterface, NullObject
25 25
 {
26 26
 
27
-    /**
28
-     * Render the view.
29
-     *
30
-     * @since 0.1.0
31
-     *
32
-     * @param array $context Optional. The context in which to render the view.
33
-     *
34
-     * @return string Rendered HTML.
35
-     */
36
-    public function render(array $context = [])
37
-    {
38
-    }
27
+	/**
28
+	 * Render the view.
29
+	 *
30
+	 * @since 0.1.0
31
+	 *
32
+	 * @param array $context Optional. The context in which to render the view.
33
+	 *
34
+	 * @return string Rendered HTML.
35
+	 */
36
+	public function render(array $context = [])
37
+	{
38
+	}
39 39
 }
Please login to merge, or discard this patch.
src/View/Engine/AbstractEngine.php 1 patch
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -24,24 +24,24 @@
 block discarded – undo
24 24
 abstract class AbstractEngine implements EngineInterface, Findable
25 25
 {
26 26
 
27
-    /**
28
-     * Check whether a given URI has a specific extension.
29
-     *
30
-     * @since 0.1.0
31
-     *
32
-     * @param string $uri       URI to check the extension of.
33
-     * @param string $extension Extension to check for.
34
-     *
35
-     * @return bool
36
-     */
37
-    protected function hasExtension($uri, $extension)
38
-    {
39
-        $uriLength       = mb_strlen($uri);
40
-        $extensionLength = mb_strlen($extension);
41
-        if ($extensionLength > $uriLength) {
42
-            return false;
43
-        }
27
+	/**
28
+	 * Check whether a given URI has a specific extension.
29
+	 *
30
+	 * @since 0.1.0
31
+	 *
32
+	 * @param string $uri       URI to check the extension of.
33
+	 * @param string $extension Extension to check for.
34
+	 *
35
+	 * @return bool
36
+	 */
37
+	protected function hasExtension($uri, $extension)
38
+	{
39
+		$uriLength       = mb_strlen($uri);
40
+		$extensionLength = mb_strlen($extension);
41
+		if ($extensionLength > $uriLength) {
42
+			return false;
43
+		}
44 44
 
45
-        return substr_compare($uri, $extension, $uriLength - $extensionLength, $extensionLength) === 0;
46
-    }
45
+		return substr_compare($uri, $extension, $uriLength - $extensionLength, $extensionLength) === 0;
46
+	}
47 47
 }
Please login to merge, or discard this patch.
src/View/Engine/PHPEngine.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@
 block discarded – undo
56 56
      */
57 57
     public function render($uri, array $context = [])
58 58
     {
59
-        if (! is_readable($uri)) {
59
+        if ( ! is_readable($uri)) {
60 60
             throw new FailedToLoadViewException(
61 61
                 sprintf(
62 62
                     _('The View URI "%1$s" is not accessible or readable.'),
Please login to merge, or discard this patch.
Indentation   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -25,73 +25,73 @@
 block discarded – undo
25 25
 class PHPEngine extends AbstractEngine
26 26
 {
27 27
 
28
-    const PHP_EXTENSION = '.php';
28
+	const PHP_EXTENSION = '.php';
29 29
 
30
-    /**
31
-     * Check whether the Findable can handle an individual criterion.
32
-     *
33
-     * @since 0.1.0
34
-     *
35
-     * @param mixed $criterion Criterion to check.
36
-     *
37
-     * @return bool Whether the Findable can handle the criterion.
38
-     */
39
-    public function canHandle($criterion)
40
-    {
41
-        return $this->hasExtension($criterion, static::PHP_EXTENSION)
42
-               && is_readable($criterion);
43
-    }
30
+	/**
31
+	 * Check whether the Findable can handle an individual criterion.
32
+	 *
33
+	 * @since 0.1.0
34
+	 *
35
+	 * @param mixed $criterion Criterion to check.
36
+	 *
37
+	 * @return bool Whether the Findable can handle the criterion.
38
+	 */
39
+	public function canHandle($criterion)
40
+	{
41
+		return $this->hasExtension($criterion, static::PHP_EXTENSION)
42
+			   && is_readable($criterion);
43
+	}
44 44
 
45
-    /**
46
-     * Render a given URI.
47
-     *
48
-     * @since 0.1.0
49
-     *
50
-     * @param string $uri     URI to render.
51
-     * @param array  $context Context in which to render.
52
-     *
53
-     * @return string Rendered HTML.
54
-     * @throws FailedToLoadViewException If the View URI is not accessible or readable.
55
-     * @throws FailedToLoadViewException If the View URI could not be loaded.
56
-     */
57
-    public function render($uri, array $context = [])
58
-    {
59
-        if (! is_readable($uri)) {
60
-            throw new FailedToLoadViewException(
61
-                sprintf(
62
-                    _('The View URI "%1$s" is not accessible or readable.'),
63
-                    $uri
64
-                )
65
-            );
66
-        }
45
+	/**
46
+	 * Render a given URI.
47
+	 *
48
+	 * @since 0.1.0
49
+	 *
50
+	 * @param string $uri     URI to render.
51
+	 * @param array  $context Context in which to render.
52
+	 *
53
+	 * @return string Rendered HTML.
54
+	 * @throws FailedToLoadViewException If the View URI is not accessible or readable.
55
+	 * @throws FailedToLoadViewException If the View URI could not be loaded.
56
+	 */
57
+	public function render($uri, array $context = [])
58
+	{
59
+		if (! is_readable($uri)) {
60
+			throw new FailedToLoadViewException(
61
+				sprintf(
62
+					_('The View URI "%1$s" is not accessible or readable.'),
63
+					$uri
64
+				)
65
+			);
66
+		}
67 67
 
68
-        extract($context, EXTR_SKIP);
68
+		extract($context, EXTR_SKIP);
69 69
 
70
-        // Save current buffering level so we can backtrack in case of an error.
71
-        // This is needed because the view itself might also add an unknown number of output buffering levels.
72
-        $bufferLevel = ob_get_level();
73
-        ob_start();
70
+		// Save current buffering level so we can backtrack in case of an error.
71
+		// This is needed because the view itself might also add an unknown number of output buffering levels.
72
+		$bufferLevel = ob_get_level();
73
+		ob_start();
74 74
 
75
-        try {
76
-            include($uri);
77
-        } catch (Exception $exception) {
75
+		try {
76
+			include($uri);
77
+		} catch (Exception $exception) {
78 78
 
79
-            // Remove whatever levels were added up until now.
80
-            while (ob_get_level() > $bufferLevel) {
81
-                ob_end_clean();
82
-            }
79
+			// Remove whatever levels were added up until now.
80
+			while (ob_get_level() > $bufferLevel) {
81
+				ob_end_clean();
82
+			}
83 83
 
84
-            throw new FailedToLoadViewException(
85
-                sprintf(
86
-                    _('Could not load the View URI "%1$s". Reason: "%2$s".'),
87
-                    $uri,
88
-                    $exception->getMessage()
89
-                ),
90
-                $exception->getCode(),
91
-                $exception
92
-            );
93
-        }
84
+			throw new FailedToLoadViewException(
85
+				sprintf(
86
+					_('Could not load the View URI "%1$s". Reason: "%2$s".'),
87
+					$uri,
88
+					$exception->getMessage()
89
+				),
90
+				$exception->getCode(),
91
+				$exception
92
+			);
93
+		}
94 94
 
95
-        return ob_get_clean();
96
-    }
95
+		return ob_get_clean();
96
+	}
97 97
 }
Please login to merge, or discard this patch.