Passed
Push — master ( a263b7...6f8328 )
by Alain
02:24
created
src/SanitizerInterface.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -1,13 +1,13 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * SanitizerInterface
4
- *
5
- * @package   brightnucleus/chainmail
6
- * @author    Alain Schlesser <[email protected]>
7
- * @license   GPL-2.0+
8
- * @link      http://www.brightnucleus.com/
9
- * @copyright 2016 Alain Schlesser, Bright Nucleus
10
- */
3
+	 * SanitizerInterface
4
+	 *
5
+	 * @package   brightnucleus/chainmail
6
+	 * @author    Alain Schlesser <[email protected]>
7
+	 * @license   GPL-2.0+
8
+	 * @link      http://www.brightnucleus.com/
9
+	 * @copyright 2016 Alain Schlesser, Bright Nucleus
10
+	 */
11 11
 
12 12
 namespace BrightNucleus\ChainMail;
13 13
 
@@ -22,14 +22,14 @@  discard block
 block discarded – undo
22 22
 interface SanitizerInterface
23 23
 {
24 24
 
25
-    /**
26
-     * Sanitize content for a given context.
27
-     *
28
-     * @since 1.0.0
29
-     *
30
-     * @param string $content Content to sanitize.
31
-     * @param array  $context Context in which to sanitize.
32
-     * @return string Sanitized content.
33
-     */
34
-    public function sanitize($content, array $context);
25
+	/**
26
+	 * Sanitize content for a given context.
27
+	 *
28
+	 * @since 1.0.0
29
+	 *
30
+	 * @param string $content Content to sanitize.
31
+	 * @param array  $context Context in which to sanitize.
32
+	 * @return string Sanitized content.
33
+	 */
34
+	public function sanitize($content, array $context);
35 35
 }
36 36
\ No newline at end of file
Please login to merge, or discard this patch.
src/Section/AbstractSection.php 1 patch
Indentation   +160 added lines, -160 removed lines patch added patch discarded remove patch
@@ -1,13 +1,13 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * AbstractSection
4
- *
5
- * @package   brightnucleus/chainmail
6
- * @author    Alain Schlesser <[email protected]>
7
- * @license   GPL-2.0+
8
- * @link      http://www.brightnucleus.com/
9
- * @copyright 2016 Alain Schlesser, Bright Nucleus
10
- */
3
+	 * AbstractSection
4
+	 *
5
+	 * @package   brightnucleus/chainmail
6
+	 * @author    Alain Schlesser <[email protected]>
7
+	 * @license   GPL-2.0+
8
+	 * @link      http://www.brightnucleus.com/
9
+	 * @copyright 2016 Alain Schlesser, Bright Nucleus
10
+	 */
11 11
 
12 12
 namespace BrightNucleus\ChainMail\Section;
13 13
 
@@ -27,156 +27,156 @@  discard block
 block discarded – undo
27 27
 abstract class AbstractSection implements SectionInterface
28 28
 {
29 29
 
30
-    /**
31
-     * Name of the Section.
32
-     *
33
-     * @since 1.0.0
34
-     *
35
-     * @var string
36
-     */
37
-    protected $sectionName;
38
-
39
-    /**
40
-     * Configuration Settings.
41
-     *
42
-     * @since 1.0.0
43
-     *
44
-     * @var ConfigInterface
45
-     */
46
-    protected $config;
47
-
48
-    /**
49
-     * Content of the section.
50
-     *
51
-     * @since 1.0.0
52
-     *
53
-     * @var string
54
-     */
55
-    protected $content;
56
-
57
-    /**
58
-     * Instantiate a AbstractSection object.
59
-     *
60
-     * @since 1.0.0
61
-     *
62
-     * @param ConfigInterface $config       Configuration settings.
63
-     * @param array           $arguments    Arguments that are passed through
64
-     *                                      the constructor. Contained
65
-     *                                      elements: string $section, string
66
-     *                                      $content
67
-     * @throws RuntimeException
68
-     */
69
-    public function __construct($config, $arguments)
70
-    {
71
-        $this->config = $config;
72
-        list($section, $content) = $arguments;
73
-        $this->setSectionName($section);
74
-        $this->content = $content;
75
-    }
76
-
77
-    /**
78
-     * Set the name of the Section.
79
-     *
80
-     * @since 1.0.0
81
-     *
82
-     * @param string $section Optional. Name of the section.
83
-     * @throws RuntimeException
84
-     */
85
-    protected function setSectionName($section = null)
86
-    {
87
-        if (null === $section) {
88
-            throw new RuntimeException('Initialised section without passing it a section name.');
89
-        }
90
-        if ( ! array_key_exists($section, $this->config['sections'])) {
91
-            throw new RuntimeException('Initialised section with an unknown section name.');
92
-        }
93
-        $this->sectionName = $section;
94
-    }
95
-
96
-    /**
97
-     * Get the name of the Section.
98
-     *
99
-     * @since 1.0.0
100
-     *
101
-     * @return string Name of the section.
102
-     */
103
-    public function getSectionName()
104
-    {
105
-        return $this->sectionName;
106
-    }
107
-
108
-    /**
109
-     * Get the name of the View to use for rendering.
110
-     *
111
-     * @since 1.0.0
112
-     *
113
-     * @return string Name of the view.
114
-     */
115
-    protected function getViewName()
116
-    {
117
-        return $this->config['sections'][$this->getSectionName()]['view_name'];
118
-    }
119
-
120
-    /**
121
-     * Render the current Renderable for a given context.
122
-     *
123
-     * @since 1.0.0
124
-     *
125
-     * @param array $context The context in which to render the Renderable.
126
-     * @return string Rendered output of the Renderable.
127
-     * @throws RuntimeException
128
-     */
129
-    public function render(array $context)
130
-    {
131
-
132
-        $viewLocation = $this->getViewLocation($context);
133
-        $viewType     = $this->config['view_type'];
134
-
135
-        $viewFactory = new Factory($this->config, 'view_types');
136
-        $view        = $viewFactory->create($viewType, $viewLocation);
137
-
138
-        $context['css_class'] = $this->getCSSClass();
139
-
140
-        return $view->render($context, $this->content);
141
-    }
142
-
143
-    /**
144
-     * Get the location of the view that is used for rendering.
145
-     *
146
-     * @since 1.0.0
147
-     *
148
-     * @param array $context Context for which to get the view location.
149
-     * @return string
150
-     */
151
-    protected function getViewLocation(array $context)
152
-    {
153
-        return $this->getViewRoot() . '/sections/' . $context['format'] . '/' . $this->getViewName();
154
-    }
155
-
156
-    /**
157
-     * Get the root location of the view that is used for rendering.
158
-     *
159
-     * @since 1.0.0
160
-     *
161
-     * @return string
162
-     */
163
-    protected function getViewRoot()
164
-    {
165
-        $viewRoots   = $this->config['view_root_locations'];
166
-        $viewRootKey = $this->config['sections'][$this->getSectionName()]['view_location'];
167
-
168
-        return $viewRoots[$viewRootKey];
169
-    }
170
-
171
-    /**
172
-     * Get the CSS class that is used for the section.
173
-     *
174
-     * @since 1.0.0
175
-     *
176
-     * @return string
177
-     */
178
-    protected function getCSSClass()
179
-    {
180
-        return $this->config['sections'][$this->getSectionName()]['css_class'];
181
-    }
30
+	/**
31
+	 * Name of the Section.
32
+	 *
33
+	 * @since 1.0.0
34
+	 *
35
+	 * @var string
36
+	 */
37
+	protected $sectionName;
38
+
39
+	/**
40
+	 * Configuration Settings.
41
+	 *
42
+	 * @since 1.0.0
43
+	 *
44
+	 * @var ConfigInterface
45
+	 */
46
+	protected $config;
47
+
48
+	/**
49
+	 * Content of the section.
50
+	 *
51
+	 * @since 1.0.0
52
+	 *
53
+	 * @var string
54
+	 */
55
+	protected $content;
56
+
57
+	/**
58
+	 * Instantiate a AbstractSection object.
59
+	 *
60
+	 * @since 1.0.0
61
+	 *
62
+	 * @param ConfigInterface $config       Configuration settings.
63
+	 * @param array           $arguments    Arguments that are passed through
64
+	 *                                      the constructor. Contained
65
+	 *                                      elements: string $section, string
66
+	 *                                      $content
67
+	 * @throws RuntimeException
68
+	 */
69
+	public function __construct($config, $arguments)
70
+	{
71
+		$this->config = $config;
72
+		list($section, $content) = $arguments;
73
+		$this->setSectionName($section);
74
+		$this->content = $content;
75
+	}
76
+
77
+	/**
78
+	 * Set the name of the Section.
79
+	 *
80
+	 * @since 1.0.0
81
+	 *
82
+	 * @param string $section Optional. Name of the section.
83
+	 * @throws RuntimeException
84
+	 */
85
+	protected function setSectionName($section = null)
86
+	{
87
+		if (null === $section) {
88
+			throw new RuntimeException('Initialised section without passing it a section name.');
89
+		}
90
+		if ( ! array_key_exists($section, $this->config['sections'])) {
91
+			throw new RuntimeException('Initialised section with an unknown section name.');
92
+		}
93
+		$this->sectionName = $section;
94
+	}
95
+
96
+	/**
97
+	 * Get the name of the Section.
98
+	 *
99
+	 * @since 1.0.0
100
+	 *
101
+	 * @return string Name of the section.
102
+	 */
103
+	public function getSectionName()
104
+	{
105
+		return $this->sectionName;
106
+	}
107
+
108
+	/**
109
+	 * Get the name of the View to use for rendering.
110
+	 *
111
+	 * @since 1.0.0
112
+	 *
113
+	 * @return string Name of the view.
114
+	 */
115
+	protected function getViewName()
116
+	{
117
+		return $this->config['sections'][$this->getSectionName()]['view_name'];
118
+	}
119
+
120
+	/**
121
+	 * Render the current Renderable for a given context.
122
+	 *
123
+	 * @since 1.0.0
124
+	 *
125
+	 * @param array $context The context in which to render the Renderable.
126
+	 * @return string Rendered output of the Renderable.
127
+	 * @throws RuntimeException
128
+	 */
129
+	public function render(array $context)
130
+	{
131
+
132
+		$viewLocation = $this->getViewLocation($context);
133
+		$viewType     = $this->config['view_type'];
134
+
135
+		$viewFactory = new Factory($this->config, 'view_types');
136
+		$view        = $viewFactory->create($viewType, $viewLocation);
137
+
138
+		$context['css_class'] = $this->getCSSClass();
139
+
140
+		return $view->render($context, $this->content);
141
+	}
142
+
143
+	/**
144
+	 * Get the location of the view that is used for rendering.
145
+	 *
146
+	 * @since 1.0.0
147
+	 *
148
+	 * @param array $context Context for which to get the view location.
149
+	 * @return string
150
+	 */
151
+	protected function getViewLocation(array $context)
152
+	{
153
+		return $this->getViewRoot() . '/sections/' . $context['format'] . '/' . $this->getViewName();
154
+	}
155
+
156
+	/**
157
+	 * Get the root location of the view that is used for rendering.
158
+	 *
159
+	 * @since 1.0.0
160
+	 *
161
+	 * @return string
162
+	 */
163
+	protected function getViewRoot()
164
+	{
165
+		$viewRoots   = $this->config['view_root_locations'];
166
+		$viewRootKey = $this->config['sections'][$this->getSectionName()]['view_location'];
167
+
168
+		return $viewRoots[$viewRootKey];
169
+	}
170
+
171
+	/**
172
+	 * Get the CSS class that is used for the section.
173
+	 *
174
+	 * @since 1.0.0
175
+	 *
176
+	 * @return string
177
+	 */
178
+	protected function getCSSClass()
179
+	{
180
+		return $this->config['sections'][$this->getSectionName()]['css_class'];
181
+	}
182 182
 }
Please login to merge, or discard this patch.
src/Section/GenericSection.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,13 +1,13 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * GenericSection
4
- *
5
- * @package   brightnucleus/chainmail
6
- * @author    Alain Schlesser <[email protected]>
7
- * @license   GPL-2.0+
8
- * @link      http://www.brightnucleus.com/
9
- * @copyright 2016 Alain Schlesser, Bright Nucleus
10
- */
3
+	 * GenericSection
4
+	 *
5
+	 * @package   brightnucleus/chainmail
6
+	 * @author    Alain Schlesser <[email protected]>
7
+	 * @license   GPL-2.0+
8
+	 * @link      http://www.brightnucleus.com/
9
+	 * @copyright 2016 Alain Schlesser, Bright Nucleus
10
+	 */
11 11
 
12 12
 namespace BrightNucleus\ChainMail\Section;
13 13
 
Please login to merge, or discard this patch.
src/SectionInterface.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -22,12 +22,12 @@
 block discarded – undo
22 22
 interface SectionInterface extends Renderable
23 23
 {
24 24
 
25
-    /**
26
-     * Get the name of the Section.
27
-     *
28
-     * @since 1.0.0
29
-     *
30
-     * @return string Name of the section.
31
-     */
32
-    public function getSectionName();
25
+	/**
26
+	 * Get the name of the Section.
27
+	 *
28
+	 * @since 1.0.0
29
+	 *
30
+	 * @return string Name of the section.
31
+	 */
32
+	public function getSectionName();
33 33
 }
34 34
\ No newline at end of file
Please login to merge, or discard this patch.
src/Support/Config.php 1 patch
Indentation   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -1,13 +1,13 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Config
4
- *
5
- * @package   brightnucleus/chainmail
6
- * @author    Alain Schlesser <[email protected]>
7
- * @license   GPL-2.0+
8
- * @link      http://www.brightnucleus.com/
9
- * @copyright 2016 Alain Schlesser, Bright Nucleus
10
- */
3
+	 * Config
4
+	 *
5
+	 * @package   brightnucleus/chainmail
6
+	 * @author    Alain Schlesser <[email protected]>
7
+	 * @license   GPL-2.0+
8
+	 * @link      http://www.brightnucleus.com/
9
+	 * @copyright 2016 Alain Schlesser, Bright Nucleus
10
+	 */
11 11
 
12 12
 namespace BrightNucleus\ChainMail\Support;
13 13
 
@@ -24,75 +24,75 @@  discard block
 block discarded – undo
24 24
 class Config extends ArrayObject implements ConfigInterface
25 25
 {
26 26
 
27
-    /**
28
-     * Instantiate the Config object.
29
-     *
30
-     * @since 1.0.0
31
-     *
32
-     * @param  array $config Array with settings.
33
-     */
34
-    public function __construct(array $config)
35
-    {
36
-        // Make sure the config entries can be accessed as properties.
37
-        parent::__construct($config, ArrayObject::ARRAY_AS_PROPS);
38
-    }
27
+	/**
28
+	 * Instantiate the Config object.
29
+	 *
30
+	 * @since 1.0.0
31
+	 *
32
+	 * @param  array $config Array with settings.
33
+	 */
34
+	public function __construct(array $config)
35
+	{
36
+		// Make sure the config entries can be accessed as properties.
37
+		parent::__construct($config, ArrayObject::ARRAY_AS_PROPS);
38
+	}
39 39
 
40
-    /**
41
-     * Magic method that enables the use of normal array_* functions on the
42
-     * Config object.
43
-     *
44
-     * @since  1.0.0
45
-     *
46
-     * @param  string $function  The function that was called on this object.
47
-     * @param  mixed  $arguments The arguments that were used for the function
48
-     *                           call.
49
-     * @return mixed
50
-     * @throws BadMethodCallException
51
-     */
52
-    public function __call($function, $arguments)
53
-    {
54
-        if ( ! is_callable($function) || substr($function, 0, 6) !== 'array_') {
55
-            throw new BadMethodCallException(__CLASS__ . '->' . $function);
56
-        }
40
+	/**
41
+	 * Magic method that enables the use of normal array_* functions on the
42
+	 * Config object.
43
+	 *
44
+	 * @since  1.0.0
45
+	 *
46
+	 * @param  string $function  The function that was called on this object.
47
+	 * @param  mixed  $arguments The arguments that were used for the function
48
+	 *                           call.
49
+	 * @return mixed
50
+	 * @throws BadMethodCallException
51
+	 */
52
+	public function __call($function, $arguments)
53
+	{
54
+		if ( ! is_callable($function) || substr($function, 0, 6) !== 'array_') {
55
+			throw new BadMethodCallException(__CLASS__ . '->' . $function);
56
+		}
57 57
 
58
-        return call_user_func_array($function,
59
-            array_merge(array($this->getArrayCopy()), $arguments));
60
-    }
58
+		return call_user_func_array($function,
59
+			array_merge(array($this->getArrayCopy()), $arguments));
60
+	}
61 61
 
62
-    /**
63
-     * Check whether the Config has a specific key.
64
-     *
65
-     * @since 1.0.0
66
-     *
67
-     * @param string $key The key to check the existence for.
68
-     * @return bool
69
-     */
70
-    public function hasKey($key)
71
-    {
72
-        return array_key_exists($key, (array)$this);
73
-    }
62
+	/**
63
+	 * Check whether the Config has a specific key.
64
+	 *
65
+	 * @since 1.0.0
66
+	 *
67
+	 * @param string $key The key to check the existence for.
68
+	 * @return bool
69
+	 */
70
+	public function hasKey($key)
71
+	{
72
+		return array_key_exists($key, (array)$this);
73
+	}
74 74
 
75
-    /**
76
-     * Get the value of a specific key.
77
-     *
78
-     * @since 1.0.0
79
-     *
80
-     * @param string $key The key to get the value for.
81
-     * @return mixed
82
-     */
83
-    public function getKey($key)
84
-    {
85
-        return $this[$key];
86
-    }
75
+	/**
76
+	 * Get the value of a specific key.
77
+	 *
78
+	 * @since 1.0.0
79
+	 *
80
+	 * @param string $key The key to get the value for.
81
+	 * @return mixed
82
+	 */
83
+	public function getKey($key)
84
+	{
85
+		return $this[$key];
86
+	}
87 87
 
88
-    /**
89
-     * Get the an array with all the keys
90
-     *
91
-     * @since 1.0.0
92
-     * @return mixed
93
-     */
94
-    public function getKeys()
95
-    {
96
-        return array_keys((array)$this);
97
-    }
88
+	/**
89
+	 * Get the an array with all the keys
90
+	 *
91
+	 * @since 1.0.0
92
+	 * @return mixed
93
+	 */
94
+	public function getKeys()
95
+	{
96
+		return array_keys((array)$this);
97
+	}
98 98
 }
99 99
\ No newline at end of file
Please login to merge, or discard this patch.
src/Support/ConfigInterface.php 1 patch
Indentation   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -1,13 +1,13 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * ConfigInterface
4
- *
5
- * @package   brightnucleus/chainmail
6
- * @author    Alain Schlesser <[email protected]>
7
- * @license   GPL-2.0+
8
- * @link      http://www.brightnucleus.com/
9
- * @copyright 2016 Alain Schlesser, Bright Nucleus
10
- */
3
+	 * ConfigInterface
4
+	 *
5
+	 * @package   brightnucleus/chainmail
6
+	 * @author    Alain Schlesser <[email protected]>
7
+	 * @license   GPL-2.0+
8
+	 * @link      http://www.brightnucleus.com/
9
+	 * @copyright 2016 Alain Schlesser, Bright Nucleus
10
+	 */
11 11
 
12 12
 namespace BrightNucleus\ChainMail\Support;
13 13
 
@@ -23,47 +23,47 @@  discard block
 block discarded – undo
23 23
 interface ConfigInterface extends ArrayAccess
24 24
 {
25 25
 
26
-    /**
27
-     * Creates a copy of the ArrayObject.
28
-     *
29
-     * Returns a copy of the array. When the ArrayObject refers to an object an
30
-     * array of the public properties of that object will be returned.
31
-     * This is implemented by \ArrayObject.
32
-     *
33
-     * @since 1.0.0
34
-     *
35
-     * @return array Copy of the array.
36
-     */
37
-    public function getArrayCopy();
26
+	/**
27
+	 * Creates a copy of the ArrayObject.
28
+	 *
29
+	 * Returns a copy of the array. When the ArrayObject refers to an object an
30
+	 * array of the public properties of that object will be returned.
31
+	 * This is implemented by \ArrayObject.
32
+	 *
33
+	 * @since 1.0.0
34
+	 *
35
+	 * @return array Copy of the array.
36
+	 */
37
+	public function getArrayCopy();
38 38
 
39
-    /**
40
-     * Check whether the Config has a specific key.
41
-     *
42
-     * @since 1.0.0
43
-     *
44
-     * @param string $key The key to check the existence for.
45
-     *
46
-     * @return bool
47
-     */
48
-    public function hasKey($key);
39
+	/**
40
+	 * Check whether the Config has a specific key.
41
+	 *
42
+	 * @since 1.0.0
43
+	 *
44
+	 * @param string $key The key to check the existence for.
45
+	 *
46
+	 * @return bool
47
+	 */
48
+	public function hasKey($key);
49 49
 
50
-    /**
51
-     * Get the value of a specific key.
52
-     *
53
-     * @since 1.0.0
54
-     *
55
-     * @param string $key The key to get the value for.
56
-     *
57
-     * @return mixed
58
-     */
59
-    public function getKey($key);
50
+	/**
51
+	 * Get the value of a specific key.
52
+	 *
53
+	 * @since 1.0.0
54
+	 *
55
+	 * @param string $key The key to get the value for.
56
+	 *
57
+	 * @return mixed
58
+	 */
59
+	public function getKey($key);
60 60
 
61
-    /**
62
-     * Get the an array with all the keys
63
-     *
64
-     * @since 1.0.0
65
-     *
66
-     * @return mixed
67
-     */
68
-    public function getKeys();
61
+	/**
62
+	 * Get the an array with all the keys
63
+	 *
64
+	 * @since 1.0.0
65
+	 *
66
+	 * @return mixed
67
+	 */
68
+	public function getKeys();
69 69
 }
70 70
\ No newline at end of file
Please login to merge, or discard this patch.
src/Support/Factory.php 1 patch
Indentation   +68 added lines, -68 removed lines patch added patch discarded remove patch
@@ -1,13 +1,13 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Factory
4
- *
5
- * @package   brightnucleus/chainmail
6
- * @author    Alain Schlesser <[email protected]>
7
- * @license   GPL-2.0+
8
- * @link      http://www.brightnucleus.com/
9
- * @copyright 2016 Alain Schlesser, Bright Nucleus
10
- */
3
+	 * Factory
4
+	 *
5
+	 * @package   brightnucleus/chainmail
6
+	 * @author    Alain Schlesser <[email protected]>
7
+	 * @license   GPL-2.0+
8
+	 * @link      http://www.brightnucleus.com/
9
+	 * @copyright 2016 Alain Schlesser, Bright Nucleus
10
+	 */
11 11
 
12 12
 namespace BrightNucleus\ChainMail\Support;
13 13
 
@@ -24,74 +24,74 @@  discard block
 block discarded – undo
24 24
 class Factory
25 25
 {
26 26
 
27
-    /**
28
-     * Configuration Settings.
29
-     *
30
-     * @since 1.0.0
31
-     *
32
-     * @var ConfigInterface
33
-     */
34
-    protected $config;
27
+	/**
28
+	 * Configuration Settings.
29
+	 *
30
+	 * @since 1.0.0
31
+	 *
32
+	 * @var ConfigInterface
33
+	 */
34
+	protected $config;
35 35
 
36
-    /**
37
-     * Type of element the factory wants to create.
38
-     *
39
-     * @since 1.0.0
40
-     *
41
-     * @var string
42
-     */
43
-    protected $element;
36
+	/**
37
+	 * Type of element the factory wants to create.
38
+	 *
39
+	 * @since 1.0.0
40
+	 *
41
+	 * @var string
42
+	 */
43
+	protected $element;
44 44
 
45
-    /**
46
-     * Instantiate a Factory object.
47
-     *
48
-     * @since 1.0.0
49
-     *
50
-     * @param ConfigInterface $config  Configuration settings.
51
-     * @param string          $element The type of element to instantiate a
52
-     *                                 factory for.
53
-     * @throws RuntimeException When an unknown element type is requested.
54
-     */
55
-    public function __construct(ConfigInterface $config, $element)
56
-    {
45
+	/**
46
+	 * Instantiate a Factory object.
47
+	 *
48
+	 * @since 1.0.0
49
+	 *
50
+	 * @param ConfigInterface $config  Configuration settings.
51
+	 * @param string          $element The type of element to instantiate a
52
+	 *                                 factory for.
53
+	 * @throws RuntimeException When an unknown element type is requested.
54
+	 */
55
+	public function __construct(ConfigInterface $config, $element)
56
+	{
57 57
 
58
-        $this->config = $config;
58
+		$this->config = $config;
59 59
 
60
-        if ( ! $this->config->hasKey($element)) {
61
-            throw new RuntimeException(sprintf(
62
-                'Could not instantiate Factory for unknown Element Type "%1$s".',
63
-                $element
64
-            ));
65
-        }
60
+		if ( ! $this->config->hasKey($element)) {
61
+			throw new RuntimeException(sprintf(
62
+				'Could not instantiate Factory for unknown Element Type "%1$s".',
63
+				$element
64
+			));
65
+		}
66 66
 
67
-        $this->element = $element;
68
-    }
67
+		$this->element = $element;
68
+	}
69 69
 
70
-    /**
71
-     * Create and return a new instance of an element.
72
-     *
73
-     * @since 1.0.0
74
-     *
75
-     * @param string $type      Type of element to create.
76
-     * @param mixed  $arguments Optional. Arguments to pass to the object.
77
-     * @return mixed
78
-     * @throws RuntimeException If an unknown element type is requested.
79
-     */
80
-    public function create($type, $arguments = null)
81
-    {
70
+	/**
71
+	 * Create and return a new instance of an element.
72
+	 *
73
+	 * @since 1.0.0
74
+	 *
75
+	 * @param string $type      Type of element to create.
76
+	 * @param mixed  $arguments Optional. Arguments to pass to the object.
77
+	 * @return mixed
78
+	 * @throws RuntimeException If an unknown element type is requested.
79
+	 */
80
+	public function create($type, $arguments = null)
81
+	{
82 82
 
83
-        $classMap = $this->config[$this->element];
83
+		$classMap = $this->config[$this->element];
84 84
 
85
-        if ( ! array_key_exists($type, $classMap)) {
86
-            throw new RuntimeException(sprintf(
87
-                'Could not create object, unknown Type "%1$s" for "%2$s" elements.',
88
-                $type,
89
-                $this->element
90
-            ));
91
-        }
85
+		if ( ! array_key_exists($type, $classMap)) {
86
+			throw new RuntimeException(sprintf(
87
+				'Could not create object, unknown Type "%1$s" for "%2$s" elements.',
88
+				$type,
89
+				$this->element
90
+			));
91
+		}
92 92
 
93
-        $className = $classMap[$type]['class_name'];
93
+		$className = $classMap[$type]['class_name'];
94 94
 
95
-        return new $className($this->config, $arguments);
96
-    }
95
+		return new $className($this->config, $arguments);
96
+	}
97 97
 }
Please login to merge, or discard this patch.
src/Template/AbstractTemplate.php 1 patch
Indentation   +153 added lines, -153 removed lines patch added patch discarded remove patch
@@ -1,13 +1,13 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * AbstractTemplate
4
- *
5
- * @package   brightnucleus/chainmail
6
- * @author    Alain Schlesser <[email protected]>
7
- * @license   GPL-2.0+
8
- * @link      http://www.brightnucleus.com/
9
- * @copyright 2016 Alain Schlesser, Bright Nucleus
10
- */
3
+	 * AbstractTemplate
4
+	 *
5
+	 * @package   brightnucleus/chainmail
6
+	 * @author    Alain Schlesser <[email protected]>
7
+	 * @license   GPL-2.0+
8
+	 * @link      http://www.brightnucleus.com/
9
+	 * @copyright 2016 Alain Schlesser, Bright Nucleus
10
+	 */
11 11
 
12 12
 namespace BrightNucleus\ChainMail\Template;
13 13
 
@@ -27,149 +27,149 @@  discard block
 block discarded – undo
27 27
 abstract class AbstractTemplate implements TemplateInterface
28 28
 {
29 29
 
30
-    /**
31
-     * Configuration Settings.
32
-     *
33
-     * @since 1.0.0
34
-     *
35
-     * @var ConfigInterface
36
-     */
37
-    protected $config;
38
-
39
-    /**
40
-     * Name of the template.
41
-     *
42
-     * @since 1.0.0
43
-     *
44
-     * @var string
45
-     */
46
-    protected $templateName;
47
-
48
-    /**
49
-     * Instantiate a AbstractTemplate object.
50
-     *
51
-     * @since 1.0.0
52
-     *
53
-     * @param ConfigInterface $config       Configuration settings.
54
-     * @param array           $arguments    Arguments that are passed through
55
-     *                                      the constructor. Contained
56
-     *                                      elements: string $template
57
-     * @throws RuntimeException
58
-     */
59
-    public function __construct($config, $arguments)
60
-    {
61
-        $this->config = $config;
62
-        list($template) = $arguments;
63
-        $this->setTemplateName($template);
64
-    }
65
-
66
-    /**
67
-     * Get the name of the Template.
68
-     *
69
-     * @since 1.0.0
70
-     *
71
-     * @return string Name of the template.
72
-     */
73
-    public function getTemplateName()
74
-    {
75
-        return $this->templateName;
76
-    }
77
-
78
-    /**
79
-     * Set the name of the Template.
80
-     *
81
-     * @since 1.0.0
82
-     *
83
-     * @param string $template Optional. Name of the template.
84
-     * @throws RuntimeException
85
-     */
86
-    protected function setTemplateName($template = null)
87
-    {
88
-        if (null === $template) {
89
-            throw new RuntimeException('Initialised template without passing it a template name.');
90
-        }
91
-        if ( ! array_key_exists($template, $this->config['templates'])) {
92
-            throw new RuntimeException('Initialised template with an unknown template name.');
93
-        }
94
-        $this->templateName = $template;
95
-    }
96
-
97
-    /**
98
-     * Get the name of the View to use for rendering.
99
-     *
100
-     * @since 1.0.0
101
-     *
102
-     * @return string Name of the view.
103
-     */
104
-    protected function getViewName()
105
-    {
106
-        return $this->config['templates'][$this->getTemplateName()]['view_name'];
107
-    }
108
-
109
-    /**
110
-     * Get an array of Sections that are used by this template.
111
-     *
112
-     * @since 1.0.0
113
-     *
114
-     * @return array Sections that are used by this template.
115
-     */
116
-    public function getUsedSections()
117
-    {
118
-        return $this->config['templates'][$this->getTemplateName()]['sections'];
119
-    }
120
-
121
-    /**
122
-     * Render the template for a given context.
123
-     *
124
-     * @since 1.0.0
125
-     *
126
-     * @param array $context The context in which to render the template.
127
-     * @return string The rendered content.
128
-     * @throws RuntimeException
129
-     */
130
-    public function render(array $context)
131
-    {
132
-
133
-        $viewLocation = $this->getViewLocation($context);
134
-        $viewType     = $this->config['view_type'];
135
-
136
-        $viewFactory = new Factory($this->config, 'view_types');
137
-        $view        = $viewFactory->create($viewType, $viewLocation);
138
-
139
-        $sanitizerType    = $this->config['formats'][$context['format']]['sanitizer'];
140
-        $sanitizerFactory = new Factory($this->config, 'sanitizers');
141
-        $sanitizer        = $sanitizerFactory->create($sanitizerType);
142
-
143
-        $output = $view->render($context);
144
-
145
-        return $sanitizer->sanitize($output, $context);
146
-    }
147
-
148
-    /**
149
-     * Get the location of the view that is used for rendering.
150
-     *
151
-     * @since 1.0.0
152
-     *
153
-     * @param array $context Context for which to get the view location.
154
-     * @return string
155
-     */
156
-    protected function getViewLocation(array $context)
157
-    {
158
-        return $this->getViewRoot() . '/templates/' . $context['format'] . '/' . $this->getViewName();
159
-    }
160
-
161
-    /**
162
-     * Get the root location of the view that is used for rendering.
163
-     *
164
-     * @since 1.0.0
165
-     *
166
-     * @return string
167
-     */
168
-    protected function getViewRoot()
169
-    {
170
-        $viewRoots   = $this->config['view_root_locations'];
171
-        $viewRootKey = $this->config['templates'][$this->getTemplateName()]['view_location'];
172
-
173
-        return $viewRoots[$viewRootKey];
174
-    }
30
+	/**
31
+	 * Configuration Settings.
32
+	 *
33
+	 * @since 1.0.0
34
+	 *
35
+	 * @var ConfigInterface
36
+	 */
37
+	protected $config;
38
+
39
+	/**
40
+	 * Name of the template.
41
+	 *
42
+	 * @since 1.0.0
43
+	 *
44
+	 * @var string
45
+	 */
46
+	protected $templateName;
47
+
48
+	/**
49
+	 * Instantiate a AbstractTemplate object.
50
+	 *
51
+	 * @since 1.0.0
52
+	 *
53
+	 * @param ConfigInterface $config       Configuration settings.
54
+	 * @param array           $arguments    Arguments that are passed through
55
+	 *                                      the constructor. Contained
56
+	 *                                      elements: string $template
57
+	 * @throws RuntimeException
58
+	 */
59
+	public function __construct($config, $arguments)
60
+	{
61
+		$this->config = $config;
62
+		list($template) = $arguments;
63
+		$this->setTemplateName($template);
64
+	}
65
+
66
+	/**
67
+	 * Get the name of the Template.
68
+	 *
69
+	 * @since 1.0.0
70
+	 *
71
+	 * @return string Name of the template.
72
+	 */
73
+	public function getTemplateName()
74
+	{
75
+		return $this->templateName;
76
+	}
77
+
78
+	/**
79
+	 * Set the name of the Template.
80
+	 *
81
+	 * @since 1.0.0
82
+	 *
83
+	 * @param string $template Optional. Name of the template.
84
+	 * @throws RuntimeException
85
+	 */
86
+	protected function setTemplateName($template = null)
87
+	{
88
+		if (null === $template) {
89
+			throw new RuntimeException('Initialised template without passing it a template name.');
90
+		}
91
+		if ( ! array_key_exists($template, $this->config['templates'])) {
92
+			throw new RuntimeException('Initialised template with an unknown template name.');
93
+		}
94
+		$this->templateName = $template;
95
+	}
96
+
97
+	/**
98
+	 * Get the name of the View to use for rendering.
99
+	 *
100
+	 * @since 1.0.0
101
+	 *
102
+	 * @return string Name of the view.
103
+	 */
104
+	protected function getViewName()
105
+	{
106
+		return $this->config['templates'][$this->getTemplateName()]['view_name'];
107
+	}
108
+
109
+	/**
110
+	 * Get an array of Sections that are used by this template.
111
+	 *
112
+	 * @since 1.0.0
113
+	 *
114
+	 * @return array Sections that are used by this template.
115
+	 */
116
+	public function getUsedSections()
117
+	{
118
+		return $this->config['templates'][$this->getTemplateName()]['sections'];
119
+	}
120
+
121
+	/**
122
+	 * Render the template for a given context.
123
+	 *
124
+	 * @since 1.0.0
125
+	 *
126
+	 * @param array $context The context in which to render the template.
127
+	 * @return string The rendered content.
128
+	 * @throws RuntimeException
129
+	 */
130
+	public function render(array $context)
131
+	{
132
+
133
+		$viewLocation = $this->getViewLocation($context);
134
+		$viewType     = $this->config['view_type'];
135
+
136
+		$viewFactory = new Factory($this->config, 'view_types');
137
+		$view        = $viewFactory->create($viewType, $viewLocation);
138
+
139
+		$sanitizerType    = $this->config['formats'][$context['format']]['sanitizer'];
140
+		$sanitizerFactory = new Factory($this->config, 'sanitizers');
141
+		$sanitizer        = $sanitizerFactory->create($sanitizerType);
142
+
143
+		$output = $view->render($context);
144
+
145
+		return $sanitizer->sanitize($output, $context);
146
+	}
147
+
148
+	/**
149
+	 * Get the location of the view that is used for rendering.
150
+	 *
151
+	 * @since 1.0.0
152
+	 *
153
+	 * @param array $context Context for which to get the view location.
154
+	 * @return string
155
+	 */
156
+	protected function getViewLocation(array $context)
157
+	{
158
+		return $this->getViewRoot() . '/templates/' . $context['format'] . '/' . $this->getViewName();
159
+	}
160
+
161
+	/**
162
+	 * Get the root location of the view that is used for rendering.
163
+	 *
164
+	 * @since 1.0.0
165
+	 *
166
+	 * @return string
167
+	 */
168
+	protected function getViewRoot()
169
+	{
170
+		$viewRoots   = $this->config['view_root_locations'];
171
+		$viewRootKey = $this->config['templates'][$this->getTemplateName()]['view_location'];
172
+
173
+		return $viewRoots[$viewRootKey];
174
+	}
175 175
 }
Please login to merge, or discard this patch.
src/Template/GenericTemplate.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,13 +1,13 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * GenericTemplate
4
- *
5
- * @package   brightnucleus/chainmail
6
- * @author    Alain Schlesser <[email protected]>
7
- * @license   GPL-2.0+
8
- * @link      http://www.brightnucleus.com/
9
- * @copyright 2016 Alain Schlesser, Bright Nucleus
10
- */
3
+	 * GenericTemplate
4
+	 *
5
+	 * @package   brightnucleus/chainmail
6
+	 * @author    Alain Schlesser <[email protected]>
7
+	 * @license   GPL-2.0+
8
+	 * @link      http://www.brightnucleus.com/
9
+	 * @copyright 2016 Alain Schlesser, Bright Nucleus
10
+	 */
11 11
 
12 12
 namespace BrightNucleus\ChainMail\Template;
13 13
 
Please login to merge, or discard this patch.