@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | class ChainMail |
28 | 28 | { |
29 | 29 | |
30 | - const DEFAULT_CONFIG = __DIR__ . '/../config/defaults.php'; |
|
30 | + const DEFAULT_CONFIG = __DIR__.'/../config/defaults.php'; |
|
31 | 31 | |
32 | 32 | /** |
33 | 33 | * Configuration Settings. |
@@ -57,8 +57,8 @@ discard block |
||
57 | 57 | } |
58 | 58 | |
59 | 59 | $this->config = new Config(array_merge( |
60 | - (array)$defaults, |
|
61 | - (array)$config) |
|
60 | + (array) $defaults, |
|
61 | + (array) $config) |
|
62 | 62 | ); |
63 | 63 | } |
64 | 64 |
@@ -26,114 +26,114 @@ |
||
26 | 26 | class ChainMail |
27 | 27 | { |
28 | 28 | |
29 | - const DEFAULT_CONFIG = __DIR__ . '/../config/defaults.php'; |
|
30 | - |
|
31 | - /** |
|
32 | - * Configuration Settings. |
|
33 | - * |
|
34 | - * @since 1.0.0 |
|
35 | - * |
|
36 | - * @var ConfigInterface |
|
37 | - */ |
|
38 | - protected $config; |
|
39 | - |
|
40 | - /** |
|
41 | - * Instantiate a ChainMail object. |
|
42 | - * |
|
43 | - * @since 1.0.0 |
|
44 | - * |
|
45 | - * @param ConfigInterface|null $config Optional. Configuration settings. |
|
46 | - */ |
|
47 | - public function __construct(ConfigInterface $config = null) |
|
48 | - { |
|
49 | - |
|
50 | - $defaults = ConfigFactory::create(include(self::DEFAULT_CONFIG)); |
|
51 | - |
|
52 | - if ( ! $config) { |
|
53 | - $this->config = $defaults; |
|
54 | - |
|
55 | - return; |
|
56 | - } |
|
57 | - |
|
58 | - $this->config = ConfigFactory::create(array_merge( |
|
59 | - (array)$defaults, |
|
60 | - (array)$config) |
|
61 | - ); |
|
62 | - } |
|
63 | - |
|
64 | - /** |
|
65 | - * Render a specific section. |
|
66 | - * |
|
67 | - * @since 1.0.0 |
|
68 | - * |
|
69 | - * @param string $sectionType Type of section to render. |
|
70 | - * @param array $context The context in which to render the section. |
|
71 | - * |
|
72 | - * @return string Rendered HTML. |
|
73 | - */ |
|
74 | - public static function renderSection($sectionType, array $context) |
|
75 | - { |
|
76 | - /** @var Section $section */ |
|
77 | - $section = $context['sections'][$sectionType]; |
|
78 | - |
|
79 | - return $section->render($context); |
|
80 | - } |
|
81 | - |
|
82 | - /** |
|
83 | - * Get an array of strings representing the sections that are used by the |
|
84 | - * template. |
|
85 | - * |
|
86 | - * @since 1.0.0 |
|
87 | - * |
|
88 | - * @param array $context The context in which to render the section. |
|
89 | - * |
|
90 | - * @return array Array of strings with section types. |
|
91 | - */ |
|
92 | - public static function getUsedSections(array $context) |
|
93 | - { |
|
94 | - /** @var Template $template */ |
|
95 | - $template = $context['template']; |
|
96 | - |
|
97 | - return $template->getUsedSections(); |
|
98 | - } |
|
99 | - |
|
100 | - /** |
|
101 | - * Render all used sections. |
|
102 | - * |
|
103 | - * @since 1.0.0 |
|
104 | - * |
|
105 | - * @param array $context The context in which to render the section. |
|
106 | - * |
|
107 | - * @return string Rendered HTML. |
|
108 | - */ |
|
109 | - public static function renderSections(array $context) |
|
110 | - { |
|
111 | - $output = ''; |
|
112 | - |
|
113 | - foreach (self::getUsedSections($context) as $section) { |
|
114 | - $output .= self::renderSection($section, $context); |
|
115 | - } |
|
116 | - |
|
117 | - return $output; |
|
118 | - } |
|
119 | - |
|
120 | - /** |
|
121 | - * Create a new mail object. |
|
122 | - * |
|
123 | - * @since 1.0.0 |
|
124 | - * |
|
125 | - * @param string $format Optional. Format to use. |
|
126 | - * @param string|Template $template Optional. Template to be used. |
|
127 | - * |
|
128 | - * @return Mail |
|
129 | - */ |
|
130 | - public function createMail($format = 'html', $template = 'BasicTemplate') |
|
131 | - { |
|
132 | - $mail_factory = new Factory($this->config, 'mails'); |
|
133 | - $mail_class = $this->config->getKey('formats')[$format]['mail']; |
|
134 | - $mail = $mail_factory->create($mail_class); |
|
135 | - $mail->setTemplate($template); |
|
136 | - |
|
137 | - return $mail; |
|
138 | - } |
|
29 | + const DEFAULT_CONFIG = __DIR__ . '/../config/defaults.php'; |
|
30 | + |
|
31 | + /** |
|
32 | + * Configuration Settings. |
|
33 | + * |
|
34 | + * @since 1.0.0 |
|
35 | + * |
|
36 | + * @var ConfigInterface |
|
37 | + */ |
|
38 | + protected $config; |
|
39 | + |
|
40 | + /** |
|
41 | + * Instantiate a ChainMail object. |
|
42 | + * |
|
43 | + * @since 1.0.0 |
|
44 | + * |
|
45 | + * @param ConfigInterface|null $config Optional. Configuration settings. |
|
46 | + */ |
|
47 | + public function __construct(ConfigInterface $config = null) |
|
48 | + { |
|
49 | + |
|
50 | + $defaults = ConfigFactory::create(include(self::DEFAULT_CONFIG)); |
|
51 | + |
|
52 | + if ( ! $config) { |
|
53 | + $this->config = $defaults; |
|
54 | + |
|
55 | + return; |
|
56 | + } |
|
57 | + |
|
58 | + $this->config = ConfigFactory::create(array_merge( |
|
59 | + (array)$defaults, |
|
60 | + (array)$config) |
|
61 | + ); |
|
62 | + } |
|
63 | + |
|
64 | + /** |
|
65 | + * Render a specific section. |
|
66 | + * |
|
67 | + * @since 1.0.0 |
|
68 | + * |
|
69 | + * @param string $sectionType Type of section to render. |
|
70 | + * @param array $context The context in which to render the section. |
|
71 | + * |
|
72 | + * @return string Rendered HTML. |
|
73 | + */ |
|
74 | + public static function renderSection($sectionType, array $context) |
|
75 | + { |
|
76 | + /** @var Section $section */ |
|
77 | + $section = $context['sections'][$sectionType]; |
|
78 | + |
|
79 | + return $section->render($context); |
|
80 | + } |
|
81 | + |
|
82 | + /** |
|
83 | + * Get an array of strings representing the sections that are used by the |
|
84 | + * template. |
|
85 | + * |
|
86 | + * @since 1.0.0 |
|
87 | + * |
|
88 | + * @param array $context The context in which to render the section. |
|
89 | + * |
|
90 | + * @return array Array of strings with section types. |
|
91 | + */ |
|
92 | + public static function getUsedSections(array $context) |
|
93 | + { |
|
94 | + /** @var Template $template */ |
|
95 | + $template = $context['template']; |
|
96 | + |
|
97 | + return $template->getUsedSections(); |
|
98 | + } |
|
99 | + |
|
100 | + /** |
|
101 | + * Render all used sections. |
|
102 | + * |
|
103 | + * @since 1.0.0 |
|
104 | + * |
|
105 | + * @param array $context The context in which to render the section. |
|
106 | + * |
|
107 | + * @return string Rendered HTML. |
|
108 | + */ |
|
109 | + public static function renderSections(array $context) |
|
110 | + { |
|
111 | + $output = ''; |
|
112 | + |
|
113 | + foreach (self::getUsedSections($context) as $section) { |
|
114 | + $output .= self::renderSection($section, $context); |
|
115 | + } |
|
116 | + |
|
117 | + return $output; |
|
118 | + } |
|
119 | + |
|
120 | + /** |
|
121 | + * Create a new mail object. |
|
122 | + * |
|
123 | + * @since 1.0.0 |
|
124 | + * |
|
125 | + * @param string $format Optional. Format to use. |
|
126 | + * @param string|Template $template Optional. Template to be used. |
|
127 | + * |
|
128 | + * @return Mail |
|
129 | + */ |
|
130 | + public function createMail($format = 'html', $template = 'BasicTemplate') |
|
131 | + { |
|
132 | + $mail_factory = new Factory($this->config, 'mails'); |
|
133 | + $mail_class = $this->config->getKey('formats')[$format]['mail']; |
|
134 | + $mail = $mail_factory->create($mail_class); |
|
135 | + $mail->setTemplate($template); |
|
136 | + |
|
137 | + return $mail; |
|
138 | + } |
|
139 | 139 | } |
@@ -22,27 +22,27 @@ |
||
22 | 22 | class HTMLMail extends AbstractMail |
23 | 23 | { |
24 | 24 | |
25 | - /** |
|
26 | - * Set the format of the mail. |
|
27 | - * |
|
28 | - * @since 1.0.0 |
|
29 | - */ |
|
30 | - protected function setFormat() |
|
31 | - { |
|
32 | - $this->format = 'html'; |
|
33 | - } |
|
25 | + /** |
|
26 | + * Set the format of the mail. |
|
27 | + * |
|
28 | + * @since 1.0.0 |
|
29 | + */ |
|
30 | + protected function setFormat() |
|
31 | + { |
|
32 | + $this->format = 'html'; |
|
33 | + } |
|
34 | 34 | |
35 | - /** |
|
36 | - * Set the context of the renderer. |
|
37 | - * |
|
38 | - * @since 1.0.0 |
|
39 | - * |
|
40 | - * @param array $context Context to set/modify. |
|
41 | - * |
|
42 | - * @return array Updated context. |
|
43 | - */ |
|
44 | - protected function setContext(array $context) |
|
45 | - { |
|
46 | - return $context; |
|
47 | - } |
|
35 | + /** |
|
36 | + * Set the context of the renderer. |
|
37 | + * |
|
38 | + * @since 1.0.0 |
|
39 | + * |
|
40 | + * @param array $context Context to set/modify. |
|
41 | + * |
|
42 | + * @return array Updated context. |
|
43 | + */ |
|
44 | + protected function setContext(array $context) |
|
45 | + { |
|
46 | + return $context; |
|
47 | + } |
|
48 | 48 | } |
@@ -22,27 +22,27 @@ |
||
22 | 22 | class TextMail extends AbstractMail |
23 | 23 | { |
24 | 24 | |
25 | - /** |
|
26 | - * Set the format of the mail. |
|
27 | - * |
|
28 | - * @since 1.0.0 |
|
29 | - */ |
|
30 | - protected function setFormat() |
|
31 | - { |
|
32 | - $this->format = 'text'; |
|
33 | - } |
|
25 | + /** |
|
26 | + * Set the format of the mail. |
|
27 | + * |
|
28 | + * @since 1.0.0 |
|
29 | + */ |
|
30 | + protected function setFormat() |
|
31 | + { |
|
32 | + $this->format = 'text'; |
|
33 | + } |
|
34 | 34 | |
35 | - /** |
|
36 | - * Set the context of the renderer. |
|
37 | - * |
|
38 | - * @since 1.0.0 |
|
39 | - * |
|
40 | - * @param array $context Context to set/modify. |
|
41 | - * |
|
42 | - * @return array Updated context. |
|
43 | - */ |
|
44 | - protected function setContext(array $context) |
|
45 | - { |
|
46 | - return $context; |
|
47 | - } |
|
35 | + /** |
|
36 | + * Set the context of the renderer. |
|
37 | + * |
|
38 | + * @since 1.0.0 |
|
39 | + * |
|
40 | + * @param array $context Context to set/modify. |
|
41 | + * |
|
42 | + * @return array Updated context. |
|
43 | + */ |
|
44 | + protected function setContext(array $context) |
|
45 | + { |
|
46 | + return $context; |
|
47 | + } |
|
48 | 48 | } |
@@ -22,18 +22,18 @@ |
||
22 | 22 | class HTMLSanitizer extends AbstractSanitizer |
23 | 23 | { |
24 | 24 | |
25 | - /** |
|
26 | - * Sanitize the 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 | - * |
|
33 | - * @return string Sanitized content. |
|
34 | - */ |
|
35 | - public function sanitize($content, array $context) |
|
36 | - { |
|
37 | - return $content; |
|
38 | - } |
|
25 | + /** |
|
26 | + * Sanitize the 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 | + * |
|
33 | + * @return string Sanitized content. |
|
34 | + */ |
|
35 | + public function sanitize($content, array $context) |
|
36 | + { |
|
37 | + return $content; |
|
38 | + } |
|
39 | 39 | } |
@@ -22,14 +22,14 @@ |
||
22 | 22 | interface Renderable |
23 | 23 | { |
24 | 24 | |
25 | - /** |
|
26 | - * Render the current Renderable for a given context. |
|
27 | - * |
|
28 | - * @since 1.0.0 |
|
29 | - * |
|
30 | - * @param array $context The context in which to render the Renderable. |
|
31 | - * |
|
32 | - * @return string Rendered output of the Renderable. |
|
33 | - */ |
|
34 | - public function render(array $context); |
|
25 | + /** |
|
26 | + * Render the current Renderable for a given context. |
|
27 | + * |
|
28 | + * @since 1.0.0 |
|
29 | + * |
|
30 | + * @param array $context The context in which to render the Renderable. |
|
31 | + * |
|
32 | + * @return string Rendered output of the Renderable. |
|
33 | + */ |
|
34 | + public function render(array $context); |
|
35 | 35 | } |
@@ -22,18 +22,18 @@ |
||
22 | 22 | class TextValidator extends AbstractValidator |
23 | 23 | { |
24 | 24 | |
25 | - /** |
|
26 | - * Validate the content for a given context. |
|
27 | - * |
|
28 | - * @since 1.0.0 |
|
29 | - * |
|
30 | - * @param string $content Content to validate. |
|
31 | - * @param array $context Context in which to validate. |
|
32 | - * |
|
33 | - * @return string Validated content. |
|
34 | - */ |
|
35 | - public function validate($content, array $context) |
|
36 | - { |
|
37 | - return $content; |
|
38 | - } |
|
25 | + /** |
|
26 | + * Validate the content for a given context. |
|
27 | + * |
|
28 | + * @since 1.0.0 |
|
29 | + * |
|
30 | + * @param string $content Content to validate. |
|
31 | + * @param array $context Context in which to validate. |
|
32 | + * |
|
33 | + * @return string Validated content. |
|
34 | + */ |
|
35 | + public function validate($content, array $context) |
|
36 | + { |
|
37 | + return $content; |
|
38 | + } |
|
39 | 39 | } |
@@ -12,7 +12,7 @@ |
||
12 | 12 | namespace BrightNucleus\ChainMail; |
13 | 13 | |
14 | 14 | if ( ! $content) { |
15 | - return; |
|
15 | + return; |
|
16 | 16 | } |
17 | 17 | ?> |
18 | 18 | <div class="<?php echo $context['css_class']; ?>"><?php echo $content; ?></div> |
@@ -22,18 +22,18 @@ |
||
22 | 22 | class TextValidator extends AbstractValidator |
23 | 23 | { |
24 | 24 | |
25 | - /** |
|
26 | - * Validate the content for a given context. |
|
27 | - * |
|
28 | - * @since 1.0.0 |
|
29 | - * |
|
30 | - * @param string $content Content to validate. |
|
31 | - * @param array $context Context in which to validate. |
|
32 | - * |
|
33 | - * @return string Validated content. |
|
34 | - */ |
|
35 | - public function validate($content, array $context) |
|
36 | - { |
|
37 | - return $content; |
|
38 | - } |
|
25 | + /** |
|
26 | + * Validate the content for a given context. |
|
27 | + * |
|
28 | + * @since 1.0.0 |
|
29 | + * |
|
30 | + * @param string $content Content to validate. |
|
31 | + * @param array $context Context in which to validate. |
|
32 | + * |
|
33 | + * @return string Validated content. |
|
34 | + */ |
|
35 | + public function validate($content, array $context) |
|
36 | + { |
|
37 | + return $content; |
|
38 | + } |
|
39 | 39 | } |
@@ -24,17 +24,17 @@ |
||
24 | 24 | class MailView extends AbstractView |
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 $criterion === $this->uri; |
|
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 $criterion === $this->uri; |
|
39 | + } |
|
40 | 40 | } |