| 1 | <?php |
||
| 10 | class SmsSenderDataCollector extends DataCollector |
||
| 11 | { |
||
| 12 | protected $logger; |
||
| 13 | |||
| 14 | public function __construct(Logger $logger) |
||
| 18 | |||
| 19 | /** |
||
| 20 | * {@inheritdoc} |
||
| 21 | */ |
||
| 22 | public function collect(Request $request, Response $response, \Exception $exception = null) |
||
| 23 | { |
||
| 24 | $this->data = array( |
||
| 25 | 'smsData' => $list = $this->retrieveSmsList(), |
||
| 26 | 'smsCount' => count($list), |
||
| 27 | 'time' => $this->computeTime(), |
||
| 28 | ); |
||
| 29 | } |
||
| 30 | |||
| 31 | /** |
||
| 32 | * Returns the collector name. |
||
| 33 | * |
||
| 34 | * @return string The collector name. |
||
| 35 | */ |
||
| 36 | public function getName() |
||
| 40 | |||
| 41 | public function getTime() |
||
| 45 | |||
| 46 | public function getSmsData() |
||
| 50 | |||
| 51 | public function getSmsCount() |
||
| 55 | |||
| 56 | protected function computeTime() |
||
| 57 | { |
||
| 58 | $total = 0; |
||
| 59 | |||
| 60 | foreach ($this->logger->getSms() as $data) { |
||
| 61 | $total += $data['duration']; |
||
| 62 | } |
||
| 63 | |||
| 64 | return $total; |
||
| 65 | } |
||
| 66 | |||
| 67 | protected function retrieveSmsList() |
||
| 71 | } |
||
| 72 |