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