1 | <?php namespace Camelcased\Postmark\Inbound\Parse; |
||
3 | class Parser { |
||
4 | |||
5 | /** |
||
6 | * @var array |
||
7 | */ |
||
8 | protected $inbound; |
||
9 | |||
10 | |||
11 | /** |
||
12 | * @var array |
||
13 | */ |
||
14 | protected $output; |
||
15 | |||
16 | public function __construct($json) |
||
33 | |||
34 | /** |
||
35 | * Parse the email from JSON to a formatted array |
||
36 | * |
||
37 | * @return array |
||
38 | */ |
||
39 | public function parse() |
||
90 | |||
91 | /** |
||
92 | * Converts the given JSON string to an array |
||
93 | * |
||
94 | * @param string $json |
||
95 | * @return array |
||
96 | */ |
||
97 | private function jsonToArray($json) |
||
108 | |||
109 | /** |
||
110 | * Checks if there is an html body |
||
111 | * |
||
112 | * @return boolean |
||
113 | */ |
||
114 | private function htmlBody() |
||
118 | |||
119 | /** |
||
120 | * Sets the correct ReplyTo field based on whether the email had a ReplyTo field or not. |
||
121 | * |
||
122 | * @return string |
||
123 | */ |
||
124 | private function replyTo() |
||
135 | |||
136 | /** |
||
137 | * Extracts the email from the input. Ex: "Full name" <[email protected]> |
||
138 | * |
||
139 | * @param string $input |
||
140 | * @return string |
||
141 | */ |
||
142 | private function extractEmail($input) |
||
150 | |||
151 | /** |
||
152 | * Converts BCC and CC fields into an array or string if needed |
||
153 | * |
||
154 | * @param string $field |
||
155 | * @return mixed |
||
156 | */ |
||
157 | private function carbon($field) |
||
174 | |||
175 | /** |
||
176 | * Simple helper function to check if the email has the given field |
||
177 | * |
||
178 | * @param string $key |
||
179 | * @return boolean |
||
180 | */ |
||
181 | private function has($key) |
||
189 | } |
||
190 |