| Total Complexity | 8 |
| Total Lines | 68 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 3 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 11 | class DebugTransport implements TransportInterface |
||
| 12 | { |
||
| 13 | /** |
||
| 14 | * @var string $path |
||
| 15 | */ |
||
| 16 | protected $path; |
||
| 17 | |||
| 18 | 5 | public function __construct(string $path = null) |
|
| 25 | 5 | } |
|
| 26 | |||
| 27 | /** |
||
| 28 | * @inheritDoc |
||
| 29 | */ |
||
| 30 | 4 | public function send(AbstractMessage $message): void |
|
| 31 | { |
||
| 32 | try { |
||
| 33 | 4 | $text = $message->render(); |
|
| 34 | 4 | $address = $message->getAddress(); |
|
| 35 | |||
| 36 | 4 | $filename = $this->getPath() . '/' . $address->__toString() . '_' . $this->getTimestamp() . '.txt'; |
|
| 37 | |||
| 38 | 4 | if (! $this->putContents($filename, $text)) { |
|
| 39 | 4 | throw new \RuntimeException('Unable to write data'); |
|
| 40 | } |
||
| 41 | 1 | } catch (\Exception $exception) { |
|
| 42 | 1 | throw new TransportException('Unable to send message', 1, $exception); |
|
| 43 | } |
||
| 44 | 3 | } |
|
| 45 | |||
| 46 | /** |
||
| 47 | * putContents wrapper |
||
| 48 | * |
||
| 49 | * @access protected |
||
| 50 | * @param string $filename |
||
| 51 | * @param mixed $content |
||
| 52 | * @return int|bool |
||
| 53 | */ |
||
| 54 | 2 | protected function putContents(string $filename, $content) |
|
| 57 | } |
||
| 58 | |||
| 59 | /** |
||
| 60 | * getTimestamp. |
||
| 61 | * |
||
| 62 | * @access protected |
||
| 63 | * @return string |
||
| 64 | */ |
||
| 65 | 2 | protected function getTimestamp(): string |
|
| 68 | } |
||
| 69 | |||
| 70 | /** |
||
| 71 | * getPath. |
||
| 72 | * |
||
| 73 | * @access protected |
||
| 74 | * @return string |
||
| 75 | */ |
||
| 76 | 4 | protected function getPath(): string |
|
| 81 |