@@ -27,51 +27,51 @@ |
||
27 | 27 | return static::$fields->all(); |
28 | 28 | } |
29 | 29 | |
30 | - public static function get($key, $default=null){ |
|
30 | + public static function get($key, $default = null) { |
|
31 | 31 | if (!static::$fields) static::$fields = new Map(); |
32 | 32 | return static::$fields->get($key, $default); |
33 | 33 | } |
34 | 34 | |
35 | - public static function set($key, $value=null){ |
|
35 | + public static function set($key, $value = null) { |
|
36 | 36 | if (!static::$fields) static::$fields = new Map(); |
37 | 37 | return static::$fields->set($key, $value); |
38 | 38 | } |
39 | 39 | |
40 | - public static function delete($key, $compact=true){ |
|
40 | + public static function delete($key, $compact = true) { |
|
41 | 41 | if (!static::$fields) static::$fields = new Map(); |
42 | 42 | static::$fields->delete($key, $compact); |
43 | 43 | } |
44 | 44 | |
45 | - public static function exists($key){ |
|
45 | + public static function exists($key) { |
|
46 | 46 | if (!static::$fields) static::$fields = new Map(); |
47 | 47 | return static::$fields->exists($key); |
48 | 48 | } |
49 | 49 | |
50 | - public static function clear(){ |
|
50 | + public static function clear() { |
|
51 | 51 | if (!static::$fields) static::$fields = new Map(); |
52 | 52 | static::$fields->clear(); |
53 | 53 | } |
54 | 54 | |
55 | - public static function load($fields){ |
|
55 | + public static function load($fields) { |
|
56 | 56 | if (!static::$fields) static::$fields = new Map(); |
57 | 57 | static::$fields->load($fields); |
58 | 58 | } |
59 | 59 | |
60 | - public static function merge(array $array, $merge_back=false){ |
|
60 | + public static function merge(array $array, $merge_back = false) { |
|
61 | 61 | if (!static::$fields) static::$fields = new Map(); |
62 | 62 | static::$fields->merge($array, $merge_back); |
63 | 63 | } |
64 | 64 | |
65 | - protected static function compact(){ |
|
65 | + protected static function compact() { |
|
66 | 66 | if (!static::$fields) static::$fields = new Map(); |
67 | 67 | static::$fields->compact(); |
68 | 68 | } |
69 | 69 | |
70 | - protected static function & find($path, $create=false, callable $operation=null) { |
|
70 | + protected static function & find($path, $create = false, callable $operation = null) { |
|
71 | 71 | return static::$fields->find($path, $create, $operation); |
72 | 72 | } |
73 | 73 | |
74 | - public function jsonSerialize(){ |
|
74 | + public function jsonSerialize() { |
|
75 | 75 | if (!static::$fields) static::$fields = new Map(); |
76 | 76 | return static::$fields->jsonSerialize(); |
77 | 77 | } |
@@ -23,47 +23,65 @@ discard block |
||
23 | 23 | protected static $fields = null; |
24 | 24 | |
25 | 25 | public static function & all(){ |
26 | - if (!static::$fields) static::$fields = new Map(); |
|
26 | + if (!static::$fields) { |
|
27 | + static::$fields = new Map(); |
|
28 | + } |
|
27 | 29 | return static::$fields->all(); |
28 | 30 | } |
29 | 31 | |
30 | - public static function get($key, $default=null){ |
|
31 | - if (!static::$fields) static::$fields = new Map(); |
|
32 | + public static function get($key, $default=null) { |
|
33 | + if (!static::$fields) { |
|
34 | + static::$fields = new Map(); |
|
35 | + } |
|
32 | 36 | return static::$fields->get($key, $default); |
33 | 37 | } |
34 | 38 | |
35 | - public static function set($key, $value=null){ |
|
36 | - if (!static::$fields) static::$fields = new Map(); |
|
39 | + public static function set($key, $value=null) { |
|
40 | + if (!static::$fields) { |
|
41 | + static::$fields = new Map(); |
|
42 | + } |
|
37 | 43 | return static::$fields->set($key, $value); |
38 | 44 | } |
39 | 45 | |
40 | - public static function delete($key, $compact=true){ |
|
41 | - if (!static::$fields) static::$fields = new Map(); |
|
46 | + public static function delete($key, $compact=true) { |
|
47 | + if (!static::$fields) { |
|
48 | + static::$fields = new Map(); |
|
49 | + } |
|
42 | 50 | static::$fields->delete($key, $compact); |
43 | 51 | } |
44 | 52 | |
45 | - public static function exists($key){ |
|
46 | - if (!static::$fields) static::$fields = new Map(); |
|
53 | + public static function exists($key) { |
|
54 | + if (!static::$fields) { |
|
55 | + static::$fields = new Map(); |
|
56 | + } |
|
47 | 57 | return static::$fields->exists($key); |
48 | 58 | } |
49 | 59 | |
50 | - public static function clear(){ |
|
51 | - if (!static::$fields) static::$fields = new Map(); |
|
60 | + public static function clear() { |
|
61 | + if (!static::$fields) { |
|
62 | + static::$fields = new Map(); |
|
63 | + } |
|
52 | 64 | static::$fields->clear(); |
53 | 65 | } |
54 | 66 | |
55 | - public static function load($fields){ |
|
56 | - if (!static::$fields) static::$fields = new Map(); |
|
67 | + public static function load($fields) { |
|
68 | + if (!static::$fields) { |
|
69 | + static::$fields = new Map(); |
|
70 | + } |
|
57 | 71 | static::$fields->load($fields); |
58 | 72 | } |
59 | 73 | |
60 | - public static function merge(array $array, $merge_back=false){ |
|
61 | - if (!static::$fields) static::$fields = new Map(); |
|
74 | + public static function merge(array $array, $merge_back=false) { |
|
75 | + if (!static::$fields) { |
|
76 | + static::$fields = new Map(); |
|
77 | + } |
|
62 | 78 | static::$fields->merge($array, $merge_back); |
63 | 79 | } |
64 | 80 | |
65 | - protected static function compact(){ |
|
66 | - if (!static::$fields) static::$fields = new Map(); |
|
81 | + protected static function compact() { |
|
82 | + if (!static::$fields) { |
|
83 | + static::$fields = new Map(); |
|
84 | + } |
|
67 | 85 | static::$fields->compact(); |
68 | 86 | } |
69 | 87 | |
@@ -71,8 +89,10 @@ discard block |
||
71 | 89 | return static::$fields->find($path, $create, $operation); |
72 | 90 | } |
73 | 91 | |
74 | - public function jsonSerialize(){ |
|
75 | - if (!static::$fields) static::$fields = new Map(); |
|
92 | + public function jsonSerialize() { |
|
93 | + if (!static::$fields) { |
|
94 | + static::$fields = new Map(); |
|
95 | + } |
|
76 | 96 | return static::$fields->jsonSerialize(); |
77 | 97 | } |
78 | 98 |
@@ -15,17 +15,17 @@ |
||
15 | 15 | class Envelope { |
16 | 16 | |
17 | 17 | protected $uid, |
18 | - $to, |
|
19 | - $from, |
|
20 | - $cc, |
|
21 | - $bcc, |
|
22 | - $replyTo, |
|
23 | - $subject, |
|
24 | - $message, |
|
25 | - $contentType = 'text/html; charset="utf-8"', |
|
26 | - $attachments, |
|
27 | - $compiled_head, |
|
28 | - $compiled_body; |
|
18 | + $to, |
|
19 | + $from, |
|
20 | + $cc, |
|
21 | + $bcc, |
|
22 | + $replyTo, |
|
23 | + $subject, |
|
24 | + $message, |
|
25 | + $contentType = 'text/html; charset="utf-8"', |
|
26 | + $attachments, |
|
27 | + $compiled_head, |
|
28 | + $compiled_body; |
|
29 | 29 | |
30 | 30 | public function __construct($email=null){ |
31 | 31 | if ($email) { |
@@ -27,126 +27,126 @@ discard block |
||
27 | 27 | $compiled_head, |
28 | 28 | $compiled_body; |
29 | 29 | |
30 | - public function __construct($email=null){ |
|
30 | + public function __construct($email = null) { |
|
31 | 31 | if ($email) { |
32 | - $email = (object)$email; |
|
33 | - if(isset($email->to)) $this->to($email->to); |
|
34 | - if(isset($email->from)) $this->from($email->from); |
|
35 | - if(isset($email->cc)) $this->cc($email->cc); |
|
36 | - if(isset($email->bcc)) $this->bcc($email->bcc); |
|
37 | - if(isset($email->replyTo)) $this->replyTo($email->replyTo); |
|
38 | - if(isset($email->subject)) $this->subject($email->subject); |
|
39 | - if(isset($email->message)) $this->message($email->message); |
|
40 | - if(isset($email->attachments)) $this->attach($email->attachments); |
|
32 | + $email = (object) $email; |
|
33 | + if (isset($email->to)) $this->to($email->to); |
|
34 | + if (isset($email->from)) $this->from($email->from); |
|
35 | + if (isset($email->cc)) $this->cc($email->cc); |
|
36 | + if (isset($email->bcc)) $this->bcc($email->bcc); |
|
37 | + if (isset($email->replyTo)) $this->replyTo($email->replyTo); |
|
38 | + if (isset($email->subject)) $this->subject($email->subject); |
|
39 | + if (isset($email->message)) $this->message($email->message); |
|
40 | + if (isset($email->attachments)) $this->attach($email->attachments); |
|
41 | 41 | } |
42 | - $this->uid = '_CORE_'.md5(uniqid(time())); |
|
42 | + $this->uid = '_CORE_'.md5(uniqid(time())); |
|
43 | 43 | |
44 | 44 | } |
45 | 45 | |
46 | - protected function add_emails(&$pool, $emails, $append=true){ |
|
46 | + protected function add_emails(&$pool, $emails, $append = true) { |
|
47 | 47 | $this->compiled_head = null; |
48 | - foreach ((array)$emails as $values) { |
|
49 | - foreach(preg_split('/\s*,\s*/',$values) as $value) { |
|
50 | - if(strpos($value,'<')!==false){ |
|
51 | - $value = str_replace('>','',$value); |
|
52 | - $parts = explode('<',$value,2); |
|
48 | + foreach ((array) $emails as $values) { |
|
49 | + foreach (preg_split('/\s*,\s*/', $values) as $value) { |
|
50 | + if (strpos($value, '<') !== false) { |
|
51 | + $value = str_replace('>', '', $value); |
|
52 | + $parts = explode('<', $value, 2); |
|
53 | 53 | $name = trim(current($parts)); |
54 | 54 | $email = trim(end($parts)); |
55 | 55 | $address = "$name <{$email}>"; |
56 | 56 | } else { |
57 | 57 | $address = $value; |
58 | 58 | } |
59 | - if ($append) $pool[] = $address; else $pool = $address; |
|
59 | + if ($append) $pool[] = $address;else $pool = $address; |
|
60 | 60 | } |
61 | 61 | } |
62 | 62 | } |
63 | 63 | |
64 | - public function from($value=null){ |
|
65 | - if ($value!==null && $value) { |
|
64 | + public function from($value = null) { |
|
65 | + if ($value !== null && $value) { |
|
66 | 66 | $this->add_emails($this->from, $value, false); |
67 | - } else if ($value===false) $this->from = ''; |
|
67 | + } else if ($value === false) $this->from = ''; |
|
68 | 68 | return $this->from; |
69 | 69 | } |
70 | 70 | |
71 | - public function to($value=null){ |
|
72 | - if ($value!==null && $value) { |
|
71 | + public function to($value = null) { |
|
72 | + if ($value !== null && $value) { |
|
73 | 73 | $this->add_emails($this->to, $value); |
74 | - } else if ($value===false) $this->to = []; |
|
74 | + } else if ($value === false) $this->to = []; |
|
75 | 75 | return $this->to; |
76 | 76 | } |
77 | 77 | |
78 | - public function cc($value=null){ |
|
79 | - if ($value!==null && $value) { |
|
78 | + public function cc($value = null) { |
|
79 | + if ($value !== null && $value) { |
|
80 | 80 | $this->add_emails($this->cc, $value); |
81 | - } else if ($value===false) $this->cc = []; |
|
81 | + } else if ($value === false) $this->cc = []; |
|
82 | 82 | return $this->cc; |
83 | 83 | } |
84 | 84 | |
85 | - public function bcc($value=null){ |
|
86 | - if ($value!==null && $value) { |
|
85 | + public function bcc($value = null) { |
|
86 | + if ($value !== null && $value) { |
|
87 | 87 | $this->add_emails($this->bcc, $value); |
88 | - } else if ($value===false) $this->bcc = []; |
|
88 | + } else if ($value === false) $this->bcc = []; |
|
89 | 89 | return $this->bcc; |
90 | 90 | } |
91 | 91 | |
92 | - public function replyTo($value=null){ |
|
93 | - if ($value!==null && $value) { |
|
92 | + public function replyTo($value = null) { |
|
93 | + if ($value !== null && $value) { |
|
94 | 94 | $this->add_emails($this->replyTo, $value, false); |
95 | - } else if ($value===false) $this->replyTo = ''; |
|
95 | + } else if ($value === false) $this->replyTo = ''; |
|
96 | 96 | return $this->replyTo; |
97 | 97 | } |
98 | 98 | |
99 | - public function subject($value=null){ |
|
100 | - if ($value!==null && $value) { |
|
99 | + public function subject($value = null) { |
|
100 | + if ($value !== null && $value) { |
|
101 | 101 | $this->compiled_head = null; |
102 | 102 | $this->subject = $value; |
103 | - } else if ($value===false) $this->subject = ''; |
|
103 | + } else if ($value === false) $this->subject = ''; |
|
104 | 104 | return $this->subject; |
105 | 105 | } |
106 | 106 | |
107 | - public function contentType($value=null){ |
|
108 | - if ($value!==null && $value) { |
|
107 | + public function contentType($value = null) { |
|
108 | + if ($value !== null && $value) { |
|
109 | 109 | $this->compiled_body = null; |
110 | 110 | $this->contentType = $value; |
111 | - } else if ($value===false) $this->contentType = ''; |
|
111 | + } else if ($value === false) $this->contentType = ''; |
|
112 | 112 | return $this->contentType; |
113 | 113 | } |
114 | 114 | |
115 | - public function message($value=null){ |
|
116 | - if ($value!==null && $value) { |
|
115 | + public function message($value = null) { |
|
116 | + if ($value !== null && $value) { |
|
117 | 117 | $this->compiled_body = null; |
118 | 118 | $this->message = $value; |
119 | - } else if ($value===false) $this->message = ''; |
|
119 | + } else if ($value === false) $this->message = ''; |
|
120 | 120 | return $this->message; |
121 | 121 | } |
122 | 122 | |
123 | - public function attach($file){ |
|
123 | + public function attach($file) { |
|
124 | 124 | $this->compiled_body = null; |
125 | 125 | if (isset($file->content) || isset($file['content'])) { |
126 | 126 | $this->attachments[] = $file; |
127 | - } else foreach ((array)$file as $curfile) { |
|
127 | + } else foreach ((array) $file as $curfile) { |
|
128 | 128 | $this->attachments[] = $curfile; |
129 | 129 | } |
130 | 130 | } |
131 | 131 | |
132 | - public function head($recompile = false){ |
|
133 | - if ($recompile || (null === $this->compiled_head)){ |
|
132 | + public function head($recompile = false) { |
|
133 | + if ($recompile || (null === $this->compiled_head)) { |
|
134 | 134 | $head = []; |
135 | 135 | $head[] = "Subject: {$this->subject}"; |
136 | - if($this->from) $head[] = "From: {$this->from}"; |
|
137 | - if(is_array($this->to) && !empty($this->to)) $head[] = "To: " . implode(', ',$this->to); |
|
138 | - if(is_array($this->cc) && !empty($this->cc)) $head[] = "Cc: " . implode(', ',$this->cc); |
|
139 | - if(is_array($this->bcc) && !empty($this->bcc)) $head[] = "Bcc: " . implode(', ',$this->bcc); |
|
140 | - if($this->replyTo) $head[] = "Reply-To: {$this->replyTo}"; |
|
136 | + if ($this->from) $head[] = "From: {$this->from}"; |
|
137 | + if (is_array($this->to) && !empty($this->to)) $head[] = "To: ".implode(', ', $this->to); |
|
138 | + if (is_array($this->cc) && !empty($this->cc)) $head[] = "Cc: ".implode(', ', $this->cc); |
|
139 | + if (is_array($this->bcc) && !empty($this->bcc)) $head[] = "Bcc: ".implode(', ', $this->bcc); |
|
140 | + if ($this->replyTo) $head[] = "Reply-To: {$this->replyTo}"; |
|
141 | 141 | $head[] = 'MIME-Version: 1.0'; |
142 | 142 | $head[] = "Content-Type: multipart/mixed; boundary=\"{$this->uid}\""; |
143 | 143 | $this->compiled_head = implode("\r\n", $head); |
144 | 144 | } |
145 | - return \Filter::with( 'core.email.source.head', $this->compiled_head); |
|
145 | + return \Filter::with('core.email.source.head', $this->compiled_head); |
|
146 | 146 | } |
147 | 147 | |
148 | - public function body($recompile = false){ |
|
149 | - if ($recompile || (null === $this->compiled_body)){ |
|
148 | + public function body($recompile = false) { |
|
149 | + if ($recompile || (null === $this->compiled_body)) { |
|
150 | 150 | $body[] = "--{$this->uid}"; |
151 | 151 | $body[] = "Content-Type: {$this->contentType}"; |
152 | 152 | $body[] = "Content-Transfer-Encoding: quoted-printable"; |
@@ -154,13 +154,13 @@ discard block |
||
154 | 154 | $body[] = quoted_printable_encode($this->message); |
155 | 155 | $body[] = ''; |
156 | 156 | |
157 | - if (!empty($this->attachments)) foreach ((array)$this->attachments as $file) { |
|
157 | + if (!empty($this->attachments)) foreach ((array) $this->attachments as $file) { |
|
158 | 158 | |
159 | 159 | if (is_string($file)) { |
160 | 160 | $name = basename($file); |
161 | 161 | $data = file_get_contents($file); |
162 | 162 | } else { |
163 | - $name = isset($file['name']) ? $file['name'] : 'untitled'; |
|
163 | + $name = isset($file['name']) ? $file['name'] : 'untitled'; |
|
164 | 164 | $data = isset($file['content']) ? $file['content'] : ''; |
165 | 165 | } |
166 | 166 | |
@@ -177,11 +177,11 @@ discard block |
||
177 | 177 | |
178 | 178 | $this->compiled_body = implode("\r\n", $body); |
179 | 179 | } |
180 | - return \Filter::with( 'core.email.source.body', $this->compiled_body); |
|
180 | + return \Filter::with('core.email.source.body', $this->compiled_body); |
|
181 | 181 | } |
182 | 182 | |
183 | - public function build(){ |
|
184 | - return \Filter::with( 'core.email.source', $this->head() . "\r\n" . $this->body() ); |
|
183 | + public function build() { |
|
184 | + return \Filter::with('core.email.source', $this->head()."\r\n".$this->body()); |
|
185 | 185 | } |
186 | 186 | |
187 | 187 | } |
@@ -27,27 +27,43 @@ discard block |
||
27 | 27 | $compiled_head, |
28 | 28 | $compiled_body; |
29 | 29 | |
30 | - public function __construct($email=null){ |
|
30 | + public function __construct($email=null) { |
|
31 | 31 | if ($email) { |
32 | 32 | $email = (object)$email; |
33 | - if(isset($email->to)) $this->to($email->to); |
|
34 | - if(isset($email->from)) $this->from($email->from); |
|
35 | - if(isset($email->cc)) $this->cc($email->cc); |
|
36 | - if(isset($email->bcc)) $this->bcc($email->bcc); |
|
37 | - if(isset($email->replyTo)) $this->replyTo($email->replyTo); |
|
38 | - if(isset($email->subject)) $this->subject($email->subject); |
|
39 | - if(isset($email->message)) $this->message($email->message); |
|
40 | - if(isset($email->attachments)) $this->attach($email->attachments); |
|
33 | + if(isset($email->to)) { |
|
34 | + $this->to($email->to); |
|
35 | + } |
|
36 | + if(isset($email->from)) { |
|
37 | + $this->from($email->from); |
|
38 | + } |
|
39 | + if(isset($email->cc)) { |
|
40 | + $this->cc($email->cc); |
|
41 | + } |
|
42 | + if(isset($email->bcc)) { |
|
43 | + $this->bcc($email->bcc); |
|
44 | + } |
|
45 | + if(isset($email->replyTo)) { |
|
46 | + $this->replyTo($email->replyTo); |
|
47 | + } |
|
48 | + if(isset($email->subject)) { |
|
49 | + $this->subject($email->subject); |
|
50 | + } |
|
51 | + if(isset($email->message)) { |
|
52 | + $this->message($email->message); |
|
53 | + } |
|
54 | + if(isset($email->attachments)) { |
|
55 | + $this->attach($email->attachments); |
|
56 | + } |
|
41 | 57 | } |
42 | 58 | $this->uid = '_CORE_'.md5(uniqid(time())); |
43 | 59 | |
44 | 60 | } |
45 | 61 | |
46 | - protected function add_emails(&$pool, $emails, $append=true){ |
|
62 | + protected function add_emails(&$pool, $emails, $append=true) { |
|
47 | 63 | $this->compiled_head = null; |
48 | 64 | foreach ((array)$emails as $values) { |
49 | 65 | foreach(preg_split('/\s*,\s*/',$values) as $value) { |
50 | - if(strpos($value,'<')!==false){ |
|
66 | + if(strpos($value,'<')!==false) { |
|
51 | 67 | $value = str_replace('>','',$value); |
52 | 68 | $parts = explode('<',$value,2); |
53 | 69 | $name = trim(current($parts)); |
@@ -56,88 +72,120 @@ discard block |
||
56 | 72 | } else { |
57 | 73 | $address = $value; |
58 | 74 | } |
59 | - if ($append) $pool[] = $address; else $pool = $address; |
|
75 | + if ($append) { |
|
76 | + $pool[] = $address; |
|
77 | + } else { |
|
78 | + $pool = $address; |
|
79 | + } |
|
60 | 80 | } |
61 | 81 | } |
62 | 82 | } |
63 | 83 | |
64 | - public function from($value=null){ |
|
84 | + public function from($value=null) { |
|
65 | 85 | if ($value!==null && $value) { |
66 | 86 | $this->add_emails($this->from, $value, false); |
67 | - } else if ($value===false) $this->from = ''; |
|
87 | + } else if ($value===false) { |
|
88 | + $this->from = ''; |
|
89 | + } |
|
68 | 90 | return $this->from; |
69 | 91 | } |
70 | 92 | |
71 | - public function to($value=null){ |
|
93 | + public function to($value=null) { |
|
72 | 94 | if ($value!==null && $value) { |
73 | 95 | $this->add_emails($this->to, $value); |
74 | - } else if ($value===false) $this->to = []; |
|
96 | + } else if ($value===false) { |
|
97 | + $this->to = []; |
|
98 | + } |
|
75 | 99 | return $this->to; |
76 | 100 | } |
77 | 101 | |
78 | - public function cc($value=null){ |
|
102 | + public function cc($value=null) { |
|
79 | 103 | if ($value!==null && $value) { |
80 | 104 | $this->add_emails($this->cc, $value); |
81 | - } else if ($value===false) $this->cc = []; |
|
105 | + } else if ($value===false) { |
|
106 | + $this->cc = []; |
|
107 | + } |
|
82 | 108 | return $this->cc; |
83 | 109 | } |
84 | 110 | |
85 | - public function bcc($value=null){ |
|
111 | + public function bcc($value=null) { |
|
86 | 112 | if ($value!==null && $value) { |
87 | 113 | $this->add_emails($this->bcc, $value); |
88 | - } else if ($value===false) $this->bcc = []; |
|
114 | + } else if ($value===false) { |
|
115 | + $this->bcc = []; |
|
116 | + } |
|
89 | 117 | return $this->bcc; |
90 | 118 | } |
91 | 119 | |
92 | - public function replyTo($value=null){ |
|
120 | + public function replyTo($value=null) { |
|
93 | 121 | if ($value!==null && $value) { |
94 | 122 | $this->add_emails($this->replyTo, $value, false); |
95 | - } else if ($value===false) $this->replyTo = ''; |
|
123 | + } else if ($value===false) { |
|
124 | + $this->replyTo = ''; |
|
125 | + } |
|
96 | 126 | return $this->replyTo; |
97 | 127 | } |
98 | 128 | |
99 | - public function subject($value=null){ |
|
129 | + public function subject($value=null) { |
|
100 | 130 | if ($value!==null && $value) { |
101 | 131 | $this->compiled_head = null; |
102 | 132 | $this->subject = $value; |
103 | - } else if ($value===false) $this->subject = ''; |
|
133 | + } else if ($value===false) { |
|
134 | + $this->subject = ''; |
|
135 | + } |
|
104 | 136 | return $this->subject; |
105 | 137 | } |
106 | 138 | |
107 | - public function contentType($value=null){ |
|
139 | + public function contentType($value=null) { |
|
108 | 140 | if ($value!==null && $value) { |
109 | 141 | $this->compiled_body = null; |
110 | 142 | $this->contentType = $value; |
111 | - } else if ($value===false) $this->contentType = ''; |
|
143 | + } else if ($value===false) { |
|
144 | + $this->contentType = ''; |
|
145 | + } |
|
112 | 146 | return $this->contentType; |
113 | 147 | } |
114 | 148 | |
115 | - public function message($value=null){ |
|
149 | + public function message($value=null) { |
|
116 | 150 | if ($value!==null && $value) { |
117 | 151 | $this->compiled_body = null; |
118 | 152 | $this->message = $value; |
119 | - } else if ($value===false) $this->message = ''; |
|
153 | + } else if ($value===false) { |
|
154 | + $this->message = ''; |
|
155 | + } |
|
120 | 156 | return $this->message; |
121 | 157 | } |
122 | 158 | |
123 | - public function attach($file){ |
|
159 | + public function attach($file) { |
|
124 | 160 | $this->compiled_body = null; |
125 | 161 | if (isset($file->content) || isset($file['content'])) { |
126 | 162 | $this->attachments[] = $file; |
127 | - } else foreach ((array)$file as $curfile) { |
|
163 | + } else { |
|
164 | + foreach ((array)$file as $curfile) { |
|
128 | 165 | $this->attachments[] = $curfile; |
129 | 166 | } |
167 | + } |
|
130 | 168 | } |
131 | 169 | |
132 | - public function head($recompile = false){ |
|
133 | - if ($recompile || (null === $this->compiled_head)){ |
|
170 | + public function head($recompile = false) { |
|
171 | + if ($recompile || (null === $this->compiled_head)) { |
|
134 | 172 | $head = []; |
135 | 173 | $head[] = "Subject: {$this->subject}"; |
136 | - if($this->from) $head[] = "From: {$this->from}"; |
|
137 | - if(is_array($this->to) && !empty($this->to)) $head[] = "To: " . implode(', ',$this->to); |
|
138 | - if(is_array($this->cc) && !empty($this->cc)) $head[] = "Cc: " . implode(', ',$this->cc); |
|
139 | - if(is_array($this->bcc) && !empty($this->bcc)) $head[] = "Bcc: " . implode(', ',$this->bcc); |
|
140 | - if($this->replyTo) $head[] = "Reply-To: {$this->replyTo}"; |
|
174 | + if($this->from) { |
|
175 | + $head[] = "From: {$this->from}"; |
|
176 | + } |
|
177 | + if(is_array($this->to) && !empty($this->to)) { |
|
178 | + $head[] = "To: " . implode(', ',$this->to); |
|
179 | + } |
|
180 | + if(is_array($this->cc) && !empty($this->cc)) { |
|
181 | + $head[] = "Cc: " . implode(', ',$this->cc); |
|
182 | + } |
|
183 | + if(is_array($this->bcc) && !empty($this->bcc)) { |
|
184 | + $head[] = "Bcc: " . implode(', ',$this->bcc); |
|
185 | + } |
|
186 | + if($this->replyTo) { |
|
187 | + $head[] = "Reply-To: {$this->replyTo}"; |
|
188 | + } |
|
141 | 189 | $head[] = 'MIME-Version: 1.0'; |
142 | 190 | $head[] = "Content-Type: multipart/mixed; boundary=\"{$this->uid}\""; |
143 | 191 | $this->compiled_head = implode("\r\n", $head); |
@@ -145,8 +193,8 @@ discard block |
||
145 | 193 | return \Filter::with( 'core.email.source.head', $this->compiled_head); |
146 | 194 | } |
147 | 195 | |
148 | - public function body($recompile = false){ |
|
149 | - if ($recompile || (null === $this->compiled_body)){ |
|
196 | + public function body($recompile = false) { |
|
197 | + if ($recompile || (null === $this->compiled_body)) { |
|
150 | 198 | $body[] = "--{$this->uid}"; |
151 | 199 | $body[] = "Content-Type: {$this->contentType}"; |
152 | 200 | $body[] = "Content-Transfer-Encoding: quoted-printable"; |
@@ -154,10 +202,12 @@ discard block |
||
154 | 202 | $body[] = quoted_printable_encode($this->message); |
155 | 203 | $body[] = ''; |
156 | 204 | |
157 | - if (!empty($this->attachments)) foreach ((array)$this->attachments as $file) { |
|
205 | + if (!empty($this->attachments)) { |
|
206 | + foreach ((array)$this->attachments as $file) { |
|
158 | 207 | |
159 | 208 | if (is_string($file)) { |
160 | 209 | $name = basename($file); |
210 | + } |
|
161 | 211 | $data = file_get_contents($file); |
162 | 212 | } else { |
163 | 213 | $name = isset($file['name']) ? $file['name'] : 'untitled'; |
@@ -180,7 +230,7 @@ discard block |
||
180 | 230 | return \Filter::with( 'core.email.source.body', $this->compiled_body); |
181 | 231 | } |
182 | 232 | |
183 | - public function build(){ |
|
233 | + public function build() { |
|
184 | 234 | return \Filter::with( 'core.email.source', $this->head() . "\r\n" . $this->body() ); |
185 | 235 | } |
186 | 236 |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | $options = (object)$options; |
19 | 19 | $region = isset($options->region) ? $options->region : 'eu-west-1'; |
20 | 20 | if (empty($options->username) || empty($options->password)) |
21 | - throw new \Exception("[core.email.ses] You must provide an Amazon SES SMTP username and password", 1); |
|
21 | + throw new \Exception("[core.email.ses] You must provide an Amazon SES SMTP username and password", 1); |
|
22 | 22 | |
23 | 23 | Smtp::onInit([ |
24 | 24 | 'host' => "email-smtp.{$region}.amazonaws.com", |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | |
33 | 33 | public function onSend(Envelope $envelope){ |
34 | 34 | if (!$envelope->from()) |
35 | - throw new \Exception("[core.email.ses] Amazon SES needs a registered `from` address", 1); |
|
35 | + throw new \Exception("[core.email.ses] Amazon SES needs a registered `from` address", 1); |
|
36 | 36 | return Smtp::onSend($envelope); |
37 | 37 | } |
38 | 38 |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | class Ses extends Smtp { |
16 | 16 | |
17 | 17 | public function onInit($options) { |
18 | - $options = (object)$options; |
|
18 | + $options = (object) $options; |
|
19 | 19 | $region = isset($options->region) ? $options->region : 'eu-west-1'; |
20 | 20 | if (empty($options->username) || empty($options->password)) |
21 | 21 | throw new \Exception("[core.email.ses] You must provide an Amazon SES SMTP username and password", 1); |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | |
31 | 31 | } |
32 | 32 | |
33 | - public function onSend(Envelope $envelope){ |
|
33 | + public function onSend(Envelope $envelope) { |
|
34 | 34 | if (!$envelope->from()) |
35 | 35 | throw new \Exception("[core.email.ses] Amazon SES needs a registered `from` address", 1); |
36 | 36 | return Smtp::onSend($envelope); |
@@ -17,8 +17,9 @@ discard block |
||
17 | 17 | public function onInit($options) { |
18 | 18 | $options = (object)$options; |
19 | 19 | $region = isset($options->region) ? $options->region : 'eu-west-1'; |
20 | - if (empty($options->username) || empty($options->password)) |
|
21 | - throw new \Exception("[core.email.ses] You must provide an Amazon SES SMTP username and password", 1); |
|
20 | + if (empty($options->username) || empty($options->password)) { |
|
21 | + throw new \Exception("[core.email.ses] You must provide an Amazon SES SMTP username and password", 1); |
|
22 | + } |
|
22 | 23 | |
23 | 24 | Smtp::onInit([ |
24 | 25 | 'host' => "email-smtp.{$region}.amazonaws.com", |
@@ -30,9 +31,10 @@ discard block |
||
30 | 31 | |
31 | 32 | } |
32 | 33 | |
33 | - public function onSend(Envelope $envelope){ |
|
34 | - if (!$envelope->from()) |
|
35 | - throw new \Exception("[core.email.ses] Amazon SES needs a registered `from` address", 1); |
|
34 | + public function onSend(Envelope $envelope) { |
|
35 | + if (!$envelope->from()) { |
|
36 | + throw new \Exception("[core.email.ses] Amazon SES needs a registered `from` address", 1); |
|
37 | + } |
|
36 | 38 | return Smtp::onSend($envelope); |
37 | 39 | } |
38 | 40 |
@@ -29,11 +29,11 @@ discard block |
||
29 | 29 | * @param mixed $default (optional) The default value. If is a callable it will executed and the return value will be used. |
30 | 30 | * @return mixed The value of the key or the default (resolved) value if the key not existed. |
31 | 31 | */ |
32 | - public function get($key, $default=null){ |
|
33 | - if ($ptr =& static::find($key,false)){ |
|
32 | + public function get($key, $default = null) { |
|
33 | + if ($ptr = & static::find($key, false)) { |
|
34 | 34 | return $ptr; |
35 | 35 | } else { |
36 | - if ($default !== null){ |
|
36 | + if ($default !== null) { |
|
37 | 37 | return static::set($key, is_callable($default) ? call_user_func($default) : $default); |
38 | 38 | } else { |
39 | 39 | return null; |
@@ -47,11 +47,11 @@ discard block |
||
47 | 47 | * @param mixed $value (optional) The value. If is a callable it will executed and the return value will be used. |
48 | 48 | * @return mixed The value of the key or the default (resolved) value if the key not existed. |
49 | 49 | */ |
50 | - public function set($key, $value=null){ |
|
50 | + public function set($key, $value = null) { |
|
51 | 51 | if (is_array($key)) { |
52 | 52 | return static::merge($key); |
53 | 53 | } else { |
54 | - $ptr = & static::find($key,true); |
|
54 | + $ptr = & static::find($key, true); |
|
55 | 55 | return $ptr = $value; |
56 | 56 | } |
57 | 57 | } |
@@ -61,8 +61,8 @@ discard block |
||
61 | 61 | * @param string $key The key path in dot notation |
62 | 62 | * @param boolean $compact (optional) Compact map removing empty paths. |
63 | 63 | */ |
64 | - public function delete($key, $compact=true){ |
|
65 | - static::set($key,null); |
|
64 | + public function delete($key, $compact = true) { |
|
65 | + static::set($key, null); |
|
66 | 66 | if ($compact) static::compact(); |
67 | 67 | } |
68 | 68 | |
@@ -71,18 +71,18 @@ discard block |
||
71 | 71 | * @param string $key The key path in dot notation |
72 | 72 | * @return boolean |
73 | 73 | */ |
74 | - public function exists($key){ |
|
75 | - return null !== static::find($key,false); |
|
74 | + public function exists($key) { |
|
75 | + return null !== static::find($key, false); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
79 | 79 | * Clear all key path in map. |
80 | 80 | */ |
81 | - public function clear(){ |
|
81 | + public function clear() { |
|
82 | 82 | $this->fields = []; |
83 | 83 | } |
84 | 84 | |
85 | - public function __construct($fields=null){ |
|
85 | + public function __construct($fields = null) { |
|
86 | 86 | $this->load($fields); |
87 | 87 | } |
88 | 88 | |
@@ -90,8 +90,8 @@ discard block |
||
90 | 90 | * Load an associative array/object as the map source. |
91 | 91 | * @param string $fields The array to merge |
92 | 92 | */ |
93 | - public function load($fields){ |
|
94 | - if ($fields) $this->fields = (array)$fields; |
|
93 | + public function load($fields) { |
|
94 | + if ($fields) $this->fields = (array) $fields; |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | * @param array $array The array to merge |
100 | 100 | * @param boolean $merge_back If `true` merge the map over the $array, if `false` (default) the reverse. |
101 | 101 | */ |
102 | - public function merge(array $array, $merge_back=false){ |
|
102 | + public function merge(array $array, $merge_back = false) { |
|
103 | 103 | $this->fields = $merge_back |
104 | 104 | ? array_replace_recursive($array, $this->fields) |
105 | 105 | : array_replace_recursive($this->fields, $array); |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | /** |
109 | 109 | * Compact map removing empty paths |
110 | 110 | */ |
111 | - public function compact(){ |
|
111 | + public function compact() { |
|
112 | 112 | function array_filter_rec($input, $callback = null) { |
113 | 113 | foreach ($input as &$value) { |
114 | 114 | if (is_array($value)) { |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | return array_filter($input, $callback); |
119 | 119 | } |
120 | 120 | |
121 | - $this->fields = array_filter_rec($this->fields,function($a){ return $a !== null; }); |
|
121 | + $this->fields = array_filter_rec($this->fields, function($a) { return $a !== null;}); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | /** |
@@ -128,15 +128,15 @@ discard block |
||
128 | 128 | * @param callable If passed this callback will be applied to the founded value. |
129 | 129 | * @return mixed The founded value. |
130 | 130 | */ |
131 | - public function & find($path, $create=false, callable $operation=null) { |
|
132 | - $tok = strtok($path,'.'); |
|
133 | - if($create){ |
|
134 | - $value =& $this->fields; |
|
131 | + public function & find($path, $create = false, callable $operation = null) { |
|
132 | + $tok = strtok($path, '.'); |
|
133 | + if ($create) { |
|
134 | + $value = & $this->fields; |
|
135 | 135 | } else { |
136 | 136 | $value = $this->fields; |
137 | 137 | } |
138 | - while($tok !== false){ |
|
139 | - $value =& $value[$tok]; |
|
138 | + while ($tok !== false) { |
|
139 | + $value = & $value[$tok]; |
|
140 | 140 | $tok = strtok('.'); |
141 | 141 | } |
142 | 142 | if (is_callable($operation)) $operation($value); |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | * |
151 | 151 | * @return string The json object |
152 | 152 | */ |
153 | - public function jsonSerialize(){ |
|
153 | + public function jsonSerialize() { |
|
154 | 154 | return $this->fields; |
155 | 155 | } |
156 | 156 |
@@ -29,11 +29,11 @@ discard block |
||
29 | 29 | * @param mixed $default (optional) The default value. If is a callable it will executed and the return value will be used. |
30 | 30 | * @return mixed The value of the key or the default (resolved) value if the key not existed. |
31 | 31 | */ |
32 | - public function get($key, $default=null){ |
|
33 | - if ($ptr =& static::find($key,false)){ |
|
32 | + public function get($key, $default=null) { |
|
33 | + if ($ptr =& static::find($key,false)) { |
|
34 | 34 | return $ptr; |
35 | 35 | } else { |
36 | - if ($default !== null){ |
|
36 | + if ($default !== null) { |
|
37 | 37 | return static::set($key, is_callable($default) ? call_user_func($default) : $default); |
38 | 38 | } else { |
39 | 39 | return null; |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | * @param mixed $value (optional) The value. If is a callable it will executed and the return value will be used. |
48 | 48 | * @return mixed The value of the key or the default (resolved) value if the key not existed. |
49 | 49 | */ |
50 | - public function set($key, $value=null){ |
|
50 | + public function set($key, $value=null) { |
|
51 | 51 | if (is_array($key)) { |
52 | 52 | return static::merge($key); |
53 | 53 | } else { |
@@ -61,9 +61,11 @@ discard block |
||
61 | 61 | * @param string $key The key path in dot notation |
62 | 62 | * @param boolean $compact (optional) Compact map removing empty paths. |
63 | 63 | */ |
64 | - public function delete($key, $compact=true){ |
|
64 | + public function delete($key, $compact=true) { |
|
65 | 65 | static::set($key,null); |
66 | - if ($compact) static::compact(); |
|
66 | + if ($compact) { |
|
67 | + static::compact(); |
|
68 | + } |
|
67 | 69 | } |
68 | 70 | |
69 | 71 | /** |
@@ -71,18 +73,18 @@ discard block |
||
71 | 73 | * @param string $key The key path in dot notation |
72 | 74 | * @return boolean |
73 | 75 | */ |
74 | - public function exists($key){ |
|
76 | + public function exists($key) { |
|
75 | 77 | return null !== static::find($key,false); |
76 | 78 | } |
77 | 79 | |
78 | 80 | /** |
79 | 81 | * Clear all key path in map. |
80 | 82 | */ |
81 | - public function clear(){ |
|
83 | + public function clear() { |
|
82 | 84 | $this->fields = []; |
83 | 85 | } |
84 | 86 | |
85 | - public function __construct($fields=null){ |
|
87 | + public function __construct($fields=null) { |
|
86 | 88 | $this->load($fields); |
87 | 89 | } |
88 | 90 | |
@@ -90,8 +92,10 @@ discard block |
||
90 | 92 | * Load an associative array/object as the map source. |
91 | 93 | * @param string $fields The array to merge |
92 | 94 | */ |
93 | - public function load($fields){ |
|
94 | - if ($fields) $this->fields = (array)$fields; |
|
95 | + public function load($fields) { |
|
96 | + if ($fields) { |
|
97 | + $this->fields = (array)$fields; |
|
98 | + } |
|
95 | 99 | } |
96 | 100 | |
97 | 101 | /** |
@@ -99,7 +103,7 @@ discard block |
||
99 | 103 | * @param array $array The array to merge |
100 | 104 | * @param boolean $merge_back If `true` merge the map over the $array, if `false` (default) the reverse. |
101 | 105 | */ |
102 | - public function merge(array $array, $merge_back=false){ |
|
106 | + public function merge(array $array, $merge_back=false) { |
|
103 | 107 | $this->fields = $merge_back |
104 | 108 | ? array_replace_recursive($array, $this->fields) |
105 | 109 | : array_replace_recursive($this->fields, $array); |
@@ -108,7 +112,7 @@ discard block |
||
108 | 112 | /** |
109 | 113 | * Compact map removing empty paths |
110 | 114 | */ |
111 | - public function compact(){ |
|
115 | + public function compact() { |
|
112 | 116 | function array_filter_rec($input, $callback = null) { |
113 | 117 | foreach ($input as &$value) { |
114 | 118 | if (is_array($value)) { |
@@ -130,16 +134,18 @@ discard block |
||
130 | 134 | */ |
131 | 135 | public function & find($path, $create=false, callable $operation=null) { |
132 | 136 | $tok = strtok($path,'.'); |
133 | - if($create){ |
|
137 | + if($create) { |
|
134 | 138 | $value =& $this->fields; |
135 | 139 | } else { |
136 | 140 | $value = $this->fields; |
137 | 141 | } |
138 | - while($tok !== false){ |
|
142 | + while($tok !== false) { |
|
139 | 143 | $value =& $value[$tok]; |
140 | 144 | $tok = strtok('.'); |
141 | 145 | } |
142 | - if (is_callable($operation)) $operation($value); |
|
146 | + if (is_callable($operation)) { |
|
147 | + $operation($value); |
|
148 | + } |
|
143 | 149 | return $value; |
144 | 150 | } |
145 | 151 | |
@@ -150,7 +156,7 @@ discard block |
||
150 | 156 | * |
151 | 157 | * @return string The json object |
152 | 158 | */ |
153 | - public function jsonSerialize(){ |
|
159 | + public function jsonSerialize() { |
|
154 | 160 | return $this->fields; |
155 | 161 | } |
156 | 162 |
@@ -22,11 +22,11 @@ |
||
22 | 22 | } |
23 | 23 | |
24 | 24 | public static function unmount($alias) { |
25 | - unset(static::$mount_points[$alias]); |
|
25 | + unset(static::$mount_points[$alias]); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | public static function mounts() { |
29 | - return array_keys(static::$mount_points); |
|
29 | + return array_keys(static::$mount_points); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | public static function __callStatic($name, $params) { |
@@ -31,22 +31,22 @@ discard block |
||
31 | 31 | |
32 | 32 | public static function __callStatic($name, $params) { |
33 | 33 | $uri = array_shift($params); |
34 | - if ($file_location = static::locate($uri)){ |
|
34 | + if ($file_location = static::locate($uri)) { |
|
35 | 35 | list($mount, $path) = $file_location; |
36 | 36 | array_unshift($params, static::resolvePath($path)); |
37 | 37 | if (empty(static::$mount_points[$mount])) return false; |
38 | - return call_user_func_array([static::$mount_points[$mount],$name],$params); |
|
38 | + return call_user_func_array([static::$mount_points[$mount], $name], $params); |
|
39 | 39 | } else return false; |
40 | 40 | } |
41 | 41 | |
42 | 42 | public static function locate($path) { |
43 | - if (strpos($path,'://')!==false) { |
|
44 | - list($mount, $filepath) = explode('://',$path,2); |
|
43 | + if (strpos($path, '://') !== false) { |
|
44 | + list($mount, $filepath) = explode('://', $path, 2); |
|
45 | 45 | $filepath = static::resolvePath($filepath); |
46 | 46 | return isset(static::$mount_points[$mount]) ? [$mount, $filepath] : false; |
47 | 47 | } else { |
48 | 48 | $path = static::resolvePath($path); |
49 | - foreach(static::$mount_points as $mount => $fs){ |
|
49 | + foreach (static::$mount_points as $mount => $fs) { |
|
50 | 50 | if ($fs->exists($path)) return [$mount, $path]; |
51 | 51 | } |
52 | 52 | return false; |
@@ -65,13 +65,13 @@ discard block |
||
65 | 65 | $absolutes[] = $part; |
66 | 66 | } |
67 | 67 | } |
68 | - return trim(implode('/', $absolutes),'/'); |
|
68 | + return trim(implode('/', $absolutes), '/'); |
|
69 | 69 | } |
70 | 70 | |
71 | - public static function search($pattern, $recursive=true){ |
|
71 | + public static function search($pattern, $recursive = true) { |
|
72 | 72 | $results = []; |
73 | 73 | foreach (static::$mount_points as $mount => $fs) { |
74 | - foreach($fs->search($pattern, $recursive) as $path) { |
|
74 | + foreach ($fs->search($pattern, $recursive) as $path) { |
|
75 | 75 | $results[] = $mount.'://'.$path; |
76 | 76 | } |
77 | 77 | } |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | } |
80 | 80 | |
81 | 81 | |
82 | - public static function move($old,$new) { |
|
82 | + public static function move($old, $new) { |
|
83 | 83 | $src = static::locate($old); |
84 | 84 | $dest = static::locate($new); |
85 | 85 | if ($src && $dest) { |
@@ -87,9 +87,9 @@ discard block |
||
87 | 87 | $_dfs = static::$mount_points[$dest[0]]; |
88 | 88 | if ($src[0] == $dest[0]) { |
89 | 89 | // Same filesystem |
90 | - return $_sfs->move($src[1],$dest[1]); |
|
90 | + return $_sfs->move($src[1], $dest[1]); |
|
91 | 91 | } else { |
92 | - return $_dfs->write($dest[1],$_sfs->read($src[1])) && $_sfs->delete($src[1]); |
|
92 | + return $_dfs->write($dest[1], $_sfs->read($src[1])) && $_sfs->delete($src[1]); |
|
93 | 93 | } |
94 | 94 | } else return false; |
95 | 95 | } |
@@ -17,7 +17,9 @@ discard block |
||
17 | 17 | |
18 | 18 | public static function mount($alias, $driver, $options = null) { |
19 | 19 | $driver_class = '\\FileSystem\\'.ucfirst(strtolower($driver)); |
20 | - if (!class_exists($driver_class)) throw new \Exception('Filesystem adapter '.$driver.' not found.'); |
|
20 | + if (!class_exists($driver_class)) { |
|
21 | + throw new \Exception('Filesystem adapter '.$driver.' not found.'); |
|
22 | + } |
|
21 | 23 | static::$mount_points[$alias] = new $driver_class($options); |
22 | 24 | } |
23 | 25 | |
@@ -31,12 +33,16 @@ discard block |
||
31 | 33 | |
32 | 34 | public static function __callStatic($name, $params) { |
33 | 35 | $uri = array_shift($params); |
34 | - if ($file_location = static::locate($uri)){ |
|
36 | + if ($file_location = static::locate($uri)) { |
|
35 | 37 | list($mount, $path) = $file_location; |
36 | 38 | array_unshift($params, static::resolvePath($path)); |
37 | - if (empty(static::$mount_points[$mount])) return false; |
|
39 | + if (empty(static::$mount_points[$mount])) { |
|
40 | + return false; |
|
41 | + } |
|
38 | 42 | return call_user_func_array([static::$mount_points[$mount],$name],$params); |
39 | - } else return false; |
|
43 | + } else { |
|
44 | + return false; |
|
45 | + } |
|
40 | 46 | } |
41 | 47 | |
42 | 48 | public static function locate($path) { |
@@ -46,8 +52,10 @@ discard block |
||
46 | 52 | return isset(static::$mount_points[$mount]) ? [$mount, $filepath] : false; |
47 | 53 | } else { |
48 | 54 | $path = static::resolvePath($path); |
49 | - foreach(static::$mount_points as $mount => $fs){ |
|
50 | - if ($fs->exists($path)) return [$mount, $path]; |
|
55 | + foreach(static::$mount_points as $mount => $fs) { |
|
56 | + if ($fs->exists($path)) { |
|
57 | + return [$mount, $path]; |
|
58 | + } |
|
51 | 59 | } |
52 | 60 | return false; |
53 | 61 | } |
@@ -58,7 +66,9 @@ discard block |
||
58 | 66 | $parts = array_filter(explode('/', $path), 'strlen'); |
59 | 67 | $absolutes = []; |
60 | 68 | foreach ($parts as $part) { |
61 | - if ('.' == $part) continue; |
|
69 | + if ('.' == $part) { |
|
70 | + continue; |
|
71 | + } |
|
62 | 72 | if ('..' == $part) { |
63 | 73 | array_pop($absolutes); |
64 | 74 | } else { |
@@ -68,7 +78,7 @@ discard block |
||
68 | 78 | return trim(implode('/', $absolutes),'/'); |
69 | 79 | } |
70 | 80 | |
71 | - public static function search($pattern, $recursive=true){ |
|
81 | + public static function search($pattern, $recursive=true) { |
|
72 | 82 | $results = []; |
73 | 83 | foreach (static::$mount_points as $mount => $fs) { |
74 | 84 | foreach($fs->search($pattern, $recursive) as $path) { |
@@ -91,7 +101,9 @@ discard block |
||
91 | 101 | } else { |
92 | 102 | return $_dfs->write($dest[1],$_sfs->read($src[1])) && $_sfs->delete($src[1]); |
93 | 103 | } |
94 | - } else return false; |
|
104 | + } else { |
|
105 | + return false; |
|
106 | + } |
|
95 | 107 | } |
96 | 108 | |
97 | 109 |