Passed
Push — master ( 215600...914e6e )
by Alain
02:30
created
src/View/View/ViewFinder.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@
 block discarded – undo
67 67
             $view = $view($uri, $engine);
68 68
         }
69 69
 
70
-        if (! $view instanceof ViewInterface) {
70
+        if ( ! $view instanceof ViewInterface) {
71 71
             throw new FailedToInstantiateViewException(
72 72
                 sprintf(
73 73
                     _('Could not instantiate view "%s".'),
Please login to merge, or discard this patch.
Indentation   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -26,91 +26,91 @@
 block discarded – undo
26 26
 class ViewFinder 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 EngineInterface $engine   Optional. Engine to use with the view.
36
-     *
37
-     * @return ViewInterface View that was found.
38
-     */
39
-    public function find(array $criteria, EngineInterface $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 EngineInterface $engine   Optional. Engine to use with the view.
36
+	 *
37
+	 * @return ViewInterface View that was found.
38
+	 */
39
+	public function find(array $criteria, EngineInterface $engine = null)
40
+	{
41
+		$uri = $criteria[0];
42 42
 
43
-        $this->initializeViews($uri, $engine);
43
+		$this->initializeViews($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
-     * Initialize the views that can be iterated.
58
-     *
59
-     * @since 0.1.0
60
-     *
61
-     * @param string          $uri    URI to use for the view.
62
-     * @param EngineInterface $engine Optional. Engine to use with the view.
63
-     */
64
-    protected function initializeViews($uri, EngineInterface $engine = null)
65
-    {
66
-        foreach ($this->findables as &$view) {
67
-            $view = $this->initializeView($view, $uri, $engine);
68
-        }
69
-    }
56
+	/**
57
+	 * Initialize the views that can be iterated.
58
+	 *
59
+	 * @since 0.1.0
60
+	 *
61
+	 * @param string          $uri    URI to use for the view.
62
+	 * @param EngineInterface $engine Optional. Engine to use with the view.
63
+	 */
64
+	protected function initializeViews($uri, EngineInterface $engine = null)
65
+	{
66
+		foreach ($this->findables as &$view) {
67
+			$view = $this->initializeView($view, $uri, $engine);
68
+		}
69
+	}
70 70
 
71
-    /**
72
-     * Initialize a single view by instantiating class name strings and calling closures.
73
-     *
74
-     * @since 0.1.0
75
-     *
76
-     * @param mixed           $view   View to instantiate.
77
-     * @param string          $uri    URI to use for the view.
78
-     * @param EngineInterface $engine Optional. Engine to use with the view.
79
-     *
80
-     * @return ViewInterface Instantiated view.
81
-     * @throws FailedToInstantiateViewException If the view could not be instantiated.
82
-     */
83
-    protected function initializeView($view, $uri, EngineInterface $engine = null)
84
-    {
85
-        if (is_string($view)) {
86
-            $view = new $view($uri, $engine);
87
-        }
71
+	/**
72
+	 * Initialize a single view by instantiating class name strings and calling closures.
73
+	 *
74
+	 * @since 0.1.0
75
+	 *
76
+	 * @param mixed           $view   View to instantiate.
77
+	 * @param string          $uri    URI to use for the view.
78
+	 * @param EngineInterface $engine Optional. Engine to use with the view.
79
+	 *
80
+	 * @return ViewInterface Instantiated view.
81
+	 * @throws FailedToInstantiateViewException If the view could not be instantiated.
82
+	 */
83
+	protected function initializeView($view, $uri, EngineInterface $engine = null)
84
+	{
85
+		if (is_string($view)) {
86
+			$view = new $view($uri, $engine);
87
+		}
88 88
 
89
-        if (is_callable($view)) {
90
-            $view = $view($uri, $engine);
91
-        }
89
+		if (is_callable($view)) {
90
+			$view = $view($uri, $engine);
91
+		}
92 92
 
93
-        if (! $view instanceof ViewInterface) {
94
-            throw new FailedToInstantiateViewException(
95
-                sprintf(
96
-                    _('Could not instantiate view "%s".'),
97
-                    serialize($view)
98
-                )
99
-            );
100
-        }
93
+		if (! $view instanceof ViewInterface) {
94
+			throw new FailedToInstantiateViewException(
95
+				sprintf(
96
+					_('Could not instantiate view "%s".'),
97
+					serialize($view)
98
+				)
99
+			);
100
+		}
101 101
 
102
-        return $view;
103
-    }
102
+		return $view;
103
+	}
104 104
 
105
-    /**
106
-     * Get the config key for the Findables definitions.
107
-     *
108
-     * @since 0.1.0
109
-     *
110
-     * @return string Config key use to define the Findables.
111
-     */
112
-    protected function getFindablesConfigKey()
113
-    {
114
-        return 'Views';
115
-    }
105
+	/**
106
+	 * Get the config key for the Findables definitions.
107
+	 *
108
+	 * @since 0.1.0
109
+	 *
110
+	 * @return string Config key use to define the Findables.
111
+	 */
112
+	protected function getFindablesConfigKey()
113
+	{
114
+		return 'Views';
115
+	}
116 116
 }
Please login to merge, or discard this patch.
src/View/Engine/EngineFinder.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -85,7 +85,7 @@
 block discarded – undo
85 85
             $engine = $engine();
86 86
         }
87 87
 
88
-        if (! $engine instanceof EngineInterface) {
88
+        if ( ! $engine instanceof EngineInterface) {
89 89
             throw new FailedToInstantiateEngineException(
90 90
                 sprintf(
91 91
                     _('Could not instantiate engine "%s".'),
Please login to merge, or discard this patch.
Indentation   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -25,84 +25,84 @@
 block discarded – undo
25 25
 class EngineFinder extends AbstractFinder
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
-     *
35
-     * @return EngineInterface Result of the search.
36
-     */
37
-    public function find(array $criteria)
38
-    {
39
-        $this->initializeEngines();
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
+	 *
35
+	 * @return EngineInterface Result of the search.
36
+	 */
37
+	public function find(array $criteria)
38
+	{
39
+		$this->initializeEngines();
40 40
 
41
-        foreach ($criteria as $entry) {
42
-            foreach ($this->findables as $engine) {
43
-                if ($engine->canHandle($entry)) {
44
-                    return $engine;
45
-                }
46
-            }
47
-        }
41
+		foreach ($criteria as $entry) {
42
+			foreach ($this->findables as $engine) {
43
+				if ($engine->canHandle($entry)) {
44
+					return $engine;
45
+				}
46
+			}
47
+		}
48 48
 
49
-        return $this->getNullObject();
50
-    }
49
+		return $this->getNullObject();
50
+	}
51 51
 
52
-    /**
53
-     * Initialize the engines that can be iterated.
54
-     *
55
-     * @since 0.1.0
56
-     *
57
-     */
58
-    protected function initializeEngines()
59
-    {
60
-        foreach ($this->findables as &$engine) {
61
-            $engine = $this->initializeEngine($engine);
62
-        }
63
-    }
52
+	/**
53
+	 * Initialize the engines that can be iterated.
54
+	 *
55
+	 * @since 0.1.0
56
+	 *
57
+	 */
58
+	protected function initializeEngines()
59
+	{
60
+		foreach ($this->findables as &$engine) {
61
+			$engine = $this->initializeEngine($engine);
62
+		}
63
+	}
64 64
 
65
-    /**
66
-     * Initialize a single engine by instantiating class name strings and calling closures.
67
-     *
68
-     * @since 0.1.0
69
-     *
70
-     * @param mixed $engine Engine to instantiate.
71
-     *
72
-     * @return EngineInterface Instantiated engine.
73
-     * @throws FailedToInstantiateEngineException If the engine could not be instantiated.
74
-     */
75
-    protected function initializeEngine($engine)
76
-    {
77
-        if (is_string($engine)) {
78
-            $engine = new $engine();
79
-        }
65
+	/**
66
+	 * Initialize a single engine by instantiating class name strings and calling closures.
67
+	 *
68
+	 * @since 0.1.0
69
+	 *
70
+	 * @param mixed $engine Engine to instantiate.
71
+	 *
72
+	 * @return EngineInterface Instantiated engine.
73
+	 * @throws FailedToInstantiateEngineException If the engine could not be instantiated.
74
+	 */
75
+	protected function initializeEngine($engine)
76
+	{
77
+		if (is_string($engine)) {
78
+			$engine = new $engine();
79
+		}
80 80
 
81
-        if (is_callable($engine)) {
82
-            $engine = $engine();
83
-        }
81
+		if (is_callable($engine)) {
82
+			$engine = $engine();
83
+		}
84 84
 
85
-        if (! $engine instanceof EngineInterface) {
86
-            throw new FailedToInstantiateEngineException(
87
-                sprintf(
88
-                    _('Could not instantiate engine "%s".'),
89
-                    serialize($engine)
90
-                )
91
-            );
92
-        }
85
+		if (! $engine instanceof EngineInterface) {
86
+			throw new FailedToInstantiateEngineException(
87
+				sprintf(
88
+					_('Could not instantiate engine "%s".'),
89
+					serialize($engine)
90
+				)
91
+			);
92
+		}
93 93
 
94
-        return $engine;
95
-    }
94
+		return $engine;
95
+	}
96 96
 
97
-    /**
98
-     * Get the config key for the Findables definitions.
99
-     *
100
-     * @since 0.1.0
101
-     *
102
-     * @return string Config key use to define the Findables.
103
-     */
104
-    protected function getFindablesConfigKey()
105
-    {
106
-        return 'Engines';
107
-    }
97
+	/**
98
+	 * Get the config key for the Findables definitions.
99
+	 *
100
+	 * @since 0.1.0
101
+	 *
102
+	 * @return string Config key use to define the Findables.
103
+	 */
104
+	protected function getFindablesConfigKey()
105
+	{
106
+		return 'Engines';
107
+	}
108 108
 }
Please login to merge, or discard this patch.
src/View/Support/FinderInterface.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -22,23 +22,23 @@
 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
 
36
-    /**
37
-     * Get the NullObject.
38
-     *
39
-     * @since 0.1.1
40
-     *
41
-     * @return NullObject NullObject for the current Finder.
42
-     */
43
-    public function getNullObject();
36
+	/**
37
+	 * Get the NullObject.
38
+	 *
39
+	 * @since 0.1.1
40
+	 *
41
+	 * @return NullObject NullObject for the current Finder.
42
+	 */
43
+	public function getNullObject();
44 44
 }
Please login to merge, or discard this patch.
src/View/Support/AbstractFinder.php 2 patches
Indentation   +113 added lines, -113 removed lines patch added patch discarded remove patch
@@ -26,128 +26,128 @@
 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
-     * Get the NullObject.
93
-     *
94
-     * @since 0.1.1
95
-     *
96
-     * @return NullObject NullObject for the current Finder.
97
-     */
98
-    public function getNullObject()
99
-    {
100
-        $this->initializeNullObject();
91
+	/**
92
+	 * Get the NullObject.
93
+	 *
94
+	 * @since 0.1.1
95
+	 *
96
+	 * @return NullObject NullObject for the current Finder.
97
+	 */
98
+	public function getNullObject()
99
+	{
100
+		$this->initializeNullObject();
101 101
 
102
-        return $this->nullObject();
103
-    }
102
+		return $this->nullObject();
103
+	}
104 104
 
105
-    /**
106
-     * Register a single Findable.
107
-     *
108
-     * @since 0.1.0
109
-     *
110
-     * @param string $key      Key used to reference the Findable.
111
-     * @param mixed  $findable Findable as a FQCN, callable or object.
112
-     */
113
-    protected function registerFindable($key, $findable)
114
-    {
115
-        $this->findables[$key] = $findable;
116
-    }
105
+	/**
106
+	 * Register a single Findable.
107
+	 *
108
+	 * @since 0.1.0
109
+	 *
110
+	 * @param string $key      Key used to reference the Findable.
111
+	 * @param mixed  $findable Findable as a FQCN, callable or object.
112
+	 */
113
+	protected function registerFindable($key, $findable)
114
+	{
115
+		$this->findables[$key] = $findable;
116
+	}
117 117
 
118
-    /**
119
-     * Get the config key for the Findables definitions.
120
-     *
121
-     * @since 0.1.0
122
-     *
123
-     * @return string Config key use to define the Findables.
124
-     */
125
-    protected function getFindablesConfigKey()
126
-    {
127
-        return 'Findables';
128
-    }
118
+	/**
119
+	 * Get the config key for the Findables definitions.
120
+	 *
121
+	 * @since 0.1.0
122
+	 *
123
+	 * @return string Config key use to define the Findables.
124
+	 */
125
+	protected function getFindablesConfigKey()
126
+	{
127
+		return 'Findables';
128
+	}
129 129
 
130
-    /**
131
-     * Get the config key for the NullObject definitions.
132
-     *
133
-     * @since 0.1.0
134
-     *
135
-     * @return string Config key use to define the NullObject.
136
-     */
137
-    protected function getNullObjectConfigKey()
138
-    {
139
-        return 'NullObject';
140
-    }
130
+	/**
131
+	 * Get the config key for the NullObject definitions.
132
+	 *
133
+	 * @since 0.1.0
134
+	 *
135
+	 * @return string Config key use to define the NullObject.
136
+	 */
137
+	protected function getNullObjectConfigKey()
138
+	{
139
+		return 'NullObject';
140
+	}
141 141
 
142
-    /**
143
-     * Initialize the NullObject.
144
-     *
145
-     * @since 0.1.1
146
-     */
147
-    protected function initializeNullObject()
148
-    {
149
-        if (! is_object($this->nullObject)) {
150
-            $this->nullObject = new $this->nullObject();
151
-        }
152
-    }
142
+	/**
143
+	 * Initialize the NullObject.
144
+	 *
145
+	 * @since 0.1.1
146
+	 */
147
+	protected function initializeNullObject()
148
+	{
149
+		if (! is_object($this->nullObject)) {
150
+			$this->nullObject = new $this->nullObject();
151
+		}
152
+	}
153 153
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -146,7 +146,7 @@
 block discarded – undo
146 146
      */
147 147
     protected function initializeNullObject()
148 148
     {
149
-        if (! is_object($this->nullObject)) {
149
+        if ( ! is_object($this->nullObject)) {
150 150
             $this->nullObject = new $this->nullObject();
151 151
         }
152 152
     }
Please login to merge, or discard this patch.
src/View/Location/FilesystemLocation.php 1 patch
Indentation   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -24,86 +24,86 @@
 block discarded – undo
24 24
 class FilesystemLocation implements LocationInterface
25 25
 {
26 26
 
27
-    /**
28
-     * Path that this location points to.
29
-     *
30
-     * @since 0.1.0
31
-     *
32
-     * @var string
33
-     */
34
-    protected $path;
27
+	/**
28
+	 * Path that this location points to.
29
+	 *
30
+	 * @since 0.1.0
31
+	 *
32
+	 * @var string
33
+	 */
34
+	protected $path;
35 35
 
36
-    /**
37
-     * Extensions that this location can accept.
38
-     *
39
-     * @since 0.1.0
40
-     *
41
-     * @var array
42
-     */
43
-    protected $extensions;
36
+	/**
37
+	 * Extensions that this location can accept.
38
+	 *
39
+	 * @since 0.1.0
40
+	 *
41
+	 * @var array
42
+	 */
43
+	protected $extensions;
44 44
 
45
-    /**
46
-     * Instantiate a FilesystemLocation object.
47
-     *
48
-     * @since 0.1.0
49
-     *
50
-     * @param string $path       Path that this location points to.
51
-     * @param array  $extensions Array of extensions that this location can accept.
52
-     */
53
-    public function __construct($path, array $extensions = [])
54
-    {
55
-        $this->path       = $path;
56
-        $this->extensions = array_merge($extensions, ['']);
57
-    }
45
+	/**
46
+	 * Instantiate a FilesystemLocation object.
47
+	 *
48
+	 * @since 0.1.0
49
+	 *
50
+	 * @param string $path       Path that this location points to.
51
+	 * @param array  $extensions Array of extensions that this location can accept.
52
+	 */
53
+	public function __construct($path, array $extensions = [])
54
+	{
55
+		$this->path       = $path;
56
+		$this->extensions = array_merge($extensions, ['']);
57
+	}
58 58
 
59
-    /**
60
-     * Get an URI that matches the given criteria.
61
-     *
62
-     * @since 0.1.0
63
-     *
64
-     * @param array $criteria Criteria to match.
65
-     *
66
-     * @return string|false URI that matches the criteria or false if none found.
67
-     */
68
-    public function getURI(array $criteria)
69
-    {
70
-        foreach ($criteria as $entry) {
71
-            if ($uri = $this->transform($entry)) {
72
-                return $uri;
73
-            }
74
-        }
59
+	/**
60
+	 * Get an URI that matches the given criteria.
61
+	 *
62
+	 * @since 0.1.0
63
+	 *
64
+	 * @param array $criteria Criteria to match.
65
+	 *
66
+	 * @return string|false URI that matches the criteria or false if none found.
67
+	 */
68
+	public function getURI(array $criteria)
69
+	{
70
+		foreach ($criteria as $entry) {
71
+			if ($uri = $this->transform($entry)) {
72
+				return $uri;
73
+			}
74
+		}
75 75
 
76
-        return false;
77
-    }
76
+		return false;
77
+	}
78 78
 
79
-    /**
80
-     * Try to transform the entry into possible URIs.
81
-     *
82
-     * @since 0.1.0
83
-     *
84
-     * @param string $entry Entry to transform.
85
-     *
86
-     * @return string|bool URI of the view, or false if none found.
87
-     */
88
-    protected function transform($entry)
89
-    {
90
-        try {
91
-            foreach ($this->extensions as $extension) {
79
+	/**
80
+	 * Try to transform the entry into possible URIs.
81
+	 *
82
+	 * @since 0.1.0
83
+	 *
84
+	 * @param string $entry Entry to transform.
85
+	 *
86
+	 * @return string|bool URI of the view, or false if none found.
87
+	 */
88
+	protected function transform($entry)
89
+	{
90
+		try {
91
+			foreach ($this->extensions as $extension) {
92 92
 
93
-                $uri = $entry . $extension;
94
-                if (is_readable($uri)) {
95
-                    return $uri;
96
-                }
93
+				$uri = $entry . $extension;
94
+				if (is_readable($uri)) {
95
+					return $uri;
96
+				}
97 97
 
98
-                $uri = $this->path . DIRECTORY_SEPARATOR . $uri;
99
-                if (is_readable($uri)) {
100
-                    return $uri;
101
-                }
102
-            }
103
-        } catch (Exception $exception) {
104
-            // Fail silently.
105
-        }
98
+				$uri = $this->path . DIRECTORY_SEPARATOR . $uri;
99
+				if (is_readable($uri)) {
100
+					return $uri;
101
+				}
102
+			}
103
+		} catch (Exception $exception) {
104
+			// Fail silently.
105
+		}
106 106
 
107
-        return false;
108
-    }
107
+		return false;
108
+	}
109 109
 }
Please login to merge, or discard this patch.
src/View/ViewBuilder.php 1 patch
Indentation   +207 added lines, -207 removed lines patch added patch discarded remove patch
@@ -32,211 +32,211 @@
 block discarded – undo
32 32
 class ViewBuilder
33 33
 {
34 34
 
35
-    use ConfigTrait;
36
-
37
-    const ENGINE_FINDER_KEY = 'EngineFinder';
38
-    const VIEW_FINDER_KEY   = 'ViewFinder';
39
-
40
-    /**
41
-     * ViewFinder instance.
42
-     *
43
-     * @since 0.1.0
44
-     *
45
-     * @var ViewFinderInterface
46
-     */
47
-    protected $viewFinder;
48
-
49
-    /**
50
-     * EngineFinder instance.
51
-     *
52
-     * @since 0.1.0
53
-     *
54
-     * @var EngineFinderInterface
55
-     */
56
-    protected $engineFinder;
57
-
58
-    /**
59
-     * Locations to scan for views.
60
-     *
61
-     * @since 0.1.0
62
-     *
63
-     * @var LocationInterface[]
64
-     */
65
-    protected $locations;
66
-
67
-    /**
68
-     * Instantiate a ViewBuilder object.
69
-     *
70
-     * @since 0.1.0
71
-     *
72
-     * @param ConfigInterface            $config       Configuration settings.
73
-     * @param ViewFinderInterface|null   $viewFinder   ViewFinder instance.
74
-     * @param EngineFinderInterface|null $engineFinder EngineFinder instance.
75
-     *
76
-     * @throws FailedToProcessConfigException If the config could not be processed.
77
-     */
78
-    public function __construct(
79
-        ConfigInterface $config,
80
-        ViewFinderInterface $viewFinder = null,
81
-        EngineFinderInterface $engineFinder = null
82
-    ) {
83
-        $this->processConfig($config);
84
-        $this->viewFinder   = $viewFinder;
85
-        $this->engineFinder = $engineFinder;
86
-    }
87
-
88
-    /**
89
-     * Create a new view for a given URI.
90
-     *
91
-     * @since 0.1.0
92
-     *
93
-     * @param string      $view View identifier to create a view for.
94
-     * @param string|null $type Type of view to create.
95
-     *
96
-     * @return ViewInterface Instance of the requested view.
97
-     */
98
-    public function create($view, $type = null)
99
-    {
100
-        $uri    = $this->scanLocations([$view]);
101
-        $engine = $this->getEngine($uri);
102
-
103
-        return $uri
104
-            ? $this->getView($uri, $engine, $type)
105
-            : $this->getViewFinder()->getNullObject();
106
-    }
107
-
108
-    /**
109
-     * Get an Engine that can deal with the given URI.
110
-     *
111
-     * @since 0.1.0
112
-     *
113
-     * @param string|false $uri URI to get an engine for.
114
-     *
115
-     * @return EngineInterface Instance of an engine that can deal with the given URI.
116
-     */
117
-    public function getEngine($uri)
118
-    {
119
-        return $this->getEngineFinder()->find([$uri]);
120
-    }
121
-
122
-    /**
123
-     * Get a view for a given URI, engine and type.
124
-     *
125
-     * @since 0.1.0
126
-     *
127
-     * @param string          $uri    URI to get a view for.
128
-     * @param EngineInterface $engine Engine to use for the view.
129
-     * @param mixed           $type   Type of view to get.
130
-     *
131
-     * @return ViewInterface View that matches the given requirements.
132
-     */
133
-    public function getView($uri, EngineInterface $engine, $type = null)
134
-    {
135
-        if (null === $type) {
136
-            return $this->getViewFinder()->find([$uri], $engine);
137
-        }
138
-
139
-        return $this->resolveType($type, $uri, $engine);
140
-    }
141
-
142
-    /**
143
-     * Get the ViewFinder instance.
144
-     *
145
-     * @since 0.1.0
146
-     *
147
-     * @return ViewFinderInterface Instance of a ViewFinder.
148
-     */
149
-    public function getViewFinder()
150
-    {
151
-        if (null === $this->viewFinder) {
152
-            $viewFinderClass  = $this->config->getKey(static::VIEW_FINDER_KEY, 'ClassName');
153
-            $this->viewFinder = new $viewFinderClass($this->config->getSubConfig(static::VIEW_FINDER_KEY));
154
-        }
155
-
156
-        return $this->viewFinder;
157
-    }
158
-
159
-    /**
160
-     * Get the EngineFinder instance.
161
-     *
162
-     * @since 0.1.0
163
-     *
164
-     * @return EngineFinderInterface Instance of a EngineFinder.
165
-     */
166
-    public function getEngineFinder()
167
-    {
168
-        if (null === $this->engineFinder) {
169
-            $engineFinderClass  = $this->config->getKey(static::ENGINE_FINDER_KEY, 'ClassName');
170
-            $this->engineFinder = new $engineFinderClass($this->config->getSubConfig(static::ENGINE_FINDER_KEY));
171
-        }
172
-
173
-        return $this->engineFinder;
174
-    }
175
-
176
-    /**
177
-     * Add a location to scan with the ViewFinder.
178
-     *
179
-     * @since 0.1.0
180
-     *
181
-     * @param LocationInterface $location Location to scan with the ViewFinder.
182
-     */
183
-    public function addLocation(LocationInterface $location)
184
-    {
185
-        $this->locations[] = $location;
186
-    }
187
-
188
-    /**
189
-     * Scan Locations for an URI that matches the specified criteria.
190
-     *
191
-     * @since 0.1.0
192
-     *
193
-     * @param array $criteria Criteria to match.
194
-     *
195
-     * @return string|bool URI of the requested view, or false if not found.
196
-     */
197
-    public function scanLocations(array $criteria)
198
-    {
199
-        /** @var LocationInterface $location */
200
-        foreach ($this->locations as $location) {
201
-            if ($uri = $location->getURI($criteria)) {
202
-                return $uri;
203
-            }
204
-        }
205
-
206
-        return false;
207
-    }
208
-
209
-    /**
210
-     * Resolve the view type.
211
-     *
212
-     * @since 0.1.0
213
-     *
214
-     * @param mixed           $type   Type of view that was requested.
215
-     * @param string          $uri    URI to get a view for.
216
-     * @param EngineInterface $engine Engine to use for the view.
217
-     *
218
-     * @return ViewInterface Resolved View object.
219
-     * @throws FailedToInstantiateViewException If the view type could not be resolved.
220
-     */
221
-    protected function resolveType($type, $uri, EngineInterface $engine = null)
222
-    {
223
-        if (is_string($type) && $this->config->hasKey(static::VIEW_FINDER_KEY)) {
224
-            $type = new $type($uri, $engine);
225
-        }
226
-
227
-        if (is_callable($type)) {
228
-            $type = $type($uri, $engine);
229
-        }
230
-
231
-        if (! $type instanceof ViewInterface) {
232
-            throw new FailedToInstantiateViewException(
233
-                sprintf(
234
-                    _('Could not instantiate view "%s".'),
235
-                    serialize($type)
236
-                )
237
-            );
238
-        }
239
-
240
-        return $type;
241
-    }
35
+	use ConfigTrait;
36
+
37
+	const ENGINE_FINDER_KEY = 'EngineFinder';
38
+	const VIEW_FINDER_KEY   = 'ViewFinder';
39
+
40
+	/**
41
+	 * ViewFinder instance.
42
+	 *
43
+	 * @since 0.1.0
44
+	 *
45
+	 * @var ViewFinderInterface
46
+	 */
47
+	protected $viewFinder;
48
+
49
+	/**
50
+	 * EngineFinder instance.
51
+	 *
52
+	 * @since 0.1.0
53
+	 *
54
+	 * @var EngineFinderInterface
55
+	 */
56
+	protected $engineFinder;
57
+
58
+	/**
59
+	 * Locations to scan for views.
60
+	 *
61
+	 * @since 0.1.0
62
+	 *
63
+	 * @var LocationInterface[]
64
+	 */
65
+	protected $locations;
66
+
67
+	/**
68
+	 * Instantiate a ViewBuilder object.
69
+	 *
70
+	 * @since 0.1.0
71
+	 *
72
+	 * @param ConfigInterface            $config       Configuration settings.
73
+	 * @param ViewFinderInterface|null   $viewFinder   ViewFinder instance.
74
+	 * @param EngineFinderInterface|null $engineFinder EngineFinder instance.
75
+	 *
76
+	 * @throws FailedToProcessConfigException If the config could not be processed.
77
+	 */
78
+	public function __construct(
79
+		ConfigInterface $config,
80
+		ViewFinderInterface $viewFinder = null,
81
+		EngineFinderInterface $engineFinder = null
82
+	) {
83
+		$this->processConfig($config);
84
+		$this->viewFinder   = $viewFinder;
85
+		$this->engineFinder = $engineFinder;
86
+	}
87
+
88
+	/**
89
+	 * Create a new view for a given URI.
90
+	 *
91
+	 * @since 0.1.0
92
+	 *
93
+	 * @param string      $view View identifier to create a view for.
94
+	 * @param string|null $type Type of view to create.
95
+	 *
96
+	 * @return ViewInterface Instance of the requested view.
97
+	 */
98
+	public function create($view, $type = null)
99
+	{
100
+		$uri    = $this->scanLocations([$view]);
101
+		$engine = $this->getEngine($uri);
102
+
103
+		return $uri
104
+			? $this->getView($uri, $engine, $type)
105
+			: $this->getViewFinder()->getNullObject();
106
+	}
107
+
108
+	/**
109
+	 * Get an Engine that can deal with the given URI.
110
+	 *
111
+	 * @since 0.1.0
112
+	 *
113
+	 * @param string|false $uri URI to get an engine for.
114
+	 *
115
+	 * @return EngineInterface Instance of an engine that can deal with the given URI.
116
+	 */
117
+	public function getEngine($uri)
118
+	{
119
+		return $this->getEngineFinder()->find([$uri]);
120
+	}
121
+
122
+	/**
123
+	 * Get a view for a given URI, engine and type.
124
+	 *
125
+	 * @since 0.1.0
126
+	 *
127
+	 * @param string          $uri    URI to get a view for.
128
+	 * @param EngineInterface $engine Engine to use for the view.
129
+	 * @param mixed           $type   Type of view to get.
130
+	 *
131
+	 * @return ViewInterface View that matches the given requirements.
132
+	 */
133
+	public function getView($uri, EngineInterface $engine, $type = null)
134
+	{
135
+		if (null === $type) {
136
+			return $this->getViewFinder()->find([$uri], $engine);
137
+		}
138
+
139
+		return $this->resolveType($type, $uri, $engine);
140
+	}
141
+
142
+	/**
143
+	 * Get the ViewFinder instance.
144
+	 *
145
+	 * @since 0.1.0
146
+	 *
147
+	 * @return ViewFinderInterface Instance of a ViewFinder.
148
+	 */
149
+	public function getViewFinder()
150
+	{
151
+		if (null === $this->viewFinder) {
152
+			$viewFinderClass  = $this->config->getKey(static::VIEW_FINDER_KEY, 'ClassName');
153
+			$this->viewFinder = new $viewFinderClass($this->config->getSubConfig(static::VIEW_FINDER_KEY));
154
+		}
155
+
156
+		return $this->viewFinder;
157
+	}
158
+
159
+	/**
160
+	 * Get the EngineFinder instance.
161
+	 *
162
+	 * @since 0.1.0
163
+	 *
164
+	 * @return EngineFinderInterface Instance of a EngineFinder.
165
+	 */
166
+	public function getEngineFinder()
167
+	{
168
+		if (null === $this->engineFinder) {
169
+			$engineFinderClass  = $this->config->getKey(static::ENGINE_FINDER_KEY, 'ClassName');
170
+			$this->engineFinder = new $engineFinderClass($this->config->getSubConfig(static::ENGINE_FINDER_KEY));
171
+		}
172
+
173
+		return $this->engineFinder;
174
+	}
175
+
176
+	/**
177
+	 * Add a location to scan with the ViewFinder.
178
+	 *
179
+	 * @since 0.1.0
180
+	 *
181
+	 * @param LocationInterface $location Location to scan with the ViewFinder.
182
+	 */
183
+	public function addLocation(LocationInterface $location)
184
+	{
185
+		$this->locations[] = $location;
186
+	}
187
+
188
+	/**
189
+	 * Scan Locations for an URI that matches the specified criteria.
190
+	 *
191
+	 * @since 0.1.0
192
+	 *
193
+	 * @param array $criteria Criteria to match.
194
+	 *
195
+	 * @return string|bool URI of the requested view, or false if not found.
196
+	 */
197
+	public function scanLocations(array $criteria)
198
+	{
199
+		/** @var LocationInterface $location */
200
+		foreach ($this->locations as $location) {
201
+			if ($uri = $location->getURI($criteria)) {
202
+				return $uri;
203
+			}
204
+		}
205
+
206
+		return false;
207
+	}
208
+
209
+	/**
210
+	 * Resolve the view type.
211
+	 *
212
+	 * @since 0.1.0
213
+	 *
214
+	 * @param mixed           $type   Type of view that was requested.
215
+	 * @param string          $uri    URI to get a view for.
216
+	 * @param EngineInterface $engine Engine to use for the view.
217
+	 *
218
+	 * @return ViewInterface Resolved View object.
219
+	 * @throws FailedToInstantiateViewException If the view type could not be resolved.
220
+	 */
221
+	protected function resolveType($type, $uri, EngineInterface $engine = null)
222
+	{
223
+		if (is_string($type) && $this->config->hasKey(static::VIEW_FINDER_KEY)) {
224
+			$type = new $type($uri, $engine);
225
+		}
226
+
227
+		if (is_callable($type)) {
228
+			$type = $type($uri, $engine);
229
+		}
230
+
231
+		if (! $type instanceof ViewInterface) {
232
+			throw new FailedToInstantiateViewException(
233
+				sprintf(
234
+					_('Could not instantiate view "%s".'),
235
+					serialize($type)
236
+				)
237
+			);
238
+		}
239
+
240
+		return $type;
241
+	}
242 242
 }
Please login to merge, or discard this patch.