Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F27326949
BuildFailureEvent.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
BuildFailureEvent.php
View Options
<?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
Details
Attached
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)
Attached To
Mode
rNOTIF Notifications center
Attached
Detach File
Event Timeline
Log In to Comment