@@ -56,15 +56,15 @@ discard block |
||
| 56 | 56 | |
| 57 | 57 | $email = $this->renderer->render($message); |
| 58 | 58 | |
| 59 | - if ($email->getFrom() === []) { |
|
| 59 | + if ($email->getFrom() === []){ |
|
| 60 | 60 | $email->from(Address::create($this->config->getFromAddress())); |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | $recipients = $this->getRecipients($email); |
| 64 | 64 | |
| 65 | - try { |
|
| 65 | + try{ |
|
| 66 | 66 | $this->mailer->send($email); |
| 67 | - } catch (TransportExceptionInterface $e) { |
|
| 67 | + }catch (TransportExceptionInterface $e){ |
|
| 68 | 68 | $this->getLogger()->error( |
| 69 | 69 | sprintf( |
| 70 | 70 | 'Failed to send `%s` to "%s": %s', |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | |
| 99 | 99 | $addresses = array_merge($message->getTo(), $message->getCc(), $message->getBcc()); |
| 100 | 100 | |
| 101 | - foreach ($addresses as $address) { |
|
| 101 | + foreach ($addresses as $address){ |
|
| 102 | 102 | $emails[] = $address->toString(); |
| 103 | 103 | } |
| 104 | 104 | |
@@ -56,15 +56,19 @@ discard block |
||
| 56 | 56 | |
| 57 | 57 | $email = $this->renderer->render($message); |
| 58 | 58 | |
| 59 | - if ($email->getFrom() === []) { |
|
| 59 | + if ($email->getFrom() === []) |
|
| 60 | + { |
|
| 60 | 61 | $email->from(Address::create($this->config->getFromAddress())); |
| 61 | 62 | } |
| 62 | 63 | |
| 63 | 64 | $recipients = $this->getRecipients($email); |
| 64 | 65 | |
| 65 | - try { |
|
| 66 | + try |
|
| 67 | + { |
|
| 66 | 68 | $this->mailer->send($email); |
| 67 | - } catch (TransportExceptionInterface $e) { |
|
| 69 | + } |
|
| 70 | + catch (TransportExceptionInterface $e) |
|
| 71 | + { |
|
| 68 | 72 | $this->getLogger()->error( |
| 69 | 73 | sprintf( |
| 70 | 74 | 'Failed to send `%s` to "%s": %s', |
@@ -98,7 +102,8 @@ discard block |
||
| 98 | 102 | |
| 99 | 103 | $addresses = array_merge($message->getTo(), $message->getCc(), $message->getBcc()); |
| 100 | 104 | |
| 101 | - foreach ($addresses as $address) { |
|
| 105 | + foreach ($addresses as $address) |
|
| 106 | + { |
|
| 102 | 107 | $emails[] = $address->toString(); |
| 103 | 108 | } |
| 104 | 109 | |
@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | */ |
| 8 | 8 | $_msg_->subject(\Spiral\SendIt\Renderer\ViewRenderer::escapeSubject(inject('subject'))); |
| 9 | 9 | |
| 10 | -if (injected('from')) { |
|
| 10 | +if (injected('from')){ |
|
| 11 | 11 | $_msg_->from(\Symfony\Component\Mime\Address::create(inject('from'))); |
| 12 | 12 | } |
| 13 | 13 | |
@@ -19,13 +19,13 @@ discard block |
||
| 19 | 19 | |
| 20 | 20 | ob_start(); ?>${html}<?php $_html_ = ob_get_clean(); |
| 21 | 21 | |
| 22 | -if (!empty($_html_)) { |
|
| 22 | +if (!empty($_html_)){ |
|
| 23 | 23 | $_msg_->html($_html_); |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | ob_start(); ?>${text}<?php $_text_ = ob_get_clean(); |
| 27 | 27 | |
| 28 | -if (!empty($_text_)) { |
|
| 28 | +if (!empty($_text_)){ |
|
| 29 | 29 | $_msg_->text($_text_); |
| 30 | 30 | } |
| 31 | 31 | ?> |
@@ -7,7 +7,8 @@ discard block |
||
| 7 | 7 | */ |
| 8 | 8 | $_msg_->subject(\Spiral\SendIt\Renderer\ViewRenderer::escapeSubject(inject('subject'))); |
| 9 | 9 | |
| 10 | -if (injected('from')) { |
|
| 10 | +if (injected('from')) |
|
| 11 | +{ |
|
| 11 | 12 | $_msg_->from(\Symfony\Component\Mime\Address::create(inject('from'))); |
| 12 | 13 | } |
| 13 | 14 | |
@@ -19,13 +20,15 @@ discard block |
||
| 19 | 20 | |
| 20 | 21 | ob_start(); ?>${html}<?php $_html_ = ob_get_clean(); |
| 21 | 22 | |
| 22 | -if (!empty($_html_)) { |
|
| 23 | +if (!empty($_html_)) |
|
| 24 | +{ |
|
| 23 | 25 | $_msg_->html($_html_); |
| 24 | 26 | } |
| 25 | 27 | |
| 26 | 28 | ob_start(); ?>${text}<?php $_text_ = ob_get_clean(); |
| 27 | 29 | |
| 28 | -if (!empty($_text_)) { |
|
| 30 | +if (!empty($_text_)) |
|
| 31 | +{ |
|
| 29 | 32 | $_msg_->text($_text_); |
| 30 | 33 | } |
| 31 | 34 | ?> |
@@ -7,4 +7,4 @@ |
||
| 7 | 7 | * @author Anton Titov (Wolfy-J) |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -return ; |
|
| 10 | +return; |
|
@@ -38,17 +38,17 @@ discard block |
||
| 38 | 38 | */ |
| 39 | 39 | public function instantiate(\ReflectionClass $attr, array $arguments, string $context): object |
| 40 | 40 | { |
| 41 | - if ($this->isNamedArgumentsSupported()) { |
|
| 42 | - try { |
|
| 41 | + if ($this->isNamedArgumentsSupported()){ |
|
| 42 | + try{ |
|
| 43 | 43 | return $attr->newInstanceArgs($arguments); |
| 44 | - } catch (\Throwable $e) { |
|
| 44 | + }catch (\Throwable $e){ |
|
| 45 | 45 | throw Exception::withLocation($e, $attr->getFileName(), $attr->getStartLine()); |
| 46 | 46 | } |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | $constructor = $this->getConstructor($attr); |
| 50 | 50 | |
| 51 | - if ($constructor === null) { |
|
| 51 | + if ($constructor === null){ |
|
| 52 | 52 | return $attr->newInstanceWithoutConstructor(); |
| 53 | 53 | } |
| 54 | 54 | |
@@ -76,16 +76,16 @@ discard block |
||
| 76 | 76 | { |
| 77 | 77 | $passed = []; |
| 78 | 78 | |
| 79 | - try { |
|
| 80 | - foreach ($constructor->getParameters() as $parameter) { |
|
| 79 | + try{ |
|
| 80 | + foreach ($constructor->getParameters() as $parameter){ |
|
| 81 | 81 | $passed[] = $this->resolveParameter($ctx, $parameter, $arguments); |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | - if (\count($arguments)) { |
|
| 84 | + if (\count($arguments)){ |
|
| 85 | 85 | $message = \sprintf(self::ERROR_UNKNOWN_ARGUMENT, \array_key_first($arguments)); |
| 86 | 86 | throw new \BadMethodCallException($message); |
| 87 | 87 | } |
| 88 | - } catch (\Throwable $e) { |
|
| 88 | + }catch (\Throwable $e){ |
|
| 89 | 89 | throw Exception::withLocation($e, $constructor->getFileName(), $constructor->getStartLine()); |
| 90 | 90 | } |
| 91 | 91 | |
@@ -101,14 +101,14 @@ discard block |
||
| 101 | 101 | */ |
| 102 | 102 | private function resolveParameter(\ReflectionClass $ctx, \ReflectionParameter $param, array &$arguments) |
| 103 | 103 | { |
| 104 | - switch (true) { |
|
| 104 | + switch (true){ |
|
| 105 | 105 | case \array_key_exists($param->getName(), $arguments): |
| 106 | - $argument = $arguments[$param->getName()]; |
|
| 106 | + $argument = $arguments[$param->getName()]; |
|
| 107 | 107 | unset($arguments[$param->getName()]); |
| 108 | 108 | return $argument; |
| 109 | 109 | |
| 110 | 110 | case \array_key_exists($param->getPosition(), $arguments): |
| 111 | - $argument = $arguments[$param->getPosition()]; |
|
| 111 | + $argument = $arguments[$param->getPosition()]; |
|
| 112 | 112 | unset($arguments[$param->getPosition()]); |
| 113 | 113 | return $argument; |
| 114 | 114 | |
@@ -38,17 +38,22 @@ discard block |
||
| 38 | 38 | */ |
| 39 | 39 | public function instantiate(\ReflectionClass $attr, array $arguments, string $context): object |
| 40 | 40 | { |
| 41 | - if ($this->isNamedArgumentsSupported()) { |
|
| 42 | - try { |
|
| 41 | + if ($this->isNamedArgumentsSupported()) |
|
| 42 | + { |
|
| 43 | + try |
|
| 44 | + { |
|
| 43 | 45 | return $attr->newInstanceArgs($arguments); |
| 44 | - } catch (\Throwable $e) { |
|
| 46 | + } |
|
| 47 | + catch (\Throwable $e) |
|
| 48 | + { |
|
| 45 | 49 | throw Exception::withLocation($e, $attr->getFileName(), $attr->getStartLine()); |
| 46 | 50 | } |
| 47 | 51 | } |
| 48 | 52 | |
| 49 | 53 | $constructor = $this->getConstructor($attr); |
| 50 | 54 | |
| 51 | - if ($constructor === null) { |
|
| 55 | + if ($constructor === null) |
|
| 56 | + { |
|
| 52 | 57 | return $attr->newInstanceWithoutConstructor(); |
| 53 | 58 | } |
| 54 | 59 | |
@@ -76,16 +81,21 @@ discard block |
||
| 76 | 81 | { |
| 77 | 82 | $passed = []; |
| 78 | 83 | |
| 79 | - try { |
|
| 80 | - foreach ($constructor->getParameters() as $parameter) { |
|
| 84 | + try |
|
| 85 | + { |
|
| 86 | + foreach ($constructor->getParameters() as $parameter) |
|
| 87 | + { |
|
| 81 | 88 | $passed[] = $this->resolveParameter($ctx, $parameter, $arguments); |
| 82 | 89 | } |
| 83 | 90 | |
| 84 | - if (\count($arguments)) { |
|
| 91 | + if (\count($arguments)) |
|
| 92 | + { |
|
| 85 | 93 | $message = \sprintf(self::ERROR_UNKNOWN_ARGUMENT, \array_key_first($arguments)); |
| 86 | 94 | throw new \BadMethodCallException($message); |
| 87 | 95 | } |
| 88 | - } catch (\Throwable $e) { |
|
| 96 | + } |
|
| 97 | + catch (\Throwable $e) |
|
| 98 | + { |
|
| 89 | 99 | throw Exception::withLocation($e, $constructor->getFileName(), $constructor->getStartLine()); |
| 90 | 100 | } |
| 91 | 101 | |
@@ -101,7 +111,8 @@ discard block |
||
| 101 | 111 | */ |
| 102 | 112 | private function resolveParameter(\ReflectionClass $ctx, \ReflectionParameter $param, array &$arguments) |
| 103 | 113 | { |
| 104 | - switch (true) { |
|
| 114 | + switch (true) |
|
| 115 | + { |
|
| 105 | 116 | case \array_key_exists($param->getName(), $arguments): |
| 106 | 117 | $argument = $arguments[$param->getName()]; |
| 107 | 118 | unset($arguments[$param->getName()]); |
@@ -185,25 +185,25 @@ discard block |
||
| 185 | 185 | public function validProvider(): array |
| 186 | 186 | { |
| 187 | 187 | return [ |
| 188 | - [true, time() - 10,], |
|
| 189 | - [true, time(),], |
|
| 190 | - [true, date('u'),], |
|
| 191 | - [true, time() + 10,], |
|
| 192 | - [true, '',], |
|
| 193 | - [true, 'tomorrow 10am',], |
|
| 194 | - [true, 'yesterday 10am',], |
|
| 195 | - [true, 'now',], |
|
| 196 | - [true, 'now + 10 seconds',], |
|
| 197 | - [true, 'now - 10 seconds',], |
|
| 198 | - [true, 0,], |
|
| 199 | - [true, 1.1,], |
|
| 200 | - [false, 'date',], |
|
| 201 | - [false, 'abc',], |
|
| 202 | - [false, false,], |
|
| 203 | - [false, true,], |
|
| 204 | - [false, null,], |
|
| 205 | - [false, [],], |
|
| 206 | - [false, new \stdClass(),], |
|
| 188 | + [true, time() - 10, ], |
|
| 189 | + [true, time(), ], |
|
| 190 | + [true, date('u'), ], |
|
| 191 | + [true, time() + 10, ], |
|
| 192 | + [true, '', ], |
|
| 193 | + [true, 'tomorrow 10am', ], |
|
| 194 | + [true, 'yesterday 10am', ], |
|
| 195 | + [true, 'now', ], |
|
| 196 | + [true, 'now + 10 seconds', ], |
|
| 197 | + [true, 'now - 10 seconds', ], |
|
| 198 | + [true, 0, ], |
|
| 199 | + [true, 1.1, ], |
|
| 200 | + [false, 'date', ], |
|
| 201 | + [false, 'abc', ], |
|
| 202 | + [false, false, ], |
|
| 203 | + [false, true, ], |
|
| 204 | + [false, null, ], |
|
| 205 | + [false, [], ], |
|
| 206 | + [false, new \stdClass(), ], |
|
| 207 | 207 | ]; |
| 208 | 208 | } |
| 209 | 209 | |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | { |
| 212 | 212 | $checker = new DatetimeChecker(); |
| 213 | 213 | |
| 214 | - foreach (\DateTimeZone::listIdentifiers() as $identifier) { |
|
| 214 | + foreach (\DateTimeZone::listIdentifiers() as $identifier){ |
|
| 215 | 215 | $this->assertTrue($checker->timezone($identifier)); |
| 216 | 216 | $this->assertFalse($checker->timezone(str_rot13($identifier))); |
| 217 | 217 | } |