Page MenuHomeDevCentral

BuildFailureEvent.php
No OneTemporary

BuildFailureEvent.php

<?php
namespace Nasqueron\Notifications\Analyzers\DockerHub;
use Mailgun;
class BuildFailureEvent extends BaseEvent {
/**
* Initializes a new instance of the BuildFailureEvent object.
*
* @param \stdClass $payload The payload to analyze
*/
public function __construct ($payload) {
parent::__construct($payload);
$this->payload = $this->getMailGunPayload();
}
/**
* Gets a MailGun message.
*
* @return \stdClass
*/
private function getMailGunPayload () {
return Mailgun::fetchMessageFromPayload($this->payload);
}
/**
* @return string
*/
private function getMailBody () {
$bodyProperty = 'body-plain';
return $this->payload->$bodyProperty;
}
/**
* Extracts a regular expression from the mail body.
*
* @param $string Regular expression
* @return string
*/
private function extractFromBody ($regex) {
preg_match($regex, $this->getMailBody(), $matches);
return $matches[1];
}
/**
* Gets text from payload.
*
* @return string
*/
public function getText() {
$repo = $this->extractFromBody("@\"(.*?\/.*?)\"@");
return "Image build by Docker Hub registry failure for $repo";
}
/**
* Gets link from payload.
*
* @return string
*/
public function getLink() {
return $this->extractFromBody("@(https\:\/\/hub.docker.com\/r.*)@");
}
}

File Metadata

Mime Type
text/x-php
Expires
Tue, May 5, 11:46 (1 d, 10 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3681419
Default Alt Text
BuildFailureEvent.php (1 KB)

Event Timeline