| Total Complexity | 3 |
| Total Lines | 34 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 10 | class StreamBucketLogger implements BucketLogger { |
||
| 11 | |||
| 12 | private $stream; |
||
| 13 | private $timeTeller; |
||
| 14 | |||
| 15 | /** |
||
| 16 | * @param resource $stream |
||
| 17 | * @param TimeTeller $timeTeller |
||
| 18 | */ |
||
| 19 | 40 | public function __construct( $stream, TimeTeller $timeTeller ) { |
|
| 20 | 40 | $this->stream = $stream; |
|
| 21 | 40 | $this->timeTeller = $timeTeller; |
|
| 22 | 40 | } |
|
| 23 | |||
| 24 | 40 | public function writeEvent( LoggingEvent $event, Bucket ...$buckets ) { |
|
| 25 | 40 | fwrite( |
|
| 26 | 40 | $this->stream, |
|
| 27 | 40 | json_encode( [ |
|
| 28 | 40 | 'date' => $this->timeTeller->getTime(), |
|
| 29 | 40 | 'eventName' => $event->getName(), |
|
| 30 | 40 | 'metadata' => $event->getMetaData(), |
|
| 31 | 40 | 'buckets' => $this->getBucketMap( $buckets ) |
|
| 32 | 40 | ] ) . "\n" |
|
| 33 | ); |
||
| 34 | 40 | } |
|
| 35 | |||
| 36 | 40 | private function getBucketMap( array $buckets ): array { |
|
| 44 | ); |
||
| 45 | } |
||
| 46 | |||
| 48 |