Page MenuHomeDevCentral

RepositoryEvent.php
No OneTemporary

RepositoryEvent.php

<?php
namespace Nasqueron\Notifications\Analyzers\GitHub\Events;
/**
* RepositoryEvent payload analyzer
*
* @link https://developer.github.com/v3/activity/events/types/#repositoryevent
*/
class RepositoryEvent extends Event {
/**
* Determines if the action is valid.
*
* @param string $action The action to check
* @return bool true if the action is valid; otherwise, false
*/
protected static function isValidAction (string $action) : bool {
$actions = ['created', 'deleted', 'publicized', 'privatized'];
return in_array($action, $actions);
}
/**
* Gets description for the payload
*/
public function getDescription () : string {
$action = $this->payload->action;
if (!static::isValidAction($action)) {
return trans(
'GitHub.EventsDescriptions.RepositoryEventUnknown',
['action' => $action]
);
}
$key = 'GitHub.EventsDescriptions.RepositoryEventPerAction.';
$key .= $action;
$repository = $this->payload->repository->full_name;
$message = trans($key, ['repository' => $repository]);
if ($this->payload->repository->fork) {
$message .= trans('GitHub.EventsDescriptions.RepositoryEventFork');
}
$description = (string)$this->payload->repository->description;
if ($description !== "") {
$message .= trans('GitHub.Separator');
$message .= $description;
}
return $message;
}
/**
* Gets link for the payload
*/
public function getLink () : string {
return $this->payload->repository->html_url;
}
}

File Metadata

Mime Type
text/x-php
Expires
Sat, Oct 11, 19:58 (2 h, 37 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3063763
Default Alt Text
RepositoryEvent.php (1 KB)

Event Timeline