public function createEvent(Request $request, $payload) { $event = \json_decode($payload); $rawEvent = new RawEvent(); $rawEvent->setType('pingdom'); $rawEvent->setSystem($event->check_params->hostname); $rawEvent->setIdentifier('pingdom_' . $rawEvent->getSystem() . '_' . $event->check_name); $rawEvent->setUrl('https://my.pingdom.com/newchecks/checks#'); if ($event->current_state == self::STATE_FAILURE) { $rawEvent->setStatus(Event::STATUS_FAILURE); $rawEvent->setMessage('Error: ' . $event->long_description . ' (url: ' . $event->check_params->full_url . ')'); } else { $rawEvent->setStatus(Event::STATUS_SUCCESS); $rawEvent->setMessage(''); } return $rawEvent; }
public function createEvent(Request $request, $payload) { $event = \json_decode($payload); if ($event->state == 'completed') { $rawEvent = new RawEvent(); $rawEvent->setSystem($event->_embedded->repository->login . ':' . $event->_embedded->repository->name . ':' . $event->_embedded->head_index->branch_reference); $rawEvent->setValue($event->_embedded->head_index->_embedded->project->metric_values->{'scrutinizer.quality'}); $rawEvent->setIdentifier('scrutinizer:' . $rawEvent->getSystem()); $rawEvent->setType('scrutinizer'); $rawEvent->setUrl('https://scrutinizer-ci.com' . str_replace('api/repositories/', '', $event->_links->self->href)); if ($rawEvent->getValue() > $this->limit) { $rawEvent->setStatus(Event::STATUS_SUCCESS); $rawEvent->setMessage(''); } else { $rawEvent->setStatus(Event::STATUS_FAILURE); $rawEvent->setMessage('The scrutinizer quality index is too low (' . round($rawEvent->getValue(), 2) . ').'); } return $rawEvent; } return []; }