Passed
Push — master ( 87ba60...d80a49 )
by Alain
02:43
created
src/View/Engine/Engine.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -24,15 +24,15 @@
 block discarded – undo
24 24
 interface Engine extends Findable
25 25
 {
26 26
 
27
-    /**
28
-     * Get the rendering callback for a given URI.
29
-     *
30
-     * @since 0.1.0
31
-     *
32
-     * @param string $uri     URI to render.
33
-     * @param array  $context Context in which to render.
34
-     *
35
-     * @return string Rendered HTML.
36
-     */
37
-    public function getRenderCallback($uri, array $context = []);
27
+	/**
28
+	 * Get the rendering callback for a given URI.
29
+	 *
30
+	 * @since 0.1.0
31
+	 *
32
+	 * @param string $uri     URI to render.
33
+	 * @param array  $context Context in which to render.
34
+	 *
35
+	 * @return string Rendered HTML.
36
+	 */
37
+	public function getRenderCallback($uri, array $context = []);
38 38
 }
Please login to merge, or discard this patch.
src/View/Engine/BaseEngineFinder.php 1 patch
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -24,39 +24,39 @@
 block discarded – undo
24 24
 class BaseEngineFinder extends AbstractFinder
25 25
 {
26 26
 
27
-    /**
28
-     * Find a result based on a specific criteria.
29
-     *
30
-     * @since 0.1.0
31
-     *
32
-     * @param array $criteria Criteria to search for.
33
-     *
34
-     * @return Engine Result of the search.
35
-     */
36
-    public function find(array $criteria)
37
-    {
38
-        $this->initializeFindables();
27
+	/**
28
+	 * Find a result based on a specific criteria.
29
+	 *
30
+	 * @since 0.1.0
31
+	 *
32
+	 * @param array $criteria Criteria to search for.
33
+	 *
34
+	 * @return Engine Result of the search.
35
+	 */
36
+	public function find(array $criteria)
37
+	{
38
+		$this->initializeFindables();
39 39
 
40
-        foreach ($criteria as $entry) {
41
-            foreach ($this->findables as $engine) {
42
-                if ($engine->canHandle($entry)) {
43
-                    return $engine;
44
-                }
45
-            }
46
-        }
40
+		foreach ($criteria as $entry) {
41
+			foreach ($this->findables as $engine) {
42
+				if ($engine->canHandle($entry)) {
43
+					return $engine;
44
+				}
45
+			}
46
+		}
47 47
 
48
-        return $this->getNullObject();
49
-    }
48
+		return $this->getNullObject();
49
+	}
50 50
 
51
-    /**
52
-     * Get the config key for the Findables definitions.
53
-     *
54
-     * @since 0.1.0
55
-     *
56
-     * @return string Config key use to define the Findables.
57
-     */
58
-    protected function getFindablesConfigKey()
59
-    {
60
-        return 'Engines';
61
-    }
51
+	/**
52
+	 * Get the config key for the Findables definitions.
53
+	 *
54
+	 * @since 0.1.0
55
+	 *
56
+	 * @return string Config key use to define the Findables.
57
+	 */
58
+	protected function getFindablesConfigKey()
59
+	{
60
+		return 'Engines';
61
+	}
62 62
 }
Please login to merge, or discard this patch.
src/View/Engine/PHPEngine.php 1 patch
Indentation   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -26,76 +26,76 @@
 block discarded – undo
26 26
 class PHPEngine extends AbstractEngine
27 27
 {
28 28
 
29
-    const PHP_EXTENSION = '.php';
29
+	const PHP_EXTENSION = '.php';
30 30
 
31
-    /**
32
-     * Check whether the Findable can handle an individual criterion.
33
-     *
34
-     * @since 0.1.0
35
-     *
36
-     * @param mixed $criterion Criterion to check.
37
-     *
38
-     * @return bool Whether the Findable can handle the criterion.
39
-     */
40
-    public function canHandle($criterion)
41
-    {
42
-        return URIHelper::hasExtension($criterion, static::PHP_EXTENSION)
43
-               && is_readable($criterion);
44
-    }
31
+	/**
32
+	 * Check whether the Findable can handle an individual criterion.
33
+	 *
34
+	 * @since 0.1.0
35
+	 *
36
+	 * @param mixed $criterion Criterion to check.
37
+	 *
38
+	 * @return bool Whether the Findable can handle the criterion.
39
+	 */
40
+	public function canHandle($criterion)
41
+	{
42
+		return URIHelper::hasExtension($criterion, static::PHP_EXTENSION)
43
+			   && is_readable($criterion);
44
+	}
45 45
 
46
-    /**
47
-     * Get the rendering callback for a given URI.
48
-     *
49
-     * @since 0.1.0
50
-     *
51
-     * @param string $uri     URI to render.
52
-     * @param array  $context Context in which to render.
53
-     *
54
-     * @return callable Rendering callback.
55
-     * @throws FailedToLoadView If the View URI is not accessible or readable.
56
-     * @throws FailedToLoadView If the View URI could not be loaded.
57
-     */
58
-    public function getRenderCallback($uri, array $context = [])
59
-    {
60
-        if ( ! is_readable($uri)) {
61
-            throw new FailedToLoadView(
62
-                sprintf(
63
-                    _('The View URI "%1$s" is not accessible or readable.'),
64
-                    $uri
65
-                )
66
-            );
67
-        }
46
+	/**
47
+	 * Get the rendering callback for a given URI.
48
+	 *
49
+	 * @since 0.1.0
50
+	 *
51
+	 * @param string $uri     URI to render.
52
+	 * @param array  $context Context in which to render.
53
+	 *
54
+	 * @return callable Rendering callback.
55
+	 * @throws FailedToLoadView If the View URI is not accessible or readable.
56
+	 * @throws FailedToLoadView If the View URI could not be loaded.
57
+	 */
58
+	public function getRenderCallback($uri, array $context = [])
59
+	{
60
+		if ( ! is_readable($uri)) {
61
+			throw new FailedToLoadView(
62
+				sprintf(
63
+					_('The View URI "%1$s" is not accessible or readable.'),
64
+					$uri
65
+				)
66
+			);
67
+		}
68 68
 
69
-        $closure = function () use ($uri, $context) {
69
+		$closure = function () use ($uri, $context) {
70 70
 
71
-            // Save current buffering level so we can backtrack in case of an error.
72
-            // This is needed because the view itself might also add an unknown number of output buffering levels.
73
-            $bufferLevel = ob_get_level();
74
-            ob_start();
71
+			// Save current buffering level so we can backtrack in case of an error.
72
+			// This is needed because the view itself might also add an unknown number of output buffering levels.
73
+			$bufferLevel = ob_get_level();
74
+			ob_start();
75 75
 
76
-            try {
77
-                include($uri);
78
-            } catch (Exception $exception) {
76
+			try {
77
+				include($uri);
78
+			} catch (Exception $exception) {
79 79
 
80
-                // Remove whatever levels were added up until now.
81
-                while (ob_get_level() > $bufferLevel) {
82
-                    ob_end_clean();
83
-                }
80
+				// Remove whatever levels were added up until now.
81
+				while (ob_get_level() > $bufferLevel) {
82
+					ob_end_clean();
83
+				}
84 84
 
85
-                throw new FailedToLoadView(
86
-                    sprintf(
87
-                        _('Could not load the View URI "%1$s". Reason: "%2$s".'),
88
-                        $uri,
89
-                        $exception->getMessage()
90
-                    ),
91
-                    $exception->getCode(),
92
-                    $exception
93
-                );
94
-            }
85
+				throw new FailedToLoadView(
86
+					sprintf(
87
+						_('Could not load the View URI "%1$s". Reason: "%2$s".'),
88
+						$uri,
89
+						$exception->getMessage()
90
+					),
91
+					$exception->getCode(),
92
+					$exception
93
+				);
94
+			}
95 95
 
96
-            return ob_get_clean();
97
-        };
96
+			return ob_get_clean();
97
+		};
98 98
 
99
-        return $closure;
100
-    }
99
+		return $closure;
100
+	}
101 101
 }
Please login to merge, or discard this patch.
src/View/Engine/NullEngine.php 1 patch
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -24,32 +24,32 @@
 block discarded – undo
24 24
 class NullEngine implements Engine, NullFindable
25 25
 {
26 26
 
27
-    /**
28
-     * Check whether the Findable can handle an individual criterion.
29
-     *
30
-     * @since 0.1.0
31
-     *
32
-     * @param mixed $criterion Criterion to check.
33
-     *
34
-     * @return bool Whether the Findable can handle the criterion.
35
-     */
36
-    public function canHandle($criterion)
37
-    {
38
-        return true;
39
-    }
27
+	/**
28
+	 * Check whether the Findable can handle an individual criterion.
29
+	 *
30
+	 * @since 0.1.0
31
+	 *
32
+	 * @param mixed $criterion Criterion to check.
33
+	 *
34
+	 * @return bool Whether the Findable can handle the criterion.
35
+	 */
36
+	public function canHandle($criterion)
37
+	{
38
+		return true;
39
+	}
40 40
 
41
-    /**
42
-     * Get the rendering callback for a given URI.
43
-     *
44
-     * @since 0.1.0
45
-     *
46
-     * @param string $uri     URI to render.
47
-     * @param array  $context Context in which to render.
48
-     *
49
-     * @return string Rendered HTML.
50
-     */
51
-    public function getRenderCallback($uri, array $context = [])
52
-    {
53
-        return '';
54
-    }
41
+	/**
42
+	 * Get the rendering callback for a given URI.
43
+	 *
44
+	 * @since 0.1.0
45
+	 *
46
+	 * @param string $uri     URI to render.
47
+	 * @param array  $context Context in which to render.
48
+	 *
49
+	 * @return string Rendered HTML.
50
+	 */
51
+	public function getRenderCallback($uri, array $context = [])
52
+	{
53
+		return '';
54
+	}
55 55
 }
Please login to merge, or discard this patch.
src/View/View/AbstractView.php 1 patch
Indentation   +134 added lines, -134 removed lines patch added patch discarded remove patch
@@ -28,138 +28,138 @@
 block discarded – undo
28 28
 abstract class AbstractView implements View
29 29
 {
30 30
 
31
-    /**
32
-     * URI of the view.
33
-     *
34
-     * @since 0.1.0
35
-     *
36
-     * @var string
37
-     */
38
-    protected $uri;
39
-
40
-    /**
41
-     * Engine to use for the view.
42
-     *
43
-     * @since 0.1.0
44
-     *
45
-     * @var Engine
46
-     */
47
-    protected $engine;
48
-
49
-    /**
50
-     * ViewBuilder instance.
51
-     *
52
-     * @since 0.2.0
53
-     *
54
-     * @var ViewBuilder
55
-     */
56
-    protected $builder;
57
-
58
-    /**
59
-     * Instantiate an AbstractView object.
60
-     *
61
-     * @since 0.1.0
62
-     *
63
-     * @param string $uri    URI for the view.
64
-     * @param Engine $engine Engine to use for the view.
65
-     */
66
-    public function __construct($uri, Engine $engine)
67
-    {
68
-        $this->uri    = $uri;
69
-        $this->engine = $engine;
70
-    }
71
-
72
-    /**
73
-     * Render the view.
74
-     *
75
-     * @since 0.1.0
76
-     *
77
-     * @param array $context Optional. The context in which to render the view.
78
-     * @param bool  $echo    Optional. Whether to echo the output immediately. Defaults to false.
79
-     *
80
-     * @return string|void Rendered HTML or nothing, depending on $echo argument.
81
-     */
82
-    public function render(array $context = [], $echo = false)
83
-    {
84
-        $this->initializeViewBuilder();
85
-        $this->assimilateContext($context);
86
-
87
-        $closure = Closure::bind(
88
-            $this->engine->getRenderCallback($this->uri, $context),
89
-            $this,
90
-            static::class
91
-        );
92
-
93
-        if ( ! $echo) {
94
-            return $closure();
95
-        }
96
-
97
-        echo $closure();
98
-    }
99
-
100
-    /**
101
-     * Render a partial view for a given URI.
102
-     *
103
-     * @since 0.2.0
104
-     *
105
-     * @param string      $view    View identifier to create a view for.
106
-     * @param array       $context Optional. The context in which to render the view.
107
-     * @param string|null $type    Type of view to create.
108
-     *
109
-     * @return string Rendered HTML content.
110
-     */
111
-    public function renderPart($view, array $context = null, $type = null)
112
-    {
113
-        if (null === $context) {
114
-            $context = $this->context;
115
-        }
116
-
117
-        $this->initializeViewBuilder();
118
-        $viewObject = $this->builder->create($view, $type);
119
-
120
-        return $viewObject->render($context);
121
-    }
122
-
123
-    /**
124
-     * Associate a view builder with this view.
125
-     *
126
-     * @since 0.2.0
127
-     *
128
-     * @param ViewBuilder $builder
129
-     *
130
-     * @return static
131
-     */
132
-    public function setBuilder(ViewBuilder $builder)
133
-    {
134
-        $this->builder = $builder;
135
-
136
-        return $this;
137
-    }
138
-
139
-    /**
140
-     * Initialize the view builder associated with the view.
141
-     *
142
-     * @since 0.2.0
143
-     */
144
-    protected function initializeViewBuilder()
145
-    {
146
-        if (null === $this->builder) {
147
-            $this->builder = Views::getViewBuilder();
148
-        }
149
-    }
150
-
151
-    /**
152
-     * Assimilate the context to make it available as properties.
153
-     *
154
-     * @since 0.2.0
155
-     *
156
-     * @param array $context Context to assimilate.
157
-     */
158
-    protected function assimilateContext(array $context = [])
159
-    {
160
-        $this->context = $context;
161
-        foreach ($context as $key => $value) {
162
-            $this->$key = $value;
163
-        }
164
-    }
31
+	/**
32
+	 * URI of the view.
33
+	 *
34
+	 * @since 0.1.0
35
+	 *
36
+	 * @var string
37
+	 */
38
+	protected $uri;
39
+
40
+	/**
41
+	 * Engine to use for the view.
42
+	 *
43
+	 * @since 0.1.0
44
+	 *
45
+	 * @var Engine
46
+	 */
47
+	protected $engine;
48
+
49
+	/**
50
+	 * ViewBuilder instance.
51
+	 *
52
+	 * @since 0.2.0
53
+	 *
54
+	 * @var ViewBuilder
55
+	 */
56
+	protected $builder;
57
+
58
+	/**
59
+	 * Instantiate an AbstractView object.
60
+	 *
61
+	 * @since 0.1.0
62
+	 *
63
+	 * @param string $uri    URI for the view.
64
+	 * @param Engine $engine Engine to use for the view.
65
+	 */
66
+	public function __construct($uri, Engine $engine)
67
+	{
68
+		$this->uri    = $uri;
69
+		$this->engine = $engine;
70
+	}
71
+
72
+	/**
73
+	 * Render the view.
74
+	 *
75
+	 * @since 0.1.0
76
+	 *
77
+	 * @param array $context Optional. The context in which to render the view.
78
+	 * @param bool  $echo    Optional. Whether to echo the output immediately. Defaults to false.
79
+	 *
80
+	 * @return string|void Rendered HTML or nothing, depending on $echo argument.
81
+	 */
82
+	public function render(array $context = [], $echo = false)
83
+	{
84
+		$this->initializeViewBuilder();
85
+		$this->assimilateContext($context);
86
+
87
+		$closure = Closure::bind(
88
+			$this->engine->getRenderCallback($this->uri, $context),
89
+			$this,
90
+			static::class
91
+		);
92
+
93
+		if ( ! $echo) {
94
+			return $closure();
95
+		}
96
+
97
+		echo $closure();
98
+	}
99
+
100
+	/**
101
+	 * Render a partial view for a given URI.
102
+	 *
103
+	 * @since 0.2.0
104
+	 *
105
+	 * @param string      $view    View identifier to create a view for.
106
+	 * @param array       $context Optional. The context in which to render the view.
107
+	 * @param string|null $type    Type of view to create.
108
+	 *
109
+	 * @return string Rendered HTML content.
110
+	 */
111
+	public function renderPart($view, array $context = null, $type = null)
112
+	{
113
+		if (null === $context) {
114
+			$context = $this->context;
115
+		}
116
+
117
+		$this->initializeViewBuilder();
118
+		$viewObject = $this->builder->create($view, $type);
119
+
120
+		return $viewObject->render($context);
121
+	}
122
+
123
+	/**
124
+	 * Associate a view builder with this view.
125
+	 *
126
+	 * @since 0.2.0
127
+	 *
128
+	 * @param ViewBuilder $builder
129
+	 *
130
+	 * @return static
131
+	 */
132
+	public function setBuilder(ViewBuilder $builder)
133
+	{
134
+		$this->builder = $builder;
135
+
136
+		return $this;
137
+	}
138
+
139
+	/**
140
+	 * Initialize the view builder associated with the view.
141
+	 *
142
+	 * @since 0.2.0
143
+	 */
144
+	protected function initializeViewBuilder()
145
+	{
146
+		if (null === $this->builder) {
147
+			$this->builder = Views::getViewBuilder();
148
+		}
149
+	}
150
+
151
+	/**
152
+	 * Assimilate the context to make it available as properties.
153
+	 *
154
+	 * @since 0.2.0
155
+	 *
156
+	 * @param array $context Context to assimilate.
157
+	 */
158
+	protected function assimilateContext(array $context = [])
159
+	{
160
+		$this->context = $context;
161
+		foreach ($context as $key => $value) {
162
+			$this->$key = $value;
163
+		}
164
+	}
165 165
 }
Please login to merge, or discard this patch.
src/View/View/NullView.php 1 patch
Indentation   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -26,64 +26,64 @@
 block discarded – undo
26 26
 class NullView implements View, NullFindable
27 27
 {
28 28
 
29
-    /**
30
-     * Check whether the Findable can handle an individual criterion.
31
-     *
32
-     * @since 0.1.0
33
-     *
34
-     * @param mixed $criterion Criterion to check.
35
-     *
36
-     * @return bool Whether the Findable can handle the criterion.
37
-     */
38
-    public function canHandle($criterion)
39
-    {
40
-        return true;
41
-    }
29
+	/**
30
+	 * Check whether the Findable can handle an individual criterion.
31
+	 *
32
+	 * @since 0.1.0
33
+	 *
34
+	 * @param mixed $criterion Criterion to check.
35
+	 *
36
+	 * @return bool Whether the Findable can handle the criterion.
37
+	 */
38
+	public function canHandle($criterion)
39
+	{
40
+		return true;
41
+	}
42 42
 
43
-    /**
44
-     * Render the view.
45
-     *
46
-     * @since 0.1.0
47
-     *
48
-     * @param array $context Optional. The context in which to render the view.
49
-     * @param bool  $echo    Optional. Whether to echo the output immediately. Defaults to false.
50
-     *
51
-     * @return string|void Rendered HTML or nothing, depending on $echo argument.
52
-     */
53
-    public function render(array $context = [], $echo = false)
54
-    {
55
-        if ( ! $echo) {
56
-            return '';
57
-        }
58
-    }
43
+	/**
44
+	 * Render the view.
45
+	 *
46
+	 * @since 0.1.0
47
+	 *
48
+	 * @param array $context Optional. The context in which to render the view.
49
+	 * @param bool  $echo    Optional. Whether to echo the output immediately. Defaults to false.
50
+	 *
51
+	 * @return string|void Rendered HTML or nothing, depending on $echo argument.
52
+	 */
53
+	public function render(array $context = [], $echo = false)
54
+	{
55
+		if ( ! $echo) {
56
+			return '';
57
+		}
58
+	}
59 59
 
60
-    /**
61
-     * Render a partial view for a given URI.
62
-     *
63
-     * @since 0.2.0
64
-     *
65
-     * @param string      $view    View identifier to create a view for.
66
-     * @param array       $context Optional. The context in which to render the view.
67
-     * @param string|null $type    Type of view to create.
68
-     *
69
-     * @return string Rendered HTML content.
70
-     */
71
-    public function renderPart($view, array $context = [], $type = null)
72
-    {
73
-        return '';
74
-    }
60
+	/**
61
+	 * Render a partial view for a given URI.
62
+	 *
63
+	 * @since 0.2.0
64
+	 *
65
+	 * @param string      $view    View identifier to create a view for.
66
+	 * @param array       $context Optional. The context in which to render the view.
67
+	 * @param string|null $type    Type of view to create.
68
+	 *
69
+	 * @return string Rendered HTML content.
70
+	 */
71
+	public function renderPart($view, array $context = [], $type = null)
72
+	{
73
+		return '';
74
+	}
75 75
 
76
-    /**
77
-     * Associate a view builder with this view.
78
-     *
79
-     * @since 0.2.0
80
-     *
81
-     * @param ViewBuilder $builder
82
-     *
83
-     * @return static
84
-     */
85
-    public function setBuilder(ViewBuilder $builder)
86
-    {
87
-        return $this;
88
-    }
76
+	/**
77
+	 * Associate a view builder with this view.
78
+	 *
79
+	 * @since 0.2.0
80
+	 *
81
+	 * @param ViewBuilder $builder
82
+	 *
83
+	 * @return static
84
+	 */
85
+	public function setBuilder(ViewBuilder $builder)
86
+	{
87
+		return $this;
88
+	}
89 89
 }
Please login to merge, or discard this patch.
src/View/View/ViewFinder.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 ViewFinder extends Finder
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 Engine|null $engine   Optional. Engine to use with the view.
35
-     *
36
-     * @return View View that was found.
37
-     */
38
-    public function find(array $criteria, Engine $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 Engine|null $engine   Optional. Engine to use with the view.
35
+	 *
36
+	 * @return View View that was found.
37
+	 */
38
+	public function find(array $criteria, Engine $engine = null);
39 39
 }
Please login to merge, or discard this patch.
src/View/View/BaseViewFinder.php 1 patch
Indentation   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -26,42 +26,42 @@
 block discarded – undo
26 26
 class BaseViewFinder extends AbstractFinder
27 27
 {
28 28
 
29
-    /**
30
-     * Find a result based on a specific criteria.
31
-     *
32
-     * @since 0.1.0
33
-     *
34
-     * @param array       $criteria Criteria to search for.
35
-     * @param Engine|null $engine   Optional. Engine to use with the view.
36
-     *
37
-     * @return View View that was found.
38
-     */
39
-    public function find(array $criteria, Engine $engine = null)
40
-    {
41
-        $uri = $criteria[0];
29
+	/**
30
+	 * Find a result based on a specific criteria.
31
+	 *
32
+	 * @since 0.1.0
33
+	 *
34
+	 * @param array       $criteria Criteria to search for.
35
+	 * @param Engine|null $engine   Optional. Engine to use with the view.
36
+	 *
37
+	 * @return View View that was found.
38
+	 */
39
+	public function find(array $criteria, Engine $engine = null)
40
+	{
41
+		$uri = $criteria[0];
42 42
 
43
-        $this->initializeFindables([$uri, $engine]);
43
+		$this->initializeFindables([$uri, $engine]);
44 44
 
45
-        foreach ($criteria as $entry) {
46
-            foreach ($this->findables as $viewObject) {
47
-                if ($viewObject->canHandle($entry)) {
48
-                    return $viewObject;
49
-                }
50
-            }
51
-        }
45
+		foreach ($criteria as $entry) {
46
+			foreach ($this->findables as $viewObject) {
47
+				if ($viewObject->canHandle($entry)) {
48
+					return $viewObject;
49
+				}
50
+			}
51
+		}
52 52
 
53
-        return $this->getNullObject();
54
-    }
53
+		return $this->getNullObject();
54
+	}
55 55
 
56
-    /**
57
-     * Get the config key for the Findables definitions.
58
-     *
59
-     * @since 0.1.0
60
-     *
61
-     * @return string Config key use to define the Findables.
62
-     */
63
-    protected function getFindablesConfigKey()
64
-    {
65
-        return 'Views';
66
-    }
56
+	/**
57
+	 * Get the config key for the Findables definitions.
58
+	 *
59
+	 * @since 0.1.0
60
+	 *
61
+	 * @return string Config key use to define the Findables.
62
+	 */
63
+	protected function getFindablesConfigKey()
64
+	{
65
+		return 'Views';
66
+	}
67 67
 }
Please login to merge, or discard this patch.
src/View/Support/AbstractFinder.php 1 patch
Indentation   +205 added lines, -205 removed lines patch added patch discarded remove patch
@@ -27,209 +27,209 @@
 block discarded – undo
27 27
 abstract class AbstractFinder implements Finder
28 28
 {
29 29
 
30
-    use ConfigTrait;
31
-
32
-    /**
33
-     * Findable collection that the Finder can iterate through to find a match.
34
-     *
35
-     * @since 0.1.0
36
-     *
37
-     * @var Findables
38
-     */
39
-    protected $findables;
40
-
41
-    /**
42
-     * NullObject that is returned if the Finder could not find a match.
43
-     *
44
-     * @since 0.1.0
45
-     *
46
-     * @var NullFindable
47
-     */
48
-    protected $nullObject;
49
-
50
-    /**
51
-     * Instantiate an AbstractFinder object.
52
-     *
53
-     * @since 0.1.0
54
-     *
55
-     * @param ConfigInterface $config Configuration of the AbstractFinder.
56
-     *
57
-     * @throws FailedToProcessConfigException If the config could not be processed.
58
-     */
59
-    public function __construct(ConfigInterface $config)
60
-    {
61
-        $this->processConfig($config);
62
-        $this->findables = new Findables();
63
-        $this->registerFindables($this->config);
64
-        $this->registerNullObject($this->config);
65
-    }
66
-
67
-    /**
68
-     * Register the Findables defined in the given configuration.
69
-     *
70
-     * @since 0.1.0
71
-     *
72
-     * @param ConfigInterface $config Configuration to register the Findables from.
73
-     */
74
-    public function registerFindables(ConfigInterface $config)
75
-    {
76
-        foreach ($config->getKey($this->getFindablesConfigKey()) as $findableKey => $findableObject) {
77
-            $this->findables->set($findableKey, $findableObject);
78
-        }
79
-    }
80
-
81
-    /**
82
-     * Register the NullObject defined in the given configuration.
83
-     *
84
-     * @since 0.1.0
85
-     *
86
-     * @param ConfigInterface $config Configuration to register the NullObject from.
87
-     */
88
-    public function registerNullObject(ConfigInterface $config)
89
-    {
90
-        $this->nullObject = $config->getKey($this->getNullObjectConfigKey());
91
-    }
92
-
93
-    /**
94
-     * Get the NullObject.
95
-     *
96
-     * @since 0.1.1
97
-     *
98
-     * @return NullFindable NullObject for the current Finder.
99
-     */
100
-    public function getNullObject()
101
-    {
102
-        $this->initializeNullObject();
103
-
104
-        return $this->nullObject;
105
-    }
106
-
107
-    /**
108
-     * Get the config key for the Findables definitions.
109
-     *
110
-     * @since 0.1.0
111
-     *
112
-     * @return string Config key use to define the Findables.
113
-     */
114
-    protected function getFindablesConfigKey()
115
-    {
116
-        return 'Findables';
117
-    }
118
-
119
-    /**
120
-     * Get the config key for the NullObject definitions.
121
-     *
122
-     * @since 0.1.0
123
-     *
124
-     * @return string Config key use to define the NullObject.
125
-     */
126
-    protected function getNullObjectConfigKey()
127
-    {
128
-        return 'NullObject';
129
-    }
130
-
131
-    /**
132
-     * Initialize the NullObject.
133
-     *
134
-     * @since 0.1.1
135
-     *
136
-     * @param mixed $arguments Optional. Arguments to use.
137
-     */
138
-    protected function initializeNullObject($arguments = null)
139
-    {
140
-        $this->nullObject = $this->maybeInstantiateFindable($this->nullObject, $arguments);
141
-    }
142
-
143
-    /**
144
-     * Initialize the Findables that can be iterated.
145
-     *
146
-     * @param mixed $arguments Optional. Arguments to use.
147
-     *
148
-     * @since 0.1.0
149
-     *
150
-     */
151
-    protected function initializeFindables($arguments = null)
152
-    {
153
-        $this->findables = $this->findables->map(function ($findable) use ($arguments) {
154
-            return $this->initializeFindable($findable, $arguments);
155
-        });
156
-    }
157
-
158
-    /**
159
-     * Initialize a single findable by instantiating class name strings and calling closures.
160
-     *
161
-     * @since 0.1.0
162
-     *
163
-     * @param mixed $findable  Findable to instantiate.
164
-     * @param mixed $arguments Optional. Arguments to use.
165
-     *
166
-     * @return Findable Instantiated findable.
167
-     */
168
-    protected function initializeFindable($findable, $arguments = null)
169
-    {
170
-        return $this->maybeInstantiateFindable($findable, $arguments);
171
-    }
172
-
173
-    /**
174
-     * Maybe instantiate a Findable if it is not yet an object.
175
-     *
176
-     * @since 0.1.1
177
-     *
178
-     * @param mixed $findable  Findable to instantiate.
179
-     * @param mixed $arguments Optional. Arguments to use.
180
-     *
181
-     * @return Findable Instantiated findable.
182
-     * @throws FailedToInstantiateFindable If the findable could not be instantiated.
183
-     */
184
-    protected function maybeInstantiateFindable($findable, $arguments = null)
185
-    {
186
-        if (is_string($findable)) {
187
-            $findable = $this->instantiateFindableFromString($findable, $arguments);
188
-        }
189
-
190
-        if (is_callable($findable)) {
191
-            $findable = $this->instantiateFindableFromCallable($findable, $arguments);
192
-        }
193
-
194
-        if ( ! $findable instanceof Findable) {
195
-            throw new FailedToInstantiateFindable(
196
-                sprintf(
197
-                    _('Could not instantiate Findable "%s".'),
198
-                    serialize($findable)
199
-                )
200
-            );
201
-        }
202
-
203
-        return $findable;
204
-    }
205
-
206
-    /**
207
-     * Instantiate a Findable from a string.
208
-     *
209
-     * @since 0.1.1
210
-     *
211
-     * @param string $string    String to use for instantiation.
212
-     * @param mixed  $arguments Optional. Arguments to use for instantiation.
213
-     *
214
-     * @return Findable Instantiated Findable.
215
-     */
216
-    protected function instantiateFindableFromString($string, $arguments = null)
217
-    {
218
-        return new $string(...$arguments);
219
-    }
220
-
221
-    /**
222
-     * Instantiate a Findable from a callable.
223
-     *
224
-     * @since 0.1.1
225
-     *
226
-     * @param callable $callable  Callable to use for instantiation.
227
-     * @param mixed    $arguments Optional. Arguments to use for instantiation.
228
-     *
229
-     * @return Findable Instantiated Findable.
230
-     */
231
-    protected function instantiateFindableFromCallable($callable, $arguments = null)
232
-    {
233
-        return $callable(...$arguments);
234
-    }
30
+	use ConfigTrait;
31
+
32
+	/**
33
+	 * Findable collection that the Finder can iterate through to find a match.
34
+	 *
35
+	 * @since 0.1.0
36
+	 *
37
+	 * @var Findables
38
+	 */
39
+	protected $findables;
40
+
41
+	/**
42
+	 * NullObject that is returned if the Finder could not find a match.
43
+	 *
44
+	 * @since 0.1.0
45
+	 *
46
+	 * @var NullFindable
47
+	 */
48
+	protected $nullObject;
49
+
50
+	/**
51
+	 * Instantiate an AbstractFinder object.
52
+	 *
53
+	 * @since 0.1.0
54
+	 *
55
+	 * @param ConfigInterface $config Configuration of the AbstractFinder.
56
+	 *
57
+	 * @throws FailedToProcessConfigException If the config could not be processed.
58
+	 */
59
+	public function __construct(ConfigInterface $config)
60
+	{
61
+		$this->processConfig($config);
62
+		$this->findables = new Findables();
63
+		$this->registerFindables($this->config);
64
+		$this->registerNullObject($this->config);
65
+	}
66
+
67
+	/**
68
+	 * Register the Findables defined in the given configuration.
69
+	 *
70
+	 * @since 0.1.0
71
+	 *
72
+	 * @param ConfigInterface $config Configuration to register the Findables from.
73
+	 */
74
+	public function registerFindables(ConfigInterface $config)
75
+	{
76
+		foreach ($config->getKey($this->getFindablesConfigKey()) as $findableKey => $findableObject) {
77
+			$this->findables->set($findableKey, $findableObject);
78
+		}
79
+	}
80
+
81
+	/**
82
+	 * Register the NullObject defined in the given configuration.
83
+	 *
84
+	 * @since 0.1.0
85
+	 *
86
+	 * @param ConfigInterface $config Configuration to register the NullObject from.
87
+	 */
88
+	public function registerNullObject(ConfigInterface $config)
89
+	{
90
+		$this->nullObject = $config->getKey($this->getNullObjectConfigKey());
91
+	}
92
+
93
+	/**
94
+	 * Get the NullObject.
95
+	 *
96
+	 * @since 0.1.1
97
+	 *
98
+	 * @return NullFindable NullObject for the current Finder.
99
+	 */
100
+	public function getNullObject()
101
+	{
102
+		$this->initializeNullObject();
103
+
104
+		return $this->nullObject;
105
+	}
106
+
107
+	/**
108
+	 * Get the config key for the Findables definitions.
109
+	 *
110
+	 * @since 0.1.0
111
+	 *
112
+	 * @return string Config key use to define the Findables.
113
+	 */
114
+	protected function getFindablesConfigKey()
115
+	{
116
+		return 'Findables';
117
+	}
118
+
119
+	/**
120
+	 * Get the config key for the NullObject definitions.
121
+	 *
122
+	 * @since 0.1.0
123
+	 *
124
+	 * @return string Config key use to define the NullObject.
125
+	 */
126
+	protected function getNullObjectConfigKey()
127
+	{
128
+		return 'NullObject';
129
+	}
130
+
131
+	/**
132
+	 * Initialize the NullObject.
133
+	 *
134
+	 * @since 0.1.1
135
+	 *
136
+	 * @param mixed $arguments Optional. Arguments to use.
137
+	 */
138
+	protected function initializeNullObject($arguments = null)
139
+	{
140
+		$this->nullObject = $this->maybeInstantiateFindable($this->nullObject, $arguments);
141
+	}
142
+
143
+	/**
144
+	 * Initialize the Findables that can be iterated.
145
+	 *
146
+	 * @param mixed $arguments Optional. Arguments to use.
147
+	 *
148
+	 * @since 0.1.0
149
+	 *
150
+	 */
151
+	protected function initializeFindables($arguments = null)
152
+	{
153
+		$this->findables = $this->findables->map(function ($findable) use ($arguments) {
154
+			return $this->initializeFindable($findable, $arguments);
155
+		});
156
+	}
157
+
158
+	/**
159
+	 * Initialize a single findable by instantiating class name strings and calling closures.
160
+	 *
161
+	 * @since 0.1.0
162
+	 *
163
+	 * @param mixed $findable  Findable to instantiate.
164
+	 * @param mixed $arguments Optional. Arguments to use.
165
+	 *
166
+	 * @return Findable Instantiated findable.
167
+	 */
168
+	protected function initializeFindable($findable, $arguments = null)
169
+	{
170
+		return $this->maybeInstantiateFindable($findable, $arguments);
171
+	}
172
+
173
+	/**
174
+	 * Maybe instantiate a Findable if it is not yet an object.
175
+	 *
176
+	 * @since 0.1.1
177
+	 *
178
+	 * @param mixed $findable  Findable to instantiate.
179
+	 * @param mixed $arguments Optional. Arguments to use.
180
+	 *
181
+	 * @return Findable Instantiated findable.
182
+	 * @throws FailedToInstantiateFindable If the findable could not be instantiated.
183
+	 */
184
+	protected function maybeInstantiateFindable($findable, $arguments = null)
185
+	{
186
+		if (is_string($findable)) {
187
+			$findable = $this->instantiateFindableFromString($findable, $arguments);
188
+		}
189
+
190
+		if (is_callable($findable)) {
191
+			$findable = $this->instantiateFindableFromCallable($findable, $arguments);
192
+		}
193
+
194
+		if ( ! $findable instanceof Findable) {
195
+			throw new FailedToInstantiateFindable(
196
+				sprintf(
197
+					_('Could not instantiate Findable "%s".'),
198
+					serialize($findable)
199
+				)
200
+			);
201
+		}
202
+
203
+		return $findable;
204
+	}
205
+
206
+	/**
207
+	 * Instantiate a Findable from a string.
208
+	 *
209
+	 * @since 0.1.1
210
+	 *
211
+	 * @param string $string    String to use for instantiation.
212
+	 * @param mixed  $arguments Optional. Arguments to use for instantiation.
213
+	 *
214
+	 * @return Findable Instantiated Findable.
215
+	 */
216
+	protected function instantiateFindableFromString($string, $arguments = null)
217
+	{
218
+		return new $string(...$arguments);
219
+	}
220
+
221
+	/**
222
+	 * Instantiate a Findable from a callable.
223
+	 *
224
+	 * @since 0.1.1
225
+	 *
226
+	 * @param callable $callable  Callable to use for instantiation.
227
+	 * @param mixed    $arguments Optional. Arguments to use for instantiation.
228
+	 *
229
+	 * @return Findable Instantiated Findable.
230
+	 */
231
+	protected function instantiateFindableFromCallable($callable, $arguments = null)
232
+	{
233
+		return $callable(...$arguments);
234
+	}
235 235
 }
Please login to merge, or discard this patch.