Page MenuHomeDevCentral

D2674.id6766.diff
No OneTemporary

D2674.id6766.diff

This file is larger than 256 KB, so syntax highlighting was skipped.
diff --git a/.arclint b/.arclint
--- a/.arclint
+++ b/.arclint
@@ -28,8 +28,12 @@
"phpcs": {
"type": "phpcs",
"bin": "vendor/bin/phpcs",
- "phpcs.standard": "PSR1",
- "include": "(^app/.*\\.php$)"
+ "phpcs.standard": "phpcs.xml",
+ "include": [
+ "(app/.*\\.php$)",
+ "(config/.*\\.php$)",
+ "(tests/.*\\.php$)"
+ ]
},
"spelling": {
"type": "spelling"
diff --git a/app/Actions/AMQPAction.php b/app/Actions/AMQPAction.php
--- a/app/Actions/AMQPAction.php
+++ b/app/Actions/AMQPAction.php
@@ -31,7 +31,7 @@
* @param string $target The queue or exchange target on the broker
* @param string $routingKey The routing key for this exchange or queue
*/
- public function __construct (
+ public function __construct(
string $method,
string $target,
string $routingKey = ''
diff --git a/app/Actions/Action.php b/app/Actions/Action.php
--- a/app/Actions/Action.php
+++ b/app/Actions/Action.php
@@ -16,8 +16,8 @@
/**
* Initializes a new instance of an action to report
*/
- public function __construct () {
- $this->action = class_basename(get_called_class());
+ public function __construct() {
+ $this->action = class_basename( get_called_class() );
}
/**
@@ -30,7 +30,7 @@
*
* @param ActionError $error The error to attach
*/
- public function attachError (ActionError $error) : void {
+ public function attachError( ActionError $error ): void {
$this->error = $error;
}
}
diff --git a/app/Actions/ActionError.php b/app/Actions/ActionError.php
--- a/app/Actions/ActionError.php
+++ b/app/Actions/ActionError.php
@@ -18,8 +18,8 @@
*/
public $message;
- public function __construct (\Exception $ex) {
- $this->type = class_basename(get_class($ex));
+ public function __construct( \Exception $ex ) {
+ $this->type = class_basename( get_class( $ex ) );
$this->message = $ex->getMessage();
}
}
diff --git a/app/Actions/ActionsReport.php b/app/Actions/ActionsReport.php
--- a/app/Actions/ActionsReport.php
+++ b/app/Actions/ActionsReport.php
@@ -34,7 +34,7 @@
/**
* Initializes a new instance of an actions report
*/
- public function __construct () {
+ public function __construct() {
$this->created = time();
}
@@ -48,7 +48,7 @@
* @param string $gate The gate
* @param string $door The door
*/
- public function attachToGate (string $gate, string $door) : void {
+ public function attachToGate( string $gate, string $door ): void {
$this->gate = $gate;
$this->door = $door;
}
@@ -58,7 +58,7 @@
*
* @param Action $action The action to add
*/
- public function addAction (Action $action) : void {
+ public function addAction( Action $action ): void {
$this->actions[] = $action;
}
@@ -67,9 +67,9 @@
*
* @return bool
*/
- public function containsError () : bool {
- foreach ($this->actions as $action) {
- if ($action->error !== null) {
+ public function containsError(): bool {
+ foreach ( $this->actions as $action ) {
+ if ( $action->error !== null ) {
return true;
}
}
@@ -84,7 +84,7 @@
/**
* Gets a JSON string representation of the current instance
*/
- public function __toString () : string {
- return json_encode($this, JSON_PRETTY_PRINT);
+ public function __toString(): string {
+ return json_encode( $this, JSON_PRETTY_PRINT );
}
}
diff --git a/app/Actions/NotifyNewCommitsAction.php b/app/Actions/NotifyNewCommitsAction.php
--- a/app/Actions/NotifyNewCommitsAction.php
+++ b/app/Actions/NotifyNewCommitsAction.php
@@ -15,7 +15,7 @@
*
* @param string $callSign The Phabricator repository call sign
*/
- public function __construct (string $callSign) {
+ public function __construct( string $callSign ) {
parent::__construct();
$this->callSign = $callSign;
diff --git a/app/Actions/TriggerDockerHubBuildAction.php b/app/Actions/TriggerDockerHubBuildAction.php
--- a/app/Actions/TriggerDockerHubBuildAction.php
+++ b/app/Actions/TriggerDockerHubBuildAction.php
@@ -15,7 +15,7 @@
*
* @param string $image The Docker Hub image to trigger
*/
- public function __construct (string $image) {
+ public function __construct( string $image ) {
parent::__construct();
$this->image = $image;
diff --git a/app/Analyzers/BasePayloadAnalyzer.php b/app/Analyzers/BasePayloadAnalyzer.php
--- a/app/Analyzers/BasePayloadAnalyzer.php
+++ b/app/Analyzers/BasePayloadAnalyzer.php
@@ -2,11 +2,10 @@
namespace Nasqueron\Notifications\Analyzers;
+use BadMethodCallException;
use Config;
use Storage;
-use BadMethodCallException;
-
abstract class BasePayloadAnalyzer {
///
@@ -36,7 +35,7 @@
/**
* The configuration for the payload analyzer
- * @var PayloadAnalyzerConfiguration;
+ * @var PayloadAnalyzerConfiguration
*/
protected $configuration;
@@ -48,9 +47,9 @@
* Creates a new JenkinsPayloadAnalyzer instance.
*
* @param string $project
- * @param \stdClass $payload
+ * @param \stdClass $payload
*/
- public function __construct(string $project, \stdClass $payload) {
+ public function __construct( string $project, \stdClass $payload ) {
$this->project = $project;
$this->payload = $payload;
@@ -71,16 +70,16 @@
*
* @return string
*/
- public function getConfigurationFileName () : string {
+ public function getConfigurationFileName(): string {
$dir = Config::get(
'services.'
- . strtolower(static::SERVICE_NAME)
+ . strtolower( static::SERVICE_NAME )
. '.analyzer.configDir'
);
$filename = $dir . '/' . $this->project . '.json';
- if (!Storage::has($filename)) {
+ if ( !Storage::has( $filename ) ) {
return $dir . '/' . static::CONFIG_DEFAULT_FILE;
}
@@ -92,8 +91,8 @@
*
* @return string
*/
- private function getCandidateConfigurationClassName() : string {
- return 'Nasqueron\Notifications\Analyzers\\' . static::SERVICE_NAME //ns
+ private function getCandidateConfigurationClassName(): string {
+ return 'Nasqueron\Notifications\Analyzers\\' . static::SERVICE_NAME // ns
. "\\"
. static::SERVICE_NAME . 'PayloadAnalyzerConfiguration'; // class
}
@@ -104,10 +103,10 @@
*
* @return string The configuration class to use
*/
- private function getConfigurationClassName () : string {
+ private function getConfigurationClassName(): string {
$class = $this->getCandidateConfigurationClassName();
- if (class_exists($class)) {
+ if ( class_exists( $class ) ) {
return $class;
}
@@ -117,14 +116,14 @@
/**
* Loads configuration for the analyzer
*/
- public function loadConfiguration () : void {
+ public function loadConfiguration(): void {
$fileName = $this->getConfigurationFileName();
$class = $this->getConfigurationClassName();
$mapper = new \JsonMapper();
$this->configuration = $mapper->map(
- json_decode(Storage::get($fileName)),
- new $class($this->project)
+ json_decode( Storage::get( $fileName ) ),
+ new $class( $this->project )
);
}
@@ -137,8 +136,8 @@
*
* @var string
*/
- public function getItemName () : string {
- throw new BadMethodCallException(<<<MSG
+ public function getItemName(): string {
+ throw new BadMethodCallException( <<<MSG
The getItemName method must be implemented in the analyzer class if used.
MSG
);
@@ -150,7 +149,7 @@
*
* @return bool
*/
- public function isAdministrativeEvent () : bool {
+ public function isAdministrativeEvent(): bool {
return false;
}
@@ -159,18 +158,18 @@
*
* @return string The group, central part of the routing key
*/
- public function getGroup () : string {
+ public function getGroup(): string {
// Some events are organization-level only and can't be mapped
// to projects.
- if ($this->isAdministrativeEvent()) {
+ if ( $this->isAdministrativeEvent() ) {
return $this->configuration->administrativeGroup;
}
// If the payload is about some repository matching a table of
// symbols, we need to sort it to the right group.
$item = $this->getItemName();
- foreach ($this->configuration->map as $mapping) {
- if ($mapping->doesItemBelong($item)) {
+ foreach ( $this->configuration->map as $mapping ) {
+ if ( $mapping->doesItemBelong( $item ) ) {
return $mapping->group;
}
}
diff --git a/app/Analyzers/DockerHub/BaseEvent.php b/app/Analyzers/DockerHub/BaseEvent.php
--- a/app/Analyzers/DockerHub/BaseEvent.php
+++ b/app/Analyzers/DockerHub/BaseEvent.php
@@ -14,7 +14,7 @@
*
* @param \stdClass $payload The payload to analyze
*/
- public function __construct ($payload) {
+ public function __construct( $payload ) {
$this->payload = $payload;
}
@@ -27,7 +27,7 @@
*
* This method allows analyzer to edit the payload.
*/
- public function getPayload () {
+ public function getPayload() {
return $this->payload;
}
diff --git a/app/Analyzers/DockerHub/BuildFailureEvent.php b/app/Analyzers/DockerHub/BuildFailureEvent.php
--- a/app/Analyzers/DockerHub/BuildFailureEvent.php
+++ b/app/Analyzers/DockerHub/BuildFailureEvent.php
@@ -11,8 +11,8 @@
*
* @param \stdClass $payload The payload to analyze
*/
- public function __construct ($payload) {
- parent::__construct($payload);
+ public function __construct( $payload ) {
+ parent::__construct( $payload );
$this->payload = $this->getMailGunPayload();
}
@@ -21,14 +21,14 @@
*
* @return \stdClass
*/
- private function getMailGunPayload () {
- return Mailgun::fetchMessageFromPayload($this->payload);
+ private function getMailGunPayload() {
+ return Mailgun::fetchMessageFromPayload( $this->payload );
}
/**
* @return string
*/
- private function getMailBody () {
+ private function getMailBody() {
$bodyProperty = 'body-plain';
return $this->payload->$bodyProperty;
}
@@ -39,8 +39,8 @@
* @param $string Regular expression
* @return string
*/
- private function extractFromBody ($regex) {
- preg_match($regex, $this->getMailBody(), $matches);
+ private function extractFromBody( $regex ) {
+ preg_match( $regex, $this->getMailBody(), $matches );
return $matches[1];
}
@@ -50,7 +50,7 @@
* @return string
*/
public function getText() {
- $repo = $this->extractFromBody("@\"(.*?\/.*?)\"@");
+ $repo = $this->extractFromBody( "@\"(.*?\/.*?)\"@" );
return "Image build by Docker Hub registry failure for $repo";
}
@@ -61,7 +61,7 @@
* @return string
*/
public function getLink() {
- return $this->extractFromBody("@(https\:\/\/hub.docker.com\/r.*)@");
+ return $this->extractFromBody( "@(https\:\/\/hub.docker.com\/r.*)@" );
}
}
diff --git a/app/Analyzers/GitHub/Events/CommitCommentEvent.php b/app/Analyzers/GitHub/Events/CommitCommentEvent.php
--- a/app/Analyzers/GitHub/Events/CommitCommentEvent.php
+++ b/app/Analyzers/GitHub/Events/CommitCommentEvent.php
@@ -14,15 +14,15 @@
*
* @return string
*/
- public function getDescription () : string {
+ public function getDescription(): string {
$comment = $this->payload->comment;
return trans(
'GitHub.EventsDescriptions.CommitCommentEvent',
[
'author' => $comment->user->login,
- 'commit' => substr($comment->commit_id, 0, 8),
- 'excerpt' => self::cut($comment->body),
+ 'commit' => substr( $comment->commit_id, 0, 8 ),
+ 'excerpt' => self::cut( $comment->body ),
]
);
}
@@ -32,7 +32,7 @@
*
* @return string
*/
- public function getLink () : string {
+ public function getLink(): string {
return $this->payload->comment->html_url;
}
}
diff --git a/app/Analyzers/GitHub/Events/CreateEvent.php b/app/Analyzers/GitHub/Events/CreateEvent.php
--- a/app/Analyzers/GitHub/Events/CreateEvent.php
+++ b/app/Analyzers/GitHub/Events/CreateEvent.php
@@ -22,12 +22,12 @@
*
* @return string
*/
- public function getDescription () : string {
+ public function getDescription(): string {
$repository = $this->payload->repository->full_name;
$type = $this->payload->ref_type;
$ref = $this->payload->ref;
- if (!self::isValidRefType($type)) {
+ if ( !self::isValidRefType( $type ) ) {
return trans(
'GitHub.EventsDescriptions.CreateEventUnknown',
[
@@ -53,7 +53,7 @@
* @return array
* @SuppressWarnings(PHPMD.UnusedPrivateMethod)
*/
- private function getLinkRefSegments () : array {
+ private function getLinkRefSegments(): array {
return [
'tag' => '/releases/tag/',
'branch' => '/tree/',
@@ -65,12 +65,12 @@
*
* @return string
*/
- public function getLink () : string {
+ public function getLink(): string {
$type = $this->payload->ref_type;
$ref = $this->payload->ref;
$url = $this->payload->repository->html_url;
- $url .= $this->getLinkRefSegment($type);
+ $url .= $this->getLinkRefSegment( $type );
$url .= $ref;
return $url;
diff --git a/app/Analyzers/GitHub/Events/DeleteEvent.php b/app/Analyzers/GitHub/Events/DeleteEvent.php
--- a/app/Analyzers/GitHub/Events/DeleteEvent.php
+++ b/app/Analyzers/GitHub/Events/DeleteEvent.php
@@ -19,12 +19,12 @@
*
* @return string
*/
- public function getDescription () : string {
+ public function getDescription(): string {
$repository = $this->payload->repository->full_name;
$type = $this->payload->ref_type;
$ref = $this->payload->ref;
- if (!self::isValidRefType($type)) {
+ if ( !self::isValidRefType( $type ) ) {
return trans(
'GitHub.EventsDescriptions.DeleteEventUnknown',
[
@@ -47,10 +47,10 @@
/**
* Gets link segments for the type
*
- * @return Array
+ * @return array
* @SuppressWarnings(PHPMD.UnusedPrivateMethod)
*/
- private function getLinkRefSegments () {
+ private function getLinkRefSegments() {
return [
'tag' => '/tags',
'branch' => '/branches',
@@ -62,11 +62,11 @@
*
* @return string
*/
- public function getLink () : string {
+ public function getLink(): string {
$type = $this->payload->ref_type;
$url = $this->payload->repository->html_url;
- $url .= $this->getLinkRefSegment($type);
+ $url .= $this->getLinkRefSegment( $type );
return $url;
}
diff --git a/app/Analyzers/GitHub/Events/Event.php b/app/Analyzers/GitHub/Events/Event.php
--- a/app/Analyzers/GitHub/Events/Event.php
+++ b/app/Analyzers/GitHub/Events/Event.php
@@ -2,6 +2,8 @@
namespace Nasqueron\Notifications\Analyzers\GitHub\Events;
+use Illuminate\Support\Str;
+
class Event {
///
@@ -31,25 +33,32 @@
* Gets class name from the GitHub webhooks event name
*
* @param string $eventName The event name (e.g. commit_comment)
+ *
* @return string The event class name (e.g. CommitCommentEvent)
*/
- public static function getClass ($eventName) {
- return __NAMESPACE__ . '\\' . studly_case($eventName) . 'Event';
+ public static function getClass (string $eventName) {
+ return __NAMESPACE__ . '\\' . self::toCamelCase($eventName) . 'Event';
+ }
+
+ private static function toCamelCase (string $string) : string {
+ return str_replace(" ", "", ucwords(str_replace("_", " ", $string)));
}
/**
* Gets an instance of the event class, from the
*
* @param string $eventName The event name (e.g. commit_comment)
+ *
* @return Event
*/
- public static function forPayload ($eventName, $payload) {
+ public static function forPayload (string $eventName, $payload) {
$class = self::getClass($eventName);
if (!class_exists($class)) {
throw new \InvalidArgumentException(
"Class doesn't exist: $class (for $eventName)"
);
}
+
return new $class($payload);
}
@@ -60,11 +69,15 @@
/**
* Cuts a text
*
- * @param string $text The text to cut
- * @param int $strLen The amount of characters to allow [optional]
+ * @param string $text The text to cut
+ * @param int $strLen The amount of characters to allow [optional]
* @param string $symbol The symbol to append to a cut text [optional]
*/
- public static function cut ($text, $strLen = 114, $symbol = '…') {
+ public static function cut (
+ string $text,
+ int $strLen = 114,
+ string $symbol = '…'
+ ) {
$len = strlen($text);
if ($len <= $strLen) {
return $text;
diff --git a/app/Analyzers/GitHub/Events/ForkEvent.php b/app/Analyzers/GitHub/Events/ForkEvent.php
--- a/app/Analyzers/GitHub/Events/ForkEvent.php
+++ b/app/Analyzers/GitHub/Events/ForkEvent.php
@@ -16,7 +16,7 @@
*
* @return string
*/
- public function getDescription () : string {
+ public function getDescription(): string {
return trans(
'GitHub.EventsDescriptions.ForkEvent',
[
@@ -31,7 +31,7 @@
*
* @return string
*/
- public function getLink () : string {
+ public function getLink(): string {
return $this->payload->forkee->html_url;
}
}
diff --git a/app/Analyzers/GitHub/Events/IssueCommentEvent.php b/app/Analyzers/GitHub/Events/IssueCommentEvent.php
--- a/app/Analyzers/GitHub/Events/IssueCommentEvent.php
+++ b/app/Analyzers/GitHub/Events/IssueCommentEvent.php
@@ -15,9 +15,9 @@
* @param string $action The action to check
* @return bool true if the action is valid; otherwise, false
*/
- protected static function isValidAction ($action) {
- $actions = ['created', 'edited', 'deleted'];
- return in_array($action, $actions);
+ protected static function isValidAction( string $action ) {
+ $actions = [ 'created', 'edited', 'deleted' ];
+ return in_array( $action, $actions );
}
/**
@@ -25,18 +25,18 @@
*
* @return string
*/
- public function getDescription () : string {
+ public function getDescription(): string {
$action = $this->payload->action;
- if (!static::isValidAction($action)) {
+ if ( !static::isValidAction( $action ) ) {
return trans(
'GitHub.EventsDescriptions.IssueCommentEventUnknown',
- ['action' => $action]
+ [ 'action' => $action ]
);
}
$key = 'GitHub.EventsDescriptions.IssueCommentEventPerAction.';
- $key .= $action;
+ $key .= $action;
$comment = $this->payload->comment;
$issue = $this->payload->issue;
@@ -47,7 +47,7 @@
'author' => $comment->user->login,
'issueNumber' => $issue->number,
'issueTitle' => $issue->title,
- 'excerpt' => self::cut($comment->body),
+ 'excerpt' => self::cut( $comment->body ),
]
);
}
@@ -57,9 +57,8 @@
*
* @return string
*/
- public function getLink () : string {
+ public function getLink(): string {
return $this->payload->comment->html_url;
}
}
-
diff --git a/app/Analyzers/GitHub/Events/PingEvent.php b/app/Analyzers/GitHub/Events/PingEvent.php
--- a/app/Analyzers/GitHub/Events/PingEvent.php
+++ b/app/Analyzers/GitHub/Events/PingEvent.php
@@ -14,7 +14,7 @@
*
* @return string
*/
- public function getDescription () : string {
+ public function getDescription(): string {
return trans(
'GitHub.EventsDescriptions.PingEvent',
[
@@ -29,7 +29,7 @@
*
* @return string
*/
- public function getLink () : string {
+ public function getLink(): string {
return '';
}
}
diff --git a/app/Analyzers/GitHub/Events/PullRequestEvent.php b/app/Analyzers/GitHub/Events/PullRequestEvent.php
--- a/app/Analyzers/GitHub/Events/PullRequestEvent.php
+++ b/app/Analyzers/GitHub/Events/PullRequestEvent.php
@@ -15,14 +15,14 @@
* @param string $action The action to check
* @return bool true if the action is valid; otherwise, false
*/
- protected static function isValidAction ($action) {
+ protected static function isValidAction( string $action ) {
$actions = [
'assigned', 'unassigned',
'labeled', 'unlabeled',
'opened', 'closed',
'edited', 'reopened',
];
- return in_array($action, $actions);
+ return in_array( $action, $actions );
}
/**
@@ -30,20 +30,20 @@
*
* @return string
*/
- public function getDescription () : string {
+ public function getDescription(): string {
$action = $this->payload->action;
- if (!static::isValidAction($action)) {
+ if ( !static::isValidAction( $action ) ) {
return trans(
'GitHub.EventsDescriptions.PullRequestEventUnknown',
- ['action' => $action]
+ [ 'action' => $action ]
);
}
$key = 'GitHub.EventsDescriptions.PullRequestEventPerAction.';
- $key .= $action;
+ $key .= $action;
- return trans($key, $this->getLocalisationParameters());
+ return trans( $key, $this->getLocalisationParameters() );
}
/**
@@ -51,13 +51,13 @@
*
* @return array
*/
- private function getLocalisationParameters () {
+ private function getLocalisationParameters() {
$parameters = [
'author' => $this->payload->sender->login,
'number' => $this->payload->number,
'title' => $this->payload->pull_request->title,
];
- switch ($this->payload->action) {
+ switch ( $this->payload->action ) {
case 'assigned':
$parameters['assignee'] = $this->getLastAssignee();
break;
@@ -71,11 +71,11 @@
private function getLastAssignee() {
$assignees = $this->payload->pull_request->assignees;
- if (count($assignees) === 0) {
+ if ( count( $assignees ) === 0 ) {
return ""; // No assignee.
}
- $assignee = array_pop($assignees);
+ $assignee = array_pop( $assignees );
return $assignee->login;
}
@@ -84,7 +84,7 @@
*
* @return string
*/
- public function getLink () : string {
+ public function getLink(): string {
return $this->payload->pull_request->html_url;
}
diff --git a/app/Analyzers/GitHub/Events/PushEvent.php b/app/Analyzers/GitHub/Events/PushEvent.php
--- a/app/Analyzers/GitHub/Events/PushEvent.php
+++ b/app/Analyzers/GitHub/Events/PushEvent.php
@@ -18,10 +18,10 @@
* @param int $count The count of commits
* @return string The l10n message key for description
*/
- private static function getDescriptionMessageKey ($count) {
+ private static function getDescriptionMessageKey( int $count ) {
$key = 'GitHub.EventsDescriptions.PushEvent';
- if ($count === 0) {
+ if ( $count === 0 ) {
return $key . '.0';
}
@@ -33,21 +33,21 @@
*
* @return string
*/
- public function getDescription () : string {
- $n = count($this->payload->commits);
+ public function getDescription(): string {
+ $n = count( $this->payload->commits );
- if ($n === 1) {
+ if ( $n === 1 ) {
// If only one commit is pushed at the time,
// we want a description for this commit.
return $this->getHeadCommitDescription();
}
// Otherwise, we want a description for the push.
- return trans(self::getDescriptionMessageKey($n), [
+ return trans( self::getDescriptionMessageKey( $n ), [
'user' => $this->payload->pusher->name,
'count' => $n,
'repoAndBranch' => $this->getWhere(),
- ]);
+ ] );
}
/**
@@ -55,10 +55,10 @@
*
* @return string
*/
- public function getLink () : string {
- $n = count($this->payload->commits);
+ public function getLink(): string {
+ $n = count( $this->payload->commits );
- if ($n === 1) {
+ if ( $n === 1 ) {
return $this->payload->head_commit->url;
}
diff --git a/app/Analyzers/GitHub/Events/RepositoryEvent.php b/app/Analyzers/GitHub/Events/RepositoryEvent.php
--- a/app/Analyzers/GitHub/Events/RepositoryEvent.php
+++ b/app/Analyzers/GitHub/Events/RepositoryEvent.php
@@ -15,9 +15,9 @@
* @param string $action The action to check
* @return bool true if the action is valid; otherwise, false
*/
- protected static function isValidAction ($action) {
- $actions = ['created', 'deleted', 'publicized', 'privatized'];
- return in_array($action, $actions);
+ protected static function isValidAction( string $action ) {
+ $actions = [ 'created', 'deleted', 'publicized', 'privatized' ];
+ return in_array( $action, $actions );
}
/**
@@ -25,30 +25,30 @@
*
* @return string
*/
- public function getDescription () : string {
+ public function getDescription(): string {
$action = $this->payload->action;
- if (!static::isValidAction($action)) {
+ if ( !static::isValidAction( $action ) ) {
return trans(
'GitHub.EventsDescriptions.RepositoryEventUnknown',
- ['action' => $action]
+ [ 'action' => $action ]
);
}
$key = 'GitHub.EventsDescriptions.RepositoryEventPerAction.';
- $key .= $action;
+ $key .= $action;
$repository = $this->payload->repository->full_name;
- $message = trans($key, ['repository' => $repository]);
+ $message = trans( $key, [ 'repository' => $repository ] );
- if ($this->payload->repository->fork) {
- $message .= trans('GitHub.EventsDescriptions.RepositoryEventFork');
+ if ( $this->payload->repository->fork ) {
+ $message .= trans( 'GitHub.EventsDescriptions.RepositoryEventFork' );
}
$description = (string)$this->payload->repository->description;
- if ($description !== "") {
- $message .= trans('GitHub.Separator');
+ if ( $description !== "" ) {
+ $message .= trans( 'GitHub.Separator' );
$message .= $description;
}
@@ -60,7 +60,7 @@
*
* @return string
*/
- public function getLink () : string {
+ public function getLink(): string {
return $this->payload->repository->html_url;
}
}
diff --git a/app/Analyzers/GitHub/Events/StatusEvent.php b/app/Analyzers/GitHub/Events/StatusEvent.php
--- a/app/Analyzers/GitHub/Events/StatusEvent.php
+++ b/app/Analyzers/GitHub/Events/StatusEvent.php
@@ -14,10 +14,10 @@
*
* @return string
*/
- private function getState () {
+ private function getState() {
$state = $this->payload->state; // pending, success, failure, or error
$key = 'GitHub.StatusEventState.' . $state;
- return trans($key);
+ return trans( $key );
}
/**
@@ -25,15 +25,15 @@
*
* @return string
*/
- private function getStatusResult () {
- $glue = trans('GitHub.Separator');
- $fragments = array_filter([
+ private function getStatusResult() {
+ $glue = trans( 'GitHub.Separator' );
+ $fragments = array_filter( [
$this->payload->context,
$this->payload->description,
$this->getState(),
- ]);
+ ] );
- return implode($glue, $fragments);
+ return implode( $glue, $fragments );
}
/**
@@ -41,11 +41,11 @@
*
* @return string
*/
- public function getDescription () : string {
- return trans('GitHub.EventsDescriptions.StatusEvent', [
- 'commit' => substr($this->payload->sha, 0, 8),
+ public function getDescription(): string {
+ return trans( 'GitHub.EventsDescriptions.StatusEvent', [
+ 'commit' => substr( $this->payload->sha, 0, 8 ),
'status' => $this->getStatusResult(),
- ]);
+ ] );
}
/**
@@ -53,10 +53,10 @@
*
* @return string
*/
- public function getLink () : string {
+ public function getLink(): string {
$url = $this->payload->target_url;
- if ($url === null) {
+ if ( $url === null ) {
return "";
}
diff --git a/app/Analyzers/GitHub/Events/UnknownEvent.php b/app/Analyzers/GitHub/Events/UnknownEvent.php
--- a/app/Analyzers/GitHub/Events/UnknownEvent.php
+++ b/app/Analyzers/GitHub/Events/UnknownEvent.php
@@ -20,9 +20,9 @@
*
* @param string $eventType The event type (e.g. push)
*/
- public function __construct ($eventType, $payload = null) {
+ public function __construct( $eventType, $payload = null ) {
$this->eventType = $eventType;
- parent::__construct($payload);
+ parent::__construct( $payload );
}
/**
@@ -30,7 +30,7 @@
*
* @return string
*/
- public function getDescription () : string {
+ public function getDescription(): string {
return "Some $this->eventType happened";
}
@@ -39,7 +39,7 @@
*
* @return string
*/
- public function getLink () : string {
+ public function getLink(): string {
return "";
}
}
diff --git a/app/Analyzers/GitHub/Events/WatchEvent.php b/app/Analyzers/GitHub/Events/WatchEvent.php
--- a/app/Analyzers/GitHub/Events/WatchEvent.php
+++ b/app/Analyzers/GitHub/Events/WatchEvent.php
@@ -20,7 +20,7 @@
*
* @return string
*/
- public function getDescription () : string {
+ public function getDescription(): string {
return trans(
'GitHub.EventsDescriptions.WatchEvent',
[
@@ -35,7 +35,7 @@
*
* @return string
*/
- public function getLink () : string {
+ public function getLink(): string {
return $this->payload->sender->html_url;
}
}
diff --git a/app/Analyzers/GitHub/Events/WithCommit.php b/app/Analyzers/GitHub/Events/WithCommit.php
--- a/app/Analyzers/GitHub/Events/WithCommit.php
+++ b/app/Analyzers/GitHub/Events/WithCommit.php
@@ -15,8 +15,8 @@
*
* @return string
*/
- private function getHeadCommitTitle () {
- return static::getCommitTitle($this->payload->head_commit->message);
+ private function getHeadCommitTitle() {
+ return static::getCommitTitle( $this->payload->head_commit->message );
}
/**
@@ -25,16 +25,16 @@
* @param string $message The commit message
* @return string The commit title
*/
- public static function getCommitTitle ($message) {
+ public static function getCommitTitle( string $message ) {
// Discards extra lines
- $pos = strpos($message, "\n");
- if ($pos > 0) {
- $message = substr($message, 0, $pos);
+ $pos = strpos( $message, "\n" );
+ if ( $pos > 0 ) {
+ $message = substr( $message, 0, $pos );
}
// Short messages are returned as is
// Longer messages are truncated
- return self::cut($message, 72);
+ return self::cut( $message, 72 );
}
/**
@@ -42,20 +42,20 @@
*
* @return string
*/
- private function getHeadCommitDescription () {
+ private function getHeadCommitDescription() {
$commit = $this->payload->head_commit;
$committer = $commit->committer->username;
$author = $commit->author->username;
- $message = trans('GitHub.Commits.Message', [
+ $message = trans( 'GitHub.Commits.Message', [
'committer' => $committer,
'title' => $this->getHeadCommitTitle(),
- ]);
-
- if ($committer !== $author) {
- $message .= trans('GitHub.Commits.Authored', [
+ ] );
+
+ if ( $committer !== $author ) {
+ $message .= trans( 'GitHub.Commits.Authored', [
'author' => $author,
- ]);
+ ] );
}
return $message;
diff --git a/app/Analyzers/GitHub/Events/WithRef.php b/app/Analyzers/GitHub/Events/WithRef.php
--- a/app/Analyzers/GitHub/Events/WithRef.php
+++ b/app/Analyzers/GitHub/Events/WithRef.php
@@ -19,9 +19,9 @@
* @param string $type The ref type to check
* @return bool true if the ref type id valid; otherwise, false
*/
- protected static function isValidRefType ($type) {
- $types = ['branch', 'tag'];
- return in_array($type, $types);
+ protected static function isValidRefType( string $type ) {
+ $types = [ 'branch', 'tag' ];
+ return in_array( $type, $types );
}
/**
@@ -30,10 +30,10 @@
* @param string $type The reference type
* @return string the part of the URL for this reference type (e.g. /tree/)
*/
- protected function getLinkRefSegment ($type) {
+ protected function getLinkRefSegment( string $type ) {
$segments = $this->getLinkRefSegments();
- if (!array_key_exists($type, $segments)) {
+ if ( !array_key_exists( $type, $segments ) ) {
throw new \InvalidArgumentException;
}
diff --git a/app/Analyzers/GitHub/Events/WithRepoAndBranch.php b/app/Analyzers/GitHub/Events/WithRepoAndBranch.php
--- a/app/Analyzers/GitHub/Events/WithRepoAndBranch.php
+++ b/app/Analyzers/GitHub/Events/WithRepoAndBranch.php
@@ -13,33 +13,33 @@
/**
* Gets repository and branch information
*/
- public function getWhere () : string {
+ public function getWhere(): string {
$repo = $this->payload->repository->name;
$branch = $this->payload->ref;
- return static::getRepositoryAndBranch($repo, $branch);
+ return static::getRepositoryAndBranch( $repo, $branch );
}
- public static function getRepositoryAndBranch (
+ public static function getRepositoryAndBranch(
$repo = "",
$branch = ""
- ) : string {
- if ($repo === "") {
+ ): string {
+ if ( $repo === "" ) {
return "";
}
- if (starts_with($branch, "refs/heads/")) {
- $branch = substr($branch, 11);
+ if ( str_starts_with( $branch, "refs/heads/" ) ) {
+ $branch = substr( $branch, 11 );
}
- if ($branch === "" || $branch === "master") {
+ if ( $branch === "" || $branch === "master" ) {
return $repo;
}
- return trans('GitHub.RepoAndBranch', [
+ return trans( 'GitHub.RepoAndBranch', [
'repo' => $repo,
'branch' => $branch,
- ]);
+ ] );
}
}
diff --git a/app/Analyzers/GitHub/GitHubPayloadAnalyzer.php b/app/Analyzers/GitHub/GitHubPayloadAnalyzer.php
--- a/app/Analyzers/GitHub/GitHubPayloadAnalyzer.php
+++ b/app/Analyzers/GitHub/GitHubPayloadAnalyzer.php
@@ -26,7 +26,7 @@
/**
* The payload analyzer event
*
- * @var \Nasqueron\Notifications\Analyzers\GitHub\Events\Event;
+ * @var \Nasqueron\Notifications\Analyzers\GitHub\Events\Event
*/
private $analyzerEvent;
@@ -46,14 +46,14 @@
string $event,
\stdClass $payload
) {
- parent::__construct($project, $payload);
+ parent::__construct( $project, $payload );
$this->event = $event;
try {
- $this->analyzerEvent = Event::forPayload($event, $payload);
- } catch (\InvalidArgumentException $ex) {
- $this->analyzerEvent = new UnknownEvent($event);
+ $this->analyzerEvent = Event::forPayload( $event, $payload );
+ } catch ( \InvalidArgumentException $ex ) {
+ $this->analyzerEvent = new UnknownEvent( $event );
}
}
@@ -66,8 +66,8 @@
*
* @var string
*/
- public function getItemName () : string {
- if ($this->isAdministrativeEvent()) {
+ public function getItemName(): string {
+ if ( $this->isAdministrativeEvent() ) {
return '';
}
@@ -81,14 +81,14 @@
/**
* @return bool
*/
- public function isAdministrativeEvent () : bool {
+ public function isAdministrativeEvent(): bool {
$administrativeEvents = [
'membership', // Member added to team
'ping', // Special ping pong event, fired on new hook
'repository', // Repository created
];
- return in_array($this->event, $administrativeEvents);
+ return in_array( $this->event, $administrativeEvents );
}
///
@@ -100,7 +100,7 @@
*
* @return string
*/
- public function getDescription () : string {
+ public function getDescription(): string {
return $this->analyzerEvent->getDescription();
}
@@ -109,7 +109,7 @@
*
* @return string The most relevant URL
*/
- public function getLink () : string {
+ public function getLink(): string {
return $this->analyzerEvent->getLink();
}
diff --git a/app/Analyzers/ItemGroupMapping.php b/app/Analyzers/ItemGroupMapping.php
--- a/app/Analyzers/ItemGroupMapping.php
+++ b/app/Analyzers/ItemGroupMapping.php
@@ -7,6 +7,7 @@
*/
class ItemGroupMapping {
+
///
/// Properties
///
@@ -38,11 +39,11 @@
* @param string $item The item name to compare with the pattern
* @return bool
*/
- public static function doesItemMatch (
+ public static function doesItemMatch(
string $pattern,
string $item
- ) : bool {
- return str_is($pattern, $item);
+ ): bool {
+ return str_contains($pattern, $item);
}
/**
@@ -50,7 +51,7 @@
*
* @return bool
*/
- public function doesItemBelong (string $actualItem) : bool {
+ public function doesItemBelong(string $actualItem): bool {
foreach ($this->items as $candidateItem) {
if (static::doesItemMatch($candidateItem, $actualItem)) {
return true;
@@ -59,5 +60,4 @@
return false;
}
-
}
diff --git a/app/Analyzers/Jenkins/JenkinsPayloadAnalyzer.php b/app/Analyzers/Jenkins/JenkinsPayloadAnalyzer.php
--- a/app/Analyzers/Jenkins/JenkinsPayloadAnalyzer.php
+++ b/app/Analyzers/Jenkins/JenkinsPayloadAnalyzer.php
@@ -20,7 +20,7 @@
*
* @var string
*/
- public function getItemName () : string {
+ public function getItemName(): string {
return $this->payload->name;
}
@@ -31,11 +31,11 @@
/**
* Tries to get build status.
*
- * @param out string $status
+ * @param out string &$status
* @return bool indicates if the build status is defined in the payload
*/
- private function tryGetBuildStatus (string &$status) : bool {
- if (!isset($this->payload->build->status)) {
+ private function tryGetBuildStatus( string &$status ): bool {
+ if ( !isset( $this->payload->build->status ) ) {
return false;
}
@@ -46,7 +46,7 @@
/**
* @return bool
*/
- public function shouldNotifyOnlyOnFailure () : bool {
+ public function shouldNotifyOnlyOnFailure(): bool {
return in_array(
$this->getItemName(),
$this->configuration->notifyOnlyOnFailure
@@ -58,10 +58,10 @@
*
* @return bool
*/
- public function isFailure () : bool {
+ public function isFailure(): bool {
$status = "";
- if (!$this->tryGetBuildStatus($status)) {
+ if ( !$this->tryGetBuildStatus( $status ) ) {
return false;
}
@@ -75,7 +75,7 @@
*
* @return bool if false, this payload is to be ignored for notifications
*/
- public function shouldNotify () : bool {
+ public function shouldNotify(): bool {
return $this->isFailure() || !$this->shouldNotifyOnlyOnFailure();
}
diff --git a/app/Analyzers/PayloadAnalyzerConfiguration.php b/app/Analyzers/PayloadAnalyzerConfiguration.php
--- a/app/Analyzers/PayloadAnalyzerConfiguration.php
+++ b/app/Analyzers/PayloadAnalyzerConfiguration.php
@@ -6,7 +6,7 @@
///
/// Private members
- ///
+ ///z
/**
* The project this configuration is for
@@ -49,7 +49,7 @@
*
* @param string $project The project name this configuration is related to
*/
- public function __construct (string $project) {
+ public function __construct( string $project ) {
$this->project = $project;
}
@@ -63,9 +63,9 @@
* @return string the default group, as set in the configuration,
* or if omitted, the project name as fallback.
*/
- public function getDefaultGroup () : string {
- if (empty($this->defaultGroup)) {
- return strtolower($this->project);
+ public function getDefaultGroup(): string {
+ if ( empty( $this->defaultGroup ) ) {
+ return strtolower( $this->project );
}
return $this->defaultGroup;
diff --git a/app/Analyzers/Phabricator/PhabricatorGroupMapping.php b/app/Analyzers/Phabricator/PhabricatorGroupMapping.php
--- a/app/Analyzers/Phabricator/PhabricatorGroupMapping.php
+++ b/app/Analyzers/Phabricator/PhabricatorGroupMapping.php
@@ -6,7 +6,7 @@
use Nasqueron\Notifications\Phabricator\PhabricatorStory;
class PhabricatorGroupMapping extends ItemGroupMapping {
-
+
///
/// Extra properties
///
@@ -27,13 +27,13 @@
*
* @return bool
*/
- public function doesStoryBelong (PhabricatorStory $story) : bool {
- foreach ($this->words as $word) {
- if (stripos($story->text, $word) !== false) {
+ public function doesStoryBelong( PhabricatorStory $story ): bool {
+ foreach ( $this->words as $word ) {
+ if ( stripos( $story->text, $word ) !== false ) {
return true;
}
}
return false;
}
-
+
}
diff --git a/app/Analyzers/Phabricator/PhabricatorPayloadAnalyzer.php b/app/Analyzers/Phabricator/PhabricatorPayloadAnalyzer.php
--- a/app/Analyzers/Phabricator/PhabricatorPayloadAnalyzer.php
+++ b/app/Analyzers/Phabricator/PhabricatorPayloadAnalyzer.php
@@ -33,7 +33,7 @@
* @param string $project
* @param PhabricatorStory $story
*/
- public function __construct(string $project, PhabricatorStory $story) {
+ public function __construct( string $project, PhabricatorStory $story ) {
$this->project = $project;
$this->story = $story;
@@ -49,27 +49,27 @@
*
* @return string the group, central part of the routing key
*/
- public function getGroup () : string {
+ public function getGroup(): string {
// If the payload is about some repository matching a table of
// symbols, we need to sort it to the right group.
- foreach ($this->configuration->map as $mapping) {
- foreach ($this->story->getProjects() as $project) {
- if ($mapping->doesItemBelong($project)) {
+ foreach ( $this->configuration->map as $mapping ) {
+ foreach ( $this->story->getProjects() as $project ) {
+ if ( $mapping->doesItemBelong( $project ) ) {
return $mapping->group;
}
}
}
// Words
- foreach ($this->configuration->map as $mapping) {
- if ($mapping->doesStoryBelong($this->story)) {
+ foreach ( $this->configuration->map as $mapping ) {
+ if ( $mapping->doesStoryBelong( $this->story ) ) {
return $mapping->group;
}
}
// By default, fallback group is the project name or a specified value.
- if (empty($this->configuration->defaultGroup)) {
- return strtolower($this->project);
+ if ( empty( $this->configuration->defaultGroup ) ) {
+ return strtolower( $this->project );
}
return $this->configuration->defaultGroup;
}
diff --git a/app/Config/Features.php b/app/Config/Features.php
--- a/app/Config/Features.php
+++ b/app/Config/Features.php
@@ -22,7 +22,7 @@
* @param string $feature The feature to get the config key
* @return string The config key
*/
- private static function getFeatureConfigKey (string $feature) : string {
+ private static function getFeatureConfigKey( string $feature ): string {
return 'app.features.' . $feature;
}
@@ -32,9 +32,9 @@
* @param string $feature The feature to check in the config
* @return bool
*/
- public static function isEnabled (string $feature) : bool {
- $key = self::getFeatureConfigKey($feature);
- return Config::has($key) && (bool)Config::get($key);
+ public static function isEnabled( string $feature ): bool {
+ $key = self::getFeatureConfigKey( $feature );
+ return Config::has( $key ) && (bool)Config::get( $key );
}
/**
@@ -42,9 +42,9 @@
*
* @param string $feature The feature
*/
- public static function enable (string $feature) : void {
- $key = self::getFeatureConfigKey($feature);
- Config::set($key, true);
+ public static function enable( string $feature ): void {
+ $key = self::getFeatureConfigKey( $feature );
+ Config::set( $key, true );
}
/**
@@ -52,9 +52,9 @@
*
* @param string $feature The feature
*/
- public static function disable (string $feature) : void {
- $key = self::getFeatureConfigKey($feature);
- Config::set($key, false);
+ public static function disable( string $feature ): void {
+ $key = self::getFeatureConfigKey( $feature );
+ Config::set( $key, false );
}
///
@@ -64,8 +64,8 @@
/**
* Gets all the features, with the toggle status.
*/
- public static function getAll () : array {
- return Config::get('app.features');
+ public static function getAll(): array {
+ return Config::get( 'app.features' );
}
/**
@@ -73,9 +73,9 @@
*
* @return string[] a list of all features
*/
- public static function getAvailable () : array {
+ public static function getAvailable(): array {
$features = self::getAll();
- return array_keys($features);
+ return array_keys( $features );
}
/**
@@ -83,10 +83,10 @@
*
* @return string[] a list of enabled features
*/
- public static function getEnabled () : array {
+ public static function getEnabled(): array {
$features = self::getAll();
- $enabledFeatures = array_filter($features);
- return array_keys($enabledFeatures);
+ $enabledFeatures = array_filter( $features );
+ return array_keys( $enabledFeatures );
}
}
diff --git a/app/Config/Reporting/BaseReportEntry.php b/app/Config/Reporting/BaseReportEntry.php
--- a/app/Config/Reporting/BaseReportEntry.php
+++ b/app/Config/Reporting/BaseReportEntry.php
@@ -8,8 +8,9 @@
/// Format
///
- public abstract function toArray () : array;
- public abstract function toFancyArray () : array;
+ abstract public function toArray(): array;
+
+ abstract public function toFancyArray(): array;
///
/// Format helper methods
@@ -22,11 +23,11 @@
* @param string $emptyStringGlyph The glyph to use if the string is empty
* @return string
*/
- public static function fancyString (
+ public static function fancyString(
string $string,
string $emptyStringGlyph
- ) : string {
- if ($string === "") {
+ ): string {
+ if ( $string === "" ) {
return $emptyStringGlyph;
}
@@ -43,12 +44,12 @@
*
* @return string The relevant glyph
*/
- public static function fancyBool (
+ public static function fancyBool(
bool $value,
string $truthyStringGlyph,
string $falsyStringGlyph = ''
- ) : string {
- if ($value) {
+ ): string {
+ if ( $value ) {
return $truthyStringGlyph;
}
diff --git a/app/Config/Reporting/ConfigReport.php b/app/Config/Reporting/ConfigReport.php
--- a/app/Config/Reporting/ConfigReport.php
+++ b/app/Config/Reporting/ConfigReport.php
@@ -2,9 +2,8 @@
namespace Nasqueron\Notifications\Config\Reporting;
-use Nasqueron\Notifications\Config\Features;
-
use Config;
+use Nasqueron\Notifications\Config\Features;
use Services;
class ConfigReport {
@@ -32,7 +31,7 @@
/// Public constructor
///
- public function __construct () {
+ public function __construct() {
$this->gates = $this->queryGates();
$this->features = $this->queryFeatures();
$this->services = $this->queryServices();
@@ -47,8 +46,8 @@
*
* @return string[]
*/
- protected function queryGates () : array {
- return Config::get('gate.controllers');
+ protected function queryGates(): array {
+ return Config::get( 'gate.controllers' );
}
/**
@@ -56,11 +55,11 @@
*
* @return FeatureReportEntry[]
*/
- protected function queryFeatures () : array {
+ protected function queryFeatures(): array {
$features = [];
- foreach (Features::getAll() as $feature => $enabled) {
- $features[] = new FeatureReportEntry($feature, $enabled);
+ foreach ( Features::getAll() as $feature => $enabled ) {
+ $features[] = new FeatureReportEntry( $feature, $enabled );
}
return $features;
@@ -71,11 +70,11 @@
*
* @return ServiceReportEntry[]
*/
- protected function queryServices () : array {
+ protected function queryServices(): array {
$services = [];
- foreach (Services::get() as $service) {
- $services[] = new ServiceReportEntry($service);
+ foreach ( Services::get() as $service ) {
+ $services[] = new ServiceReportEntry( $service );
}
return $services;
diff --git a/app/Config/Reporting/FeatureReportEntry.php b/app/Config/Reporting/FeatureReportEntry.php
--- a/app/Config/Reporting/FeatureReportEntry.php
+++ b/app/Config/Reporting/FeatureReportEntry.php
@@ -28,7 +28,7 @@
* @var name The feature name
* @var bool If the feature enabled, true. Otherwise, false.
*/
- public function __construct (string $name, bool $enabled) {
+ public function __construct( string $name, bool $enabled ) {
$this->name = $name;
$this->enabled = $enabled;
}
@@ -42,7 +42,7 @@
*
* @return string[]
*/
- public function toArray () : array {
+ public function toArray(): array {
return [
$this->name,
(string)$this->enabled,
@@ -54,10 +54,10 @@
*
* @return string[]
*/
- public function toFancyArray () : array {
+ public function toFancyArray(): array {
return [
$this->name,
- self::fancyBool($this->enabled, '✓'),
+ self::fancyBool( $this->enabled, '✓' ),
];
}
diff --git a/app/Config/Reporting/ServiceReportEntry.php b/app/Config/Reporting/ServiceReportEntry.php
--- a/app/Config/Reporting/ServiceReportEntry.php
+++ b/app/Config/Reporting/ServiceReportEntry.php
@@ -45,7 +45,7 @@
/// Constructor
///
- public function __construct (Service $service) {
+ public function __construct( Service $service ) {
$this->service = $service;
$this->query();
}
@@ -57,7 +57,7 @@
/**
* Queries the service to fill public properties.
*/
- protected function query () : void {
+ protected function query(): void {
// Direct properties
$this->gate = $this->service->gate;
$this->door = $this->service->door;
@@ -70,8 +70,8 @@
/**
* @return string An issue to fix, or an empty string if all looks good.
*/
- protected function getServiceStatus () : string {
- if ($this->isPhabricatorServiceWithNotCachedProjectsMap()) {
+ protected function getServiceStatus(): string {
+ if ( $this->isPhabricatorServiceWithNotCachedProjectsMap() ) {
return "Projects map not cached.";
}
@@ -85,12 +85,12 @@
*
* @return bool
*/
- protected function isPhabricatorServiceWithNotCachedProjectsMap () : bool {
- if ($this->service->gate !== 'Phabricator') {
+ protected function isPhabricatorServiceWithNotCachedProjectsMap(): bool {
+ if ( $this->service->gate !== 'Phabricator' ) {
return false;
}
- $map = ProjectsMap::fetch($this->service->door);
+ $map = ProjectsMap::fetch( $this->service->door );
return !$map->isCached();
}
@@ -103,7 +103,7 @@
*
* @return string[]
*/
- public function toArray () : array {
+ public function toArray(): array {
return [
$this->gate,
$this->door,
@@ -117,12 +117,12 @@
*
* @return string[]
*/
- public function toFancyArray () : array {
+ public function toFancyArray(): array {
return [
$this->gate,
$this->door,
- self::fancyString($this->instance, 'ø'),
- self::fancyString($this->status, '✓'),
+ self::fancyString( $this->instance, 'ø' ),
+ self::fancyString( $this->status, '✓' ),
];
}
diff --git a/app/Config/Services/Service.php b/app/Config/Services/Service.php
--- a/app/Config/Services/Service.php
+++ b/app/Config/Services/Service.php
@@ -28,8 +28,8 @@
*
* @return string The instance name or "ø" if omitted
*/
- public function getInstanceName () : string {
- if (!isset($this->instance)) {
+ public function getInstanceName(): string {
+ if ( !isset( $this->instance ) ) {
return "ø";
}
diff --git a/app/Config/Services/Services.php b/app/Config/Services/Services.php
--- a/app/Config/Services/Services.php
+++ b/app/Config/Services/Services.php
@@ -23,11 +23,11 @@
* @param string $file The JSON file to deserialize
* @return Services The deserialized instance
*/
- public static function loadFromJson (string $file) : Services {
- $data = json_decode(Storage::get($file));
+ public static function loadFromJson( string $file ): Services {
+ $data = json_decode( Storage::get( $file ) );
$mapper = new \JsonMapper();
- return $mapper->map($data, new self());
+ return $mapper->map( $data, new self() );
}
///
@@ -39,7 +39,7 @@
*
* @return Service[]
*/
- public function get () {
+ public function get() {
return $this->services;
}
@@ -49,11 +49,11 @@
* @param string $gate The gate (e.g. GitHub)
* @return Service[]
*/
- public function getForGate (string $gate) : array {
+ public function getForGate( string $gate ): array {
$services = [];
- foreach ($this->services as $service) {
- if ($service->gate === $gate) {
+ foreach ( $this->services as $service ) {
+ if ( $service->gate === $gate ) {
$services[] = $service;
}
}
@@ -72,9 +72,9 @@
* @param string $door The door (e.g. Nasqueron)
* @return Service|null The service information is found; otherwise, null.
*/
- public function findServiceByDoor (string $gate, string $door) : ?Service {
- foreach ($this->services as $service) {
- if ($service->gate === $gate && $service->door === $door) {
+ public function findServiceByDoor( string $gate, string $door ): ?Service {
+ foreach ( $this->services as $service ) {
+ if ( $service->gate === $gate && $service->door === $door ) {
return $service;
}
}
@@ -91,13 +91,13 @@
* (e.g. 'http://devcentral.nasqueron.org')
* @return Service|null The service information is found; otherwise, null.
*/
- public function findServiceByProperty (
+ public function findServiceByProperty(
string $gate,
string $property,
$value
- ) : ?Service {
- foreach ($this->services as $service) {
- if ($service->gate === $gate && $service->$property === $value) {
+ ): ?Service {
+ foreach ( $this->services as $service ) {
+ if ( $service->gate === $gate && $service->$property === $value ) {
return $service;
}
}
diff --git a/app/Console/Commands/ConfigShow.php b/app/Console/Commands/ConfigShow.php
--- a/app/Console/Commands/ConfigShow.php
+++ b/app/Console/Commands/ConfigShow.php
@@ -36,10 +36,10 @@
*
* @return array
*/
- protected function getServicesTableRows () : array {
+ protected function getServicesTableRows(): array {
$rows = [];
- foreach ($this->report->services as $service) {
+ foreach ( $this->report->services as $service ) {
$rows[] = $service->toFancyArray();
}
@@ -51,10 +51,10 @@
*
* @return array
*/
- protected function getFeaturesTableRows () : array {
+ protected function getFeaturesTableRows(): array {
$rows = [];
- foreach ($this->report->features as $feature) {
+ foreach ( $this->report->features as $feature ) {
$rows[] = $feature->toFancyArray();
}
@@ -68,7 +68,7 @@
/**
* Executes the console command.
*/
- public function handle () : void {
+ public function handle(): void {
$this->prepareReport();
$this->printGates();
@@ -76,29 +76,29 @@
$this->printServices();
}
- protected final function prepareReport() : void {
+ final protected function prepareReport(): void {
$this->report = new ConfigReport();
}
- protected final function printGates () : void {
- $this->info("Gates:\n");
- foreach ($this->report->gates as $gate) {
- $this->line('- ' . $gate);
+ final protected function printGates(): void {
+ $this->info( "Gates:\n" );
+ foreach ( $this->report->gates as $gate ) {
+ $this->line( '- ' . $gate );
}
}
- protected final function printFeatures () : void {
- $this->info("\nFeatures:\n");
+ final protected function printFeatures(): void {
+ $this->info( "\nFeatures:\n" );
$this->table(
- ['Feature', 'Enabled'],
+ [ 'Feature', 'Enabled' ],
$this->getFeaturesTableRows()
);
}
- protected final function printServices () : void {
- $this->info("\nServices declared in credentials:\n");
+ final protected function printServices(): void {
+ $this->info( "\nServices declared in credentials:\n" );
$this->table(
- ['Gate', 'Door', 'Instance', 'Status'],
+ [ 'Gate', 'Door', 'Instance', 'Status' ],
$this->getServicesTableRows()
);
}
diff --git a/app/Console/Commands/ConfigValidate.php b/app/Console/Commands/ConfigValidate.php
--- a/app/Console/Commands/ConfigValidate.php
+++ b/app/Console/Commands/ConfigValidate.php
@@ -2,11 +2,10 @@
namespace Nasqueron\Notifications\Console\Commands;
+use App;
use Illuminate\Console\Command;
use Illuminate\Filesystem\FilesystemAdapter;
-use App;
-
class ConfigValidate extends Command {
/**
@@ -23,17 +22,17 @@
*/
protected $description = 'Validates JSON configuration files';
- private function getFS () : FilesystemAdapter {
- return App::make('filesystem')->disk('local');
+ private function getFS(): FilesystemAdapter {
+ return App::make( 'filesystem' )->disk( 'local' );
}
- private function getConfigFiles () : array {
+ private function getConfigFiles(): array {
return array_filter(
$this->getFS()->allFiles(),
// Filters *.json
- function ($file) : bool {
- return substr($file, -5) === ".json";
+ static function ( $file ): bool {
+ return substr( $file, -5 ) === ".json";
}
);
}
@@ -41,13 +40,13 @@
/**
* Executes the console command.
*/
- public function handle() : void {
+ public function handle(): void {
$files = $this->getConfigFiles();
- foreach ($files as $file) {
- $content = $this->getFS()->get($file);
- if (json_decode($content) === null) {
- $this->line("$file — " . json_last_error_msg());
+ foreach ( $files as $file ) {
+ $content = $this->getFS()->get( $file );
+ if ( json_decode( $content ) === null ) {
+ $this->line( "$file — " . json_last_error_msg() );
}
}
}
diff --git a/app/Console/Commands/Inspire.php b/app/Console/Commands/Inspire.php
--- a/app/Console/Commands/Inspire.php
+++ b/app/Console/Commands/Inspire.php
@@ -23,7 +23,7 @@
/**
* Executes the console command.
*/
- public function handle() : void {
- $this->comment(PHP_EOL . Inspiring::quote() . PHP_EOL);
+ public function handle(): void {
+ $this->comment( PHP_EOL . Inspiring::quote() . PHP_EOL );
}
}
diff --git a/app/Console/Commands/NotificationsPayload.php b/app/Console/Commands/NotificationsPayload.php
--- a/app/Console/Commands/NotificationsPayload.php
+++ b/app/Console/Commands/NotificationsPayload.php
@@ -2,12 +2,10 @@
namespace Nasqueron\Notifications\Console\Commands;
-use Nasqueron\Notifications\Notifications\Notification;
-use Nasqueron\Notifications\Phabricator\PhabricatorStory;
-
use Illuminate\Console\Command;
-
use InvalidArgumentException;
+use Nasqueron\Notifications\Notifications\Notification;
+use Nasqueron\Notifications\Phabricator\PhabricatorStory;
use ReflectionClass;
class NotificationsPayload extends Command {
@@ -27,7 +25,6 @@
Gets a notification payload from a service payload
TXT;
-
/**
* The service to handle a payload for.
*
@@ -54,8 +51,8 @@
/**
* Executes the console command.
*/
- public function handle() : void {
- if ($this->parseArguments()) {
+ public function handle(): void {
+ if ( $this->parseArguments() ) {
$this->printNotification();
}
}
@@ -65,13 +62,13 @@
*
* @return bool true if arguments looks good; otherwise, false.
*/
- private function parseArguments () : bool {
+ private function parseArguments(): bool {
try {
$this->parseService();
$this->parsePayload();
$this->parseConstructorParameters();
- } catch (InvalidArgumentException $ex) {
- $this->error($ex->getMessage());
+ } catch ( InvalidArgumentException $ex ) {
+ $this->error( $ex->getMessage() );
return false;
}
@@ -86,10 +83,10 @@
* @throws InvalidArgumentException when a notification class can't be
* found for the requested service.
*/
- private function parseService () : void {
- $this->service = $this->argument('service');
+ private function parseService(): void {
+ $this->service = $this->argument( 'service' );
- if (!class_exists($this->getNotificationClass())) {
+ if ( !class_exists( $this->getNotificationClass() ) ) {
throw new InvalidArgumentException(
"Unknown service: $this->service"
);
@@ -103,14 +100,14 @@
*
* @throws InvalidArgumentException when payload file is not found.
*/
- private function parsePayload () : void {
- $payloadFile = $this->argument('payload');
+ private function parsePayload(): void {
+ $payloadFile = $this->argument( 'payload' );
- if (!file_exists($payloadFile)) {
- throw new InvalidArgumentException("File not found: $payloadFile");
+ if ( !file_exists( $payloadFile ) ) {
+ throw new InvalidArgumentException( "File not found: $payloadFile" );
}
- $this->payload = file_get_contents($payloadFile);
+ $this->payload = file_get_contents( $payloadFile );
}
/**
@@ -119,13 +116,13 @@
*
* @throws InvalidArgumentException on wrong arguments count.
*/
- private function parseConstructorParameters () : void {
+ private function parseConstructorParameters(): void {
$keys = $this->getNotificationConstructorParameters();
- $values = $this->argument('args');
+ $values = $this->argument( 'args' );
$values['payload'] = $this->payload;
- $this->constructor = self::argumentsArrayCombine($keys, $values);
+ $this->constructor = self::argumentsArrayCombine( $keys, $values );
$this->constructor['payload'] = $this->formatPayload();
}
@@ -135,12 +132,12 @@
* @return PhabricatorStory|stdClass A deserialization of the payload
*/
private function formatPayload() {
- if ($this->service === "Phabricator") {
+ if ( $this->service === "Phabricator" ) {
$project = $this->constructor['project'];
- return PhabricatorStory::loadFromJson($project, $this->payload);
+ return PhabricatorStory::loadFromJson( $project, $this->payload );
}
- return json_decode($this->payload);
+ return json_decode( $this->payload );
}
/**
@@ -152,20 +149,20 @@
*
* @throws InvalidArgumentException when keys and values counts don't match
*/
- public static function argumentsArrayCombine (
+ public static function argumentsArrayCombine(
array $keys, array $values
- ) : array {
- $countKeys = count($keys);
- $countValues = count($values);
+ ): array {
+ $countKeys = count( $keys );
+ $countValues = count( $values );
- if ($countKeys != $countValues) {
- throw new InvalidArgumentException(<<<MSG
+ if ( $countKeys != $countValues ) {
+ throw new InvalidArgumentException( <<<MSG
Number of arguments mismatch: got $countValues but expected $countKeys.
MSG
);
}
- return array_combine($keys, $values);
+ return array_combine( $keys, $values );
}
/**
@@ -174,10 +171,10 @@
*
* @return \Nasqueron\Notifications\Notifications\Notification
*/
- private function getNotification () : Notification {
+ private function getNotification(): Notification {
$class = $this->getNotificationClass();
- $args = array_values($this->constructor);
- return new $class(...$args);
+ $args = array_values( $this->constructor );
+ return new $class( ...$args );
}
/**
@@ -185,15 +182,15 @@
*
* @return string
*/
- private function formatNotification () : string {
- return json_encode($this->getNotification(), JSON_PRETTY_PRINT);
+ private function formatNotification(): string {
+ return json_encode( $this->getNotification(), JSON_PRETTY_PRINT );
}
/**
* Prints the notification for the service, payload and specified arguments.
*/
- private function printNotification () : void {
- $this->line($this->formatNotification());
+ private function printNotification(): void {
+ $this->line( $this->formatNotification() );
}
/**
@@ -201,7 +198,7 @@
*
* @return string
*/
- private function getNotificationClass () : string {
+ private function getNotificationClass(): string {
$namespace = "Nasqueron\Notifications\Notifications\\";
return $namespace . $this->service . "Notification";
}
@@ -212,11 +209,11 @@
*
* @return array
*/
- private function getNotificationConstructorParameters () : array {
+ private function getNotificationConstructorParameters(): array {
$parameters = [];
- $class = new ReflectionClass($this->getNotificationClass());
- foreach ($class->getConstructor()->getParameters() as $parameter) {
+ $class = new ReflectionClass( $this->getNotificationClass() );
+ foreach ( $class->getConstructor()->getParameters() as $parameter ) {
$parameters[] = $parameter->getName();
}
diff --git a/app/Console/Commands/PhabricatorProjectsMap.php b/app/Console/Commands/PhabricatorProjectsMap.php
--- a/app/Console/Commands/PhabricatorProjectsMap.php
+++ b/app/Console/Commands/PhabricatorProjectsMap.php
@@ -27,13 +27,13 @@
/**
* Executes the console command.
*/
- public function handle() : void {
- foreach (Services::getForGate('Phabricator') as $service) {
- $this->info("Querying projects map for " . $service->instance);
- $map = ProjectsMap::fetch($service->door);
+ public function handle(): void {
+ foreach ( Services::getForGate( 'Phabricator' ) as $service ) {
+ $this->info( "Querying projects map for " . $service->instance );
+ $map = ProjectsMap::fetch( $service->door );
$map->saveToCache();
$this->table(
- ['PHID', 'Project name'],
+ [ 'PHID', 'Project name' ],
$map->toArray()
);
}
diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php
--- a/app/Console/Kernel.php
+++ b/app/Console/Kernel.php
@@ -24,11 +24,11 @@
/**
* Define the application's command schedule.
*
- * @param \Illuminate\Console\Scheduling\Schedule $schedule
+ * @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
- protected function schedule (Schedule $schedule) : void {
- $schedule->command('inspire')
+ protected function schedule( Schedule $schedule ): void {
+ $schedule->command( 'inspire' )
->hourly();
}
@@ -37,14 +37,14 @@
*
* @throws \RuntimeException when command doesn't exit
*/
- public function get (string $name) : Command {
+ public function get( string $name ): Command {
$commands = $this->all();
- if (array_key_exists($name, $commands)) {
+ if ( array_key_exists( $name, $commands ) ) {
return $commands[$name];
}
- throw new \RuntimeException("Command $name doesn't exist.");
+ throw new \RuntimeException( "Command $name doesn't exist." );
}
/**
@@ -54,15 +54,15 @@
* @return \Illuminate\Console\Command
* @throws \RuntimeException when command doesn't exit
*/
- public function getByClass (string $class) : Command {
+ public function getByClass( string $class ): Command {
$commands = $this->all();
- foreach ($commands as $command) {
- if ($command instanceof $class) {
+ foreach ( $commands as $command ) {
+ if ( $command instanceof $class ) {
return $command;
}
}
- throw new \RuntimeException("Command $class doesn't exist.");
+ throw new \RuntimeException( "Command $class doesn't exist." );
}
}
diff --git a/app/Contracts/APIClient.php b/app/Contracts/APIClient.php
--- a/app/Contracts/APIClient.php
+++ b/app/Contracts/APIClient.php
@@ -10,7 +10,7 @@
* @param string $url The API end point URL
* @return void
*/
- public function setEndPoint ($url);
+ public function setEndPoint( string $url );
/**
* Calls an API method
@@ -19,6 +19,6 @@
* @param array $arguments The arguments to use
* @return mixed The API result
*/
- public function call ($method, $arguments = []);
+ public function call( string $method, array $arguments = [] );
}
diff --git a/app/Contracts/APIFactory.php b/app/Contracts/APIFactory.php
--- a/app/Contracts/APIFactory.php
+++ b/app/Contracts/APIFactory.php
@@ -10,6 +10,6 @@
* @param string $endPoint The API end point
* @return APIClient
*/
- public function get ($endPoint);
+ public function get( string $endPoint );
}
diff --git a/app/Events/DockerHubPayloadEvent.php b/app/Events/DockerHubPayloadEvent.php
--- a/app/Events/DockerHubPayloadEvent.php
+++ b/app/Events/DockerHubPayloadEvent.php
@@ -2,7 +2,6 @@
namespace Nasqueron\Notifications\Events;
-use Nasqueron\Notifications\Events\Event;
use Illuminate\Queue\SerializesModels;
class DockerHubPayloadEvent extends Event {
@@ -31,8 +30,8 @@
*
* @return string
*/
- public function getEvent () : string {
- if (isset($this->payload->repository->repo_url)) {
+ public function getEvent(): string {
+ if ( isset( $this->payload->repository->repo_url ) ) {
return "push";
}
@@ -45,7 +44,7 @@
* @param string $door
* @param \stdClass $payload
*/
- public function __construct($door, $payload) {
+ public function __construct( $door, $payload ) {
$this->door = $door;
$this->payload = $payload;
$this->event = $this->getEvent();
diff --git a/app/Events/GitHubPayloadEvent.php b/app/Events/GitHubPayloadEvent.php
--- a/app/Events/GitHubPayloadEvent.php
+++ b/app/Events/GitHubPayloadEvent.php
@@ -2,7 +2,6 @@
namespace Nasqueron\Notifications\Events;
-use Nasqueron\Notifications\Events\Event;
use Illuminate\Queue\SerializesModels;
class GitHubPayloadEvent extends Event {
@@ -33,7 +32,7 @@
* @param string $event
* @param \stdClass $payload
*/
- public function __construct($door, $event, $payload) {
+ public function __construct( $door, $event, $payload ) {
$this->door = $door;
$this->event = $event;
$this->payload = $payload;
diff --git a/app/Events/JenkinsPayloadEvent.php b/app/Events/JenkinsPayloadEvent.php
--- a/app/Events/JenkinsPayloadEvent.php
+++ b/app/Events/JenkinsPayloadEvent.php
@@ -2,7 +2,6 @@
namespace Nasqueron\Notifications\Events;
-use Nasqueron\Notifications\Events\Event;
use Illuminate\Queue\SerializesModels;
class JenkinsPayloadEvent extends Event {
@@ -26,7 +25,7 @@
* @param string $door
* @param \stdClass $payload
*/
- public function __construct($door, $payload) {
+ public function __construct( $door, $payload ) {
$this->door = $door;
$this->payload = $payload;
}
diff --git a/app/Events/NotificationEvent.php b/app/Events/NotificationEvent.php
--- a/app/Events/NotificationEvent.php
+++ b/app/Events/NotificationEvent.php
@@ -2,10 +2,8 @@
namespace Nasqueron\Notifications\Events;
-use Nasqueron\Notifications\Events\Event;
-use Nasqueron\Notifications\Notifications\Notification;
-
use Illuminate\Queue\SerializesModels;
+use Nasqueron\Notifications\Notifications\Notification;
class NotificationEvent extends Event {
use SerializesModels;
@@ -20,7 +18,7 @@
*
* @param Notification $notification the notification
*/
- public function __construct(Notification $notification) {
+ public function __construct( Notification $notification ) {
$this->notification = $notification;
}
}
diff --git a/app/Events/PhabricatorPayloadEvent.php b/app/Events/PhabricatorPayloadEvent.php
--- a/app/Events/PhabricatorPayloadEvent.php
+++ b/app/Events/PhabricatorPayloadEvent.php
@@ -2,9 +2,8 @@
namespace Nasqueron\Notifications\Events;
-use Nasqueron\Notifications\Events\Event;
-use Nasqueron\Notifications\Phabricator\PhabricatorStory;
use Illuminate\Queue\SerializesModels;
+use Nasqueron\Notifications\Phabricator\PhabricatorStory;
class PhabricatorPayloadEvent extends Event {
use SerializesModels;
@@ -32,7 +31,7 @@
*
* @return PhabricatorStory
*/
- protected function getStory () {
+ protected function getStory() {
return PhabricatorStory::loadFromIterable(
$this->door,
$this->payload
@@ -45,7 +44,7 @@
* @param string $door
* @param iterable $payload
*/
- public function __construct(string $door, iterable $payload) {
+ public function __construct( string $door, iterable $payload ) {
$this->door = $door;
$this->payload = $payload;
diff --git a/app/Events/ReportEvent.php b/app/Events/ReportEvent.php
--- a/app/Events/ReportEvent.php
+++ b/app/Events/ReportEvent.php
@@ -2,9 +2,8 @@
namespace Nasqueron\Notifications\Events;
-use Nasqueron\Notifications\Actions\Action;
-use Nasqueron\Notifications\Events\Event;
use Illuminate\Queue\SerializesModels;
+use Nasqueron\Notifications\Actions\Action;
class ReportEvent extends Event {
use SerializesModels;
@@ -19,7 +18,7 @@
*
* @param Action $action the action to report
*/
- public function __construct(Action $action) {
+ public function __construct( Action $action ) {
$this->action = $action;
}
}
diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php
--- a/app/Exceptions/Handler.php
+++ b/app/Exceptions/Handler.php
@@ -2,21 +2,18 @@
namespace Nasqueron\Notifications\Exceptions;
-use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
-
+use Config;
+use Exception;
use Illuminate\Auth\Access\AuthorizationException;
use Illuminate\Database\Eloquent\ModelNotFoundException;
+use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Illuminate\Foundation\Validation\ValidationException;
use Illuminate\Session\TokenMismatchException;
use Psr\Log\LoggerInterface;
+use Raven;
use Symfony\Component\Console\Exception\CommandNotFoundException;
use Symfony\Component\HttpKernel\Exception\HttpException;
-use Config;
-use Raven;
-
-use Exception;
-
class Handler extends ExceptionHandler {
/**
@@ -40,17 +37,17 @@
*
* @param \Exception $e
*/
- public function report(Exception $e) : void {
- if (!$this->shouldReport($e)) {
+ public function report( \Throwable $e ): void {
+ if ( !$this->shouldReport( $e ) ) {
return;
}
- if ($this->shouldReportToSentry()) {
- $this->reportToSentry($e);
+ if ( $this->shouldReportToSentry() ) {
+ $this->reportToSentry( $e );
}
- $log = $this->container->make(LoggerInterface::class);
- $log->error((string)$e);
+ $log = $this->container->make( LoggerInterface::class );
+ $log->error( (string)$e );
}
/**
@@ -58,8 +55,8 @@
*
* @return bool
*/
- protected function shouldReportToSentry () : bool {
- return Raven::isConfigured() && Config::get('app.env') !== 'testing';
+ protected function shouldReportToSentry(): bool {
+ return Raven::isConfigured() && Config::get( 'app.env' ) !== 'testing';
}
/**
@@ -67,8 +64,8 @@
*
* @param Exception $e The exception to report
*/
- protected function reportToSentry (Exception $e) : void {
- Raven::captureException($e);
+ protected function reportToSentry( Exception $e ): void {
+ Raven::captureException( $e );
}
}
diff --git a/app/Facades/Broker.php b/app/Facades/Broker.php
--- a/app/Facades/Broker.php
+++ b/app/Facades/Broker.php
@@ -14,7 +14,7 @@
*
* @return string
*/
- protected static function getFacadeAccessor() : string {
+ protected static function getFacadeAccessor(): string {
return 'broker';
}
diff --git a/app/Facades/DockerHub.php b/app/Facades/DockerHub.php
--- a/app/Facades/DockerHub.php
+++ b/app/Facades/DockerHub.php
@@ -14,7 +14,7 @@
*
* @return string
*/
- protected static function getFacadeAccessor() : string {
+ protected static function getFacadeAccessor(): string {
return 'dockerhub';
}
diff --git a/app/Facades/Mailgun.php b/app/Facades/Mailgun.php
--- a/app/Facades/Mailgun.php
+++ b/app/Facades/Mailgun.php
@@ -14,7 +14,7 @@
*
* @return string
*/
- protected static function getFacadeAccessor() : string {
+ protected static function getFacadeAccessor(): string {
return 'mailgun';
}
diff --git a/app/Facades/PhabricatorAPI.php b/app/Facades/PhabricatorAPI.php
--- a/app/Facades/PhabricatorAPI.php
+++ b/app/Facades/PhabricatorAPI.php
@@ -14,7 +14,7 @@
*
* @return string
*/
- protected static function getFacadeAccessor() : string {
+ protected static function getFacadeAccessor(): string {
return 'phabricator-api';
}
diff --git a/app/Facades/ProjectsMap.php b/app/Facades/ProjectsMap.php
--- a/app/Facades/ProjectsMap.php
+++ b/app/Facades/ProjectsMap.php
@@ -14,7 +14,7 @@
*
* @return string
*/
- protected static function getFacadeAccessor() : string {
+ protected static function getFacadeAccessor(): string {
return 'phabricator-projectsmap';
}
diff --git a/app/Facades/Raven.php b/app/Facades/Raven.php
--- a/app/Facades/Raven.php
+++ b/app/Facades/Raven.php
@@ -2,9 +2,8 @@
namespace Nasqueron\Notifications\Facades;
-use Illuminate\Support\Facades\Facade;
-
use Config;
+use Illuminate\Support\Facades\Facade;
/**
* @see \Raven_Client
@@ -16,14 +15,14 @@
*
* @return string
*/
- protected static function getFacadeAccessor() : string {
+ protected static function getFacadeAccessor(): string {
return 'raven';
}
/**
* Determines if a Sentry DSN is provided in the configuration
*/
- public static function isConfigured () : bool {
- return Config::get('services.sentry.dsn') !== null;
+ public static function isConfigured(): bool {
+ return Config::get( 'services.sentry.dsn' ) !== null;
}
}
diff --git a/app/Facades/Report.php b/app/Facades/Report.php
--- a/app/Facades/Report.php
+++ b/app/Facades/Report.php
@@ -14,7 +14,7 @@
*
* @return string
*/
- protected static function getFacadeAccessor() : string {
+ protected static function getFacadeAccessor(): string {
return 'report';
}
diff --git a/app/Facades/Services.php b/app/Facades/Services.php
--- a/app/Facades/Services.php
+++ b/app/Facades/Services.php
@@ -14,7 +14,7 @@
*
* @return string
*/
- protected static function getFacadeAccessor() : string {
+ protected static function getFacadeAccessor(): string {
return 'services';
}
diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php
--- a/app/Http/Controllers/Controller.php
+++ b/app/Http/Controllers/Controller.php
@@ -2,12 +2,14 @@
namespace Nasqueron\Notifications\Http\Controllers;
+use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs;
-use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
-use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
+use Illuminate\Routing\Controller as BaseController;
abstract class Controller extends BaseController {
- use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
+ use AuthorizesRequests;
+ use DispatchesJobs;
+ use ValidatesRequests;
}
diff --git a/app/Http/Controllers/Gate/DockerHubGateController.php b/app/Http/Controllers/Gate/DockerHubGateController.php
--- a/app/Http/Controllers/Gate/DockerHubGateController.php
+++ b/app/Http/Controllers/Gate/DockerHubGateController.php
@@ -2,12 +2,10 @@
namespace Nasqueron\Notifications\Http\Controllers\Gate;
-use Nasqueron\Notifications\Events\DockerHubPayloadEvent;
-
-use Symfony\Component\HttpFoundation\Response;
-
use Event;
+use Nasqueron\Notifications\Events\DockerHubPayloadEvent;
use Request;
+use Symfony\Component\HttpFoundation\Response;
class DockerHubGateController extends GateController {
@@ -39,7 +37,7 @@
* @param string $door The door, matching the project for this payload
* @return \Symfony\Component\HttpFoundation\Response
*/
- public function onPost (string $door) : Response {
+ public function onPost( string $door ): Response {
// Parses the request and check if it's legit
$this->door = $door;
@@ -58,13 +56,13 @@
/**
* Extracts payload from the request
*/
- protected function extractPayload () : void {
+ protected function extractPayload(): void {
$request = Request::instance();
$this->rawRequestContent = $request->getContent();
- $this->payload = json_decode($this->rawRequestContent);
+ $this->payload = json_decode( $this->rawRequestContent );
}
- public function getServiceName () : string {
+ public function getServiceName(): string {
return "DockerHub";
}
@@ -72,12 +70,12 @@
/// Payload processing
///
- protected function onPayload () : void {
+ protected function onPayload(): void {
$this->initializeReport();
- Event::fire(new DockerHubPayloadEvent(
+ Event::fire( new DockerHubPayloadEvent(
$this->door,
$this->payload
- ));
+ ) );
}
}
diff --git a/app/Http/Controllers/Gate/GateController.php b/app/Http/Controllers/Gate/GateController.php
--- a/app/Http/Controllers/Gate/GateController.php
+++ b/app/Http/Controllers/Gate/GateController.php
@@ -2,18 +2,16 @@
namespace Nasqueron\Notifications\Http\Controllers\Gate;
+use App;
+use Illuminate\View\View;
+use Log;
use Nasqueron\Notifications\Config\Features;
use Nasqueron\Notifications\Config\Services\Service;
use Nasqueron\Notifications\Http\Controllers\Controller;
-
-use Symfony\Component\HttpFoundation\Response as BaseResponse;
-use Illuminate\View\View;
-
-use App;
-use Log;
use Report;
use Response;
use Services;
+use Symfony\Component\HttpFoundation\Response as BaseResponse;
/**
* Represents a controller handling an entry-point for API payloads
@@ -36,21 +34,21 @@
/**
* Handles GET requests
*/
- public function onGet () : View {
+ public function onGet(): View {
// Virtually all the push APIs will send they payloads
// using a POST request, so we can provide a sensible
// default GET error message.
- return view('gate/ispostonly');
+ return view( 'gate/ispostonly' );
}
/**
* Logs the request
*/
- protected function logRequest (array $extraContextualData = []) : void {
- Log::info('[Gate] New payload.', [
+ protected function logRequest( array $extraContextualData = [] ): void {
+ Log::info( '[Gate] New payload.', [
'service' => $this->getServiceName(),
'door' => $this->door,
- ] + $extraContextualData);
+ ] + $extraContextualData );
}
///
@@ -60,9 +58,9 @@
/**
* Initializes the report and registers it
*/
- protected function initializeReport () : void {
- if (Features::isEnabled('ActionsReport')) {
- Report::attachToGate($this->getServiceName(), $this->door);
+ protected function initializeReport(): void {
+ if ( Features::isEnabled( 'ActionsReport' ) ) {
+ Report::attachToGate( $this->getServiceName(), $this->door );
}
}
@@ -71,15 +69,15 @@
*
* @return \Symfony\Component\HttpFoundation\Response
*/
- protected function renderReport () : BaseResponse {
- if (!Features::isEnabled('ActionsReport')) {
- return response("");
+ protected function renderReport(): BaseResponse {
+ if ( !Features::isEnabled( 'ActionsReport' ) ) {
+ return response( "" );
}
- $report = App::make('report');
+ $report = App::make( 'report' );
$statusCode = $report->containsError() ? 503 : 200;
- return Response::json($report)
- ->setStatusCode($statusCode);
+ return Response::json( $report )
+ ->setStatusCode( $statusCode );
}
///
@@ -89,7 +87,7 @@
/**
* Gets service credentials for this gate and door
*/
- public function getService () : ?Service {
+ public function getService(): ?Service {
return Services::findServiceByDoor(
$this->getServiceName(),
$this->door
@@ -99,7 +97,7 @@
/**
* Checks if a registered service exists for this service and door.
*/
- protected function doesServiceExist () : bool {
+ protected function doesServiceExist(): bool {
return $this->getService() !== null;
}
@@ -108,10 +106,10 @@
*
* @return string the secret, or if unknown, an empty string
*/
- protected function getSecret () : string {
- $service= $this->getService();
+ protected function getSecret(): string {
+ $service = $this->getService();
- if ($service !== null) {
+ if ( $service !== null ) {
return $service->secret;
}
diff --git a/app/Http/Controllers/Gate/GitHubGateController.php b/app/Http/Controllers/Gate/GitHubGateController.php
--- a/app/Http/Controllers/Gate/GitHubGateController.php
+++ b/app/Http/Controllers/Gate/GitHubGateController.php
@@ -2,13 +2,11 @@
namespace Nasqueron\Notifications\Http\Controllers\Gate;
-use Nasqueron\Notifications\Events\GitHubPayloadEvent;
-
-use Keruald\GitHub\XHubSignature;
-use Symfony\Component\HttpFoundation\Response;
-
use Event;
+use Keruald\GitHub\XHubSignature;
+use Nasqueron\Notifications\Events\GitHubPayloadEvent;
use Request;
+use Symfony\Component\HttpFoundation\Response;
class GitHubGateController extends GateController {
@@ -61,19 +59,19 @@
* @param string $door The door, matching the project for this payload
* @return \Symfony\Component\HttpFoundation\Response
*/
- public function onPost (string $door) : Response {
+ public function onPost( string $door ): Response {
// Parses the request and check if it's legit
$this->door = $door;
$this->extractHeaders();
$this->extractPayload();
- if (!$this->isLegitRequest()) {
- abort(403, 'Unauthorized action.');
+ if ( !$this->isLegitRequest() ) {
+ abort( 403, 'Unauthorized action.' );
}
- if (!$this->isValidRequest()) {
- abort(400, 'Bad request.');
+ if ( !$this->isValidRequest() ) {
+ abort( 400, 'Bad request.' );
}
// Process the request
@@ -89,10 +87,10 @@
/**
* Extracts headers from the request
*/
- protected function extractHeaders () : void {
+ protected function extractHeaders(): void {
$this->signature = $this->getSignature();
- $this->event = Request::header('X-Github-Event');
- $this->delivery = Request::header('X-Github-Delivery');
+ $this->event = Request::header( 'X-Github-Event' );
+ $this->delivery = Request::header( 'X-Github-Delivery' );
}
/**
@@ -100,18 +98,18 @@
*
* @return string The signature part of the header
*/
- private function getSignature () : string {
- $headerSignature = Request::header('X-Hub-Signature');
- return XHubSignature::parseSignature($headerSignature);
+ private function getSignature(): string {
+ $headerSignature = Request::header( 'X-Hub-Signature' );
+ return XHubSignature::parseSignature( $headerSignature );
}
/**
* Extracts payload from the request
*/
- protected function extractPayload () : void {
+ protected function extractPayload(): void {
$request = Request::instance();
$this->rawRequestContent = $request->getContent();
- $this->payload = json_decode($this->rawRequestContent);
+ $this->payload = json_decode( $this->rawRequestContent );
}
/**
@@ -120,14 +118,14 @@
*
* @return bool true if the request looks valid; otherwise, false.
*/
- protected function isValidRequest () : bool {
- if (empty($this->event)) {
+ protected function isValidRequest(): bool {
+ if ( empty( $this->event ) ) {
return false;
}
- if (empty($this->delivery)) {
+ if ( empty( $this->delivery ) ) {
return false;
}
- if (empty($this->payload) || !is_object($this->payload)) {
+ if ( empty( $this->payload ) || !is_object( $this->payload ) ) {
return false;
}
return true;
@@ -138,17 +136,17 @@
*
* @return bool true if the request looks legit; otherwise, false.
*/
- protected function isLegitRequest () : bool {
+ protected function isLegitRequest(): bool {
$secret = $this->getSecret();
// If the secret is not defined, request legitimation is bypassed
- if (empty($secret)) {
+ if ( empty( $secret ) ) {
return true;
}
// If the secret is defined, but signature is missing from the
// request, we don't need to perform any other validation.
- if (empty($this->signature)) {
+ if ( empty( $this->signature ) ) {
return false;
}
@@ -162,14 +160,14 @@
/**
* Logs the request
*/
- protected function logGateRequest () {
- $this->logRequest([
+ protected function logGateRequest() {
+ $this->logRequest( [
'delivery' => $this->delivery,
'event' => $this->event,
- ]);
+ ] );
}
- public function getServiceName () : string {
+ public function getServiceName(): string {
return "GitHub";
}
@@ -177,13 +175,13 @@
/// Payload processing
///
- protected function onPayload () {
+ protected function onPayload() {
$this->initializeReport();
- Event::fire(new GitHubPayloadEvent(
+ Event::fire( new GitHubPayloadEvent(
$this->door,
$this->event,
$this->payload
- ));
+ ) );
}
}
diff --git a/app/Http/Controllers/Gate/JenkinsGateController.php b/app/Http/Controllers/Gate/JenkinsGateController.php
--- a/app/Http/Controllers/Gate/JenkinsGateController.php
+++ b/app/Http/Controllers/Gate/JenkinsGateController.php
@@ -2,12 +2,10 @@
namespace Nasqueron\Notifications\Http\Controllers\Gate;
-use Nasqueron\Notifications\Events\JenkinsPayloadEvent;
-
-use Symfony\Component\HttpFoundation\Response;
-
use Event;
+use Nasqueron\Notifications\Events\JenkinsPayloadEvent;
use Request;
+use Symfony\Component\HttpFoundation\Response;
class JenkinsGateController extends GateController {
@@ -39,7 +37,7 @@
* @param string $door The door, matching the project for this payload
* @return \Symfony\Component\HttpFoundation\Response
*/
- public function onPost (string $door) : Response {
+ public function onPost( string $door ): Response {
// Parses the request and check if it's legit
$this->door = $door;
@@ -58,13 +56,13 @@
/**
* Extracts payload from the request
*/
- protected function extractPayload () {
+ protected function extractPayload() {
$request = Request::instance();
$this->rawRequestContent = $request->getContent();
- $this->payload = json_decode($this->rawRequestContent);
+ $this->payload = json_decode( $this->rawRequestContent );
}
- public function getServiceName () : string {
+ public function getServiceName(): string {
return "Jenkins";
}
@@ -72,12 +70,12 @@
/// Payload processing
///
- protected function onPayload () {
+ protected function onPayload() {
$this->initializeReport();
- Event::fire(new JenkinsPayloadEvent(
+ Event::fire( new JenkinsPayloadEvent(
$this->door,
$this->payload
- ));
+ ) );
}
}
diff --git a/app/Http/Controllers/Gate/NotificationGateController.php b/app/Http/Controllers/Gate/NotificationGateController.php
--- a/app/Http/Controllers/Gate/NotificationGateController.php
+++ b/app/Http/Controllers/Gate/NotificationGateController.php
@@ -2,15 +2,12 @@
namespace Nasqueron\Notifications\Http\Controllers\Gate;
+use Event;
+use InvalidArgumentException;
use Nasqueron\Notifications\Events\NotificationEvent;
use Nasqueron\Notifications\Notifications\Notification;
-
-use Symfony\Component\HttpFoundation\Response;
-
-use Event;
use Request;
-
-use InvalidArgumentException;
+use Symfony\Component\HttpFoundation\Response;
class NotificationGateController extends GateController {
@@ -42,7 +39,7 @@
* @param string $door The door, matching the project for this payload
* @return \Symfony\Component\HttpFoundation\Response
*/
- public function onPost (string $door) : Response {
+ public function onPost( string $door ): Response {
// Parses the request and check if it's legit
$this->door = $door;
@@ -50,8 +47,8 @@
try {
$this->extractPayload();
$this->normalizePayload();
- } catch (InvalidArgumentException $ex) {
- abort(400, 'Bad request.');
+ } catch ( InvalidArgumentException $ex ) {
+ abort( 400, 'Bad request.' );
}
// Process the request
@@ -67,13 +64,13 @@
/**
* Extracts payload from the request
*/
- protected function extractPayload () {
+ protected function extractPayload() {
$request = Request::instance();
$this->rawRequestContent = $request->getContent();
$this->payload = $this->getNotification();
}
- protected function getServiceName () : string {
+ protected function getServiceName(): string {
return (string)$this->payload->service;
}
@@ -81,39 +78,39 @@
/// Helper methods to get notification
///
- private function getNotification () : Notification {
- $payload = json_decode($this->rawRequestContent);
- if ($payload === null) {
- throw new InvalidArgumentException("Invalid JSON");
+ private function getNotification(): Notification {
+ $payload = json_decode( $this->rawRequestContent );
+ if ( $payload === null ) {
+ throw new InvalidArgumentException( "Invalid JSON" );
}
$mapper = new \JsonMapper();
- return (Notification)($mapper->map(
+ return ( Notification )( $mapper->map(
$payload,
new Notification
- ));
+ ) );
}
- private function normalizePayload () : void {
+ private function normalizePayload(): void {
$this->normalizeProject();
$this->ensureRequiredPayloadFieldsArePresent();
}
- private function normalizeProject () : void {
- if (!$this->isPayloadFieldPresent('project')) {
+ private function normalizeProject(): void {
+ if ( !$this->isPayloadFieldPresent( 'project' ) ) {
$this->payload->project = $this->door;
}
}
- private function ensureRequiredPayloadFieldsArePresent () : void {
- foreach ($this->getMandatoryPayloadFields() as $field) {
- if (!$this->isPayloadFieldPresent($field)) {
- throw new InvalidArgumentException("Field $field is missing.");
+ private function ensureRequiredPayloadFieldsArePresent(): void {
+ foreach ( $this->getMandatoryPayloadFields() as $field ) {
+ if ( !$this->isPayloadFieldPresent( $field ) ) {
+ throw new InvalidArgumentException( "Field $field is missing." );
}
}
}
- private function getMandatoryPayloadFields () : array {
+ private function getMandatoryPayloadFields(): array {
return [
'service',
'project',
@@ -122,7 +119,7 @@
];
}
- private function isPayloadFieldPresent (string $field) : bool {
+ private function isPayloadFieldPresent( string $field ): bool {
return (string)$this->payload->$field !== "";
}
@@ -130,10 +127,10 @@
/// Payload processing
///
- protected function onPayload () {
+ protected function onPayload() {
$this->initializeReport();
- Event::fire(new NotificationEvent($this->payload));
+ Event::fire( new NotificationEvent( $this->payload ) );
}
}
diff --git a/app/Http/Controllers/Gate/PhabricatorGateController.php b/app/Http/Controllers/Gate/PhabricatorGateController.php
--- a/app/Http/Controllers/Gate/PhabricatorGateController.php
+++ b/app/Http/Controllers/Gate/PhabricatorGateController.php
@@ -2,12 +2,10 @@
namespace Nasqueron\Notifications\Http\Controllers\Gate;
-use Nasqueron\Notifications\Events\PhabricatorPayloadEvent;
-
-use Symfony\Component\HttpFoundation\Response;
-
use Event;
+use Nasqueron\Notifications\Events\PhabricatorPayloadEvent;
use Request;
+use Symfony\Component\HttpFoundation\Response;
class PhabricatorGateController extends GateController {
@@ -32,11 +30,11 @@
* @param string $door The door, matching the project for this payload
* @return \Symfony\Component\HttpFoundation\Response
*/
- public function onPost (string $door) : Response {
+ public function onPost( string $door ): Response {
$this->door = $door;
- if (!$this->doesServiceExist()) {
- abort(404, 'Unknown Phabricator instance.');
+ if ( !$this->doesServiceExist() ) {
+ abort( 404, 'Unknown Phabricator instance.' );
}
$this->extractPayload();
@@ -50,11 +48,11 @@
/**
* Extracts payload from the request
*/
- protected function extractPayload () : void {
+ protected function extractPayload(): void {
$this->payload = Request::all();
}
- public function getServiceName () : string {
+ public function getServiceName(): string {
return "Phabricator";
}
@@ -62,12 +60,12 @@
/// Payload processing
///
- protected function onPayload () : void {
+ protected function onPayload(): void {
$this->initializeReport();
- Event::fire(new PhabricatorPayloadEvent(
+ Event::fire( new PhabricatorPayloadEvent(
$this->door,
$this->payload
- ));
+ ) );
}
}
diff --git a/app/Http/routes.php b/app/Http/routes.php
--- a/app/Http/routes.php
+++ b/app/Http/routes.php
@@ -14,29 +14,29 @@
|
*/
-Route::get('/', function () {
- return view('welcome');
-});
+Route::get( '/', static function () {
+ return view( 'welcome' );
+} );
// Allows to external tool to ping your instalation and know if the site is up.
-Route::get('/status', function() {
+Route::get( '/status', static function () {
return "ALIVE";
-});
+} );
// Allows to external tool to check the current configuration.
-if (Features::isEnabled('GetConfig')) {
- Route::get('/config', function() {
+if ( Features::isEnabled( 'GetConfig' ) ) {
+ Route::get( '/config', static function () {
$report = new ConfigReport();
- return Response::json($report);
- });
+ return Response::json( $report );
+ } );
}
// Gate controllers
-if (Features::isEnabled('Gate')) {
- foreach (Config::get('gate.controllers') as $controller) {
+if ( Features::isEnabled( 'Gate' ) ) {
+ foreach ( Config::get( 'gate.controllers' ) as $controller ) {
$controllerRoute = '/gate/' . $controller . '/';
$controllerClass = "Gate\\${controller}GateController";
- Route::get($controllerRoute . '{door?}', "$controllerClass@onGet");
- Route::post($controllerRoute . '{door}', "$controllerClass@onPost");
+ Route::get( $controllerRoute . '{door?}', "$controllerClass@onGet" );
+ Route::post( $controllerRoute . '{door}', "$controllerClass@onPost" );
}
}
diff --git a/app/Jobs/FireDockerHubNotification.php b/app/Jobs/FireDockerHubNotification.php
--- a/app/Jobs/FireDockerHubNotification.php
+++ b/app/Jobs/FireDockerHubNotification.php
@@ -2,17 +2,15 @@
namespace Nasqueron\Notifications\Jobs;
-use Nasqueron\Notifications\Notifications\DockerHubNotification;
+use Event;
use Nasqueron\Notifications\Events\DockerHubPayloadEvent;
use Nasqueron\Notifications\Events\NotificationEvent;
-use Nasqueron\Notifications\Jobs\Job;
-
-use Event;
+use Nasqueron\Notifications\Notifications\DockerHubNotification;
class FireDockerHubNotification extends Job {
/**
- * @var DockerHubPayloadEvent;
+ * @var DockerHubPayloadEvent
*/
private $event;
@@ -21,7 +19,7 @@
*
* @param DockerHubPayloadEvent $event The event to notify
*/
- public function __construct (DockerHubPayloadEvent $event) {
+ public function __construct( DockerHubPayloadEvent $event ) {
$this->event = $event;
}
@@ -32,12 +30,12 @@
/**
* Executes the job.
*/
- public function handle() : void {
+ public function handle(): void {
$notification = $this->createNotification();
- Event::fire(new NotificationEvent($notification));
+ Event::fire( new NotificationEvent( $notification ) );
}
- protected function createNotification() : DockerHubNotification {
+ protected function createNotification(): DockerHubNotification {
return new DockerHubNotification(
$this->event->door, // project
$this->event->event, // event type
diff --git a/app/Jobs/FireGitHubNotification.php b/app/Jobs/FireGitHubNotification.php
--- a/app/Jobs/FireGitHubNotification.php
+++ b/app/Jobs/FireGitHubNotification.php
@@ -2,17 +2,15 @@
namespace Nasqueron\Notifications\Jobs;
-use Nasqueron\Notifications\Notifications\GitHubNotification;
+use Event;
use Nasqueron\Notifications\Events\GitHubPayloadEvent;
use Nasqueron\Notifications\Events\NotificationEvent;
-use Nasqueron\Notifications\Jobs\Job;
-
-use Event;
+use Nasqueron\Notifications\Notifications\GitHubNotification;
class FireGitHubNotification extends Job {
/**
- * @var GitHubPayloadEvent;
+ * @var GitHubPayloadEvent
*/
private $event;
@@ -21,7 +19,7 @@
*
* @param GitHubPayloadEvent $event The event to notify
*/
- public function __construct (GitHubPayloadEvent $event) {
+ public function __construct( GitHubPayloadEvent $event ) {
$this->event = $event;
}
@@ -32,13 +30,12 @@
/**
* Executes the job.
*/
- public function handle() : void {
+ public function handle(): void {
$notification = $this->createNotification();
- Event::fire(new NotificationEvent($notification));
+ Event::fire( new NotificationEvent( $notification ) );
}
-
- protected function createNotification() : GitHubNotification {
+ protected function createNotification(): GitHubNotification {
return new GitHubNotification(
$this->event->door, // project
$this->event->event, // event type
diff --git a/app/Jobs/FireJenkinsNotification.php b/app/Jobs/FireJenkinsNotification.php
--- a/app/Jobs/FireJenkinsNotification.php
+++ b/app/Jobs/FireJenkinsNotification.php
@@ -2,17 +2,15 @@
namespace Nasqueron\Notifications\Jobs;
-use Nasqueron\Notifications\Notifications\JenkinsNotification;
+use Event;
use Nasqueron\Notifications\Events\JenkinsPayloadEvent;
use Nasqueron\Notifications\Events\NotificationEvent;
-use Nasqueron\Notifications\Jobs\Job;
-
-use Event;
+use Nasqueron\Notifications\Notifications\JenkinsNotification;
class FireJenkinsNotification extends Job {
/**
- * @var JenkinsPayloadEvent;
+ * @var JenkinsPayloadEvent
*/
private $event;
@@ -21,7 +19,7 @@
*
* @param JenkinsPayloadEvent $event The event to notify
*/
- public function __construct (JenkinsPayloadEvent $event) {
+ public function __construct( JenkinsPayloadEvent $event ) {
$this->event = $event;
}
@@ -34,14 +32,14 @@
*
* @return void
*/
- public function handle() : void {
+ public function handle(): void {
$notification = $this->createNotification();
- if ($notification->shouldNotify()) {
- Event::fire(new NotificationEvent($notification));
+ if ( $notification->shouldNotify() ) {
+ Event::fire( new NotificationEvent( $notification ) );
}
}
- protected function createNotification() : JenkinsNotification {
+ protected function createNotification(): JenkinsNotification {
return new JenkinsNotification(
$this->event->door, // project
$this->event->payload // raw content
diff --git a/app/Jobs/FirePhabricatorNotification.php b/app/Jobs/FirePhabricatorNotification.php
--- a/app/Jobs/FirePhabricatorNotification.php
+++ b/app/Jobs/FirePhabricatorNotification.php
@@ -2,17 +2,15 @@
namespace Nasqueron\Notifications\Jobs;
-use Nasqueron\Notifications\Notifications\PhabricatorNotification;
-use Nasqueron\Notifications\Events\PhabricatorPayloadEvent;
-use Nasqueron\Notifications\Events\NotificationEvent;
-use Nasqueron\Notifications\Jobs\Job;
-
use Event;
+use Nasqueron\Notifications\Events\NotificationEvent;
+use Nasqueron\Notifications\Events\PhabricatorPayloadEvent;
+use Nasqueron\Notifications\Notifications\PhabricatorNotification;
class FirePhabricatorNotification extends Job {
/**
- * @var PhabricatorPayloadEvent;
+ * @var PhabricatorPayloadEvent
*/
private $event;
@@ -21,7 +19,7 @@
*
* @param PhabricatorPayloadEvent $event The event to notify
*/
- public function __construct (PhabricatorPayloadEvent $event) {
+ public function __construct( PhabricatorPayloadEvent $event ) {
$this->event = $event;
}
@@ -32,12 +30,12 @@
/**
* Executes the job.
*/
- public function handle() : void {
+ public function handle(): void {
$notification = $this->createNotification();
- Event::fire(new NotificationEvent($notification));
+ Event::fire( new NotificationEvent( $notification ) );
}
- protected function createNotification() : PhabricatorNotification {
+ protected function createNotification(): PhabricatorNotification {
return new PhabricatorNotification(
$this->event->door, // Project
$this->event->story // Story
diff --git a/app/Jobs/NotifyNewCommitsToDiffusion.php b/app/Jobs/NotifyNewCommitsToDiffusion.php
--- a/app/Jobs/NotifyNewCommitsToDiffusion.php
+++ b/app/Jobs/NotifyNewCommitsToDiffusion.php
@@ -2,16 +2,14 @@
namespace Nasqueron\Notifications\Jobs;
+use Event;
+use Log;
use Nasqueron\Notifications\Actions\ActionError;
use Nasqueron\Notifications\Actions\NotifyNewCommitsAction;
use Nasqueron\Notifications\Events\ReportEvent;
use Nasqueron\Notifications\Phabricator\PhabricatorAPI as API;
use Nasqueron\Notifications\Phabricator\PhabricatorAPIException;
-
-use Event;
-use Log;
use PhabricatorAPI;
-
use RuntimeException;
/**
@@ -58,7 +56,7 @@
/**
* Initializes a new instance of NotifyNewCommitsToDiffusion.
*/
- public function __construct ($sourceProject, $repository) {
+ public function __construct( $sourceProject, $repository ) {
$this->sourceProject = $sourceProject;
$this->repository = $repository;
}
@@ -72,8 +70,8 @@
*
* @return void
*/
- public function handle () : void {
- if (!$this->fetchRequirements()) {
+ public function handle(): void {
+ if ( !$this->fetchRequirements() ) {
return;
}
@@ -85,32 +83,31 @@
/**
* Initializes the actions report.
*/
- private function initializeReport () : void {
- $this->actionToReport = new NotifyNewCommitsAction($this->callSign);
+ private function initializeReport(): void {
+ $this->actionToReport = new NotifyNewCommitsAction( $this->callSign );
}
/**
* Notifies Phabricator to pull from the repository.
*/
- private function notifyPhabricator () : void {
+ private function notifyPhabricator(): void {
try {
$this->callDiffusionLookSoon();
- } catch (PhabricatorAPIException $ex) {
- $actionError = new ActionError($ex);
- $this->actionToReport->attachError($actionError);
- Log::error($ex);
+ } catch ( PhabricatorAPIException $ex ) {
+ $actionError = new ActionError( $ex );
+ $this->actionToReport->attachError( $actionError );
+ Log::error( $ex );
}
}
/**
* Fires a report event with the actions report.
*/
- private function sendReport () : void {
- $event = new ReportEvent($this->actionToReport);
- Event::fire($event);
+ private function sendReport(): void {
+ $event = new ReportEvent( $this->actionToReport );
+ Event::fire( $event );
}
-
///
/// Helper methods to find correct Phabricator instance and get the API
///
@@ -120,7 +117,7 @@
*
* @return string The Phabricator project name
*/
- private function getPhabricatorProject () : string {
+ private function getPhabricatorProject(): string {
return $this->sourceProject;
}
@@ -133,7 +130,7 @@
*
* @return bool true if all requirement have been fetched
*/
- private function fetchRequirements () : bool {
+ private function fetchRequirements(): bool {
return $this->fetchAPI() && $this->fetchCallSign();
}
@@ -142,13 +139,13 @@
*
* @return bool true if an API instance has been fetched
*/
- private function fetchAPI () : bool {
+ private function fetchAPI(): bool {
$project = $this->getPhabricatorProject();
try {
- $this->api = PhabricatorAPI::getForProject($project);
+ $this->api = PhabricatorAPI::getForProject( $project );
return true;
- } catch (RuntimeException $ex) {
+ } catch ( RuntimeException $ex ) {
return false;
}
}
@@ -158,7 +155,7 @@
*
* @return bool true if a call sign have been found ; otherwise, false.
*/
- private function fetchCallSign () : bool {
+ private function fetchCallSign(): bool {
$this->callSign = $this->getCallSign();
return $this->callSign !== "";
@@ -173,17 +170,17 @@
*
* @return string the repository call sign, or "" if not in Phabricator
*/
- private function getCallSign () : string {
+ private function getCallSign(): string {
$reply = $this->api->call(
'repository.query',
[ 'remoteURIs[0]' => $this->repository ]
);
- if ($reply === null || !count($reply)) {
+ if ( $reply === null || !count( $reply ) ) {
return "";
}
- return API::getFirstResult($reply)->callsign;
+ return API::getFirstResult( $reply )->callsign;
}
/**
@@ -191,7 +188,7 @@
*
* @throws PhabricatorAPIException
*/
- private function callDiffusionLookSoon () : void {
+ private function callDiffusionLookSoon(): void {
$this->api->call(
'diffusion.looksoon',
[ 'callsigns[0]' => $this->callSign ]
diff --git a/app/Jobs/SendMessageToBroker.php b/app/Jobs/SendMessageToBroker.php
--- a/app/Jobs/SendMessageToBroker.php
+++ b/app/Jobs/SendMessageToBroker.php
@@ -2,14 +2,12 @@
namespace Nasqueron\Notifications\Jobs;
-use Nasqueron\Notifications\Actions\ActionError;
-use Nasqueron\Notifications\Actions\AMQPAction;
-use Nasqueron\Notifications\Events\ReportEvent;
-use Nasqueron\Notifications\Jobs\Job;
-
use Broker;
use Event;
use Log;
+use Nasqueron\Notifications\Actions\ActionError;
+use Nasqueron\Notifications\Actions\AMQPAction;
+use Nasqueron\Notifications\Events\ReportEvent;
class SendMessageToBroker extends Job {
@@ -58,7 +56,7 @@
*
* @return void
*/
- public function __construct (
+ public function __construct(
string $target,
string $routingKey,
string $message
@@ -77,7 +75,7 @@
*
* @return void
*/
- public function handle() : void {
+ public function handle(): void {
$this->sendMessage();
$this->report();
}
@@ -85,29 +83,29 @@
/**
* Sends the message to the broker.
*/
- protected function sendMessage () : void {
+ protected function sendMessage(): void {
try {
- Broker::setExchangeTarget($this->target, "topic", true)
- ->routeTo($this->routingKey)
- ->sendMessage($this->message);
- } catch (\Exception $ex) {
+ Broker::setExchangeTarget( $this->target, "topic", true )
+ ->routeTo( $this->routingKey )
+ ->sendMessage( $this->message );
+ } catch ( \Exception $ex ) {
$this->exception = $ex;
- Log::error($ex);
+ Log::error( $ex );
}
}
/**
* Prepares a report and fires a report event.
*/
- protected function report () : void {
+ protected function report(): void {
$actionToReport = new AMQPAction(
"publish",
$this->target,
$this->routingKey
);
- if ($this->exception !== null) {
- $actionToReport->attachError(new ActionError($this->exception));
+ if ( $this->exception !== null ) {
+ $actionToReport->attachError( new ActionError( $this->exception ) );
}
- Event::fire(new ReportEvent($actionToReport));
+ Event::fire( new ReportEvent( $actionToReport ) );
}
}
diff --git a/app/Jobs/TriggerDockerHubBuild.php b/app/Jobs/TriggerDockerHubBuild.php
--- a/app/Jobs/TriggerDockerHubBuild.php
+++ b/app/Jobs/TriggerDockerHubBuild.php
@@ -2,14 +2,12 @@
namespace Nasqueron\Notifications\Jobs;
-use Nasqueron\Notifications\Actions\ActionError;
-use Nasqueron\Notifications\Actions\TriggerDockerHubBuildAction;
-use Nasqueron\Notifications\Events\ReportEvent;
-
use DockerHub;
use Event;
-
use Exception;
+use Nasqueron\Notifications\Actions\ActionError;
+use Nasqueron\Notifications\Actions\TriggerDockerHubBuildAction;
+use Nasqueron\Notifications\Events\ReportEvent;
/**
* This class allows to trigger a new Docker Hub build.
@@ -37,7 +35,7 @@
/**
* Initializes a new instance of TriggerDockerHubBuild.
*/
- public function __construct ($image) {
+ public function __construct( $image ) {
$this->image = $image;
}
@@ -50,7 +48,7 @@
*
* @return void
*/
- public function handle () : void {
+ public function handle(): void {
$this->initializeReport();
$this->triggerBuild();
$this->sendReport();
@@ -59,28 +57,28 @@
/**
* Initializes the actions report.
*/
- private function initializeReport () : void {
- $this->actionToReport = new TriggerDockerHubBuildAction($this->image);
+ private function initializeReport(): void {
+ $this->actionToReport = new TriggerDockerHubBuildAction( $this->image );
}
/**
* Triggers a new Docker Hub build.
*/
- private function triggerBuild () : void {
+ private function triggerBuild(): void {
try {
- DockerHub::build($this->image);
- } catch (Exception $ex) {
- $actionError = new ActionError($ex);
- $this->actionToReport->attachError($actionError);
+ DockerHub::build( $this->image );
+ } catch ( Exception $ex ) {
+ $actionError = new ActionError( $ex );
+ $this->actionToReport->attachError( $actionError );
}
}
/**
* Fires a report event with the actions report.
*/
- private function sendReport () : void {
- $event = new ReportEvent($this->actionToReport);
- Event::fire($event);
+ private function sendReport(): void {
+ $event = new ReportEvent( $this->actionToReport );
+ Event::fire( $event );
}
}
diff --git a/app/Listeners/AMQPEventListener.php b/app/Listeners/AMQPEventListener.php
--- a/app/Listeners/AMQPEventListener.php
+++ b/app/Listeners/AMQPEventListener.php
@@ -2,14 +2,12 @@
namespace Nasqueron\Notifications\Listeners;
+use Config;
+use Illuminate\Events\Dispatcher;
use Nasqueron\Notifications\Events\NotificationEvent;
use Nasqueron\Notifications\Jobs\SendMessageToBroker;
use Nasqueron\Notifications\Notifications\Notification;
-use Illuminate\Events\Dispatcher;
-
-use Config;
-
class AMQPEventListener {
///
@@ -21,13 +19,13 @@
*
* @param NotificationEvent $event
*/
- public function onNotification(NotificationEvent $event) : void {
- $this->sendNotification($event->notification);
+ public function onNotification( NotificationEvent $event ): void {
+ $this->sendNotification( $event->notification );
}
- protected static function getNotificationRoutingKey (
+ protected static function getNotificationRoutingKey(
Notification $notification
- ) : string {
+ ): string {
$keyParts = [
$notification->project,
$notification->group,
@@ -35,7 +33,7 @@
$notification->type,
];
- return strtolower(implode('.', $keyParts));
+ return strtolower( implode( '.', $keyParts ) );
}
/**
@@ -43,12 +41,12 @@
*
* @param Notification The notification to send
*/
- protected function sendNotification(Notification $notification) : void {
- $target = Config::get('broker.targets.notifications');
- $routingKey = static::getNotificationRoutingKey($notification);
- $message = json_encode($notification);
+ protected function sendNotification( Notification $notification ): void {
+ $target = Config::get( 'broker.targets.notifications' );
+ $routingKey = static::getNotificationRoutingKey( $notification );
+ $message = json_encode( $notification );
- $job = new SendMessageToBroker($target, $routingKey, $message);
+ $job = new SendMessageToBroker( $target, $routingKey, $message );
$job->handle();
}
@@ -61,8 +59,8 @@
*
* @param Dispatcher $events
*/
- public function subscribe (Dispatcher $events) : void {
- $class = AMQPEventListener::class;
+ public function subscribe( Dispatcher $events ): void {
+ $class = self::class;
$events->listen(
NotificationEvent::class,
"$class@onNotification"
diff --git a/app/Listeners/DockerHubListener.php b/app/Listeners/DockerHubListener.php
--- a/app/Listeners/DockerHubListener.php
+++ b/app/Listeners/DockerHubListener.php
@@ -2,13 +2,11 @@
namespace Nasqueron\Notifications\Listeners;
+use DockerHub;
+use Illuminate\Events\Dispatcher;
use Nasqueron\Notifications\Events\GitHubPayloadEvent;
use Nasqueron\Notifications\Jobs\TriggerDockerHubBuild;
-use Illuminate\Events\Dispatcher;
-
-use DockerHub;
-
/**
* Listens to events Docker Hub is interested by.
*/
@@ -23,9 +21,9 @@
*
* @param GitHubPayloadEvent $event The GitHub payload event
*/
- public function onGitHubPayload (GitHubPayloadEvent $event) : void {
- if ($this->shouldNotify($event)) {
- $this->notifyNewCommits($event);
+ public function onGitHubPayload( GitHubPayloadEvent $event ): void {
+ if ( $this->shouldNotify( $event ) ) {
+ $this->notifyNewCommits( $event );
}
}
@@ -37,9 +35,9 @@
* @param GitHubPayloadEvent $event The GitHub payload event
* @return bool
*/
- public function shouldNotify (GitHubPayloadEvent $event) : bool {
+ public function shouldNotify( GitHubPayloadEvent $event ): bool {
return $event->event === 'push'
- && DockerHub::hasToken($this->getRepository($event));
+ && DockerHub::hasToken( $this->getRepository( $event ) );
}
/**
@@ -47,8 +45,8 @@
*
* @param GitHubPayloadEvent $event The GitHub payload event
*/
- public function notifyNewCommits (GitHubPayloadEvent $event) : void {
- $job = new TriggerDockerHubBuild($this->getRepository($event));
+ public function notifyNewCommits( GitHubPayloadEvent $event ): void {
+ $job = new TriggerDockerHubBuild( $this->getRepository( $event ) );
$job->handle();
}
@@ -57,7 +55,7 @@
*
* @var string
*/
- private function getRepository (GitHubPayloadEvent $event) : string {
+ private function getRepository( GitHubPayloadEvent $event ): string {
return $event->payload->repository->full_name;
}
@@ -70,8 +68,8 @@
*
* @param Dispatcher $events
*/
- public function subscribe (Dispatcher $events) : void {
- $class = DockerHubListener::class;
+ public function subscribe( Dispatcher $events ): void {
+ $class = self::class;
$events->listen(
GitHubPayloadEvent::class,
"$class@onGitHubPayload"
diff --git a/app/Listeners/LastPayloadSaver.php b/app/Listeners/LastPayloadSaver.php
--- a/app/Listeners/LastPayloadSaver.php
+++ b/app/Listeners/LastPayloadSaver.php
@@ -12,8 +12,8 @@
/**
* Handles payload events
*/
- public function onPayload (Event $event) : void {
- self::savePayload($event->payload);
+ public function onPayload( Event $event ): void {
+ self::savePayload( $event->payload );
}
/**
@@ -21,10 +21,10 @@
*
* @param mixed $payload The payload to save
*/
- public static function savePayload ($payload) : void {
- $filename = storage_path('logs/payload.json');
- $content = json_encode($payload);
- file_put_contents($filename, $content);
+ public static function savePayload( $payload ): void {
+ $filename = storage_path( 'logs/payload.json' );
+ $content = json_encode( $payload );
+ file_put_contents( $filename, $content );
}
///
@@ -36,7 +36,7 @@
*
* @param \Illuminate\Events\Dispatcher $events
*/
- public function subscribe (\Illuminate\Events\Dispatcher $events) : void {
+ public function subscribe( \Illuminate\Events\Dispatcher $events ): void {
$ns = 'Nasqueron\Notifications\Events';
$class = 'Nasqueron\Notifications\Listeners\LastPayloadSaver';
$eventsToListen = [
@@ -46,8 +46,8 @@
'PhabricatorPayloadEvent',
];
- foreach ($eventsToListen as $event) {
- $events->listen("$ns\\$event", "$class@onPayload");
+ foreach ( $eventsToListen as $event ) {
+ $events->listen( "$ns\\$event", "$class@onPayload" );
}
}
}
diff --git a/app/Listeners/NotificationListener.php b/app/Listeners/NotificationListener.php
--- a/app/Listeners/NotificationListener.php
+++ b/app/Listeners/NotificationListener.php
@@ -23,8 +23,8 @@
* @param DockerHubPayloadEvent $event
* @return void
*/
- public function onDockerHubPayload(DockerHubPayloadEvent $event) : void {
- $job = new FireDockerHubNotification($event);
+ public function onDockerHubPayload( DockerHubPayloadEvent $event ): void {
+ $job = new FireDockerHubNotification( $event );
$job->handle();
}
@@ -34,8 +34,8 @@
* @param GitHubPayloadEvent $event
* @return void
*/
- public function onGitHubPayload(GitHubPayloadEvent $event) : void {
- $job = new FireGitHubNotification($event);
+ public function onGitHubPayload( GitHubPayloadEvent $event ): void {
+ $job = new FireGitHubNotification( $event );
$job->handle();
}
@@ -47,8 +47,8 @@
*/
public function onPhabricatorPayload(
PhabricatorPayloadEvent $event
- ) : void {
- $job = new FirePhabricatorNotification($event);
+ ): void {
+ $job = new FirePhabricatorNotification( $event );
$job->handle();
}
@@ -58,8 +58,8 @@
* @param JenkinsPayloadEvent $event
* @return void
*/
- public function onJenkinsPayload (JenkinsPayloadEvent $event) : void {
- $job = new FireJenkinsNotification($event);
+ public function onJenkinsPayload( JenkinsPayloadEvent $event ): void {
+ $job = new FireJenkinsNotification( $event );
$job->handle();
}
@@ -72,7 +72,7 @@
*
* @param \Illuminate\Events\Dispatcher $events
*/
- public function subscribe (\Illuminate\Events\Dispatcher $events) : void {
+ public function subscribe( \Illuminate\Events\Dispatcher $events ): void {
$class = 'Nasqueron\Notifications\Listeners\NotificationListener';
$events->listen(
'Nasqueron\Notifications\Events\DockerHubPayloadEvent',
@@ -90,7 +90,6 @@
'Nasqueron\Notifications\Events\PhabricatorPayloadEvent',
"$class@onPhabricatorPayload"
);
-
}
}
diff --git a/app/Listeners/PhabricatorListener.php b/app/Listeners/PhabricatorListener.php
--- a/app/Listeners/PhabricatorListener.php
+++ b/app/Listeners/PhabricatorListener.php
@@ -2,11 +2,10 @@
namespace Nasqueron\Notifications\Listeners;
+use Illuminate\Events\Dispatcher;
use Nasqueron\Notifications\Events\GitHubPayloadEvent;
use Nasqueron\Notifications\Jobs\NotifyNewCommitsToDiffusion;
-use Illuminate\Events\Dispatcher;
-
/**
* Listens to events Phabricator is interested by.
*/
@@ -21,9 +20,9 @@
*
* @param GitHubPayloadEvent $event The GitHub payload event
*/
- public function onGitHubPayload (GitHubPayloadEvent $event) : void {
- if ($event->event === 'push') {
- $this->notifyNewCommits($event);
+ public function onGitHubPayload( GitHubPayloadEvent $event ): void {
+ if ( $event->event === 'push' ) {
+ $this->notifyNewCommits( $event );
}
}
@@ -32,7 +31,7 @@
*
* @param GitHubPayloadEvent $event The GitHub payload event
*/
- public function notifyNewCommits (GitHubPayloadEvent $event) : void {
+ public function notifyNewCommits( GitHubPayloadEvent $event ): void {
$job = new NotifyNewCommitsToDiffusion(
$event->door,
$event->payload->repository->clone_url
@@ -49,8 +48,8 @@
*
* @param Dispatcher $events
*/
- public function subscribe (Dispatcher $events) : void {
- $class = PhabricatorListener::class;
+ public function subscribe( Dispatcher $events ): void {
+ $class = self::class;
$events->listen(
GitHubPayloadEvent::class,
"$class@onGitHubPayload"
diff --git a/app/Notifications/DockerHubNotification.php b/app/Notifications/DockerHubNotification.php
--- a/app/Notifications/DockerHubNotification.php
+++ b/app/Notifications/DockerHubNotification.php
@@ -2,9 +2,8 @@
namespace Nasqueron\Notifications\Notifications;
-use Nasqueron\Notifications\Analyzers\DockerHub\BaseEvent;
-
use InvalidArgumentException;
+use Nasqueron\Notifications\Analyzers\DockerHub\BaseEvent;
/**
* A Docker Hub notification.
@@ -27,7 +26,7 @@
*/
class DockerHubNotification extends Notification {
- public function __construct (
+ public function __construct(
string $project,
string $event,
\stdClass $payload
@@ -50,7 +49,7 @@
/**
* Fills properties from event payload.
*/
- public function analyzeByEvent () : void {
+ public function analyzeByEvent(): void {
$analyzer = $this->getAnalyzer();
$this->rawContent = $analyzer->getPayload();
$this->text = $analyzer->getText();
@@ -62,9 +61,9 @@
*
* @return string
*/
- private function getAnalyzerClassName () : string {
+ private function getAnalyzerClassName(): string {
return "Nasqueron\Notifications\Analyzers\DockerHub\\"
- . ucfirst($this->type)
+ . ucfirst( $this->type )
. "Event";
}
@@ -73,19 +72,16 @@
*
* @return \Nasqueron\Notifications\Analyzers\DockerHub\BaseEvent
*/
- private function getAnalyzer () : BaseEvent {
+ private function getAnalyzer(): BaseEvent {
$class = $this->getAnalyzerClassName();
- if (!class_exists($class)) {
+ if ( !class_exists( $class ) ) {
throw new InvalidArgumentException(
"Event $this->type doesn't have a matching $class class."
);
}
- return new $class($this->rawContent);
+ return new $class( $this->rawContent );
}
-
-
-
}
diff --git a/app/Notifications/GitHubNotification.php b/app/Notifications/GitHubNotification.php
--- a/app/Notifications/GitHubNotification.php
+++ b/app/Notifications/GitHubNotification.php
@@ -11,7 +11,7 @@
*/
private $analyzer = null;
- public function __construct (
+ public function __construct(
string $project,
string $event,
\stdClass $payload
@@ -31,8 +31,8 @@
/**
* Gets analyzer
*/
- private function getAnalyzer () : GitHubPayloadAnalyzer {
- if ($this->analyzer === null) {
+ private function getAnalyzer(): GitHubPayloadAnalyzer {
+ if ( $this->analyzer === null ) {
$this->analyzer = new GitHubPayloadAnalyzer(
$this->project,
$this->type,
@@ -47,7 +47,7 @@
*
* @return string the target group for the notification
*/
- public function getGroup () : string {
+ public function getGroup(): string {
return $this->getAnalyzer()->getGroup();
}
@@ -57,7 +57,7 @@
*
* @return string
*/
- public function getText () : string {
+ public function getText(): string {
return $this->getAnalyzer()->getDescription();
}
@@ -66,7 +66,7 @@
*
* @return string
*/
- public function getLink () : string {
+ public function getLink(): string {
return $this->getAnalyzer()->getLink();
}
diff --git a/app/Notifications/JenkinsNotification.php b/app/Notifications/JenkinsNotification.php
--- a/app/Notifications/JenkinsNotification.php
+++ b/app/Notifications/JenkinsNotification.php
@@ -23,7 +23,7 @@
* @param string $project The project this message is for
* @param mixed $payload The message fired by Jenkins notification plugin
*/
- public function __construct ($project, $payload) {
+ public function __construct( $project, $payload ) {
// Straightforward properties
$this->service = "Jenkins";
$this->project = $project;
@@ -41,17 +41,17 @@
*
* @return string
*/
- public function getType () : string {
+ public function getType(): string {
$build = $this->rawContent->build;
- $type = strtolower($build->phase);
+ $type = strtolower( $build->phase );
- if (property_exists($build, 'status')) {
+ if ( property_exists( $build, 'status' ) ) {
$type .= '.';
$type .= $build->status;
}
- return strtolower($type);
+ return strtolower( $type );
}
/**
@@ -60,16 +60,16 @@
*
* @return string
*/
- public function getText () : string {
+ public function getText(): string {
$name = $this->rawContent->name;
$build = $this->rawContent->build;
- $phase = strtolower($build->phase);
+ $phase = strtolower( $build->phase );
$text = "Jenkins job $name has been $phase";
- if (property_exists($build, 'status')) {
- $status = strtolower($build->status);
+ if ( property_exists( $build, 'status' ) ) {
+ $status = strtolower( $build->status );
$text .= ": $status";
}
@@ -81,8 +81,8 @@
*
* @return \Nasqueron\Notifications\Analyzers\Jenkins\JenkinsPayloadAnalyzer
*/
- private function getAnalyzer () : JenkinsPayloadAnalyzer {
- if ($this->analyzer === null) {
+ private function getAnalyzer(): JenkinsPayloadAnalyzer {
+ if ( $this->analyzer === null ) {
$this->analyzer = new JenkinsPayloadAnalyzer(
$this->project,
$this->rawContent
@@ -96,7 +96,7 @@
*
* @return string
*/
- public function getGroup () : string {
+ public function getGroup(): string {
return $this->getAnalyzer()->getGroup();
}
@@ -105,7 +105,7 @@
*
* @return bool if false, this payload is to be ignored for notifications
*/
- public function shouldNotify () : bool {
+ public function shouldNotify(): bool {
return $this->getAnalyzer()->shouldNotify();
}
diff --git a/app/Notifications/PhabricatorNotification.php b/app/Notifications/PhabricatorNotification.php
--- a/app/Notifications/PhabricatorNotification.php
+++ b/app/Notifications/PhabricatorNotification.php
@@ -18,7 +18,7 @@
* @param string $project The project for this notification
* @param PhabricatorStory $payload The story to convert into a notification
*/
- public function __construct (string $project, PhabricatorStory $payload) {
+ public function __construct( string $project, PhabricatorStory $payload ) {
// Straightforward properties
$this->service = "Phabricator";
$this->project = $project;
@@ -36,8 +36,8 @@
*
* @return \Nasqueron\Notifications\Analyzers\Phabricator\PhabricatorPayloadAnalyzer
*/
- private function getAnalyzer () : PhabricatorPayloadAnalyzer {
- if ($this->analyzer === null) {
+ private function getAnalyzer(): PhabricatorPayloadAnalyzer {
+ if ( $this->analyzer === null ) {
$this->analyzer = new PhabricatorPayloadAnalyzer(
$this->project,
$this->rawContent
@@ -51,7 +51,7 @@
*
* @return string the target group for the notification
*/
- public function getGroup () : string {
+ public function getGroup(): string {
return $this->getAnalyzer()->getGroup();
}
@@ -60,7 +60,7 @@
*
* @return string
*/
- public function getLink () : string {
+ public function getLink(): string {
return "";
}
diff --git a/app/Phabricator/PhabricatorAPI.php b/app/Phabricator/PhabricatorAPI.php
--- a/app/Phabricator/PhabricatorAPI.php
+++ b/app/Phabricator/PhabricatorAPI.php
@@ -36,7 +36,7 @@
* @param string $endPoint The Phabricator main URL, without trailing slash
* @param string $apiToken The token generated at /settings/panel/apitokens/
*/
- public function __construct ($endPoint, $apiToken) {
+ public function __construct( $endPoint, $apiToken ) {
$this->endPoint = $endPoint;
$this->apiToken = $apiToken;
}
@@ -44,31 +44,31 @@
/**
* @throws \RuntimeException when the service isn't in credentials.json
*/
- public static function forInstance ($instance) : PhabricatorAPI {
+ public static function forInstance( $instance ): PhabricatorAPI {
$service = Services::findServiceByProperty(
'Phabricator',
'instance',
$instance
);
- if ($service === null) {
+ if ( $service === null ) {
throw new \RuntimeException(
"No credentials for Phabricator instance $instance."
);
}
- return new self($service->instance, $service->secret);
+ return new self( $service->instance, $service->secret );
}
/**
* @throws \RuntimeException when the service isn't in credentials.json
*/
- public static function forProject ($project) {
- $service = Services::findServiceByDoor('Phabricator', $project);
- if ($service === null) {
+ public static function forProject( $project ) {
+ $service = Services::findServiceByDoor( 'Phabricator', $project );
+ if ( $service === null ) {
throw new \RuntimeException(
"No credentials for Phabricator project $project."
);
}
- return new self($service->instance, $service->secret);
+ return new self( $service->instance, $service->secret );
}
///
@@ -80,7 +80,7 @@
*
* @param string $url The API end point URL
*/
- public function setEndPoint ($url) {
+ public function setEndPoint( $url ) {
$this->endPoint = $url;
}
@@ -91,13 +91,13 @@
* @param array $arguments The arguments to use
* @return mixed The API result
*/
- public function call ($method, $arguments = []) {
+ public function call( $method, $arguments = [] ) {
$url = $this->endPoint . '/api/' . $method;
$arguments['api.token'] = $this->apiToken;
- $reply = json_decode(static::post($url, $arguments));
+ $reply = json_decode( static::post( $url, $arguments ) );
- if ($reply->error_code !== null) {
+ if ( $reply->error_code !== null ) {
throw new PhabricatorAPIException(
$reply->error_code,
$reply->error_info
@@ -114,15 +114,14 @@
/**
* Gets the first result of an API reply.
*
- * @param iterable $reply
* @return mixed
*/
- public static function getFirstResult ($reply) {
- if (is_object($reply) && property_exists($reply, 'data')) {
+ public static function getFirstResult( iterable $reply ) {
+ if ( is_object( $reply ) && property_exists( $reply, 'data' ) ) {
$reply = $reply->data;
}
- foreach ($reply as $value) {
+ foreach ( $reply as $value ) {
return $value;
}
}
@@ -131,29 +130,29 @@
/// CURL session
///
- protected static function getPostFields ($arguments) {
+ protected static function getPostFields( $arguments ) {
$items = [];
- foreach ($arguments as $key => $value) {
- $items[] = urlencode($key) . '=' . urlencode($value);
+ foreach ( $arguments as $key => $value ) {
+ $items[] = urlencode( $key ) . '=' . urlencode( $value );
}
- return implode('&', $items);
+ return implode( '&', $items );
}
- protected static function post ($url, $arguments) {
+ protected static function post( $url, $arguments ) {
$options = [
CURLOPT_URL => $url,
CURLOPT_HEADER => false,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_FOLLOWLOCATION => 1,
- CURLOPT_POSTFIELDS => static::getPostFields($arguments),
+ CURLOPT_POSTFIELDS => static::getPostFields( $arguments ),
];
$ch = curl_init();
- curl_setopt_array($ch, $options);
- $result = curl_exec($ch);
- curl_close($ch);
+ curl_setopt_array( $ch, $options );
+ $result = curl_exec( $ch );
+ curl_close( $ch );
- if ($result === false) {
+ if ( $result === false ) {
throw new \RuntimeException(
"Can't reach Phabricator API endpoint: $url"
);
diff --git a/app/Phabricator/PhabricatorAPIException.php b/app/Phabricator/PhabricatorAPIException.php
--- a/app/Phabricator/PhabricatorAPIException.php
+++ b/app/Phabricator/PhabricatorAPIException.php
@@ -3,14 +3,14 @@
namespace Nasqueron\Notifications\Phabricator;
class PhabricatorAPIException extends \RuntimeException {
-
+
/**
* @param int $code The error_code field for the API reply
* @param string $message The error_info field from the API reply
*/
- public function __construct ($code, $message) {
+ public function __construct( $code, $message ) {
$this->code = $code;
$this->message = $message;
}
-
+
}
diff --git a/app/Phabricator/PhabricatorAPIFactory.php b/app/Phabricator/PhabricatorAPIFactory.php
--- a/app/Phabricator/PhabricatorAPIFactory.php
+++ b/app/Phabricator/PhabricatorAPIFactory.php
@@ -12,8 +12,8 @@
* @param string $instance The Phabricator instance
* @return \Nasqueron\Notifications\Phabricator\PhabricatorAPI
*/
- public function get ($instance) {
- return PhabricatorAPI::forInstance($instance);
+ public function get( $instance ) {
+ return PhabricatorAPI::forInstance( $instance );
}
/**
@@ -22,7 +22,7 @@
* @param string $project The Phabricator project name
* @return PhabricatorAPI
*/
- public function getForProject ($project) {
- return PhabricatorAPI::forProject($project);
+ public function getForProject( string $project ) {
+ return PhabricatorAPI::forProject( $project );
}
}
diff --git a/app/Phabricator/PhabricatorStory.php b/app/Phabricator/PhabricatorStory.php
--- a/app/Phabricator/PhabricatorStory.php
+++ b/app/Phabricator/PhabricatorStory.php
@@ -76,7 +76,7 @@
*
* @param string $instanceName The Phabricator instance name
*/
- public function __construct ($instanceName) {
+ public function __construct( $instanceName ) {
$this->instanceName = $instanceName;
}
@@ -89,41 +89,41 @@
* @param iterable $payload The data submitted by Phabricator
* @return PhabricatorStory
*/
- public static function loadFromIterable (
+ public static function loadFromIterable(
string $instanceName, iterable $payload
) {
- $instance = new self($instanceName);
+ $instance = new self( $instanceName );
- foreach ($payload as $key => $value) {
- $property = self::mapPhabricatorFeedKey($key);
+ foreach ( $payload as $key => $value ) {
+ $property = self::mapPhabricatorFeedKey( $key );
$instance->$property = $value;
}
return $instance;
}
- public static function loadFromJson (
+ public static function loadFromJson(
$instanceName,
$payload
) {
- $array = json_decode($payload, true);
+ $array = json_decode( $payload, true );
- if (!is_array($array)) {
- throw new InvalidArgumentException(<<<MSG
+ if ( !is_array( $array ) ) {
+ throw new InvalidArgumentException( <<<MSG
Payload should be deserializable as an array.
MSG
);
}
- return self::loadFromIterable($instanceName, $array);
+ return self::loadFromIterable( $instanceName, $array );
}
///
/// Helper methods
///
- private function hasVoidObjectType () : bool {
- return $this->data === null || !isset($this->data['objectPHID']);
+ private function hasVoidObjectType(): bool {
+ return $this->data === null || !isset( $this->data['objectPHID'] );
}
/**
@@ -131,12 +131,12 @@
*
* @return string The object type, as a 4 letters string (e.g. 'TASK')
*/
- public function getObjectType () {
- if ($this->hasVoidObjectType()) {
+ public function getObjectType() {
+ if ( $this->hasVoidObjectType() ) {
return 'VOID';
}
- return substr($this->data['objectPHID'], 5, 4);
+ return substr( $this->data['objectPHID'], 5, 4 );
}
/**
@@ -144,19 +144,19 @@
*
* return string[] The list of project PHIDs
*/
- public function getProjectsPHIDs () {
- if (!array_key_exists('objectPHID', $this->data)) {
+ public function getProjectsPHIDs() {
+ if ( !array_key_exists( 'objectPHID', $this->data ) ) {
return [];
}
$objectPHID = $this->data['objectPHID'];
$objectType = $this->getObjectType();
- switch ($objectType) {
+ switch ( $objectType ) {
case 'DREV':
return $this->getItemProjectsPHIDs(
'repository.query',
- $this->getRepositoryPHID('differential.query')
+ $this->getRepositoryPHID( 'differential.query' )
);
case 'TASK':
@@ -168,7 +168,7 @@
case 'CMIT':
return $this->getItemProjectsPHIDs(
'repository.query',
- $this->getRepositoryPHID('diffusion.querycommits')
+ $this->getRepositoryPHID( 'diffusion.querycommits' )
);
case 'PSTE':
@@ -188,21 +188,21 @@
* @param string $method The API method to call (e.g. differential.query)
* @return string The repository PHID or "" if not found
*/
- public function getRepositoryPHID ($method) {
+ public function getRepositoryPHID( string $method ) {
$objectPHID = $this->data['objectPHID'];
- $api = PhabricatorAPI::forProject($this->instanceName);
+ $api = PhabricatorAPI::forProject( $this->instanceName );
$reply = $api->call(
$method,
[ 'phids[0]' => $objectPHID ]
);
- if ($reply === []) {
+ if ( $reply === [] ) {
return "";
}
- $apiResult = PhabricatorAPI::getFirstResult($reply);
- if ($apiResult === null) {
+ $apiResult = PhabricatorAPI::getFirstResult( $reply );
+ if ( $apiResult === null ) {
// Repository information can't be fetched (T1136).
// This occurs when the bot account used to fetch information
// doesn't have access to the repository, for example if it's
@@ -220,22 +220,22 @@
* @param string $objectPHID The object PHID to pass as method parameter
* @return string[] The list of project PHIDs
*/
- public function getItemProjectsPHIDs ($method, $objectPHID) {
- if (!$objectPHID) {
+ public function getItemProjectsPHIDs( string $method, string $objectPHID ) {
+ if ( !$objectPHID ) {
return [];
}
- $api = PhabricatorAPI::forProject($this->instanceName);
+ $api = PhabricatorAPI::forProject( $this->instanceName );
$reply = $api->call(
$method,
[ 'phids[0]' => $objectPHID ]
);
- if ($reply === []) {
+ if ( $reply === [] ) {
return [];
}
- return PhabricatorAPI::getFirstResult($reply)->projectPHIDs;
+ return PhabricatorAPI::getFirstResult( $reply )->projectPHIDs;
}
/**
@@ -245,15 +245,15 @@
* migrated from info (generation 1) or query (generation 2) to search
* (generation 3), we'll rename it to getItemProjectsPHIDs and overwrite it.
*/
- protected function getItemProjectsPHIDsThroughApplicationSearch (
+ protected function getItemProjectsPHIDsThroughApplicationSearch(
$method,
$objectPHID
) {
- if (!$objectPHID) {
+ if ( !$objectPHID ) {
return [];
}
- $api = PhabricatorAPI::forProject($this->instanceName);
+ $api = PhabricatorAPI::forProject( $this->instanceName );
$reply = $api->call(
$method,
[
@@ -262,8 +262,8 @@
]
);
- $apiResult = PhabricatorAPI::getFirstResult($reply);
- if ($apiResult === null) {
+ $apiResult = PhabricatorAPI::getFirstResult( $reply );
+ if ( $apiResult === null ) {
// Object information (e.g. a paste) can't be fetched (T1138).
// This occurs when the bot account used to fetch information
// doesn't have access to the object, for example if it's
@@ -279,8 +279,8 @@
*
* @return string[] The list of project PHIDs
*/
- public function getProjects () {
- if ($this->projects === null) {
+ public function getProjects() {
+ if ( $this->projects === null ) {
$this->attachProjects();
}
return $this->projects;
@@ -290,19 +290,19 @@
* Queries the list of the projects associated to the story
* and attached it to the projects property.
*/
- public function attachProjects () {
+ public function attachProjects() {
$this->projects = [];
$PHIDs = $this->getProjectsPHIDs();
- if (count($PHIDs) == 0) {
+ if ( count( $PHIDs ) == 0 ) {
// No project is attached to the story's object
return;
}
- $map = ProjectsMap::load($this->instanceName);
- foreach ($PHIDs as $PHID) {
- $this->projects[] = $map->getProjectName($PHID);
+ $map = ProjectsMap::load( $this->instanceName );
+ foreach ( $PHIDs as $PHID ) {
+ $this->projects[] = $map->getProjectName( $PHID );
}
}
@@ -316,13 +316,13 @@
* @param string $key The field of the API reply
* @return string The property's name
*/
- public static function mapPhabricatorFeedKey ($key) {
- if ($key == "storyID") {
+ public static function mapPhabricatorFeedKey( string $key ) {
+ if ( $key == "storyID" ) {
return "id";
}
- if (starts_with($key, "story") && strlen($key) > 5) {
- return lcfirst(substr($key, 5));
+ if ( str_starts_with( $key, "story" ) && strlen( $key ) > 5 ) {
+ return lcfirst( substr( $key, 5 ) );
}
return $key;
diff --git a/app/Phabricator/ProjectsMap.php b/app/Phabricator/ProjectsMap.php
--- a/app/Phabricator/ProjectsMap.php
+++ b/app/Phabricator/ProjectsMap.php
@@ -2,10 +2,9 @@
namespace Nasqueron\Notifications\Phabricator;
-use Nasqueron\Notifications\Contracts\APIClient as APIClient;
-
use App;
use Cache;
+use Nasqueron\Notifications\Contracts\APIClient as APIClient;
class ProjectsMap implements \IteratorAggregate, \ArrayAccess {
@@ -39,10 +38,10 @@
private $apiClient;
/**
- * The source of the map
- *
- * @var string
- */
+ * The source of the map
+ *
+ * @var string
+ */
private $source = 'unloaded';
///
@@ -54,7 +53,7 @@
*
* @param string $instanceName The Phabricator instance name
*/
- public function __construct ($instanceName) {
+ public function __construct( $instanceName ) {
$this->instanceName = $instanceName;
}
@@ -67,8 +66,8 @@
*
* @return \Traversable
*/
- public function getIterator () {
- return new \ArrayIterator($this->map);
+ public function getIterator() {
+ return new \ArrayIterator( $this->map );
}
///
@@ -81,8 +80,8 @@
* @param mixed $offset The offset
* @return bool
*/
- public function offsetExists ($offset) {
- return array_key_exists($offset, $this->map);
+ public function offsetExists( $offset ) {
+ return array_key_exists( $offset, $this->map );
}
/**
@@ -91,7 +90,7 @@
* @param mixed $offset The offset.
* @return mixed The value
*/
- public function offsetGet ($offset) {
+ public function offsetGet( $offset ) {
return $this->map[$offset];
}
@@ -101,7 +100,7 @@
* @param mixed $offset The offset
* @param mixed $value The value to assign
*/
- public function offsetSet ($offset, $value) {
+ public function offsetSet( $offset, $value ) {
$this->map[$offset] = $value;
}
@@ -110,8 +109,8 @@
*
* @param mixed $offset The offset where to remove the value
*/
- public function offsetUnset ($offset) {
- unset($this->map[$offset]);
+ public function offsetUnset( $offset ) {
+ unset( $this->map[$offset] );
}
///
@@ -124,10 +123,10 @@
* @param string $phabricatorInstanceName The Phabricator instance name
* @return ProjectsMap
*/
- public static function load ($phabricatorInstanceName) {
- $instance = new self($phabricatorInstanceName);
+ public static function load( string $phabricatorInstanceName ) {
+ $instance = new self( $phabricatorInstanceName );
- if ($instance->isCached()) {
+ if ( $instance->isCached() ) {
$instance->loadFromCache();
} else {
$instance->fetchFromAPI();
@@ -139,12 +138,12 @@
/**
* Gets a new ProjectsMap instance and queries Phabricator API to fill it.
*/
- public static function fetch (
+ public static function fetch(
string $phabricatorInstanceName,
?APIClient $apiClient = null
) {
- $instance = new self($phabricatorInstanceName);
- $instance->setAPIClient($apiClient);
+ $instance = new self( $phabricatorInstanceName );
+ $instance->setAPIClient( $apiClient );
$instance->fetchFromAPI();
return $instance;
}
@@ -156,10 +155,10 @@
/**
* @return \Nasqueron\Notifications\Contracts\APIClient
*/
- public function getAPIClient () {
- if ($this->apiClient === null) {
- $factory = App::make('phabricator-api');
- $this->apiClient = $factory->getForProject($this->instanceName);
+ public function getAPIClient() {
+ if ( $this->apiClient === null ) {
+ $factory = App::make( 'phabricator-api' );
+ $this->apiClient = $factory->getForProject( $this->instanceName );
}
return $this->apiClient;
}
@@ -167,7 +166,7 @@
/**
* @param \Nasqueron\Notifications\Contracts\APIClient|null $apiClient
*/
- public function setAPIClient (?APIClient $apiClient = null) {
+ public function setAPIClient( ?APIClient $apiClient = null ) {
$this->apiClient = $apiClient;
}
@@ -176,28 +175,28 @@
*
* @throws \Exception when API reply is empty or invalid.
*/
- private function fetchFromAPI () {
+ private function fetchFromAPI() {
$reply = $this->getAPIClient()->call(
'project.query',
[ 'limit' => self::LIMIT ]
);
- if (!$reply) {
- throw new \Exception(<<<MSG
+ if ( !$reply ) {
+ throw new \Exception( <<<MSG
Empty reply calling project.query at $this->instanceName Conduit API.
MSG
);
}
- if (!property_exists($reply, 'data')) {
- throw new \Exception(<<<MSG
+ if ( !property_exists( $reply, 'data' ) ) {
+ throw new \Exception( <<<MSG
Invalid reply calling project.query at $this->instanceName Conduit API.
MSG
);
}
- foreach ($reply->data as $phid => $projectInfo) {
- $this->offsetSet($phid, $projectInfo->name);
+ foreach ( $reply->data as $phid => $projectInfo ) {
+ $this->offsetSet( $phid, $projectInfo->name );
}
$this->source = 'api';
@@ -212,10 +211,10 @@
*
* @return string The cache key for the current projects map
*/
- private function getCacheKey () {
- return class_basename(get_class($this))
+ private function getCacheKey() {
+ return class_basename( get_class( $this ) )
. '-'
- . md5($this->instanceName);
+ . md5( $this->instanceName );
}
/**
@@ -223,15 +222,15 @@
*
* @return bool true if cached; otherwise, false.
*/
- public function isCached () {
- return Cache::has($this->getCacheKey());
+ public function isCached() {
+ return Cache::has( $this->getCacheKey() );
}
/**
* Saves data to cache
*/
- public function saveToCache () {
- Cache::forever($this->getCacheKey(), $this->map);
+ public function saveToCache() {
+ Cache::forever( $this->getCacheKey(), $this->map );
}
/**
@@ -239,9 +238,9 @@
*
* Populates 'map' and 'source' properties
*/
- public function loadFromCache () {
- $cachedMap = Cache::get($this->getCacheKey());
- if ($cachedMap !== null) {
+ public function loadFromCache() {
+ $cachedMap = Cache::get( $this->getCacheKey() );
+ if ( $cachedMap !== null ) {
$this->map = $cachedMap;
$this->source = 'cache';
}
@@ -257,14 +256,14 @@
* @param string $projectPHID the PHID of the project to query the name
* @return string The name of the poject, or an empty string if not found
*/
- public function getProjectName ($projectPHID) {
- if ($this->offsetExists($projectPHID)) {
- return $this->offsetGet($projectPHID);
+ public function getProjectName( string $projectPHID ) {
+ if ( $this->offsetExists( $projectPHID ) ) {
+ return $this->offsetGet( $projectPHID );
}
- if ($this->source !== 'api') {
+ if ( $this->source !== 'api' ) {
$this->fetchFromAPI();
- return $this->getProjectName($projectPHID);
+ return $this->getProjectName( $projectPHID );
}
return "";
@@ -275,10 +274,10 @@
*
* @return array An array, each row containing ['PHID', 'project name']
*/
- public function toArray () {
+ public function toArray() {
$array = [];
- foreach ($this->map as $phid => $projectName) {
- $array[] = [$phid, $projectName];
+ foreach ( $this->map as $phid => $projectName ) {
+ $array[] = [ $phid, $projectName ];
}
return $array;
}
diff --git a/app/Phabricator/ProjectsMapFactory.php b/app/Phabricator/ProjectsMapFactory.php
--- a/app/Phabricator/ProjectsMapFactory.php
+++ b/app/Phabricator/ProjectsMapFactory.php
@@ -10,8 +10,8 @@
* @param string $instanceName The Phabricator instance name
* @return ProjectsMap
*/
- public function load ($instanceName) {
- return ProjectsMap::load($instanceName);
+ public function load( string $instanceName ) {
+ return ProjectsMap::load( $instanceName );
}
/**
@@ -20,8 +20,8 @@
* @param string $instanceName The Phabricator instance name
* @return ProjectsMap
*/
- public function fetch ($instanceName) {
- return ProjectsMap::fetch($instanceName);
+ public function fetch( string $instanceName ) {
+ return ProjectsMap::fetch( $instanceName );
}
}
diff --git a/app/Providers/BrokerServiceProvider.php b/app/Providers/BrokerServiceProvider.php
--- a/app/Providers/BrokerServiceProvider.php
+++ b/app/Providers/BrokerServiceProvider.php
@@ -23,12 +23,12 @@
* @return void
*/
public function register() {
- $this->app->singleton('broker', function (Application $app) {
- $config = $app->make('config');
- $driver = $config->get('broker.driver');
- $params = $config->get('broker.connections.' . $driver);
+ $this->app->singleton( 'broker', static function ( Application $app ) {
+ $config = $app->make( 'config' );
+ $driver = $config->get( 'broker.driver' );
+ $params = $config->get( 'broker.connections.' . $driver );
- return BrokerFactory::make($params);
- });
+ return BrokerFactory::make( $params );
+ } );
}
}
diff --git a/app/Providers/DockerHubServiceProvider.php b/app/Providers/DockerHubServiceProvider.php
--- a/app/Providers/DockerHubServiceProvider.php
+++ b/app/Providers/DockerHubServiceProvider.php
@@ -2,10 +2,9 @@
namespace Nasqueron\Notifications\Providers;
+use GuzzleHttp\Client;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Support\ServiceProvider;
-
-use GuzzleHttp\Client;
use Keruald\DockerHub\Build\TriggerBuildFactory;
class DockerHubServiceProvider extends ServiceProvider {
@@ -23,13 +22,13 @@
* @param \Illuminate\Contracts\Foundation\Application $app
* @return array
*/
- public static function getTokens (Application $app) {
- $file = $app->make('config')->get('services.dockerhub.tokens');
- $fs = $app->make('filesystem')->disk('local');
+ public static function getTokens( Application $app ) {
+ $file = $app->make( 'config' )->get( 'services.dockerhub.tokens' );
+ $fs = $app->make( 'filesystem' )->disk( 'local' );
- if ($fs->exists($file)) {
- $content = $fs->get($file);
- return json_decode($content, true);
+ if ( $fs->exists( $file ) ) {
+ $content = $fs->get( $file );
+ return json_decode( $content, true );
}
return [];
@@ -41,9 +40,9 @@
* @return void
*/
public function register() {
- $this->app->singleton('dockerhub', function (Application $app) {
- $tokens = DockerHubServiceProvider::getTokens($app);
- return new TriggerBuildFactory(new Client, $tokens);
- });
+ $this->app->singleton( 'dockerhub', static function ( Application $app ) {
+ $tokens = DockerHubServiceProvider::getTokens( $app );
+ return new TriggerBuildFactory( new Client, $tokens );
+ } );
}
}
diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.php
--- a/app/Providers/EventServiceProvider.php
+++ b/app/Providers/EventServiceProvider.php
@@ -2,20 +2,16 @@
namespace Nasqueron\Notifications\Providers;
-use Illuminate\{
- Contracts\Events\Dispatcher as DispatcherContract,
- Foundation\Support\Providers\EventServiceProvider as ServiceProvider
-};
-
use Config;
+use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
class EventServiceProvider extends ServiceProvider {
/**
* Registers all our listeners as subscriber classes
*/
- private function subscribeListeners () {
- $this->subscribe += Config::get('app.listeners');
+ private function subscribeListeners() {
+ $this->subscribe += Config::get( 'app.listeners' );
}
/**
diff --git a/app/Providers/MailgunServiceProvider.php b/app/Providers/MailgunServiceProvider.php
--- a/app/Providers/MailgunServiceProvider.php
+++ b/app/Providers/MailgunServiceProvider.php
@@ -2,10 +2,9 @@
namespace Nasqueron\Notifications\Providers;
+use GuzzleHttp\Client;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Support\ServiceProvider;
-
-use GuzzleHttp\Client;
use Keruald\Mailgun\MailgunMessageFactory;
class MailgunServiceProvider extends ServiceProvider {
@@ -23,11 +22,11 @@
* @return void
*/
public function register() {
- $this->app->singleton('mailgun', function (Application $app) {
- $config = $app->make('config');
- $key = $config->get('services.mailgun.secret');
+ $this->app->singleton( 'mailgun', static function ( Application $app ) {
+ $config = $app->make( 'config' );
+ $key = $config->get( 'services.mailgun.secret' );
- return new MailgunMessageFactory(new Client, $key);
- });
+ return new MailgunMessageFactory( new Client, $key );
+ } );
}
}
diff --git a/app/Providers/PhabricatorAPIServiceProvider.php b/app/Providers/PhabricatorAPIServiceProvider.php
--- a/app/Providers/PhabricatorAPIServiceProvider.php
+++ b/app/Providers/PhabricatorAPIServiceProvider.php
@@ -22,8 +22,8 @@
* @return void
*/
public function register() {
- $this->app->singleton('phabricator-api', function () {
+ $this->app->singleton( 'phabricator-api', static function () {
return new PhabricatorAPIFactory;
- });
+ } );
}
}
diff --git a/app/Providers/PhabricatorProjectsMapServiceProvider.php b/app/Providers/PhabricatorProjectsMapServiceProvider.php
--- a/app/Providers/PhabricatorProjectsMapServiceProvider.php
+++ b/app/Providers/PhabricatorProjectsMapServiceProvider.php
@@ -22,8 +22,8 @@
* @return void
*/
public function register() {
- $this->app->singleton('phabricator-projectsmap', function () {
+ $this->app->singleton( 'phabricator-projectsmap', static function () {
return new ProjectsMapFactory;
- });
+ } );
}
}
diff --git a/app/Providers/ReportServiceProvider.php b/app/Providers/ReportServiceProvider.php
--- a/app/Providers/ReportServiceProvider.php
+++ b/app/Providers/ReportServiceProvider.php
@@ -16,24 +16,24 @@
* @return void
*/
public function register() {
- $this->app->singleton('report', function (Application $app) {
+ $this->app->singleton( 'report', function ( Application $app ) {
$report = new ActionsReport();
static::listenToActionsForReport(
$report,
- $app->make('events')
+ $app->make( 'events' )
);
return $report;
- });
+ } );
}
- public static function listenToActionsForReport (
+ public static function listenToActionsForReport(
ActionsReport $report,
Dispatcher $events
) {
$events->listen(
'Nasqueron\Notifications\Events\ReportEvent',
- function (ReportEvent $event) use ($report) {
- $report->addAction($event->action);
+ static function ( ReportEvent $event ) use ( $report ) {
+ $report->addAction( $event->action );
}
);
}
diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php
--- a/app/Providers/RouteServiceProvider.php
+++ b/app/Providers/RouteServiceProvider.php
@@ -2,10 +2,8 @@
namespace Nasqueron\Notifications\Providers;
-use Illuminate\{
- Routing\Router,
- Foundation\Support\Providers\RouteServiceProvider as ServiceProvider
-};
+use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
+use Illuminate\Routing\Router;
class RouteServiceProvider extends ServiceProvider {
@@ -32,12 +30,12 @@
/**
* Define the routes for the application.
*
- * @param \Illuminate\Routing\Router $router
+ * @param \Illuminate\Routing\Router $router
* @return void
*/
- public function map(Router $router) {
- $router->group(['namespace' => $this->namespace], function ($router) {
- require app_path('Http/routes.php');
- });
+ public function map( Router $router ) {
+ $router->group( [ 'namespace' => $this->namespace ], static function ( $router ) {
+ require app_path( 'Http/routes.php' );
+ } );
}
}
diff --git a/app/Providers/SentryServiceProvider.php b/app/Providers/SentryServiceProvider.php
--- a/app/Providers/SentryServiceProvider.php
+++ b/app/Providers/SentryServiceProvider.php
@@ -21,10 +21,10 @@
* @return void
*/
public function register() {
- $this->app->singleton('raven', function (Application $app) {
- $config = $app->make('config');
- $dsn = $config->get('services.sentry.dsn');
- return new \Raven_Client($dsn);
- });
+ $this->app->singleton( 'raven', static function ( Application $app ) {
+ $config = $app->make( 'config' );
+ $dsn = $config->get( 'services.sentry.dsn' );
+ return new \Raven_Client( $dsn );
+ } );
}
}
diff --git a/app/Providers/ServicesServiceProvider.php b/app/Providers/ServicesServiceProvider.php
--- a/app/Providers/ServicesServiceProvider.php
+++ b/app/Providers/ServicesServiceProvider.php
@@ -14,13 +14,13 @@
* @return void
*/
public function register() {
- $this->app->singleton('services', function (Application $app) {
- $path = config('services.gate.credentials');
- if (strlen($path) > 0 && $app->make('filesystem')->has($path)) {
- return Services::loadFromJson($path);
+ $this->app->singleton( 'services', static function ( Application $app ) {
+ $path = config( 'services.gate.credentials' );
+ if ( strlen( $path ) > 0 && $app->make( 'filesystem' )->has( $path ) ) {
+ return Services::loadFromJson( $path );
}
return new Services;
- });
+ } );
}
}
diff --git a/bootstrap/app.php b/bootstrap/app.php
--- a/bootstrap/app.php
+++ b/bootstrap/app.php
@@ -12,7 +12,7 @@
*/
$app = new Illuminate\Foundation\Application(
- realpath(__DIR__.'/../')
+ realpath( __DIR__ . '/../' )
);
/*
@@ -27,18 +27,18 @@
*/
$app->singleton(
- Illuminate\Contracts\Http\Kernel::class,
- Nasqueron\Notifications\Http\Kernel::class
+ Illuminate\Contracts\Http\Kernel::class,
+ Nasqueron\Notifications\Http\Kernel::class
);
$app->singleton(
- Illuminate\Contracts\Console\Kernel::class,
- Nasqueron\Notifications\Console\Kernel::class
+ Illuminate\Contracts\Console\Kernel::class,
+ Nasqueron\Notifications\Console\Kernel::class
);
$app->singleton(
- Illuminate\Contracts\Debug\ExceptionHandler::class,
- Nasqueron\Notifications\Exceptions\Handler::class
+ Illuminate\Contracts\Debug\ExceptionHandler::class,
+ Nasqueron\Notifications\Exceptions\Handler::class
);
/*
diff --git a/bootstrap/autoload.php b/bootstrap/autoload.php
--- a/bootstrap/autoload.php
+++ b/bootstrap/autoload.php
@@ -1,6 +1,6 @@
<?php
-define('LARAVEL_START', microtime(true));
+define( 'LARAVEL_START', microtime( true ) );
/*
|--------------------------------------------------------------------------
@@ -14,7 +14,7 @@
|
*/
-require __DIR__.'/../vendor/autoload.php';
+require __DIR__ . '/../vendor/autoload.php';
/*
|--------------------------------------------------------------------------
@@ -27,8 +27,8 @@
|
*/
-$compiledPath = __DIR__.'/cache/compiled.php';
+$compiledPath = __DIR__ . '/cache/compiled.php';
-if (file_exists($compiledPath)) {
- require $compiledPath;
+if ( file_exists( $compiledPath ) ) {
+ require $compiledPath;
}
diff --git a/composer.json b/composer.json
--- a/composer.json
+++ b/composer.json
@@ -10,8 +10,8 @@
"license": "BSD-2-Clause",
"type": "project",
"require": {
- "php": ">=7.1.0",
- "laravel/framework": "5.3.*",
+ "php": ">=8.1.0",
+ "laravel/framework": "8.*",
"guzzlehttp/guzzle": "^6.2",
"keruald/dockerhub": "^0.0.3",
"keruald/github": "^0.2.1",
@@ -21,18 +21,18 @@
"sentry/sentry": "^0.13.0"
},
"require-dev": {
- "phan/phan": "^3.2.2",
+ "phan/phan": "^5.3",
"fzaninotto/faker": "~1.4",
- "mockery/mockery": "0.9.*",
- "pdepend/pdepend": "^2.4.1",
- "phploc/phploc": "^3.0.1",
- "phpmd/phpmd" : "@stable",
- "phpunit/phpunit": "~5.4",
- "phpspec/phpspec": "~2.1",
- "sebastian/phpcpd": "^2.0.4",
- "squizlabs/php_codesniffer": "2.*",
+ "mockery/mockery": "^1.5.0",
+ "phpunit/phpunit": "~8.0",
+ "squizlabs/php_codesniffer": "^3.6",
"symfony/css-selector": "~3.0",
- "symfony/dom-crawler": "~3.0"
+ "symfony/dom-crawler": "~3.0",
+ "rector/rector": "^0.12.21",
+ "pdepend/pdepend": "^2.10",
+ "phpmd/phpmd": "^2.12",
+ "phpspec/phpspec": "^7.2",
+ "nasqueron/codestyle": "^0.1.0"
},
"autoload": {
"psr-4": {
@@ -48,13 +48,16 @@
"php artisan key:generate"
],
"phpmd": [
- "vendor/bin/phpmd app/ xml ruleset.xml"
+ "vendor/bin/phpmd app/ xml phpcs.xml"
],
"test": [
"phpunit --no-coverage"
]
},
"config": {
- "preferred-install": "dist"
+ "preferred-install": "dist",
+ "allow-plugins": {
+ "kylekatarnls/update-helper": true
+ }
}
}
diff --git a/config/app.php b/config/app.php
--- a/config/app.php
+++ b/config/app.php
@@ -25,7 +25,7 @@
|
*/
- 'env' => env('APP_ENV', 'production'),
+ 'env' => env( 'APP_ENV', 'production' ),
/*
|--------------------------------------------------------------------------
@@ -38,7 +38,7 @@
|
*/
- 'debug' => env('APP_DEBUG', false),
+ 'debug' => env( 'APP_DEBUG', false ),
/*
|--------------------------------------------------------------------------
@@ -103,7 +103,7 @@
|
*/
- 'key' => env('APP_KEY'),
+ 'key' => env( 'APP_KEY' ),
'cipher' => 'AES-256-CBC',
@@ -120,7 +120,7 @@
|
*/
- 'log' => env('APP_LOG', 'single'),
+ 'log' => env( 'APP_LOG', 'single' ),
/*
|--------------------------------------------------------------------------
@@ -246,7 +246,7 @@
'File' => Illuminate\Support\Facades\File::class,
'Gate' => Illuminate\Support\Facades\Gate::class,
'Hash' => Illuminate\Support\Facades\Hash::class,
- 'Input' => Illuminate\Support\Facades\Input::class,
+ 'Input' => \Illuminate\Support\Facades\Request::class,
'Inspiring' => Illuminate\Foundation\Inspiring::class,
'Lang' => Illuminate\Support\Facades\Lang::class,
'Log' => Illuminate\Support\Facades\Log::class,
diff --git a/config/broadcasting.php b/config/broadcasting.php
--- a/config/broadcasting.php
+++ b/config/broadcasting.php
@@ -13,7 +13,7 @@
|
*/
- 'default' => env('BROADCAST_DRIVER', 'pusher'),
+ 'default' => env( 'BROADCAST_DRIVER', 'pusher' ),
/*
|--------------------------------------------------------------------------
@@ -30,9 +30,9 @@
'pusher' => [
'driver' => 'pusher',
- 'key' => env('PUSHER_KEY'),
- 'secret' => env('PUSHER_SECRET'),
- 'app_id' => env('PUSHER_APP_ID'),
+ 'key' => env( 'PUSHER_KEY' ),
+ 'secret' => env( 'PUSHER_SECRET' ),
+ 'app_id' => env( 'PUSHER_APP_ID' ),
'options' => [
//
],
diff --git a/config/broker.php b/config/broker.php
--- a/config/broker.php
+++ b/config/broker.php
@@ -14,7 +14,7 @@
|
*/
- 'driver' => env('BROKER_DRIVER', 'amqp'),
+ 'driver' => env( 'BROKER_DRIVER', 'amqp' ),
/*
|--------------------------------------------------------------------------
@@ -29,11 +29,11 @@
'amqp' => [
'driver' => 'amqp',
- 'host' => env('BROKER_HOST', 'localhost'),
- 'port' => env('BROKER_PORT', 5672),
- 'username' => env('BROKER_USERNAME', 'guest'),
- 'password' => env('BROKER_PASSWORD', 'guest'),
- 'vhost' => env('BROKER_VHOST', '/'),
+ 'host' => env( 'BROKER_HOST', 'localhost' ),
+ 'port' => env( 'BROKER_PORT', 5672 ),
+ 'username' => env( 'BROKER_USERNAME', 'guest' ),
+ 'password' => env( 'BROKER_PASSWORD', 'guest' ),
+ 'vhost' => env( 'BROKER_VHOST', '/' ),
],
'blackhole' => [
diff --git a/config/cache.php b/config/cache.php
--- a/config/cache.php
+++ b/config/cache.php
@@ -13,7 +13,7 @@
|
*/
- 'default' => env('CACHE_DRIVER', 'file'),
+ 'default' => env( 'CACHE_DRIVER', 'file' ),
/*
|--------------------------------------------------------------------------
@@ -44,7 +44,7 @@
'file' => [
'driver' => 'file',
- 'path' => storage_path('framework/cache'),
+ 'path' => storage_path( 'framework/cache' ),
],
'memcached' => [
diff --git a/config/database.php b/config/database.php
--- a/config/database.php
+++ b/config/database.php
@@ -26,7 +26,7 @@
|
*/
- 'default' => env('DB_CONNECTION', 'mysql'),
+ 'default' => env( 'DB_CONNECTION', 'mysql' ),
/*
|--------------------------------------------------------------------------
@@ -48,16 +48,16 @@
'sqlite' => [
'driver' => 'sqlite',
- 'database' => database_path('database.sqlite'),
+ 'database' => database_path( 'database.sqlite' ),
'prefix' => '',
],
'mysql' => [
'driver' => 'mysql',
- 'host' => env('DB_HOST', 'localhost'),
- 'database' => env('DB_DATABASE', 'forge'),
- 'username' => env('DB_USERNAME', 'forge'),
- 'password' => env('DB_PASSWORD', ''),
+ 'host' => env( 'DB_HOST', 'localhost' ),
+ 'database' => env( 'DB_DATABASE', 'forge' ),
+ 'username' => env( 'DB_USERNAME', 'forge' ),
+ 'password' => env( 'DB_PASSWORD', '' ),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
@@ -66,10 +66,10 @@
'pgsql' => [
'driver' => 'pgsql',
- 'host' => env('DB_HOST', 'localhost'),
- 'database' => env('DB_DATABASE', 'forge'),
- 'username' => env('DB_USERNAME', 'forge'),
- 'password' => env('DB_PASSWORD', ''),
+ 'host' => env( 'DB_HOST', 'localhost' ),
+ 'database' => env( 'DB_DATABASE', 'forge' ),
+ 'username' => env( 'DB_USERNAME', 'forge' ),
+ 'password' => env( 'DB_PASSWORD', '' ),
'charset' => 'utf8',
'prefix' => '',
'schema' => 'public',
@@ -77,10 +77,10 @@
'sqlsrv' => [
'driver' => 'sqlsrv',
- 'host' => env('DB_HOST', 'localhost'),
- 'database' => env('DB_DATABASE', 'forge'),
- 'username' => env('DB_USERNAME', 'forge'),
- 'password' => env('DB_PASSWORD', ''),
+ 'host' => env( 'DB_HOST', 'localhost' ),
+ 'database' => env( 'DB_DATABASE', 'forge' ),
+ 'username' => env( 'DB_USERNAME', 'forge' ),
+ 'password' => env( 'DB_PASSWORD', '' ),
'charset' => 'utf8',
'prefix' => '',
],
diff --git a/config/filesystems.php b/config/filesystems.php
--- a/config/filesystems.php
+++ b/config/filesystems.php
@@ -45,9 +45,9 @@
'local' => [
'driver' => 'local',
- 'root' => (env('APP_ENV') == 'testing') ?
- base_path('tests/data') :
- storage_path('app'),
+ 'root' => ( env( 'APP_ENV' ) == 'testing' ) ?
+ base_path( 'tests/data' ) :
+ storage_path( 'app' ),
],
'ftp' => [
diff --git a/config/mail.php b/config/mail.php
--- a/config/mail.php
+++ b/config/mail.php
@@ -15,7 +15,7 @@
|
*/
- 'driver' => env('MAIL_DRIVER', 'smtp'),
+ 'driver' => env( 'MAIL_DRIVER', 'smtp' ),
/*
|--------------------------------------------------------------------------
@@ -28,7 +28,7 @@
|
*/
- 'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
+ 'host' => env( 'MAIL_HOST', 'smtp.mailgun.org' ),
/*
|--------------------------------------------------------------------------
@@ -41,7 +41,7 @@
|
*/
- 'port' => env('MAIL_PORT', 587),
+ 'port' => env( 'MAIL_PORT', 587 ),
/*
|--------------------------------------------------------------------------
@@ -54,7 +54,7 @@
|
*/
- 'from' => ['address' => null, 'name' => null],
+ 'from' => [ 'address' => null, 'name' => null ],
/*
|--------------------------------------------------------------------------
@@ -67,7 +67,7 @@
|
*/
- 'encryption' => env('MAIL_ENCRYPTION', 'tls'),
+ 'encryption' => env( 'MAIL_ENCRYPTION', 'tls' ),
/*
|--------------------------------------------------------------------------
@@ -80,7 +80,7 @@
|
*/
- 'username' => env('MAIL_USERNAME'),
+ 'username' => env( 'MAIL_USERNAME' ),
/*
|--------------------------------------------------------------------------
@@ -93,7 +93,7 @@
|
*/
- 'password' => env('MAIL_PASSWORD'),
+ 'password' => env( 'MAIL_PASSWORD' ),
/*
|--------------------------------------------------------------------------
@@ -119,6 +119,6 @@
|
*/
- 'pretend' => env('MAIL_PRETEND', false),
+ 'pretend' => env( 'MAIL_PRETEND', false ),
];
diff --git a/config/queue.php b/config/queue.php
--- a/config/queue.php
+++ b/config/queue.php
@@ -16,7 +16,7 @@
|
*/
- 'default' => env('QUEUE_DRIVER', 'sync'),
+ 'default' => env( 'QUEUE_DRIVER', 'sync' ),
/*
|--------------------------------------------------------------------------
@@ -87,7 +87,7 @@
*/
'failed' => [
- 'database' => env('DB_CONNECTION', 'mysql'),
+ 'database' => env( 'DB_CONNECTION', 'mysql' ),
'table' => 'failed_jobs',
],
diff --git a/config/services.php b/config/services.php
--- a/config/services.php
+++ b/config/services.php
@@ -15,54 +15,54 @@
*/
'mailgun' => [
- 'domain' => env('MAILGUN_DOMAIN'),
- 'secret' => env('MAILGUN_SECRET'),
+ 'domain' => env( 'MAILGUN_DOMAIN' ),
+ 'secret' => env( 'MAILGUN_SECRET' ),
],
'mandrill' => [
- 'secret' => env('MANDRILL_SECRET'),
+ 'secret' => env( 'MANDRILL_SECRET' ),
],
'ses' => [
- 'key' => env('SES_KEY'),
- 'secret' => env('SES_SECRET'),
+ 'key' => env( 'SES_KEY' ),
+ 'secret' => env( 'SES_SECRET' ),
'region' => 'us-east-1',
],
'stripe' => [
'model' => Nasqueron\Notifications\User::class,
- 'key' => env('STRIPE_KEY'),
- 'secret' => env('STRIPE_SECRET'),
+ 'key' => env( 'STRIPE_KEY' ),
+ 'secret' => env( 'STRIPE_SECRET' ),
],
'sentry' => [
- 'dsn' => env('SENTRY_DSN'),
+ 'dsn' => env( 'SENTRY_DSN' ),
],
'dockerhub' => [
- 'tokens' => env('DOCKERHUB_TOKENS', 'DockerHubTokens.json')
+ 'tokens' => env( 'DOCKERHUB_TOKENS', 'DockerHubTokens.json' )
],
'github' => [
'analyzer' => [
- 'configDir' => env('GITHUB_ANALYZER_CONFIG_DIR', 'GitHubPayloadAnalyzer')
+ 'configDir' => env( 'GITHUB_ANALYZER_CONFIG_DIR', 'GitHubPayloadAnalyzer' )
]
],
'jenkins' => [
'analyzer' => [
- 'configDir' => env('JENKINS_ANALYZER_CONFIG_DIR', 'JenkinsPayloadAnalyzer')
+ 'configDir' => env( 'JENKINS_ANALYZER_CONFIG_DIR', 'JenkinsPayloadAnalyzer' )
]
],
'phabricator' => [
'analyzer' => [
- 'configDir' => env('PHABRICATOR_ANALYZER_CONFIG_DIR', 'PhabricatorPayloadAnalyzer')
+ 'configDir' => env( 'PHABRICATOR_ANALYZER_CONFIG_DIR', 'PhabricatorPayloadAnalyzer' )
]
],
'gate' => [
- 'credentials' => env('CREDENTIALS', 'credentials.json'),
+ 'credentials' => env( 'CREDENTIALS', 'credentials.json' ),
]
];
diff --git a/config/session.php b/config/session.php
--- a/config/session.php
+++ b/config/session.php
@@ -16,7 +16,7 @@
|
*/
- 'driver' => env('SESSION_DRIVER', 'file'),
+ 'driver' => env( 'SESSION_DRIVER', 'file' ),
/*
|--------------------------------------------------------------------------
@@ -57,7 +57,7 @@
|
*/
- 'files' => storage_path('framework/sessions'),
+ 'files' => storage_path( 'framework/sessions' ),
/*
|--------------------------------------------------------------------------
@@ -96,7 +96,7 @@
|
*/
- 'lottery' => [2, 100],
+ 'lottery' => [ 2, 100 ],
/*
|--------------------------------------------------------------------------
diff --git a/config/view.php b/config/view.php
--- a/config/view.php
+++ b/config/view.php
@@ -14,7 +14,7 @@
*/
'paths' => [
- realpath(base_path('resources/views')),
+ realpath( base_path( 'resources/views' ) ),
],
/*
@@ -28,6 +28,6 @@
|
*/
- 'compiled' => realpath(storage_path('framework/views')),
+ 'compiled' => realpath( storage_path( 'framework/views' ) ),
];
diff --git a/phpcs.xml b/phpcs.xml
new file mode 100644
--- /dev/null
+++ b/phpcs.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0"?>
+<ruleset name="Nasqueron">
+ <rule ref="vendor/nasqueron/codestyle/CodeSniffer/ruleset.xml" />
+
+ <file>app</file>
+ <file>config</file>
+ <file>tests</file>
+</ruleset>
diff --git a/public/index.php b/public/index.php
--- a/public/index.php
+++ b/public/index.php
@@ -19,7 +19,7 @@
|
*/
-require __DIR__.'/../bootstrap/autoload.php';
+require __DIR__ . '/../bootstrap/autoload.php';
/*
|--------------------------------------------------------------------------
@@ -33,7 +33,7 @@
|
*/
-$app = require_once __DIR__.'/../bootstrap/app.php';
+$app = require_once __DIR__ . '/../bootstrap/app.php';
/*
|--------------------------------------------------------------------------
@@ -47,12 +47,12 @@
|
*/
-$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);
+$kernel = $app->make( Illuminate\Contracts\Http\Kernel::class );
$response = $kernel->handle(
- $request = Illuminate\Http\Request::capture()
+ $request = Illuminate\Http\Request::capture()
);
$response->send();
-$kernel->terminate($request, $response);
+$kernel->terminate( $request, $response );
diff --git a/rector.php b/rector.php
new file mode 100644
--- /dev/null
+++ b/rector.php
@@ -0,0 +1,10 @@
+<?php
+
+declare( strict_types=1 );
+
+use Rector\Laravel\Set\LaravelSetList;
+use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
+
+return static function ( ContainerConfigurator $containerConfigurator ): void {
+ $containerConfigurator->import( LaravelSetList::LARAVEL_80 );
+};
diff --git a/resources/lang/en/GitHub.php b/resources/lang/en/GitHub.php
--- a/resources/lang/en/GitHub.php
+++ b/resources/lang/en/GitHub.php
@@ -2,81 +2,81 @@
return [
- /*
- |--------------------------------------------------------------------------
- | GitHub notifications messages
- |--------------------------------------------------------------------------
- |
- | The following language lines are used to localize notifications for events
- | fired by GitHub
- |
- */
-
- 'Separator' => ' — ',
-
- 'Commits' => [
- 'Message' => ':committer committed :title',
- 'Authored' => ' (authored by :author)', // appended to Message
- ],
-
- 'RepoAndBranch' => ':repo (branch :branch)',
-
- 'EventsDescriptions' => [
- 'CommitCommentEvent' => ':author added a comment to :commit: :excerpt',
-
- 'CreateEvent' => 'New :type on :repository: :ref',
- 'CreateEventUnknown' => 'Unknown create reference: :type :ref',
-
- 'DeleteEvent' => 'Removed :type on :repository: :ref',
- 'DeleteEventUnknown' => 'Unknown delete reference: :type :ref',
-
- 'ForkEvent' => ':repo_base has been forked to :repo_fork',
-
- 'IssueCommentEventPerAction' => [
- 'created' => ":author added a comment to issue #:issueNumber — :issueTitle: :excerpt",
- 'edited' => ":author edited a comment to issue #:issueNumber — :issueTitle: :excerpt",
- 'deleted' => ":author deleted a comment to issue #:issueNumber — :issueTitle",
- ],
- 'IssueCommentEventUnknown' => 'Unknown issue comment action: :action',
-
- 'PingEvent' => '« :zen » — GitHub Webhooks ping zen aphorism.',
-
- 'PullRequestEventPerAction' => [
- 'assigned' => ':author has assigned the pull request #:number — :title to :assignee',
- 'unassigned' => ':author has edited the assignees from the pull request #:number — :title',
- 'labeled' => ':author has labeled the pull request #:number — :title',
- 'unlabeled' => ':author has removed a label from the pull request #:number — :title',
- 'opened' => ':author has opened a pull request: #:number — :title',
- 'edited' => ':author has edited the pull request #:number — :title',
- 'closed' => ':author has closed the pull request #:number — :title',
- 'reopened' => ':author has reopened the pull request #:number — :title',
- ],
- 'PullRequestEventUnknown' => 'Unknown pull request action: :action',
-
- 'PushEvent' => [
- '0' => ':user forcely updated :repoAndBranch',
- 'n' => ':user pushed :count commits to :repoAndBranch', // n > 1
- ],
-
- 'RepositoryEventPerAction' => [
- 'created' => 'New repository :repository',
- 'deleted' => "Repository :repository deleted (danger zone)",
- 'publicized' => "Repository :repository is now public",
- 'privatized' => "Repository :repository is now private",
- ],
- 'RepositoryEventFork' => ' (fork)',
- 'RepositoryEventUnknown' => 'Unknown repository action: :action',
-
- 'StatusEvent' => 'Status of :commit: :status',
-
- 'WatchEvent' => ':user starred :repository',
- ],
-
- 'StatusEventState' => [
- 'pending' => 'pending',
- 'success' => 'success',
- 'failure' => 'failure',
- 'error' => 'error',
- ],
+ /*
+ |--------------------------------------------------------------------------
+ | GitHub notifications messages
+ |--------------------------------------------------------------------------
+ |
+ | The following language lines are used to localize notifications for events
+ | fired by GitHub
+ |
+ */
+
+ 'Separator' => ' — ',
+
+ 'Commits' => [
+ 'Message' => ':committer committed :title',
+ 'Authored' => ' (authored by :author)', // appended to Message
+ ],
+
+ 'RepoAndBranch' => ':repo (branch :branch)',
+
+ 'EventsDescriptions' => [
+ 'CommitCommentEvent' => ':author added a comment to :commit: :excerpt',
+
+ 'CreateEvent' => 'New :type on :repository: :ref',
+ 'CreateEventUnknown' => 'Unknown create reference: :type :ref',
+
+ 'DeleteEvent' => 'Removed :type on :repository: :ref',
+ 'DeleteEventUnknown' => 'Unknown delete reference: :type :ref',
+
+ 'ForkEvent' => ':repo_base has been forked to :repo_fork',
+
+ 'IssueCommentEventPerAction' => [
+ 'created' => ":author added a comment to issue #:issueNumber — :issueTitle: :excerpt",
+ 'edited' => ":author edited a comment to issue #:issueNumber — :issueTitle: :excerpt",
+ 'deleted' => ":author deleted a comment to issue #:issueNumber — :issueTitle",
+ ],
+ 'IssueCommentEventUnknown' => 'Unknown issue comment action: :action',
+
+ 'PingEvent' => '« :zen » — GitHub Webhooks ping zen aphorism.',
+
+ 'PullRequestEventPerAction' => [
+ 'assigned' => ':author has assigned the pull request #:number — :title to :assignee',
+ 'unassigned' => ':author has edited the assignees from the pull request #:number — :title',
+ 'labeled' => ':author has labeled the pull request #:number — :title',
+ 'unlabeled' => ':author has removed a label from the pull request #:number — :title',
+ 'opened' => ':author has opened a pull request: #:number — :title',
+ 'edited' => ':author has edited the pull request #:number — :title',
+ 'closed' => ':author has closed the pull request #:number — :title',
+ 'reopened' => ':author has reopened the pull request #:number — :title',
+ ],
+ 'PullRequestEventUnknown' => 'Unknown pull request action: :action',
+
+ 'PushEvent' => [
+ '0' => ':user forcely updated :repoAndBranch',
+ 'n' => ':user pushed :count commits to :repoAndBranch', // n > 1
+ ],
+
+ 'RepositoryEventPerAction' => [
+ 'created' => 'New repository :repository',
+ 'deleted' => "Repository :repository deleted (danger zone)",
+ 'publicized' => "Repository :repository is now public",
+ 'privatized' => "Repository :repository is now private",
+ ],
+ 'RepositoryEventFork' => ' (fork)',
+ 'RepositoryEventUnknown' => 'Unknown repository action: :action',
+
+ 'StatusEvent' => 'Status of :commit: :status',
+
+ 'WatchEvent' => ':user starred :repository',
+ ],
+
+ 'StatusEventState' => [
+ 'pending' => 'pending',
+ 'success' => 'success',
+ 'failure' => 'failure',
+ 'error' => 'error',
+ ],
];
diff --git a/resources/lang/en/auth.php b/resources/lang/en/auth.php
--- a/resources/lang/en/auth.php
+++ b/resources/lang/en/auth.php
@@ -2,18 +2,18 @@
return [
- /*
- |--------------------------------------------------------------------------
- | Authentication Language Lines
- |--------------------------------------------------------------------------
- |
- | The following language lines are used during authentication for various
- | messages that we need to display to the user. You are free to modify
- | these language lines according to your application's requirements.
- |
- */
+ /*
+ |--------------------------------------------------------------------------
+ | Authentication Language Lines
+ |--------------------------------------------------------------------------
+ |
+ | The following language lines are used during authentication for various
+ | messages that we need to display to the user. You are free to modify
+ | these language lines according to your application's requirements.
+ |
+ */
- 'failed' => 'These credentials do not match our records.',
- 'throttle' => 'Too many login attempts. Please try again in :seconds seconds.',
+ 'failed' => 'These credentials do not match our records.',
+ 'throttle' => 'Too many login attempts. Please try again in :seconds seconds.',
];
diff --git a/resources/lang/en/pagination.php b/resources/lang/en/pagination.php
--- a/resources/lang/en/pagination.php
+++ b/resources/lang/en/pagination.php
@@ -2,18 +2,18 @@
return [
- /*
- |--------------------------------------------------------------------------
- | Pagination Language Lines
- |--------------------------------------------------------------------------
- |
- | The following language lines are used by the paginator library to build
- | the simple pagination links. You are free to change them to anything
- | you want to customize your views to better match your application.
- |
- */
+ /*
+ |--------------------------------------------------------------------------
+ | Pagination Language Lines
+ |--------------------------------------------------------------------------
+ |
+ | The following language lines are used by the paginator library to build
+ | the simple pagination links. You are free to change them to anything
+ | you want to customize your views to better match your application.
+ |
+ */
- 'previous' => '&laquo; Previous',
- 'next' => 'Next &raquo;',
+ 'previous' => '&laquo; Previous',
+ 'next' => 'Next &raquo;',
];
diff --git a/resources/lang/en/passwords.php b/resources/lang/en/passwords.php
--- a/resources/lang/en/passwords.php
+++ b/resources/lang/en/passwords.php
@@ -2,21 +2,21 @@
return [
- /*
- |--------------------------------------------------------------------------
- | Password Reminder Language Lines
- |--------------------------------------------------------------------------
- |
- | The following language lines are the default lines which match reasons
- | that are given by the password broker for a password update attempt
- | has failed, such as for an invalid token or invalid new password.
- |
- */
+ /*
+ |--------------------------------------------------------------------------
+ | Password Reminder Language Lines
+ |--------------------------------------------------------------------------
+ |
+ | The following language lines are the default lines which match reasons
+ | that are given by the password broker for a password update attempt
+ | has failed, such as for an invalid token or invalid new password.
+ |
+ */
- 'password' => 'Passwords must be at least six characters and match the confirmation.',
- 'reset' => 'Your password has been reset!',
- 'sent' => 'We have e-mailed your password reset link!',
- 'token' => 'This password reset token is invalid.',
- 'user' => "We can't find a user with that e-mail address.",
+ 'password' => 'Passwords must be at least six characters and match the confirmation.',
+ 'reset' => 'Your password has been reset!',
+ 'sent' => 'We have e-mailed your password reset link!',
+ 'token' => 'This password reset token is invalid.',
+ 'user' => "We can't find a user with that e-mail address.",
];
diff --git a/resources/lang/en/validation.php b/resources/lang/en/validation.php
--- a/resources/lang/en/validation.php
+++ b/resources/lang/en/validation.php
@@ -2,109 +2,109 @@
return [
- /*
- |--------------------------------------------------------------------------
- | Validation Language Lines
- |--------------------------------------------------------------------------
- |
- | The following language lines contain the default error messages used by
- | the validator class. Some of these rules have multiple versions such
- | as the size rules. Feel free to tweak each of these messages here.
- |
- */
+ /*
+ |--------------------------------------------------------------------------
+ | Validation Language Lines
+ |--------------------------------------------------------------------------
+ |
+ | The following language lines contain the default error messages used by
+ | the validator class. Some of these rules have multiple versions such
+ | as the size rules. Feel free to tweak each of these messages here.
+ |
+ */
- 'accepted' => 'The :attribute must be accepted.',
- 'active_url' => 'The :attribute is not a valid URL.',
- 'after' => 'The :attribute must be a date after :date.',
- 'alpha' => 'The :attribute may only contain letters.',
- 'alpha_dash' => 'The :attribute may only contain letters, numbers, and dashes.',
- 'alpha_num' => 'The :attribute may only contain letters and numbers.',
- 'array' => 'The :attribute must be an array.',
- 'before' => 'The :attribute must be a date before :date.',
- 'between' => [
- 'numeric' => 'The :attribute must be between :min and :max.',
- 'file' => 'The :attribute must be between :min and :max kilobytes.',
- 'string' => 'The :attribute must be between :min and :max characters.',
- 'array' => 'The :attribute must have between :min and :max items.',
- ],
- 'boolean' => 'The :attribute field must be true or false.',
- 'confirmed' => 'The :attribute confirmation does not match.',
- 'date' => 'The :attribute is not a valid date.',
- 'date_format' => 'The :attribute does not match the format :format.',
- 'different' => 'The :attribute and :other must be different.',
- 'digits' => 'The :attribute must be :digits digits.',
- 'digits_between' => 'The :attribute must be between :min and :max digits.',
- 'email' => 'The :attribute must be a valid email address.',
- 'exists' => 'The selected :attribute is invalid.',
- 'filled' => 'The :attribute field is required.',
- 'image' => 'The :attribute must be an image.',
- 'in' => 'The selected :attribute is invalid.',
- 'integer' => 'The :attribute must be an integer.',
- 'ip' => 'The :attribute must be a valid IP address.',
- 'json' => 'The :attribute must be a valid JSON string.',
- 'max' => [
- 'numeric' => 'The :attribute may not be greater than :max.',
- 'file' => 'The :attribute may not be greater than :max kilobytes.',
- 'string' => 'The :attribute may not be greater than :max characters.',
- 'array' => 'The :attribute may not have more than :max items.',
- ],
- 'mimes' => 'The :attribute must be a file of type: :values.',
- 'min' => [
- 'numeric' => 'The :attribute must be at least :min.',
- 'file' => 'The :attribute must be at least :min kilobytes.',
- 'string' => 'The :attribute must be at least :min characters.',
- 'array' => 'The :attribute must have at least :min items.',
- ],
- 'not_in' => 'The selected :attribute is invalid.',
- 'numeric' => 'The :attribute must be a number.',
- 'regex' => 'The :attribute format is invalid.',
- 'required' => 'The :attribute field is required.',
- 'required_if' => 'The :attribute field is required when :other is :value.',
- 'required_unless' => 'The :attribute field is required unless :other is in :values.',
- 'required_with' => 'The :attribute field is required when :values is present.',
- 'required_with_all' => 'The :attribute field is required when :values is present.',
- 'required_without' => 'The :attribute field is required when :values is not present.',
- 'required_without_all' => 'The :attribute field is required when none of :values are present.',
- 'same' => 'The :attribute and :other must match.',
- 'size' => [
- 'numeric' => 'The :attribute must be :size.',
- 'file' => 'The :attribute must be :size kilobytes.',
- 'string' => 'The :attribute must be :size characters.',
- 'array' => 'The :attribute must contain :size items.',
- ],
- 'string' => 'The :attribute must be a string.',
- 'timezone' => 'The :attribute must be a valid zone.',
- 'unique' => 'The :attribute has already been taken.',
- 'url' => 'The :attribute format is invalid.',
+ 'accepted' => 'The :attribute must be accepted.',
+ 'active_url' => 'The :attribute is not a valid URL.',
+ 'after' => 'The :attribute must be a date after :date.',
+ 'alpha' => 'The :attribute may only contain letters.',
+ 'alpha_dash' => 'The :attribute may only contain letters, numbers, and dashes.',
+ 'alpha_num' => 'The :attribute may only contain letters and numbers.',
+ 'array' => 'The :attribute must be an array.',
+ 'before' => 'The :attribute must be a date before :date.',
+ 'between' => [
+ 'numeric' => 'The :attribute must be between :min and :max.',
+ 'file' => 'The :attribute must be between :min and :max kilobytes.',
+ 'string' => 'The :attribute must be between :min and :max characters.',
+ 'array' => 'The :attribute must have between :min and :max items.',
+ ],
+ 'boolean' => 'The :attribute field must be true or false.',
+ 'confirmed' => 'The :attribute confirmation does not match.',
+ 'date' => 'The :attribute is not a valid date.',
+ 'date_format' => 'The :attribute does not match the format :format.',
+ 'different' => 'The :attribute and :other must be different.',
+ 'digits' => 'The :attribute must be :digits digits.',
+ 'digits_between' => 'The :attribute must be between :min and :max digits.',
+ 'email' => 'The :attribute must be a valid email address.',
+ 'exists' => 'The selected :attribute is invalid.',
+ 'filled' => 'The :attribute field is required.',
+ 'image' => 'The :attribute must be an image.',
+ 'in' => 'The selected :attribute is invalid.',
+ 'integer' => 'The :attribute must be an integer.',
+ 'ip' => 'The :attribute must be a valid IP address.',
+ 'json' => 'The :attribute must be a valid JSON string.',
+ 'max' => [
+ 'numeric' => 'The :attribute may not be greater than :max.',
+ 'file' => 'The :attribute may not be greater than :max kilobytes.',
+ 'string' => 'The :attribute may not be greater than :max characters.',
+ 'array' => 'The :attribute may not have more than :max items.',
+ ],
+ 'mimes' => 'The :attribute must be a file of type: :values.',
+ 'min' => [
+ 'numeric' => 'The :attribute must be at least :min.',
+ 'file' => 'The :attribute must be at least :min kilobytes.',
+ 'string' => 'The :attribute must be at least :min characters.',
+ 'array' => 'The :attribute must have at least :min items.',
+ ],
+ 'not_in' => 'The selected :attribute is invalid.',
+ 'numeric' => 'The :attribute must be a number.',
+ 'regex' => 'The :attribute format is invalid.',
+ 'required' => 'The :attribute field is required.',
+ 'required_if' => 'The :attribute field is required when :other is :value.',
+ 'required_unless' => 'The :attribute field is required unless :other is in :values.',
+ 'required_with' => 'The :attribute field is required when :values is present.',
+ 'required_with_all' => 'The :attribute field is required when :values is present.',
+ 'required_without' => 'The :attribute field is required when :values is not present.',
+ 'required_without_all' => 'The :attribute field is required when none of :values are present.',
+ 'same' => 'The :attribute and :other must match.',
+ 'size' => [
+ 'numeric' => 'The :attribute must be :size.',
+ 'file' => 'The :attribute must be :size kilobytes.',
+ 'string' => 'The :attribute must be :size characters.',
+ 'array' => 'The :attribute must contain :size items.',
+ ],
+ 'string' => 'The :attribute must be a string.',
+ 'timezone' => 'The :attribute must be a valid zone.',
+ 'unique' => 'The :attribute has already been taken.',
+ 'url' => 'The :attribute format is invalid.',
- /*
- |--------------------------------------------------------------------------
- | Custom Validation Language Lines
- |--------------------------------------------------------------------------
- |
- | Here you may specify custom validation messages for attributes using the
- | convention "attribute.rule" to name the lines. This makes it quick to
- | specify a specific custom language line for a given attribute rule.
- |
- */
+ /*
+ |--------------------------------------------------------------------------
+ | Custom Validation Language Lines
+ |--------------------------------------------------------------------------
+ |
+ | Here you may specify custom validation messages for attributes using the
+ | convention "attribute.rule" to name the lines. This makes it quick to
+ | specify a specific custom language line for a given attribute rule.
+ |
+ */
- 'custom' => [
- 'attribute-name' => [
- 'rule-name' => 'custom-message',
- ],
- ],
+ 'custom' => [
+ 'attribute-name' => [
+ 'rule-name' => 'custom-message',
+ ],
+ ],
- /*
- |--------------------------------------------------------------------------
- | Custom Validation Attributes
- |--------------------------------------------------------------------------
- |
- | The following language lines are used to swap attribute place-holders
- | with something more reader friendly such as E-Mail Address instead
- | of "email". This simply helps us make messages a little cleaner.
- |
- */
+ /*
+ |--------------------------------------------------------------------------
+ | Custom Validation Attributes
+ |--------------------------------------------------------------------------
+ |
+ | The following language lines are used to swap attribute place-holders
+ | with something more reader friendly such as E-Mail Address instead
+ | of "email". This simply helps us make messages a little cleaner.
+ |
+ */
- 'attributes' => [],
+ 'attributes' => [],
];
diff --git a/ruleset.xml b/ruleset.xml
deleted file mode 100644
--- a/ruleset.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-<?xml version="1.0"?>
-<ruleset name="Nasqueron PHPMD rule set"
- xmlns="http://pmd.sf.net/ruleset/1.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0
- http://pmd.sf.net/ruleset_xml_schema.xsd"
- xsi:noNamespaceSchemaLocation="
- http://pmd.sf.net/ruleset_xml_schema.xsd">
- <description>
- The PHPMD rule set for Nasqueron projects.
- </description>
-
- <rule ref="rulesets/unusedcode.xml" />
- <rule ref="rulesets/naming.xml/BooleanGetMethodName" />
- <rule ref="rulesets/naming.xml/ConstantNamingConventions" />
- <rule ref="rulesets/naming.xml/ConstructorWithNameAsEnclosingClass" />
- <rule ref="rulesets/cleancode.xml/BooleanArgumentFlag" />
-</ruleset>
diff --git a/server.php b/server.php
--- a/server.php
+++ b/server.php
@@ -8,14 +8,14 @@
*/
$uri = urldecode(
- parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)
+ parse_url( $_SERVER['REQUEST_URI'], PHP_URL_PATH )
);
// This file allows us to emulate Apache's "mod_rewrite" functionality from the
// built-in PHP web server. This provides a convenient way to test a Laravel
// application without having installed a "real" web server software here.
-if ($uri !== '/' && file_exists(__DIR__.'/public'.$uri)) {
- return false;
+if ( $uri !== '/' && file_exists( __DIR__ . '/public' . $uri ) ) {
+ return false;
}
-require_once __DIR__.'/public/index.php';
+require_once __DIR__ . '/public/index.php';
diff --git a/tests/Actions/AMQPActionTest.php b/tests/Actions/AMQPActionTest.php
--- a/tests/Actions/AMQPActionTest.php
+++ b/tests/Actions/AMQPActionTest.php
@@ -2,8 +2,6 @@
namespace Nasqueron\Notifications\Tests\Actions;
-use Illuminate\Foundation\Testing\WithoutMiddleware;
-
use Nasqueron\Notifications\Actions\AMQPAction;
use Nasqueron\Notifications\Tests\TestCase;
@@ -11,15 +9,15 @@
protected $action;
- public function setUp () {
+ public function setUp(): void {
$this->action = new AMQPAction(
'method',
'target'
);
}
- public function testPublicProperties () {
- $this->assertNull($this->action->error);
- $this->assertSame('AMQPAction', $this->action->action);
+ public function testPublicProperties() {
+ $this->assertNull( $this->action->error );
+ $this->assertSame( 'AMQPAction', $this->action->action );
}
}
diff --git a/tests/Actions/ActionErrorTest.php b/tests/Actions/ActionErrorTest.php
--- a/tests/Actions/ActionErrorTest.php
+++ b/tests/Actions/ActionErrorTest.php
@@ -2,8 +2,6 @@
namespace Nasqueron\Notifications\Tests\Actions;
-use Illuminate\Foundation\Testing\WithoutMiddleware;
-
use Nasqueron\Notifications\Actions\ActionError;
use Nasqueron\Notifications\Tests\TestCase;
@@ -11,13 +9,13 @@
protected $actionError;
- public function setUp () {
- $ex = new \RuntimeException('Lorem ipsum dolor');
- $this->actionError = new ActionError($ex);
+ public function setUp(): void {
+ $ex = new \RuntimeException( 'Lorem ipsum dolor' );
+ $this->actionError = new ActionError( $ex );
}
- public function testPublicProperties () {
- $this->assertSame('RuntimeException', $this->actionError->type);
- $this->assertSame('Lorem ipsum dolor', $this->actionError->message);
+ public function testPublicProperties() {
+ $this->assertSame( 'RuntimeException', $this->actionError->type );
+ $this->assertSame( 'Lorem ipsum dolor', $this->actionError->message );
}
}
diff --git a/tests/Actions/ActionsReportTest.php b/tests/Actions/ActionsReportTest.php
--- a/tests/Actions/ActionsReportTest.php
+++ b/tests/Actions/ActionsReportTest.php
@@ -2,8 +2,6 @@
namespace Nasqueron\Notifications\Tests\Actions;
-use Illuminate\Foundation\Testing\WithoutMiddleware;
-
use Nasqueron\Notifications\Actions\ActionError;
use Nasqueron\Notifications\Actions\ActionsReport;
use Nasqueron\Notifications\Actions\AMQPAction;
@@ -13,16 +11,16 @@
protected $report;
- public function setUp () {
+ public function setUp(): void {
$this->report = new ActionsReport();
}
- public function testReport () {
+ public function testReport() {
// Empty report
- $this->assertEmpty($this->report->gate);
- $this->assertEmpty($this->report->door);
- $this->assertFalse($this->report->containsError());
- $this->assertSame(0, count($this->report->actions));
+ $this->assertEmpty( $this->report->gate );
+ $this->assertEmpty( $this->report->door );
+ $this->assertFalse( $this->report->containsError() );
+ $this->assertCount( 0, $this->report->actions );
// Adds a first action
// Our report should be valid.
@@ -30,10 +28,10 @@
'method',
'target'
);
- $this->report->addAction($action);
+ $this->report->addAction( $action );
- $this->assertSame(1, count($this->report->actions));
- $this->assertFalse($this->report->containsError());
+ $this->assertCount( 1, $this->report->actions );
+ $this->assertFalse( $this->report->containsError() );
// Let's attach an exception to a new action.
// Our report should then be invalid.
@@ -41,23 +39,23 @@
'methodWithException',
'target'
);
- $ex = new \RuntimeException('Lorem ipsum dolor');
- $action->attachError(new ActionError($ex));
- $this->report->addAction($action);
+ $ex = new \RuntimeException( 'Lorem ipsum dolor' );
+ $action->attachError( new ActionError( $ex ) );
+ $this->report->addAction( $action );
- $this->assertSame(2, count($this->report->actions));
- $this->assertTrue($this->report->containsError());
+ $this->assertCount( 2, $this->report->actions );
+ $this->assertTrue( $this->report->containsError() );
// Attaches to gate
- $this->report->attachToGate('QuuxGate', 'Quuxians');
- $this->assertSame('QuuxGate', $this->report->gate);
- $this->assertSame('Quuxians', $this->report->door);
+ $this->report->attachToGate( 'QuuxGate', 'Quuxians' );
+ $this->assertSame( 'QuuxGate', $this->report->gate );
+ $this->assertSame( 'Quuxians', $this->report->door );
// Test rendering
$actualReport = (string)$this->report;
- $expectedReport = file_get_contents(__DIR__ . '/../data/report.json');
+ $expectedReport = file_get_contents( __DIR__ . '/../data/report.json' );
- $score = similar_text($expectedReport, $actualReport);
- $this->assertGreaterThan(550, $score, 'data/report.json and rendered report differ too much. Try $this->assertEquals($expectedReport, $actualReport) to see a diff.');
+ $score = similar_text( $expectedReport, $actualReport );
+ $this->assertGreaterThan( 550, $score, 'data/report.json and rendered report differ too much. Try $this->assertEquals($expectedReport, $actualReport) to see a diff.' );
}
}
diff --git a/tests/Actions/NotifyNewCommitsActionTest.php b/tests/Actions/NotifyNewCommitsActionTest.php
--- a/tests/Actions/NotifyNewCommitsActionTest.php
+++ b/tests/Actions/NotifyNewCommitsActionTest.php
@@ -2,8 +2,6 @@
namespace Nasqueron\Notifications\Tests\Actions;
-use Illuminate\Foundation\Testing\WithoutMiddleware;
-
use Nasqueron\Notifications\Actions\NotifyNewCommitsAction;
use Nasqueron\Notifications\Tests\TestCase;
@@ -11,14 +9,14 @@
protected $action;
- public function setUp () {
+ public function setUp(): void {
$this->action = new NotifyNewCommitsAction(
'QUUX'
);
}
- public function testPublicProperties () {
- $this->assertNull($this->action->error);
- $this->assertSame('NotifyNewCommitsAction', $this->action->action);
+ public function testPublicProperties() {
+ $this->assertNull( $this->action->error );
+ $this->assertSame( 'NotifyNewCommitsAction', $this->action->action );
}
}
diff --git a/tests/Actions/TriggerDockerHubBuildActionTest.php b/tests/Actions/TriggerDockerHubBuildActionTest.php
--- a/tests/Actions/TriggerDockerHubBuildActionTest.php
+++ b/tests/Actions/TriggerDockerHubBuildActionTest.php
@@ -2,8 +2,6 @@
namespace Nasqueron\Notifications\Tests\Actions;
-use Illuminate\Foundation\Testing\WithoutMiddleware;
-
use Nasqueron\Notifications\Actions\TriggerDockerHubBuildAction;
use Nasqueron\Notifications\Tests\TestCase;
@@ -11,15 +9,15 @@
protected $action;
- public function setUp () {
+ public function setUp(): void {
$this->action = new TriggerDockerHubBuildAction(
'acme/foo'
);
}
- public function testPublicProperties () {
- $this->assertNull($this->action->error);
- $this->assertSame('acme/foo', $this->action->image);
- $this->assertSame('TriggerDockerHubBuildAction', $this->action->action);
+ public function testPublicProperties() {
+ $this->assertNull( $this->action->error );
+ $this->assertSame( 'acme/foo', $this->action->image );
+ $this->assertSame( 'TriggerDockerHubBuildAction', $this->action->action );
}
}
diff --git a/tests/Analyzers/GitHub/Events/CreateEventTest.php b/tests/Analyzers/GitHub/Events/CreateEventTest.php
--- a/tests/Analyzers/GitHub/Events/CreateEventTest.php
+++ b/tests/Analyzers/GitHub/Events/CreateEventTest.php
@@ -11,7 +11,7 @@
*/
private $event;
- public function setUp () {
+ public function setUp(): void {
$payload = new \stdClass;
$payload->repository = new \stdClass;
$payload->repository->full_name = 'baxterthehacker/public-repo';
@@ -19,22 +19,20 @@
$payload->ref_type = 'bookmark';
$payload->ref = 'quux';
- $this->event = new CreateEvent($payload);
+ $this->event = new CreateEvent( $payload );
parent::setUp();
}
- public function testNonExistingRefType () {
+ public function testNonExistingRefType() {
$this->assertSame(
"Unknown create reference: bookmark quux",
$this->event->getDescription()
);
}
- /**
- * @expectedException InvalidArgumentException
- */
- public function testNonExistingRefTypeLinkException () {
+ public function testNonExistingRefTypeLinkException() {
+ $this->expectException( \InvalidArgumentException::class );
$this->event->getLink();
}
diff --git a/tests/Analyzers/GitHub/Events/DeleteEventTest.php b/tests/Analyzers/GitHub/Events/DeleteEventTest.php
--- a/tests/Analyzers/GitHub/Events/DeleteEventTest.php
+++ b/tests/Analyzers/GitHub/Events/DeleteEventTest.php
@@ -11,7 +11,7 @@
*/
private $event;
- public function setUp () {
+ public function setUp(): void {
$payload = new \stdClass;
$payload->repository = new \stdClass;
$payload->repository->full_name = 'baxterthehacker/public-repo';
@@ -19,22 +19,20 @@
$payload->ref_type = 'bookmark';
$payload->ref = 'quux';
- $this->event = new DeleteEvent($payload);
+ $this->event = new DeleteEvent( $payload );
parent::setUp();
}
- public function testNonExistingRefType () {
+ public function testNonExistingRefType() {
$this->assertSame(
"Unknown delete reference: bookmark quux",
$this->event->getDescription()
);
}
- /**
- * @expectedException InvalidArgumentException
- */
- public function testNonExistingRefTypeLinkException () {
+ public function testNonExistingRefTypeLinkException() {
+ $this->expectException( \InvalidArgumentException::class );
$this->event->getLink();
}
diff --git a/tests/Analyzers/GitHub/Events/EventTest.php b/tests/Analyzers/GitHub/Events/EventTest.php
--- a/tests/Analyzers/GitHub/Events/EventTest.php
+++ b/tests/Analyzers/GitHub/Events/EventTest.php
@@ -7,50 +7,48 @@
class EventTest extends TestCase {
- public function testGetClass () {
+ public function testGetClass() {
$this->assertSame(
'Nasqueron\Notifications\Analyzers\GitHub\Events\CommitCommentEvent',
- Event::getClass('commit_comment')
+ Event::getClass( 'commit_comment' )
);
}
- public function testForPayload () {
+ public function testForPayload() {
$this->assertInstanceOf(
'Nasqueron\Notifications\Analyzers\GitHub\Events\CommitCommentEvent',
- Event::forPayload('commit_comment', new \stdClass)
+ Event::forPayload( 'commit_comment', new \stdClass )
);
}
- /**
- * @expectedException InvalidArgumentException
- */
- public function testForPayloadWithException () {
- Event::forPayload('not_existing', new \stdClass);
+ public function testForPayloadWithException() {
+ $this->expectException( \InvalidArgumentException::class );
+ Event::forPayload( 'not_existing', new \stdClass );
}
- public function testCut () {
- $this->assertSame('', Event::cut(''));
- $this->assertSame('', Event::cut('', 0));
- $this->assertSame('…', Event::cut('Lorem ipsum dolor', 0));
- $this->assertSame('Lorem…', Event::cut('Lorem ipsum dolor', 6));
- $this->assertSame('Lorem ipsum dolor', Event::cut('Lorem ipsum dolor'));
+ public function testCut() {
+ $this->assertSame( '', Event::cut( '' ) );
+ $this->assertSame( '', Event::cut( '', 0 ) );
+ $this->assertSame( '…', Event::cut( 'Lorem ipsum dolor', 0 ) );
+ $this->assertSame( 'Lorem…', Event::cut( 'Lorem ipsum dolor', 6 ) );
+ $this->assertSame( 'Lorem ipsum dolor', Event::cut( 'Lorem ipsum dolor' ) );
}
/**
* @dataProvider payloadDescriptionProvider
*/
- public function testGetDescriptionAndLink ($eventName,
- $expectedDescription,
- $expectedLink) {
+ public function testGetDescriptionAndLink( string $eventName,
+ string $expectedDescription,
+ string $expectedLink ) {
$filename = __DIR__ . "/../../../data/payloads/GitHubEvents/$eventName.json";
- $payload = json_decode(file_get_contents($filename));
- $event = Event::forPayload($eventName, $payload);
+ $payload = json_decode( file_get_contents( $filename ) );
+ $event = Event::forPayload( $eventName, $payload );
- $this->assertSame($expectedDescription, $event->getDescription());
- $this->assertSame($expectedLink, $event->getLink());
+ $this->assertSame( $expectedDescription, $event->getDescription() );
+ $this->assertSame( $expectedLink, $event->getLink() );
}
- public function payloadDescriptionProvider () {
+ public function payloadDescriptionProvider() {
return [
'CommitCommentEvent' => [
'commit_comment',
diff --git a/tests/Analyzers/GitHub/Events/IssueCommentEventTest.php b/tests/Analyzers/GitHub/Events/IssueCommentEventTest.php
--- a/tests/Analyzers/GitHub/Events/IssueCommentEventTest.php
+++ b/tests/Analyzers/GitHub/Events/IssueCommentEventTest.php
@@ -12,9 +12,9 @@
*/
private $payload;
- public function setUp () {
+ public function setUp(): void {
$filename = __DIR__ . "/../../../data/payloads/GitHubEvents/issue_comment.json";
- $this->payload = json_decode(file_get_contents($filename));
+ $this->payload = json_decode( file_get_contents( $filename ) );
parent::setUp();
}
@@ -22,10 +22,10 @@
/**
* @dataProvider payloadDescriptionProvider
*/
- public function testWhenRepositoryPerAction ($action, $description) {
+ public function testWhenRepositoryPerAction( string $action, string $description ) {
$this->payload->action = $action;
- $event = new IssueCommentEvent($this->payload);
- $this->assertSame($description, $event->getDescription());
+ $event = new IssueCommentEvent( $this->payload );
+ $this->assertSame( $description, $event->getDescription() );
}
/**
@@ -33,11 +33,11 @@
*
* See https://developer.github.com/v3/activity/events/types/#issuecommentevent
*/
- public function payloadDescriptionProvider () {
+ public function payloadDescriptionProvider() {
return [
- ['created', "baxterthehacker added a comment to issue #2 — Spelling error in the README file: You are totally right! I'll get this fixed right away."],
- ['edited', "baxterthehacker edited a comment to issue #2 — Spelling error in the README file: You are totally right! I'll get this fixed right away."],
- ['deleted', "baxterthehacker deleted a comment to issue #2 — Spelling error in the README file"],
+ [ 'created', "baxterthehacker added a comment to issue #2 — Spelling error in the README file: You are totally right! I'll get this fixed right away." ],
+ [ 'edited', "baxterthehacker edited a comment to issue #2 — Spelling error in the README file: You are totally right! I'll get this fixed right away." ],
+ [ 'deleted', "baxterthehacker deleted a comment to issue #2 — Spelling error in the README file" ],
];
}
diff --git a/tests/Analyzers/GitHub/Events/PullRequestEventTest.php b/tests/Analyzers/GitHub/Events/PullRequestEventTest.php
--- a/tests/Analyzers/GitHub/Events/PullRequestEventTest.php
+++ b/tests/Analyzers/GitHub/Events/PullRequestEventTest.php
@@ -12,9 +12,9 @@
*/
private $payload;
- public function setUp () {
+ public function setUp(): void {
$filename = __DIR__ . "/../../../data/payloads/GitHubEvents/pull_request.json";
- $this->payload = json_decode(file_get_contents($filename));
+ $this->payload = json_decode( file_get_contents( $filename ) );
parent::setUp();
}
@@ -22,10 +22,10 @@
/**
* @dataProvider payloadDescriptionProvider
*/
- public function testWhenRepositoryPerAction ($action, $description) {
+ public function testWhenRepositoryPerAction( string $action, string $description ) {
$this->payload->action = $action;
- $event = new PullRequestEvent($this->payload);
- $this->assertSame($description, $event->getDescription());
+ $event = new PullRequestEvent( $this->payload );
+ $this->assertSame( $description, $event->getDescription() );
}
/**
@@ -33,17 +33,17 @@
*
* See https://developer.github.com/v3/activity/events/types/#pullrequestevent
*/
- public function payloadDescriptionProvider () {
+ public function payloadDescriptionProvider() {
return [
- ['assigned', "baxterthehacker has assigned the pull request #1 — Update the README with new information to alken-orin"],
- ['unassigned', "baxterthehacker has edited the assignees from the pull request #1 — Update the README with new information"],
- ['labeled', "baxterthehacker has labeled the pull request #1 — Update the README with new information"],
- ['unlabeled', "baxterthehacker has removed a label from the pull request #1 — Update the README with new information"],
- ['opened', "baxterthehacker has opened a pull request: #1 — Update the README with new information"],
- ['edited', "baxterthehacker has edited the pull request #1 — Update the README with new information"],
- ['closed', "baxterthehacker has closed the pull request #1 — Update the README with new information"],
- ['reopened', "baxterthehacker has reopened the pull request #1 — Update the README with new information"],
- ['quuxed', "Unknown pull request action: quuxed"],
+ [ 'assigned', "baxterthehacker has assigned the pull request #1 — Update the README with new information to alken-orin" ],
+ [ 'unassigned', "baxterthehacker has edited the assignees from the pull request #1 — Update the README with new information" ],
+ [ 'labeled', "baxterthehacker has labeled the pull request #1 — Update the README with new information" ],
+ [ 'unlabeled', "baxterthehacker has removed a label from the pull request #1 — Update the README with new information" ],
+ [ 'opened', "baxterthehacker has opened a pull request: #1 — Update the README with new information" ],
+ [ 'edited', "baxterthehacker has edited the pull request #1 — Update the README with new information" ],
+ [ 'closed', "baxterthehacker has closed the pull request #1 — Update the README with new information" ],
+ [ 'reopened', "baxterthehacker has reopened the pull request #1 — Update the README with new information" ],
+ [ 'quuxed', "Unknown pull request action: quuxed" ],
];
}
diff --git a/tests/Analyzers/GitHub/Events/PushEventTest.php b/tests/Analyzers/GitHub/Events/PushEventTest.php
--- a/tests/Analyzers/GitHub/Events/PushEventTest.php
+++ b/tests/Analyzers/GitHub/Events/PushEventTest.php
@@ -12,16 +12,16 @@
*/
private $payloads;
- public function setUp () {
+ public function setUp(): void {
$payloadsToPrepare = [
'0' => 'GitHubPushForceZeroPayload.json',
'1' => 'GitHubEvents/push.json',
'n' => 'GitHubPushSeveralCommitsPayload.json',
];
- foreach ($payloadsToPrepare as $key => $filename) {
+ foreach ( $payloadsToPrepare as $key => $filename ) {
$filename = __DIR__ . "/../../../data/payloads/" . $filename;
- $this->payloads[$key] = json_decode(file_get_contents($filename));
+ $this->payloads[$key] = json_decode( file_get_contents( $filename ) );
}
parent::setUp();
@@ -31,45 +31,44 @@
/// WithRepoAndBranch trait
///
-
- public function testGetRepositoryAndBranch () {
- $this->assertSame("", PushEvent::getRepositoryAndBranch("", "master"));
- $this->assertSame("", PushEvent::getRepositoryAndBranch("", "foo"));
- $this->assertSame("quux", PushEvent::getRepositoryAndBranch("quux", "master"));
- $this->assertSame("quux", PushEvent::getRepositoryAndBranch("quux", "refs/heads/master"));
- $this->assertSame("quux", PushEvent::getRepositoryAndBranch("quux", ""));
- $this->assertSame("quux (branch foo)", PushEvent::getRepositoryAndBranch("quux", "refs/heads/foo"));
- $this->assertSame("quux (branch feature/foo)", PushEvent::getRepositoryAndBranch("quux", "refs/heads/feature/foo"));
- $this->assertSame("quux (branch feature/foo)", PushEvent::getRepositoryAndBranch("quux", "feature/foo"));
- $this->assertSame("quux (branch foo)", PushEvent::getRepositoryAndBranch("quux", "foo"));
- $this->assertSame("quux (branch 0)", PushEvent::getRepositoryAndBranch("quux", "0"));
+ public function testGetRepositoryAndBranch() {
+ $this->assertSame( "", PushEvent::getRepositoryAndBranch( "", "master" ) );
+ $this->assertSame( "", PushEvent::getRepositoryAndBranch( "", "foo" ) );
+ $this->assertSame( "quux", PushEvent::getRepositoryAndBranch( "quux", "master" ) );
+ $this->assertSame( "quux", PushEvent::getRepositoryAndBranch( "quux", "refs/heads/master" ) );
+ $this->assertSame( "quux", PushEvent::getRepositoryAndBranch( "quux", "" ) );
+ $this->assertSame( "quux (branch foo)", PushEvent::getRepositoryAndBranch( "quux", "refs/heads/foo" ) );
+ $this->assertSame( "quux (branch feature/foo)", PushEvent::getRepositoryAndBranch( "quux", "refs/heads/feature/foo" ) );
+ $this->assertSame( "quux (branch feature/foo)", PushEvent::getRepositoryAndBranch( "quux", "feature/foo" ) );
+ $this->assertSame( "quux (branch foo)", PushEvent::getRepositoryAndBranch( "quux", "foo" ) );
+ $this->assertSame( "quux (branch 0)", PushEvent::getRepositoryAndBranch( "quux", "0" ) );
}
///
/// WithCommit trait
///
- public function testGetCommitTitle () {
- $this->assertSame("", PushEvent::getCommitTitle(""));
- $this->assertSame("Lorem ipsum dolor", PushEvent::getCommitTitle("Lorem ipsum dolor"));
+ public function testGetCommitTitle() {
+ $this->assertSame( "", PushEvent::getCommitTitle( "" ) );
+ $this->assertSame( "Lorem ipsum dolor", PushEvent::getCommitTitle( "Lorem ipsum dolor" ) );
$longCommitMessages = [
"I was born in a water moon. Some people, especially its inhabitants, called it a planet, but as it was only a little over two hundred kilometres in diameter, 'moon' seems the more accurate term. The moon was made entirely of water, by which I mean it was a globe that not only had no land, but no rock either, a sphere with no solid core at all, just liquid water, all the way down to the very centre of the globe.",
"I was born in a water moon. Some people, especially its inhabitants, called it a planet, but as it was only a little over two hundred kilometres in diameter, 'moon' seems the more accurate term. The moon was made entirely of water, by which I mean it was a globe that not only had no land, but no rock either, a sphere with no solid core at all, just liquid water, all the way down to the very centre of the globe.\n\nIf it had been much bigger the moon would have had a core of ice, for water, though supposedly incompressible, is not entirely so, and will change under extremes of pressure to become ice. (If you are used to living on a planet where ice floats on the surface of water, this seems odd and even wrong, but nevertheless it is the case.) The moon was not quite of a size for an ice core to form, and therefore one could, if one was sufficiently hardy, and adequately proof against the water pressure, make one's way down, through the increasing weight of water above, to the very centre of the moon.",
];
$shortCommitTitle = "I was born in a water moon. Some people, especially its inhabitants, ca…";
- foreach ($longCommitMessages as $longCommitMessage) {
+ foreach ( $longCommitMessages as $longCommitMessage ) {
$this->assertSame(
$shortCommitTitle,
- PushEvent::getCommitTitle($longCommitMessage)
+ PushEvent::getCommitTitle( $longCommitMessage )
);
}
}
- public function testWhenTheCommitterAndAuthorAreDifferent () {
+ public function testWhenTheCommitterAndAuthorAreDifferent() {
$payload = clone $this->payloads['1'];
$payload->head_commit->author->username = "Skrunge";
- $event = new PushEvent($payload);
+ $event = new PushEvent( $payload );
$this->assertSame(
"baxterthehacker committed Update README.md (authored by Skrunge)",
@@ -77,23 +76,23 @@
);
}
- public function testOnGitPushForce () {
- $event = new PushEvent($this->payloads['0']);
+ public function testOnGitPushForce() {
+ $event = new PushEvent( $this->payloads['0'] );
$this->assertSame(
"dereckson forcely updated docker-nginx-php-fpm (branch novolume)",
$event->getDescription()
);
- $this->assertContains("compare", $event->getLink());
+ $this->assertStringContainsString( "compare", $event->getLink() );
}
- public function testOnGitPushWithSeveralCommits () {
- $event = new PushEvent($this->payloads['n']);
+ public function testOnGitPushWithSeveralCommits() {
+ $event = new PushEvent( $this->payloads['n'] );
$this->assertSame(
"dereckson pushed 2 commits to notifications",
$event->getDescription()
);
- $this->assertContains("compare", $event->getLink());
+ $this->assertStringContainsString( "compare", $event->getLink() );
}
}
diff --git a/tests/Analyzers/GitHub/Events/RepositoryEventTest.php b/tests/Analyzers/GitHub/Events/RepositoryEventTest.php
--- a/tests/Analyzers/GitHub/Events/RepositoryEventTest.php
+++ b/tests/Analyzers/GitHub/Events/RepositoryEventTest.php
@@ -12,46 +12,46 @@
*/
private $payload;
- public function setUp () {
+ public function setUp(): void {
$filename = __DIR__ . "/../../../data/payloads/GitHubEvents/repository.json";
- $this->payload = json_decode(file_get_contents($filename));
+ $this->payload = json_decode( file_get_contents( $filename ) );
parent::setUp();
}
- public function testWhenRepositoryIsForked () {
+ public function testWhenRepositoryIsForked() {
$payload = clone $this->payload;
$payload->repository->fork = true;
- $event = new RepositoryEvent($payload);
+ $event = new RepositoryEvent( $payload );
- $this->assertContains("fork", $event->getDescription());
+ $this->assertStringContainsString( "fork", $event->getDescription() );
}
- public function testWhenRepositoryContainsDescription () {
+ public function testWhenRepositoryContainsDescription() {
$payload = clone $this->payload;
$payload->repository->description = "Lorem ipsum dolor";
- $event = new RepositoryEvent($payload);
+ $event = new RepositoryEvent( $payload );
- $this->assertContains("Lorem ipsum dolor", $event->getDescription());
+ $this->assertStringContainsString( "Lorem ipsum dolor", $event->getDescription() );
}
- public function testWhenRepositoryIsForkedAndContainsDescription () {
+ public function testWhenRepositoryIsForkedAndContainsDescription() {
$payload = clone $this->payload;
$payload->repository->fork = true;
$payload->repository->description = "Lorem ipsum dolor";
- $event = new RepositoryEvent($payload);
+ $event = new RepositoryEvent( $payload );
- $this->assertContains("fork", $event->getDescription());
- $this->assertContains("Lorem ipsum dolor", $event->getDescription());
+ $this->assertStringContainsString( "fork", $event->getDescription() );
+ $this->assertStringContainsString( "Lorem ipsum dolor", $event->getDescription() );
}
/**
* @dataProvider payloadDescriptionProvider
*/
- public function testWhenRepositoryPerAction ($action, $description) {
+ public function testWhenRepositoryPerAction( string $action, string $description ) {
$this->payload->action = $action;
- $event = new RepositoryEvent($this->payload);
- $this->assertSame($description, $event->getDescription());
+ $event = new RepositoryEvent( $this->payload );
+ $this->assertSame( $description, $event->getDescription() );
}
/**
@@ -59,13 +59,13 @@
*
* See https://developer.github.com/v3/activity/events/types/#repositoryevent
*/
- public function payloadDescriptionProvider () {
+ public function payloadDescriptionProvider() {
return [
- ['created', "New repository baxterandthehackers/new-repository"],
- ['deleted', "Repository baxterandthehackers/new-repository deleted (danger zone)"],
- ['publicized', "Repository baxterandthehackers/new-repository is now public"],
- ['privatized', "Repository baxterandthehackers/new-repository is now private"],
- ['quuxed', "Unknown repository action: quuxed"],
+ [ 'created', "New repository baxterandthehackers/new-repository" ],
+ [ 'deleted', "Repository baxterandthehackers/new-repository deleted (danger zone)" ],
+ [ 'publicized', "Repository baxterandthehackers/new-repository is now public" ],
+ [ 'privatized', "Repository baxterandthehackers/new-repository is now private" ],
+ [ 'quuxed', "Unknown repository action: quuxed" ],
];
}
diff --git a/tests/Analyzers/GitHub/Events/StatusEventTest.php b/tests/Analyzers/GitHub/Events/StatusEventTest.php
--- a/tests/Analyzers/GitHub/Events/StatusEventTest.php
+++ b/tests/Analyzers/GitHub/Events/StatusEventTest.php
@@ -12,17 +12,17 @@
*/
private $payload;
- public function setUp () {
+ public function setUp(): void {
$filename = __DIR__ . "/../../../data/payloads/GitHubEvents/status.json";
- $this->payload = json_decode(file_get_contents($filename));
+ $this->payload = json_decode( file_get_contents( $filename ) );
parent::setUp();
}
- public function testWhenStatusContainsUrl () {
+ public function testWhenStatusContainsUrl() {
$payload = clone $this->payload;
$payload->target_url = "http://www.perdu.com/";
- $event = new StatusEvent($payload);
+ $event = new StatusEvent( $payload );
$this->assertSame(
"http://www.perdu.com/",
diff --git a/tests/Analyzers/GitHub/Events/UnknownEventTest.php b/tests/Analyzers/GitHub/Events/UnknownEventTest.php
--- a/tests/Analyzers/GitHub/Events/UnknownEventTest.php
+++ b/tests/Analyzers/GitHub/Events/UnknownEventTest.php
@@ -12,17 +12,17 @@
*/
private $event;
- public function setUp () {
+ public function setUp(): void {
$filename = __DIR__ . "/../../../data/payloads/GitHubEvents/push.json";
- $payload = json_decode(file_get_contents($filename));
- $this->event = new UnknownEvent("quux", $payload);
+ $payload = json_decode( file_get_contents( $filename ) );
+ $this->event = new UnknownEvent( "quux", $payload );
parent::setUp();
}
- public function testUnknownEvent () {
- $this->assertInstanceOf("Nasqueron\Notifications\Analyzers\GitHub\Events\UnknownEvent", $this->event);
- $this->assertSame("Some quux happened", $this->event->getDescription());
- $this->assertEmpty($this->event->getLink());
+ public function testUnknownEvent() {
+ $this->assertInstanceOf( "Nasqueron\Notifications\Analyzers\GitHub\Events\UnknownEvent", $this->event );
+ $this->assertSame( "Some quux happened", $this->event->getDescription() );
+ $this->assertEmpty( $this->event->getLink() );
}
}
diff --git a/tests/Analyzers/GitHub/GitHubPayloadAnalyzerTest.php b/tests/Analyzers/GitHub/GitHubPayloadAnalyzerTest.php
--- a/tests/Analyzers/GitHub/GitHubPayloadAnalyzerTest.php
+++ b/tests/Analyzers/GitHub/GitHubPayloadAnalyzerTest.php
@@ -30,7 +30,7 @@
/**
* Prepares the tests
*/
- public function setUp () {
+ public function setUp(): void {
parent::setUp();
$this->unknownEventAnalyzer = new GitHubPayloadAnalyzer(
@@ -46,16 +46,16 @@
);
$filename = __DIR__ . "/../../data/payloads/GitHubEvents/push.json";
- $payloadRawContent = file_get_contents($filename);
+ $payloadRawContent = file_get_contents( $filename );
- $payload = json_decode($payloadRawContent);
+ $payload = json_decode( $payloadRawContent );
$this->pushAnalyzer = new GitHubPayloadAnalyzer(
"Nasqueron", // Expected with known config
"push",
$payload
);
- $dockerPayload = json_decode($payloadRawContent);
+ $dockerPayload = json_decode( $payloadRawContent );
$dockerPayload->repository->name = "docker-someapp";
$this->pushToMappedRepositoryAnalyzer = new GitHubPayloadAnalyzer(
"Nasqueron", // Expected with known config
@@ -64,14 +64,8 @@
);
}
- ///
- /// Test constructor
- ///
-
- /**
- * @expectedException TypeError
- */
- public function testConstructorThrowsAnExceptionWhenPayloadIsInvalid () {
+ public function testConstructorThrowsAnExceptionWhenPayloadIsInvalid() {
+ $this->expectException( \TypeError::class );
new GitHubPayloadAnalyzer(
"Acme",
"push",
@@ -83,14 +77,14 @@
/// Test getConfigurationFileName
///
- public function testGetConfigurationFileNameWhenConfigExists () {
+ public function testGetConfigurationFileNameWhenConfigExists() {
$this->assertSame(
"GitHubPayloadAnalyzer/Nasqueron.json",
$this->pingAnalyzer->getConfigurationFileName()
);
}
- public function testGetConfigurationFileNameWhenConfigDoesNotExist () {
+ public function testGetConfigurationFileNameWhenConfigDoesNotExist() {
$this->assertSame(
"GitHubPayloadAnalyzer/default.json",
$this->unknownEventAnalyzer->getConfigurationFileName()
@@ -101,37 +95,36 @@
/// Test getItemName
///
- public function testGetItemNameWhenEventIsAdministrative () {
- $this->assertEmpty($this->pingAnalyzer->getItemName());
+ public function testGetItemNameWhenEventIsAdministrative() {
+ $this->assertEmpty( $this->pingAnalyzer->getItemName() );
}
- public function testGetItemNameWhenEventIsRepositoryRelative () {
- $this->assertSame("public-repo", $this->pushAnalyzer->getItemName());
+ public function testGetItemNameWhenEventIsRepositoryRelative() {
+ $this->assertSame( "public-repo", $this->pushAnalyzer->getItemName() );
}
///
/// Test getGroup
///
- public function testGetGroupWhenEventIsAdministrative () {
- $this->assertSame("orgz", $this->pingAnalyzer->getGroup());
+ public function testGetGroupWhenEventIsAdministrative() {
+ $this->assertSame( "orgz", $this->pingAnalyzer->getGroup() );
}
- public function testGetGroupOnPushToMappedRepository () {
- $this->assertSame("docker", $this->pushToMappedRepositoryAnalyzer->getGroup());
-
+ public function testGetGroupOnPushToMappedRepository() {
+ $this->assertSame( "docker", $this->pushToMappedRepositoryAnalyzer->getGroup() );
}
- public function testGetGroupOnPushToNotMappedRepository () {
- $this->assertSame("nasqueron", $this->pushAnalyzer->getGroup());
+ public function testGetGroupOnPushToNotMappedRepository() {
+ $this->assertSame( "nasqueron", $this->pushAnalyzer->getGroup() );
}
///
/// Test if our fallback is correct when the GitHub event type is unknown
///
- public function testDescriptionContainsTypeWhenEventTypeIsUnknown () {
- $this->assertContains(
+ public function testDescriptionContainsTypeWhenEventTypeIsUnknown() {
+ $this->assertStringContainsString(
"quux",
$this->unknownEventAnalyzer->getDescription()
);
diff --git a/tests/Analyzers/ItemGroupMappingTest.php b/tests/Analyzers/ItemGroupMappingTest.php
--- a/tests/Analyzers/ItemGroupMappingTest.php
+++ b/tests/Analyzers/ItemGroupMappingTest.php
@@ -2,14 +2,12 @@
namespace Nasqueron\Notifications\Tests\Analyzers;
-use Illuminate\Foundation\Testing\WithoutMiddleware;
-
use Nasqueron\Notifications\Analyzers\ItemGroupMapping;
use Nasqueron\Notifications\Tests\TestCase;
class ItemGroupMappingTest extends TestCase {
- public function testDoesItemMatch () {
+ public function testDoesItemMatch() {
$this->assertTrue(
ItemGroupMapping::doesItemMatch(
'quux*',
@@ -49,26 +47,26 @@
/**
* @dataProvider payloadProvider
*/
- public function testDeserialize (ItemGroupMapping $payload, ItemGroupMapping $expected) {
- $this->assertEquals($payload, $expected);
+ public function testDeserialize( ItemGroupMapping $payload, ItemGroupMapping $expected ) {
+ $this->assertEquals( $payload, $expected );
}
- private function deserialize ($file) : ItemGroupMapping {
+ private function deserialize( $file ): ItemGroupMapping {
$mapper = new \JsonMapper();
- $payload = json_decode(file_get_contents($file));
- return $mapper->map($payload, new ItemGroupMapping);
+ $payload = json_decode( file_get_contents( $file ) );
+ return $mapper->map( $payload, new ItemGroupMapping );
}
- public function payloadProvider () : array {
+ public function payloadProvider(): array {
$toProvide = [];
$path = __DIR__ . '/../data/ItemGroupMapping';
- $files = glob($path . "/*.expected.json");
- foreach ($files as $expectedResultFile) {
- $resultFile = str_replace(".expected", "", $expectedResultFile);
+ $files = glob( $path . "/*.expected.json" );
+ foreach ( $files as $expectedResultFile ) {
+ $resultFile = str_replace( ".expected", "", $expectedResultFile );
$toProvide[] = [
- $this->deserialize($resultFile),
- $this->deserialize($expectedResultFile),
+ $this->deserialize( $resultFile ),
+ $this->deserialize( $expectedResultFile ),
];
}
diff --git a/tests/Analyzers/Jenkins/JenkinsPayloadAnalyzerConfigurationTest.php b/tests/Analyzers/Jenkins/JenkinsPayloadAnalyzerConfigurationTest.php
--- a/tests/Analyzers/Jenkins/JenkinsPayloadAnalyzerConfigurationTest.php
+++ b/tests/Analyzers/Jenkins/JenkinsPayloadAnalyzerConfigurationTest.php
@@ -2,10 +2,8 @@
namespace Nasqueron\Notifications\Tests\Analyzers;
-use Illuminate\Foundation\Testing\WithoutMiddleware;
-
-use Nasqueron\Notifications\Analyzers\Jenkins\JenkinsPayloadAnalyzerConfiguration;
use Nasqueron\Notifications\Analyzers\ItemGroupMapping;
+use Nasqueron\Notifications\Analyzers\Jenkins\JenkinsPayloadAnalyzerConfiguration;
use Nasqueron\Notifications\Tests\TestCase;
class JenkinsPayloadAnalyzerConfigurationTest extends TestCase {
@@ -20,12 +18,12 @@
/**
* Prepares the test
*/
- public function setUp () {
+ public function setUp(): void {
$filename = __DIR__ . '/../../data/JenkinsPayloadAnalyzer/Nasqueron.json';
$mapper = new \JsonMapper();
$this->configuration = $mapper->map(
- json_decode(file_get_contents($filename)),
- new JenkinsPayloadAnalyzerConfiguration('Nasqueron')
+ json_decode( file_get_contents( $filename ) ),
+ new JenkinsPayloadAnalyzerConfiguration( 'Nasqueron' )
);
parent::setUp();
@@ -34,11 +32,11 @@
/**
* Determines the JSON object is well parsed
*/
- public function testProperties () {
- $this->assertSame("ci", $this->configuration->defaultGroup);
+ public function testProperties() {
+ $this->assertSame( "ci", $this->configuration->defaultGroup );
- foreach ($this->configuration->map as $item) {
- $this->assertInstanceOf(ItemGroupMapping::class, $item);
+ foreach ( $this->configuration->map as $item ) {
+ $this->assertInstanceOf( ItemGroupMapping::class, $item );
}
}
@@ -46,17 +44,17 @@
/// Tests for getDefaultGroup
///
- public function testGetDefaultGroup () {
+ public function testGetDefaultGroup() {
$this->configuration->defaultGroup = "quux";
- $this->assertSame("quux", $this->configuration->getDefaultGroup());
+ $this->assertSame( "quux", $this->configuration->getDefaultGroup() );
}
- public function testGetDefaultGroupWhenNotInConfig () {
+ public function testGetDefaultGroupWhenNotInConfig() {
$this->configuration->defaultGroup = "";
- $this->assertSame("nasqueron", $this->configuration->getDefaultGroup());
+ $this->assertSame( "nasqueron", $this->configuration->getDefaultGroup() );
$this->configuration->defaultGroup = null;
- $this->assertSame("nasqueron", $this->configuration->getDefaultGroup());
+ $this->assertSame( "nasqueron", $this->configuration->getDefaultGroup() );
}
}
diff --git a/tests/Analyzers/Jenkins/JenkinsPayloadAnalyzerTest.php b/tests/Analyzers/Jenkins/JenkinsPayloadAnalyzerTest.php
--- a/tests/Analyzers/Jenkins/JenkinsPayloadAnalyzerTest.php
+++ b/tests/Analyzers/Jenkins/JenkinsPayloadAnalyzerTest.php
@@ -3,7 +3,6 @@
namespace Nasqueron\Notifications\Tests\Analyzers;
use Nasqueron\Notifications\Analyzers\Jenkins\JenkinsPayloadAnalyzer;
-use Nasqueron\Notifications\Analyzers\Jenkins\JenkinsPayloadAnalyzerConfiguration;
use Nasqueron\Notifications\Tests\TestCase;
class JenkinsPayloadAnalyzerTest extends TestCase {
@@ -23,38 +22,38 @@
/**
* Prepares the test
*/
- public function setUp () {
+ public function setUp(): void {
parent::setUp();
$filename = __DIR__ . '/../../data/payloads/JenkinsToIgnorePayload.json';
- $this->payload = json_decode(file_get_contents($filename));
- $this->analyzer = new JenkinsPayloadAnalyzer("Nasqueron", $this->payload);
+ $this->payload = json_decode( file_get_contents( $filename ) );
+ $this->analyzer = new JenkinsPayloadAnalyzer( "Nasqueron", $this->payload );
}
- public function testGetItemName () {
- $this->assertSame("test-prod-env", $this->analyzer->getItemName());
+ public function testGetItemName() {
+ $this->assertSame( "test-prod-env", $this->analyzer->getItemName() );
}
- public function testGetGroup () {
- $this->assertSame("ops", $this->analyzer->getGroup());
+ public function testGetGroup() {
+ $this->assertSame( "ops", $this->analyzer->getGroup() );
}
- public function testGetGroupWhenWeNeedDefaultFallback () {
+ public function testGetGroupWhenWeNeedDefaultFallback() {
$this->payload->name = "quux";
- $this->assertSame("ci", $this->analyzer->getGroup());
+ $this->assertSame( "ci", $this->analyzer->getGroup() );
}
- public function testShouldNotifyWhenStatusIsUndefined () {
- unset($this->payload->build->status);
- $this->assertFalse($this->analyzer->shouldNotify());
+ public function testShouldNotifyWhenStatusIsUndefined() {
+ unset( $this->payload->build->status );
+ $this->assertFalse( $this->analyzer->shouldNotify() );
}
/**
* @dataProvider payloadStatusProvider
*/
- public function testShouldNotifyByStatus ($status, $shouldNotify) {
+ public function testShouldNotifyByStatus( string $status, bool $shouldNotify ) {
$this->payload->build->status = $status;
- $this->assertSame($shouldNotify, $this->analyzer->shouldNotify());
+ $this->assertSame( $shouldNotify, $this->analyzer->shouldNotify() );
}
/**
@@ -62,16 +61,16 @@
*
* @return array
*/
- public function payloadStatusProvider () {
+ public function payloadStatusProvider() {
return [
// Build status to notify
- ["FAILURE", true],
- ["ABORTED", true],
- ["UNSTABLE", true],
+ [ "FAILURE", true ],
+ [ "ABORTED", true ],
+ [ "UNSTABLE", true ],
// Build status to ignore
- ["SUCCESS", false],
- ["NOT_BUILT", false],
+ [ "SUCCESS", false ],
+ [ "NOT_BUILT", false ],
];
}
diff --git a/tests/Analyzers/PayloadAnalyzerConfigurationTest.php b/tests/Analyzers/PayloadAnalyzerConfigurationTest.php
--- a/tests/Analyzers/PayloadAnalyzerConfigurationTest.php
+++ b/tests/Analyzers/PayloadAnalyzerConfigurationTest.php
@@ -2,10 +2,8 @@
namespace Nasqueron\Notifications\Tests\Analyzers;
-use Illuminate\Foundation\Testing\WithoutMiddleware;
-
-use Nasqueron\Notifications\Analyzers\PayloadAnalyzerConfiguration;
use Nasqueron\Notifications\Analyzers\ItemGroupMapping;
+use Nasqueron\Notifications\Analyzers\PayloadAnalyzerConfiguration;
use Nasqueron\Notifications\Tests\TestCase;
class PayloadAnalyzerConfigurationTest extends TestCase {
@@ -20,12 +18,12 @@
/**
* Prepares the test
*/
- public function setUp () {
+ public function setUp(): void {
$filename = __DIR__ . '/../data/GitHubPayloadAnalyzer/Nasqueron.json';
$mapper = new \JsonMapper();
$this->configuration = $mapper->map(
- json_decode(file_get_contents($filename)),
- new PayloadAnalyzerConfiguration('Nasqueron')
+ json_decode( file_get_contents( $filename ) ),
+ new PayloadAnalyzerConfiguration( 'Nasqueron' )
);
parent::setUp();
@@ -34,12 +32,12 @@
/**
* Determines the JSON object is well parsed
*/
- public function testProperties () {
- $this->assertSame("orgz", $this->configuration->administrativeGroup);
- $this->assertSame("nasqueron", $this->configuration->defaultGroup);
+ public function testProperties() {
+ $this->assertSame( "orgz", $this->configuration->administrativeGroup );
+ $this->assertSame( "nasqueron", $this->configuration->defaultGroup );
- foreach ($this->configuration->map as $item) {
- $this->assertInstanceOf(ItemGroupMapping::class, $item);
+ foreach ( $this->configuration->map as $item ) {
+ $this->assertInstanceOf( ItemGroupMapping::class, $item );
}
}
@@ -47,17 +45,17 @@
/// Tests for getDefaultGroup
///
- public function testGetDefaultGroup () {
+ public function testGetDefaultGroup() {
$this->configuration->defaultGroup = "quux";
- $this->assertSame("quux", $this->configuration->getDefaultGroup());
+ $this->assertSame( "quux", $this->configuration->getDefaultGroup() );
}
- public function testGetDefaultGroupWhenNotInConfig () {
+ public function testGetDefaultGroupWhenNotInConfig() {
$this->configuration->defaultGroup = "";
- $this->assertSame("nasqueron", $this->configuration->getDefaultGroup());
+ $this->assertSame( "nasqueron", $this->configuration->getDefaultGroup() );
$this->configuration->defaultGroup = null;
- $this->assertSame("nasqueron", $this->configuration->getDefaultGroup());
+ $this->assertSame( "nasqueron", $this->configuration->getDefaultGroup() );
}
}
diff --git a/tests/Analyzers/Phabricator/PhabricatorGroupMappingTest.php b/tests/Analyzers/Phabricator/PhabricatorGroupMappingTest.php
--- a/tests/Analyzers/Phabricator/PhabricatorGroupMappingTest.php
+++ b/tests/Analyzers/Phabricator/PhabricatorGroupMappingTest.php
@@ -19,7 +19,7 @@
*/
private $story;
- public function setUp () {
+ public function setUp(): void {
parent::setUp();
$config = $this->getPhabricatorPayloadAnalyzerConfiguration();
@@ -30,7 +30,7 @@
'strongWords',
];
- $this->mappings = array_combine($keys, $config->map);
+ $this->mappings = array_combine( $keys, $config->map );
$this->story = $this->getStory();
}
@@ -39,51 +39,51 @@
/// Tests
///
- public function testDoesProjectBelong () {
+ public function testDoesProjectBelong() {
$mapping = $this->mappings['projects'];
$this->assertFalse(
- $mapping->doesItemBelong("")
+ $mapping->doesItemBelong( "" )
);
$this->assertFalse(
- $mapping->doesItemBelong("Tasacora")
+ $mapping->doesItemBelong( "Tasacora" )
);
$this->assertTrue(
- $mapping->doesItemBelong("Docker images")
+ $mapping->doesItemBelong( "Docker images" )
);
$this->assertFalse(
- $mapping->doesItemBelong("Docker")
+ $mapping->doesItemBelong( "Docker" )
);
$this->assertFalse(
- $mapping->doesItemBelong("Docker images quux")
+ $mapping->doesItemBelong( "Docker images quux" )
);
}
- public function testDoesStoryBelong () {
+ public function testDoesStoryBelong() {
$mapping = $this->mappings['words'];
$this->assertFalse(
- $mapping->doesStoryBelong($this->story)
+ $mapping->doesStoryBelong( $this->story )
);
$this->story->text = "Review the cartography elements.";
$this->assertTrue(
- $mapping->doesStoryBelong($this->story)
+ $mapping->doesStoryBelong( $this->story )
);
}
/**
* Test to fix T773
*/
- public function testDoesStoryBelongWhenWordIsInAnotherCase () {
+ public function testDoesStoryBelongWhenWordIsInAnotherCase() {
$mapping = $this->mappings['words'];
$this->story->text = "Review the Cartography elements.";
$this->assertTrue(
- $mapping->doesStoryBelong($this->story)
+ $mapping->doesStoryBelong( $this->story )
);
}
diff --git a/tests/Analyzers/Phabricator/PhabricatorPayloadAnalyzerTest.php b/tests/Analyzers/Phabricator/PhabricatorPayloadAnalyzerTest.php
--- a/tests/Analyzers/Phabricator/PhabricatorPayloadAnalyzerTest.php
+++ b/tests/Analyzers/Phabricator/PhabricatorPayloadAnalyzerTest.php
@@ -19,7 +19,7 @@
*/
private $story;
- public function setUp () {
+ public function setUp(): void {
parent::setUp();
$this->story = $this->getStory();
@@ -29,14 +29,14 @@
);
}
- public function testGetConfigurationFileName () {
+ public function testGetConfigurationFileName() {
$this->assertSame(
"PhabricatorPayloadAnalyzer/Nasqueron.json",
$this->analyzer->getConfigurationFileName()
);
}
- public function testGetGroupWhereEventIsAdministrative () {
+ public function testGetGroupWhereEventIsAdministrative() {
$this->markTestIncomplete(
"Not yet implemented feature. See T664."
);
@@ -47,24 +47,24 @@
);
}
- public function testGetGroupWhereStoryDoesntMatchAnything () {
- $this->attachProjectsToStoryMock($this->story, []);
+ public function testGetGroupWhereStoryDoesntMatchAnything() {
+ $this->attachProjectsToStoryMock( $this->story, [] );
$this->assertSame(
"nasqueron",
$this->analyzer->getGroup()
);
}
- public function testGetGroupWhereStoryMatchesProject () {
- $this->attachProjectsToStoryMock($this->story, ['Docker images']);
+ public function testGetGroupWhereStoryMatchesProject() {
+ $this->attachProjectsToStoryMock( $this->story, [ 'Docker images' ] );
$this->assertSame(
"docker",
$this->analyzer->getGroup()
);
}
- public function testGetGroupWhereStoryMatchesWords () {
- $this->attachProjectsToStoryMock($this->story, []);
+ public function testGetGroupWhereStoryMatchesWords() {
+ $this->attachProjectsToStoryMock( $this->story, [] );
$this->story->text = "Review the cartography elements.";
$this->assertSame(
"tasacora",
@@ -72,12 +72,12 @@
);
}
- public function testGetGroupWhereWordsAreStrong () {
+ public function testGetGroupWhereWordsAreStrong() {
$this->markTestIncomplete(
"Not yet implemented feature. See T748."
);
- $this->attachProjectsToStoryMock($this->story, ['Docker images']);
+ $this->attachProjectsToStoryMock( $this->story, [ 'Docker images' ] );
$this->story->text = "Review the cartography elements on Dwellers.";
$this->assertSame(
@@ -86,10 +86,8 @@
);
}
- /**
- * @expectedException \BadMethodCallException
- */
- public function testGetItemThrowsBadMethodCallException () {
+ public function testGetItemThrowsBadMethodCallException() {
+ $this->expectException( \BadMethodCallException::class );
$this->analyzer->getItemName();
}
diff --git a/tests/Analyzers/Phabricator/WithConfiguration.php b/tests/Analyzers/Phabricator/WithConfiguration.php
--- a/tests/Analyzers/Phabricator/WithConfiguration.php
+++ b/tests/Analyzers/Phabricator/WithConfiguration.php
@@ -3,34 +3,33 @@
namespace Nasqueron\Notifications\Tests\Analyzers\Phabricator;
use Nasqueron\Notifications\Analyzers\Phabricator\PhabricatorPayloadAnalyzerConfiguration;
-use Nasqueron\Notifications\Phabricator\PhabricatorStory;
/**
* Helper methods to construct needed objects
*/
trait WithConfiguration {
- private function getPhabricatorPayloadAnalyzerConfiguration () {
+ private function getPhabricatorPayloadAnalyzerConfiguration() {
$filename = __DIR__ . '/../../data/PhabricatorPayloadAnalyzer/Nasqueron.json';
$mapper = new \JsonMapper();
return $mapper->map(
- json_decode(file_get_contents($filename)),
- new PhabricatorPayloadAnalyzerConfiguration('Nasqueron')
+ json_decode( file_get_contents( $filename ) ),
+ new PhabricatorPayloadAnalyzerConfiguration( 'Nasqueron' )
);
}
private function getStory() {
return $this
- ->getMockBuilder("Nasqueron\Notifications\Phabricator\PhabricatorStory")
- ->setConstructorArgs(["Acme"])
+ ->getMockBuilder( "Nasqueron\Notifications\Phabricator\PhabricatorStory" )
+ ->setConstructorArgs( [ "Acme" ] )
->getMock();
}
- private function attachProjectsToStoryMock ($mock, $projects) {
+ private function attachProjectsToStoryMock( $mock, $projects ) {
$mock
- ->expects($this->any())
- ->method("getProjects")
- ->will($this->returnValue($projects));
+ ->expects( $this->any() )
+ ->method( "getProjects" )
+ ->will( $this->returnValue( $projects ) );
}
}
diff --git a/tests/Config/FeaturesTest.php b/tests/Config/FeaturesTest.php
--- a/tests/Config/FeaturesTest.php
+++ b/tests/Config/FeaturesTest.php
@@ -7,24 +7,24 @@
class FeaturesTest extends TestCase {
- public function testEnable () {
+ public function testEnable() {
// Find it (en vain …)
- $this->assertNotContains('Quux', Features::getEnabled());
- $this->assertFalse(Features::isEnabled('Quux'));
+ $this->assertNotContains( 'Quux', Features::getEnabled() );
+ $this->assertFalse( Features::isEnabled( 'Quux' ) );
// Enable it
- Features::enable('Quux');
- $this->assertTrue(Features::isEnabled('Quux'));
- $this->assertContains('Quux', Features::getEnabled());
+ Features::enable( 'Quux' );
+ $this->assertTrue( Features::isEnabled( 'Quux' ) );
+ $this->assertContains( 'Quux', Features::getEnabled() );
// Disable it
- Features::disable('Quux');
- $this->assertFalse(Features::isEnabled('Quux'));
+ Features::disable( 'Quux' );
+ $this->assertFalse( Features::isEnabled( 'Quux' ) );
// Count it
- $this->assertContains('Quux', Features::getAll());
- $this->assertContains('Quux', Features::getAvailable());
- $this->assertNotContains('Quux', Features::getEnabled());
+ $this->assertContains( 'Quux', Features::getAll() );
+ $this->assertContains( 'Quux', Features::getAvailable() );
+ $this->assertNotContains( 'Quux', Features::getEnabled() );
}
}
diff --git a/tests/Config/Reporting/BaseReportEntryTest.php b/tests/Config/Reporting/BaseReportEntryTest.php
--- a/tests/Config/Reporting/BaseReportEntryTest.php
+++ b/tests/Config/Reporting/BaseReportEntryTest.php
@@ -8,19 +8,19 @@
class BaseReportEntryTest extends TestCase {
public function testFancyString() {
- $this->assertSame('ø', BaseReportEntry::fancyString('', 'ø'));
- $this->assertSame('ø', BaseReportEntry::fancyString('ø', 'ø'));
- $this->assertSame('o', BaseReportEntry::fancyString('o', 'ø'));
- $this->assertSame('', BaseReportEntry::fancyString('', ''));
+ $this->assertSame( 'ø', BaseReportEntry::fancyString( '', 'ø' ) );
+ $this->assertSame( 'ø', BaseReportEntry::fancyString( 'ø', 'ø' ) );
+ $this->assertSame( 'o', BaseReportEntry::fancyString( 'o', 'ø' ) );
+ $this->assertSame( '', BaseReportEntry::fancyString( '', '' ) );
}
public function testFancyBool() {
- $this->assertSame('ø', BaseReportEntry::fancyBool(false, '✓', 'ø'));
- $this->assertSame('✓', BaseReportEntry::fancyBool(true, '✓', 'ø'));
- $this->assertSame('', BaseReportEntry::fancyBool(false, '✓'));
- $this->assertSame('✓', BaseReportEntry::fancyBool(true, '✓'));
- $this->assertSame('', BaseReportEntry::fancyBool(true, '', ''));
- $this->assertSame('', BaseReportEntry::fancyBool(false, '', ''));
+ $this->assertSame( 'ø', BaseReportEntry::fancyBool( false, '✓', 'ø' ) );
+ $this->assertSame( '✓', BaseReportEntry::fancyBool( true, '✓', 'ø' ) );
+ $this->assertSame( '', BaseReportEntry::fancyBool( false, '✓' ) );
+ $this->assertSame( '✓', BaseReportEntry::fancyBool( true, '✓' ) );
+ $this->assertSame( '', BaseReportEntry::fancyBool( true, '', '' ) );
+ $this->assertSame( '', BaseReportEntry::fancyBool( false, '', '' ) );
}
}
diff --git a/tests/Config/Reporting/FeatureReportEntryTest.php b/tests/Config/Reporting/FeatureReportEntryTest.php
--- a/tests/Config/Reporting/FeatureReportEntryTest.php
+++ b/tests/Config/Reporting/FeatureReportEntryTest.php
@@ -17,30 +17,30 @@
*/
private $disabledFeatureEntry;
- public function setUp () {
- $this->enabledFeatureEntry = new FeatureReportEntry("foo", true);
- $this->disabledFeatureEntry = new FeatureReportEntry("bar", false);
+ public function setUp(): void {
+ $this->enabledFeatureEntry = new FeatureReportEntry( "foo", true );
+ $this->disabledFeatureEntry = new FeatureReportEntry( "bar", false );
}
public function testToArray() {
$this->assertSame(
- ["foo", (string)true],
+ [ "foo", (string)true ],
$this->enabledFeatureEntry->toArray()
);
$this->assertSame(
- ["bar", (string)false],
+ [ "bar", (string)false ],
$this->disabledFeatureEntry->toArray()
);
}
public function testToFancyArray() {
$this->assertSame(
- ["foo", "✓"],
+ [ "foo", "✓" ],
$this->enabledFeatureEntry->toFancyArray()
);
$this->assertSame(
- ["bar", ""],
+ [ "bar", "" ],
$this->disabledFeatureEntry->toFancyArray()
);
}
diff --git a/tests/Config/Reporting/IntegrationTest.php b/tests/Config/Reporting/IntegrationTest.php
--- a/tests/Config/Reporting/IntegrationTest.php
+++ b/tests/Config/Reporting/IntegrationTest.php
@@ -6,20 +6,20 @@
class IntegrationTest extends TestCase {
- public function setUp () {
+ public function setUp(): void {
parent::setUp();
$this->mockServices()
- ->shouldReceive('get')
+ ->shouldReceive( 'get' )
->once()
- ->andReturn([]); // No service
+ ->andReturn( [] ); // No service
}
/**
* Config works.
*/
public function testConfig() {
- $json = $this->get('/config')
+ $json = $this->get( '/config' )
->response
->getContent();
diff --git a/tests/Config/Reporting/ServiceReportEntryTest.php b/tests/Config/Reporting/ServiceReportEntryTest.php
--- a/tests/Config/Reporting/ServiceReportEntryTest.php
+++ b/tests/Config/Reporting/ServiceReportEntryTest.php
@@ -3,7 +3,6 @@
namespace Nasqueron\Notifications\Tests\Config\Reporting;
use Nasqueron\Notifications\Config\Reporting\ServiceReportEntry;
-use Nasqueron\Notifications\Config\Services\Service;
use Nasqueron\Notifications\Tests\TestCase;
class ServiceReportEntryTest extends TestCase {
@@ -13,21 +12,21 @@
*/
private $serviceEntry;
- public function setUp () {
+ public function setUp(): void {
$service = $this->mockService();
- $this->serviceEntry = new ServiceReportEntry($service);
+ $this->serviceEntry = new ServiceReportEntry( $service );
}
public function testToArray() {
$this->assertSame(
- ["Storm", "Acme", "http://www.perdu.com", ""],
+ [ "Storm", "Acme", "http://www.perdu.com", "" ],
$this->serviceEntry->toArray()
);
}
public function testToFancyArray() {
$this->assertSame(
- ["Storm", "Acme", "http://www.perdu.com", "✓"],
+ [ "Storm", "Acme", "http://www.perdu.com", "✓" ],
$this->serviceEntry->toFancyArray()
);
}
diff --git a/tests/Config/Services/ServiceTest.php b/tests/Config/Services/ServiceTest.php
--- a/tests/Config/Services/ServiceTest.php
+++ b/tests/Config/Services/ServiceTest.php
@@ -17,7 +17,7 @@
*/
private $serviceWithoutInstance;
- public function setUp () {
+ public function setUp(): void {
$this->serviceWithoutInstance = new Service();
$this->serviceWithInstance = clone $this->serviceWithoutInstance;
@@ -28,14 +28,14 @@
/// Tests for getInstanceName()
///
- public function testGetInstanceName () {
+ public function testGetInstanceName() {
$this->assertSame(
"http://www.perdu.com",
$this->serviceWithInstance->getInstanceName()
);
}
- public function testGetInstanceNameWhenThereIsNoInstance () {
+ public function testGetInstanceNameWhenThereIsNoInstance() {
$this->assertSame(
"ø",
$this->serviceWithoutInstance->getInstanceName()
diff --git a/tests/Config/Services/ServicesTest.php b/tests/Config/Services/ServicesTest.php
--- a/tests/Config/Services/ServicesTest.php
+++ b/tests/Config/Services/ServicesTest.php
@@ -9,23 +9,23 @@
private $services;
- public function setUp () {
+ public function setUp(): void {
parent::setUp();
- $this->services = Services::loadFromJson('credentials.json');
+ $this->services = Services::loadFromJson( 'credentials.json' );
}
- public function testGet () {
+ public function testGet() {
$actualServices = $this->services->get();
- $this->assertGreaterThan(0, $actualServices);
+ $this->assertGreaterThan( 0, $actualServices );
$this->assertSame(
$this->services->services, // This is public, so testable
$actualServices
);
- foreach ($actualServices as $service) {
+ foreach ( $actualServices as $service ) {
$this->assertInstanceOf(
'Nasqueron\Notifications\Config\Services\Service',
$service
@@ -33,36 +33,36 @@
}
}
- public function testGetForGate () {
- $actualServices = $this->services->getForGate('GitHub');
- $this->assertGreaterThan(0, $actualServices);
- foreach ($actualServices as $service) {
+ public function testGetForGate() {
+ $actualServices = $this->services->getForGate( 'GitHub' );
+ $this->assertGreaterThan( 0, $actualServices );
+ foreach ( $actualServices as $service ) {
$this->assertInstanceOf(
'Nasqueron\Notifications\Config\Services\Service',
$service
);
- $this->assertSame('GitHub', $service->gate);
+ $this->assertSame( 'GitHub', $service->gate );
}
}
- public function testFindServiceByDoor () {
+ public function testFindServiceByDoor() {
// Search gives a result
- $service = $this->services->findServiceByDoor('GitHub', 'Acme');
+ $service = $this->services->findServiceByDoor( 'GitHub', 'Acme' );
$this->assertInstanceOf(
'Nasqueron\Notifications\Config\Services\Service',
$service
);
- $this->assertSame('GitHub', $service->gate);
- $this->assertSame('Acme', $service->door);
+ $this->assertSame( 'GitHub', $service->gate );
+ $this->assertSame( 'Acme', $service->door );
// Search doesn't give any result
- $service = $this->services->findServiceByDoor('GitHub', 'Quux');
- $this->assertNull($service);
+ $service = $this->services->findServiceByDoor( 'GitHub', 'Quux' );
+ $this->assertNull( $service );
}
- public function testFindServiceByProperty () {
+ public function testFindServiceByProperty() {
// Search gives a result
$service = $this->services->findServiceByProperty(
@@ -74,8 +74,8 @@
'Nasqueron\Notifications\Config\Services\Service',
$service
);
- $this->assertSame('Phabricator', $service->gate);
- $this->assertSame('Acme', $service->door);
+ $this->assertSame( 'Phabricator', $service->gate );
+ $this->assertSame( 'Acme', $service->door );
// Search doesn't give any result
@@ -84,7 +84,7 @@
'instance',
'https://notfound.acme.tld'
);
- $this->assertNull($service);
+ $this->assertNull( $service );
}
}
diff --git a/tests/Console/Commands/ConfigShowTest.php b/tests/Console/Commands/ConfigShowTest.php
--- a/tests/Console/Commands/ConfigShowTest.php
+++ b/tests/Console/Commands/ConfigShowTest.php
@@ -2,10 +2,8 @@
namespace Nasqueron\Notifications\Tests\Console\Commands;
-use Nasqueron\Notifications\Config\Features;
-use Nasqueron\Notifications\Config\Services\Service;
-
use Mockery;
+use Nasqueron\Notifications\Config\Features;
class ConfigShowTest extends TestCase {
@@ -19,81 +17,81 @@
*/
private $servicesMock;
- public function setUp () {
+ public function setUp(): void {
parent::setUp();
$this->servicesMock = $this->mockServices();
}
- public function testRegularExecute () {
- //Our command calls Services::get()
- $this->servicesMock->shouldReceive('get')->once()->andReturn([]);
+ public function testRegularExecute() {
+ // Our command calls Services::get()
+ $this->servicesMock->shouldReceive( 'get' )->once()->andReturn( [] );
- $this->tester->execute(['command' => $this->command->getName()]);
+ $this->tester->execute( [ 'command' => $this->command->getName() ] );
- $this->assertRegexpInDisplay('/Gates/');
- $this->assertRegexpInDisplay('/Features/');
- $this->assertRegexpInDisplay('/Services declared/');
+ $this->assertRegexpInDisplay( '/Gates/' );
+ $this->assertRegexpInDisplay( '/Features/' );
+ $this->assertRegexpInDisplay( '/Services declared/' );
}
- public function testRegularExecuteWithService () {
+ public function testRegularExecuteWithService() {
$service = $this->mockService();
$this->servicesMock
- ->shouldReceive('get')
+ ->shouldReceive( 'get' )
->once()
- ->andReturn([$service]);
+ ->andReturn( [ $service ] );
- $this->tester->execute(['command' => $this->command->getName()]);
- $this->assertRegexpInDisplay('/Storm/');
+ $this->tester->execute( [ 'command' => $this->command->getName() ] );
+ $this->assertRegexpInDisplay( '/Storm/' );
}
- public function testRegularExecuteWithPhabricatorService () {
+ public function testRegularExecuteWithPhabricatorService() {
$this->mockPhabricatorAPIForProjectsMap();
- $service = $this->mockService('Phabricator');
+ $service = $this->mockService( 'Phabricator' );
$this->servicesMock
- ->shouldReceive('get')
+ ->shouldReceive( 'get' )
->once()
- ->andReturn([$service]);
+ ->andReturn( [ $service ] );
$this->servicesMock
- ->shouldReceive('findServiceByProperty');
+ ->shouldReceive( 'findServiceByProperty' );
- $this->tester->execute(['command' => $this->command->getName()]);
+ $this->tester->execute( [ 'command' => $this->command->getName() ] );
$this->assertRegexpInDisplay(
'/Phabricator.*Projects map not cached./'
);
}
- protected function mockProjectsMap () {
+ protected function mockProjectsMap() {
$mock = Mockery::mock(
'Nasqueron\Notifications\Phabricator\ProjectsMap'
);
- $this->app->instance('phabricator-projectsmap', $mock);
+ $this->app->instance( 'phabricator-projectsmap', $mock );
return $mock;
}
- public function testRegularExecuteWithPhabricatorServiceWhenTheProjectsMapIsCached () {
+ public function testRegularExecuteWithPhabricatorServiceWhenTheProjectsMapIsCached() {
// The services list will return only one, for the Phabricator gate.
- $service = $this->mockService('Phabricator');
+ $service = $this->mockService( 'Phabricator' );
$this->servicesMock
- ->shouldReceive('get')->once()->andReturn([$service]);
+ ->shouldReceive( 'get' )->once()->andReturn( [ $service ] );
// The project map (built by the factory) will say it's cached.
$this->mockProjectsMap()
- ->shouldReceive('fetch->isCached')->once()->andReturn(true);
+ ->shouldReceive( 'fetch->isCached' )->once()->andReturn( true );
- $this->tester->execute(['command' => $this->command->getName()]);
- $this->assertRegexpInDisplay('/Phabricator.*✓/');
+ $this->tester->execute( [ 'command' => $this->command->getName() ] );
+ $this->assertRegexpInDisplay( '/Phabricator.*✓/' );
}
- public function testExecuteWhenSomeFeatureIsDisabled () {
- Features::disable('ActionsReport');
+ public function testExecuteWhenSomeFeatureIsDisabled() {
+ Features::disable( 'ActionsReport' );
- $this->servicesMock->shouldReceive('get')->once()->andReturn([]);
+ $this->servicesMock->shouldReceive( 'get' )->once()->andReturn( [] );
- $this->tester->execute(['command' => $this->command->getName()]);
+ $this->tester->execute( [ 'command' => $this->command->getName() ] );
$this->assertRegexpInDisplay(
'/Gate *\| *✓ *\|/'
);
diff --git a/tests/Console/Commands/ConfigValidateTest.php b/tests/Console/Commands/ConfigValidateTest.php
--- a/tests/Console/Commands/ConfigValidateTest.php
+++ b/tests/Console/Commands/ConfigValidateTest.php
@@ -13,47 +13,47 @@
const TEST_FILE = 'bug.json';
- public function testRegularExecute () {
- $this->tester->execute(['command' => $this->command->getName()]);
+ public function testRegularExecute() {
+ $this->tester->execute( [ 'command' => $this->command->getName() ] );
// When all files are valid, nothing is displayed
- $this->assertEquals('', $this->tester->getDisplay());
+ $this->assertSame( '', $this->tester->getDisplay() );
}
/**
* @dataProvider provideErrors
*/
- public function testSyntaxErrorExecute (string $content, string $error) {
- $this->populateTestFile($content); // Not JSON
+ public function testSyntaxErrorExecute( string $content, string $error ) {
+ $this->populateTestFile( $content ); // Not JSON
- $this->tester->execute(['command' => $this->command->getName()]);
+ $this->tester->execute( [ 'command' => $this->command->getName() ] );
// When all files are valid, nothing is displayed
- $this->assertRegexpInDisplay("/$error/");
+ $this->assertRegexpInDisplay( "/$error/" );
}
/**
* Provides invalid JSON strings and associated error
*/
- public function provideErrors () : array {
+ public function provideErrors(): array {
return [
- ["lorem ipsum dolor", "Syntax error"],
- ['{"}', "Control character error"]
+ [ "lorem ipsum dolor", "Syntax error" ],
+ [ '{"}', "Control character error" ]
];
}
- private function populateTestFile (string $content) : void {
- Storage::disk('local')->put(self::TEST_FILE, $content);
+ private function populateTestFile( string $content ): void {
+ Storage::disk( 'local' )->put( self::TEST_FILE, $content );
}
- private function deleteTestFile () : void {
- $fs = Storage::disk('local');
- if ($fs->exists(self::TEST_FILE)) {
- $fs->delete(self::TEST_FILE);
+ private function deleteTestFile(): void {
+ $fs = Storage::disk( 'local' );
+ if ( $fs->exists( self::TEST_FILE ) ) {
+ $fs->delete( self::TEST_FILE );
}
}
- public function tearDown () {
+ public function tearDown(): void {
$this->deleteTestFile();
parent::tearDown();
}
diff --git a/tests/Console/Commands/InspireTest.php b/tests/Console/Commands/InspireTest.php
--- a/tests/Console/Commands/InspireTest.php
+++ b/tests/Console/Commands/InspireTest.php
@@ -9,10 +9,10 @@
*/
protected $class = 'Nasqueron\Notifications\Console\Commands\Inspire';
- public function testExecute () {
+ public function testExecute() {
// A quote contain a - character and is embedded by PHP_EOL
- $this->tester->execute(['command' => $this->command->getName()]);
- $this->assertRegexpInDisplay('/\n.*-.*\n/');
+ $this->tester->execute( [ 'command' => $this->command->getName() ] );
+ $this->assertRegexpInDisplay( '/\n.*-.*\n/' );
}
}
diff --git a/tests/Console/Commands/NotificationsPayloadTest.php b/tests/Console/Commands/NotificationsPayloadTest.php
--- a/tests/Console/Commands/NotificationsPayloadTest.php
+++ b/tests/Console/Commands/NotificationsPayloadTest.php
@@ -11,9 +11,9 @@
*/
protected $class = NotificationsPayload::class;
- public function testRegularExecute () {
+ public function testRegularExecute() {
$path = __DIR__ . '/../../data/payloads/DockerHubPushPayload.json';
- $this->tester->execute([
+ $this->tester->execute( [
'command' => $this->command->getName(),
'service' => 'DockerHub',
'payload' => $path,
@@ -21,38 +21,36 @@
'Acme',
'push'
],
- ]);
+ ] );
- $this->assertDisplayContains('"service": "DockerHub"');
- $this->assertDisplayContains('"project": "Acme"');
- $this->assertDisplayContains('svendowideit\/testhook');
+ $this->assertDisplayContains( '"service": "DockerHub"' );
+ $this->assertDisplayContains( '"project": "Acme"' );
+ $this->assertDisplayContains( 'svendowideit\/testhook' );
}
- public function testPhabricatorPayload () {
+ public function testPhabricatorPayload() {
$path = __DIR__ . '/../../data/payloads/PhabricatorPastePayload.json';
- $this->tester->execute([
+ $this->tester->execute( [
'command' => $this->command->getName(),
'service' => 'Phabricator',
'payload' => $path,
'args' => [
'Acme',
],
- ]);
+ ] );
- $this->assertDisplayContains('"service": "Phabricator"');
- $this->assertDisplayContains('"project": "Acme"');
- $this->assertDisplayContains('"type": "PSTE"');
+ $this->assertDisplayContains( '"service": "Phabricator"' );
+ $this->assertDisplayContains( '"project": "Acme"' );
+ $this->assertDisplayContains( '"type": "PSTE"' );
}
- /**
- * @expectedException InvalidArgumentException
- */
- public function testArgumentsArrayCombine () {
- NotificationsPayload::argumentsArrayCombine(['foo'], []);
+ public function testArgumentsArrayCombine() {
+ $this->expectException( \InvalidArgumentException::class );
+ NotificationsPayload::argumentsArrayCombine( [ 'foo' ], [] );
}
- public function testFileNotFound () {
- $this->tester->execute([
+ public function testFileNotFound() {
+ $this->tester->execute( [
'command' => $this->command->getName(),
'service' => 'DockerHub',
'payload' => "/tmp/not.found",
@@ -60,14 +58,14 @@
'Acme',
'push'
],
- ]);
+ ] );
- $this->assertDisplayContains('File not found: /tmp/not.found');
+ $this->assertDisplayContains( 'File not found: /tmp/not.found' );
}
- public function testServiceNotFound () {
+ public function testServiceNotFound() {
$path = __DIR__ . '/../../data/payloads/DockerHubPushPayload.json';
- $this->tester->execute([
+ $this->tester->execute( [
'command' => $this->command->getName(),
'service' => 'InterdimensionalTeleport',
'payload' => $path,
@@ -75,12 +73,11 @@
'Acme',
'push'
],
- ]);
+ ] );
$this->assertDisplayContains(
'Unknown service: InterdimensionalTeleport'
);
-
}
}
diff --git a/tests/Console/Commands/PhabricatorProjectsMapTest.php b/tests/Console/Commands/PhabricatorProjectsMapTest.php
--- a/tests/Console/Commands/PhabricatorProjectsMapTest.php
+++ b/tests/Console/Commands/PhabricatorProjectsMapTest.php
@@ -2,7 +2,6 @@
namespace Nasqueron\Notifications\Tests\Console\Commands;
-use Nasqueron\Notifications\Config\Services\Service;
use Nasqueron\Notifications\Console\Commands\PhabricatorProjectsMap;
class PhabricatorProjectsMapTest extends TestCase {
@@ -12,21 +11,21 @@
*/
protected $class = PhabricatorProjectsMap::class;
- public function setUp () {
+ public function setUp(): void {
parent::setUp();
- $service = $this->mockService('Phabricator');
+ $service = $this->mockService( 'Phabricator' );
$this->mockServices()
- ->shouldReceive('getForGate')
+ ->shouldReceive( 'getForGate' )
->once()
- ->andReturn([$service]);
+ ->andReturn( [ $service ] );
$this->mockPhabricatorAPIForProjectsMap();
}
- public function testRegularExecute () {
- $this->tester->execute(['command' => $this->command->getName()]);
- $this->assertRegexpInDisplay('/PHID.*Project name/');
+ public function testRegularExecute() {
+ $this->tester->execute( [ 'command' => $this->command->getName() ] );
+ $this->assertRegexpInDisplay( '/PHID.*Project name/' );
$this->assertRegexpInDisplay(
'/PHID-PROJ-cztcgpvqr6smnnekotq7.*Agora/'
);
diff --git a/tests/Console/Commands/TestCase.php b/tests/Console/Commands/TestCase.php
--- a/tests/Console/Commands/TestCase.php
+++ b/tests/Console/Commands/TestCase.php
@@ -2,14 +2,10 @@
namespace Nasqueron\Notifications\Tests\Console\Commands;
-use Nasqueron\Notifications\Config\Services\Service;
-use Nasqueron\Notifications\Tests\TestCase as BaseTestCase;
-
use Illuminate\Contracts\Console\Kernel;
+use Nasqueron\Notifications\Tests\TestCase as BaseTestCase;
use Symfony\Component\Console\Tester\CommandTester;
-use Mockery;
-
class TestCase extends BaseTestCase {
///
@@ -22,31 +18,31 @@
protected $command;
/**
- * @var Symfony\Component\Console\Tester\CommandTester;
+ * @var Symfony\Component\Console\Tester\CommandTester
*/
protected $tester;
- public function setUp () {
+ public function setUp(): void {
parent::setUp();
- $kernel = $this->app->make(Kernel::class);
- $this->command = $kernel->getByClass($this->class);
- $this->tester = new CommandTester($this->command);
+ $kernel = $this->app->make( Kernel::class );
+ $this->command = $kernel->getByClass( $this->class );
+ $this->tester = new CommandTester( $this->command );
}
///
/// Display assertions
///
- public function assertDisplayContains(string $expectedNeedle) {
+ public function assertDisplayContains( string $expectedNeedle ) {
$this->assertContains(
$expectedNeedle,
$this->tester->getDisplay()
);
}
- public function assertRegexpInDisplay (string $pattern) {
- $this->assertRegexp($pattern, $this->tester->getDisplay());
+ public function assertRegexpInDisplay( string $pattern ) {
+ $this->assertRegexp( $pattern, $this->tester->getDisplay() );
}
}
diff --git a/tests/Console/KernelTest.php b/tests/Console/KernelTest.php
--- a/tests/Console/KernelTest.php
+++ b/tests/Console/KernelTest.php
@@ -2,13 +2,9 @@
namespace Nasqueron\Notifications\Tests\Console;
-use Nasqueron\Notifications\Tests\TestCase;
-
-use Nasqueron\Notifications\Console\Kernel;
-use Illuminate\Contracts\Console\Kernel as BaseKernel;
-
-use Artisan;
use File;
+use Illuminate\Contracts\Console\Kernel as BaseKernel;
+use Nasqueron\Notifications\Tests\TestCase;
class KernelTest extends TestCase {
/**
@@ -30,20 +26,20 @@
*/
private $namespace;
- public function setUp () {
+ public function setUp(): void {
parent::setUp();
- $this->kernel = $this->app->make(BaseKernel::class);
+ $this->kernel = $this->app->make( BaseKernel::class );
$this->commands = $this->kernel->all();
$this->namespace = $this->app->getInstance()->getNamespace()
. 'Console\\Commands\\';
}
- public function testOmittedFiles () {
- $files = File::allFiles(app_path('Console/Commands'));
+ public function testOmittedFiles() {
+ $files = File::allFiles( app_path( 'Console/Commands' ) );
- foreach ($files as $file) {
- $class = $this->namespace . $file->getBasename('.php');
+ foreach ( $files as $file ) {
+ $class = $this->namespace . $file->getBasename( '.php' );
$this->assertArrayContainsInstanceOf(
$class,
$this->commands,
@@ -52,30 +48,26 @@
}
}
- public function testGet () {
+ public function testGet() {
$this->assertInstanceOf(
\Nasqueron\Notifications\Console\Commands\Inspire::class,
- $this->kernel->get('inspire')
+ $this->kernel->get( 'inspire' )
);
}
- /**
- * @expectedException \RuntimeException
- */
- public function testGetWhenCommandDoesNotExist () {
- $this->kernel->get('notexisting');
+ public function testGetWhenCommandDoesNotExist() {
+ $this->expectException( \RuntimeException::class );
+ $this->kernel->get( 'notexisting' );
}
- public function testGetByClass () {
+ public function testGetByClass() {
$class = \Nasqueron\Notifications\Console\Commands\Inspire::class;
- $this->assertInstanceOf($class, $this->kernel->getByClass($class));
+ $this->assertInstanceOf( $class, $this->kernel->getByClass( $class ) );
}
- /**
- * @expectedException \RuntimeException
- */
- public function testGetByClassWhenCommandDoesNotExist () {
- $this->kernel->getByClass('notexisting');
+ public function testGetByClassWhenCommandDoesNotExist() {
+ $this->expectException( \RuntimeException::class );
+ $this->kernel->getByClass( 'notexisting' );
}
///
@@ -89,13 +81,13 @@
* @param array $haystack The array where to find
* @param string $message The test message
*/
- public static function assertArrayContainsInstanceOf (
+ public static function assertArrayContainsInstanceOf(
$expectedType,
- $haystack,
- $message = ''
+ array $haystack,
+ string $message = ''
) {
self::assertThat(
- self::arrayContainsInstanceOf($expectedType, $haystack),
+ self::arrayContainsInstanceOf( $expectedType, $haystack ),
self::isTrue(),
$message
);
@@ -109,12 +101,12 @@
* @param array $haystack The array where to find
* @return bool
*/
- protected static function arrayContainsInstanceOf (
+ protected static function arrayContainsInstanceOf(
$expectedType,
- $haystack
+ array $haystack
) {
- foreach ($haystack as $item) {
- if ($item instanceof $expectedType) {
+ foreach ( $haystack as $item ) {
+ if ( $item instanceof $expectedType ) {
return true;
}
}
diff --git a/tests/Exceptions/HandlerTest.php b/tests/Exceptions/HandlerTest.php
--- a/tests/Exceptions/HandlerTest.php
+++ b/tests/Exceptions/HandlerTest.php
@@ -2,13 +2,12 @@
namespace Nasqueron\Notifications\Tests\Exceptions;
-use Illuminate\Auth\Access\AuthorizationException;
-use Nasqueron\Notifications\Exceptions\Handler;
-use Nasqueron\Notifications\Tests\TestCase;
-
use App;
use Config;
+use Illuminate\Auth\Access\AuthorizationException;
use Mockery;
+use Nasqueron\Notifications\Exceptions\Handler;
+use Nasqueron\Notifications\Tests\TestCase;
class HandlerTest extends TestCase {
@@ -22,32 +21,32 @@
*/
private $ravenClientMock;
- public function setUp () {
+ public function setUp(): void {
parent::setUp();
- $this->handler = new Handler(app());
+ $this->handler = new Handler( app() );
$this->mockRavenClient();
}
- protected function mockRavenClient () {
+ protected function mockRavenClient() {
// Inject into our container a mock of Raven_Client
- $this->ravenClientMock = Mockery::mock('Raven_Client');
- $this->app->instance('raven', $this->ravenClientMock);
+ $this->ravenClientMock = Mockery::mock( 'Raven_Client' );
+ $this->app->instance( 'raven', $this->ravenClientMock );
// Environment shouldn't be 'testing' and DSN should be defined,
// so Handler::report will call Raven to report to Sentry
- Config::set('app.env', 'testing-raven');
- Config::set('services.sentry.dsn', 'mock');
+ Config::set( 'app.env', 'testing-raven' );
+ Config::set( 'services.sentry.dsn', 'mock' );
}
- public function testRavenReport () {
- $this->ravenClientMock->shouldReceive('captureException')->once();
- $this->handler->report(new \Exception);
+ public function testRavenReport() {
+ $this->ravenClientMock->shouldReceive( 'captureException' )->once();
+ $this->handler->report( new \Exception );
}
- public function testExceptionInDontReportArray () {
- $this->ravenClientMock->shouldReceive('captureException')->never();
- $this->handler->report(new AuthorizationException);
+ public function testExceptionInDontReportArray() {
+ $this->ravenClientMock->shouldReceive( 'captureException' )->never();
+ $this->handler->report( new AuthorizationException );
}
}
diff --git a/tests/Facades/DockerHubTest.php b/tests/Facades/DockerHubTest.php
--- a/tests/Facades/DockerHubTest.php
+++ b/tests/Facades/DockerHubTest.php
@@ -2,16 +2,13 @@
namespace Nasqueron\Notifications\Tests\Facades;
-use Nasqueron\Notifications\Tests\TestCase;
-
-use Config;
use DockerHub;
-
use Keruald\DockerHub\Build\TriggerBuildFactory;
+use Nasqueron\Notifications\Tests\TestCase;
class DockerHubTest extends TestCase {
- public function testIfFacadeAccessorCouldBeResolvedInAppContainer () {
+ public function testIfFacadeAccessorCouldBeResolvedInAppContainer() {
$this->assertInstanceOf(
TriggerBuildFactory::class,
DockerHub::getFacadeRoot()
diff --git a/tests/Facades/MailgunTest.php b/tests/Facades/MailgunTest.php
--- a/tests/Facades/MailgunTest.php
+++ b/tests/Facades/MailgunTest.php
@@ -2,16 +2,13 @@
namespace Nasqueron\Notifications\Tests\Facades;
-use Nasqueron\Notifications\Tests\TestCase;
-
-use Config;
-use Mailgun;
-
use Keruald\Mailgun\MailgunMessageFactory;
+use Mailgun;
+use Nasqueron\Notifications\Tests\TestCase;
class MailgunTest extends TestCase {
- public function testIfFacadeAccessorCouldBeResolvedInAppContainer () {
+ public function testIfFacadeAccessorCouldBeResolvedInAppContainer() {
$this->assertInstanceOf(
MailgunMessageFactory::class,
Mailgun::getFacadeRoot()
diff --git a/tests/Facades/PhabricatorAPITest.php b/tests/Facades/PhabricatorAPITest.php
--- a/tests/Facades/PhabricatorAPITest.php
+++ b/tests/Facades/PhabricatorAPITest.php
@@ -7,7 +7,7 @@
class PhabricatorAPITest extends TestCase {
- public function testIfFacadeAccessorCouldBeResolvedInAppContainer () {
+ public function testIfFacadeAccessorCouldBeResolvedInAppContainer() {
$this->assertInstanceOf(
'Nasqueron\Notifications\Phabricator\PhabricatorAPIFactory',
PhabricatorAPI::getFacadeRoot()
diff --git a/tests/Facades/ProjectsMapTest.php b/tests/Facades/ProjectsMapTest.php
--- a/tests/Facades/ProjectsMapTest.php
+++ b/tests/Facades/ProjectsMapTest.php
@@ -7,7 +7,7 @@
class ProjectsMapTest extends TestCase {
- public function testIfFacadeAccessorCouldBeResolvedInAppContainer () {
+ public function testIfFacadeAccessorCouldBeResolvedInAppContainer() {
$this->assertInstanceOf(
'Nasqueron\Notifications\Phabricator\ProjectsMapFactory',
ProjectsMap::getFacadeRoot()
diff --git a/tests/Facades/RavenTest.php b/tests/Facades/RavenTest.php
--- a/tests/Facades/RavenTest.php
+++ b/tests/Facades/RavenTest.php
@@ -2,28 +2,27 @@
namespace Nasqueron\Notifications\Tests\Facades;
-use Nasqueron\Notifications\Tests\TestCase;
-
use Config;
+use Nasqueron\Notifications\Tests\TestCase;
use Raven;
class RavenTest extends TestCase {
- public function testIfFacadeAccessorCouldBeResolvedInAppContainer () {
+ public function testIfFacadeAccessorCouldBeResolvedInAppContainer() {
$this->assertInstanceOf(
'Raven_Client',
Raven::getFacadeRoot()
);
}
- public function testIsConfigured () {
- Config::set("services.sentry.dsn", "something");
- $this->assertTrue(Raven::isConfigured());
+ public function testIsConfigured() {
+ Config::set( "services.sentry.dsn", "something" );
+ $this->assertTrue( Raven::isConfigured() );
}
- public function testIsConfiguredWhenItIsNot () {
- Config::offsetUnset("services.sentry.dsn");
- $this->assertFalse(Raven::isConfigured());
+ public function testIsConfiguredWhenItIsNot() {
+ Config::offsetUnset( "services.sentry.dsn" );
+ $this->assertFalse( Raven::isConfigured() );
}
}
diff --git a/tests/Http/Controllers/GitHubGateControllerTest.php b/tests/Http/Controllers/GitHubGateControllerTest.php
--- a/tests/Http/Controllers/GitHubGateControllerTest.php
+++ b/tests/Http/Controllers/GitHubGateControllerTest.php
@@ -5,7 +5,7 @@
use Nasqueron\Notifications\Tests\TestCase;
class GitHubGateControllerTest extends TestCase {
- public function setUp () {
+ public function setUp(): void {
parent::setUp();
$this->disableEvents();
@@ -16,16 +16,15 @@
*
* @return void
*/
- public function testGet () {
- $this->visit('/gate/GitHub')
- ->see('POST');
+ public function testGet() {
+ $this->sendPayload( '/gate/GitHub', "test" );
}
/**
* Tests a GitHub gate payload.
*/
- public function testPost () {
- $payload = file_get_contents(__DIR__ . '/../../data/payloads/GitHubPingPayload.json');
+ public function testPost() {
+ $payload = file_get_contents( __DIR__ . '/../../data/payloads/GitHubPingPayload.json' );
$this->sendPayload(
'/gate/GitHub/Quux', // A gate not existing in data/credentials.json
$payload,
@@ -35,11 +34,11 @@
'X-Github-Delivery' => 'e5dd9fc7-17ac-11e5-9427-73dad6b9b17c'
]
)
- ->seeJson([
+ ->seeJson( [
'gate' => 'GitHub',
'door' => 'Quux',
'actions' => []
- ]);
+ ] );
$this->assertResponseOk();
}
@@ -47,7 +46,7 @@
/**
* Tests a malformed GitHub gate payload.
*/
- public function testMalformedPost () {
+ public function testMalformedPost() {
$this->sendPayload(
'/gate/GitHub/Quux', // A gate not existing in data/credentials.json
"",
@@ -56,7 +55,7 @@
'X-Github-Delivery' => 'e5dd9fc7-17ac-11e5-9427-73dad6b9b17c',
]
);
- $this->assertResponseStatus(400);
+ $this->assertResponseStatus( 400 );
$this->sendPayload(
'/gate/GitHub/Quux', // A gate not existing in data/credentials.json
@@ -66,7 +65,7 @@
'X-Github-Event' => 'ping',
]
);
- $this->assertResponseStatus(400);
+ $this->assertResponseStatus( 400 );
$this->sendPayload(
'/gate/GitHub/Quux', // A gate not existing in data/credentials.json
@@ -77,10 +76,10 @@
'X-Github-Event' => 'ping',
]
);
- $this->assertResponseStatus(400);
+ $this->assertResponseStatus( 400 );
}
- public function testEmptySignature () {
+ public function testEmptySignature() {
$this->sendPayload(
'/gate/GitHub/Acme', // A gate existing in data/credentials.json
"",
@@ -90,6 +89,6 @@
'X-Github-Delivery' => 'e5dd9fc7-17ac-11e5-9427-73dad6b9b17c',
]
);
- $this->assertResponseStatus(403);
+ $this->assertResponseStatus( 403 );
}
}
diff --git a/tests/Http/PayloadFullTest.php b/tests/Http/PayloadFullTest.php
--- a/tests/Http/PayloadFullTest.php
+++ b/tests/Http/PayloadFullTest.php
@@ -7,7 +7,7 @@
class PayloadFullTest extends TestCase {
- public function setUp () {
+ public function setUp(): void {
parent::setUp();
$this->disableBroker();
@@ -16,19 +16,19 @@
/**
* Sends a GitHub ping payload to the application, with a valid signature
*/
- protected function sendValidTestPayload () {
- return $this->sendTestPayload('sha1=25f6cbd17ea4c6c69958b95fb88c879de4b66dcc');
+ protected function sendValidTestPayload() {
+ return $this->sendTestPayload( 'sha1=25f6cbd17ea4c6c69958b95fb88c879de4b66dcc' );
}
/**
* Sends a GitHub ping payload to the application, with a valid signature
*/
- protected function sendInvalidTestPayload () {
- return $this->sendTestPayload('sha1=somethingwrong');
+ protected function sendInvalidTestPayload() {
+ return $this->sendTestPayload( 'sha1=somethingwrong' );
}
- protected function sendTestPayload ($signature) {
- $payload = file_get_contents(__DIR__ . '/../data/payloads/GitHubPingPayload.json');
+ protected function sendTestPayload( $signature ) {
+ $payload = file_get_contents( __DIR__ . '/../data/payloads/GitHubPingPayload.json' );
$this->sendPayload(
'/gate/GitHub/Acme', // A gate existing in data/credentials.json
$payload,
@@ -45,12 +45,12 @@
/**
* Tests a GitHub gate payload.
*/
- public function testPost () {
- $this->sendValidTestPayload()->seeJson([
+ public function testPost() {
+ $this->sendValidTestPayload()->seeJson( [
'gate' => 'GitHub',
'door' => 'Acme',
'action' => 'AMQPAction'
- ]);
+ ] );
$this->assertResponseOk();
}
@@ -58,41 +58,41 @@
/**
* Tests a DockerHub gate payload.
*/
- public function testDockerHubPayload () {
- $payload = file_get_contents(__DIR__ . '/../data/payloads/DockerHubPushPayload.json');
+ public function testDockerHubPayload() {
+ $payload = file_get_contents( __DIR__ . '/../data/payloads/DockerHubPushPayload.json' );
$this->sendPayload(
'/gate/DockerHub/Acme', // A gate existing in data/credentials.json
$payload,
'POST',
[]
- )->seeJson([
+ )->seeJson( [
'gate' => 'DockerHub',
'door' => 'Acme',
'action' => 'AMQPAction'
- ]);
+ ] );
$this->assertResponseOk();
}
/**
* Tests a Jenkins gate payload.
*/
- public function testJenkinsPayload () {
- $payload = file_get_contents(__DIR__ . '/../data/payloads/JenkinsPayload.json');
+ public function testJenkinsPayload() {
+ $payload = file_get_contents( __DIR__ . '/../data/payloads/JenkinsPayload.json' );
$this->sendPayload(
'/gate/Jenkins/Acme', // A gate existing in data/credentials.json
$payload,
'POST',
[]
- )->seeJson([
+ )->seeJson( [
'gate' => 'Jenkins',
'door' => 'Acme',
'action' => 'AMQPAction'
- ]);
+ ] );
$this->assertResponseOk();
}
- private function getDataForPhabricatorPayloadTests () {
+ private function getDataForPhabricatorPayloadTests() {
return [
'storyID' => 3849,
'storyType' => 'PhabricatorApplicationTransactionFeedStory',
@@ -107,61 +107,61 @@
/**
* Tests a Phabricator gate payload.
*/
- public function testPhabricatorPayload () {
+ public function testPhabricatorPayload() {
$data = $this->getDataForPhabricatorPayloadTests();
- $this->post('/gate/Phabricator/Acme', $data)->seeJson([
+ $this->post( '/gate/Phabricator/Acme', $data )->seeJson( [
'gate' => 'Phabricator',
'door' => 'Acme',
'action' => 'AMQPAction'
- ]);
+ ] );
$this->assertResponseOk();
}
/**
* Tests a Phabricator gate payload, when the door doesn't exist.
*/
- public function testPhabricatorPayloadOnNotExistingDoor () {
+ public function testPhabricatorPayloadOnNotExistingDoor() {
$data = $this->getDataForPhabricatorPayloadTests();
- $this->post('/gate/Phabricator/NotExistingDoor', $data);
- $this->assertResponseStatus(404);
+ $this->post( '/gate/Phabricator/NotExistingDoor', $data );
+ $this->assertResponseStatus( 404 );
}
/**
* Same than testPost, but without actions report.
*/
- public function testPostWithoutActionsReport () {
- Features::disable("ActionsReport");
+ public function testPostWithoutActionsReport() {
+ Features::disable( "ActionsReport" );
$this->sendValidTestPayload();
- $this->assertEmpty($this->response->getContent());
+ $this->assertEmpty( $this->response->getContent() );
$this->assertResponseOk();
// Let's throw an Exception at broker level.
// Without ActionsReport, the client must always receive a 200 OK.
- $this->app->instance('broker', function ($app) {
+ $this->app->instance( 'broker', static function ( $app ) {
// A non omnipotent instance, so it doesn't mock connect().
return new BlackholeBroker;
- });
+ } );
$this->sendValidTestPayload();
- $this->assertEmpty($this->response->getContent());
+ $this->assertEmpty( $this->response->getContent() );
$this->assertResponseOk();
}
/**
* Tests a GitHub gate payload.
*/
- public function testInvalidSignature () {
+ public function testInvalidSignature() {
$this->sendInvalidTestPayload()
- ->assertResponseStatus(403);
+ ->assertResponseStatus( 403 );
}
- public function testBrokerIssue () {
+ public function testBrokerIssue() {
$this->mockNotOperationalBroker();
- $payload = file_get_contents(__DIR__ . '/../data/payloads/GitHubPingPayload.json');
+ $payload = file_get_contents( __DIR__ . '/../data/payloads/GitHubPingPayload.json' );
$this->sendPayload(
'/gate/GitHub/Acme', // A gate existing in data/credentials.json
$payload,
@@ -171,13 +171,13 @@
'X-Github-Delivery' => 'e5dd9fc7-17ac-11e5-9427-73dad6b9b17c',
'X-Hub-Signature' => 'sha1=25f6cbd17ea4c6c69958b95fb88c879de4b66dcc',
]
- )->seeJson([
+ )->seeJson( [
'gate' => 'GitHub',
'door' => 'Acme',
'action' => 'AMQPAction',
'type' => 'RuntimeException',
- ]);
+ ] );
- $this->assertResponseStatus(503);
+ $this->assertResponseStatus( 503 );
}
}
diff --git a/tests/Http/PlaceholderTest.php b/tests/Http/PlaceholderTest.php
--- a/tests/Http/PlaceholderTest.php
+++ b/tests/Http/PlaceholderTest.php
@@ -2,20 +2,15 @@
namespace Nasqueron\Notifications\Tests;
-use Illuminate\Foundation\Testing\WithoutMiddleware;
-use Illuminate\Foundation\Testing\DatabaseMigrations;
-use Illuminate\Foundation\Testing\DatabaseTransactions;
-
-class PlaceholderTest extends TestCase
-{
+class PlaceholderTest extends TestCase {
/**
* Placeholder homepage works.
*
* @return void
+ * @doesNotPerformAssertions
*/
- public function testPlaceholder()
- {
- $this->visit('/')
- ->see('Notifications center');
+ public function testPlaceholder() {
+ $this->visit( '/' )
+ ->see( 'Notifications center' );
}
}
diff --git a/tests/Http/StatusTest.php b/tests/Http/StatusTest.php
--- a/tests/Http/StatusTest.php
+++ b/tests/Http/StatusTest.php
@@ -2,20 +2,15 @@
namespace Nasqueron\Notifications\Tests;
-use Illuminate\Foundation\Testing\WithoutMiddleware;
-use Illuminate\Foundation\Testing\DatabaseMigrations;
-use Illuminate\Foundation\Testing\DatabaseTransactions;
-
-class StatusTest extends TestCase
-{
+class StatusTest extends TestCase {
/**
* Status works.
*
* @return void
+ * @doesNotPerformAssertions
*/
- public function testStatus()
- {
- $this->visit('/status')
- ->see('ALIVE');
+ public function testStatus() {
+ $this->visit( '/status' )
+ ->see( 'ALIVE' );
}
}
diff --git a/tests/Jobs/NotifyNewCommitsToDiffusionTest.php b/tests/Jobs/NotifyNewCommitsToDiffusionTest.php
--- a/tests/Jobs/NotifyNewCommitsToDiffusionTest.php
+++ b/tests/Jobs/NotifyNewCommitsToDiffusionTest.php
@@ -15,9 +15,9 @@
/**
* @dataProvider apiRepositoryReplyProvider
*/
- public function testHandle ($apiRepositoryReply, int $apiCallCounts) {
+ public function testHandle( ?array $apiRepositoryReply, int $apiCallCounts ) {
$this->mockPhabricatorAPI()
- ->shouldReceive('getForProject->call')
+ ->shouldReceive( 'getForProject->call' )
->andReturn(
// First API call: repository.query
$apiRepositoryReply,
@@ -25,15 +25,18 @@
// Second API call: diffusion.looksoon
null
)
- ->times($apiCallCounts); // 2 when repository.query is valid
+ ->times( $apiCallCounts ); // 2 when repository.query is valid
// 1 otherwise
$job = $this->mockJob();
$job->handle();
}
- public function testJobWhenThereIsNoPhabricatorInstanceForTheProject () {
- $job = $this->mockJob("not-existing-project");
+ /**
+ * @doesNotPerformAssertions
+ */
+ public function testJobWhenThereIsNoPhabricatorInstanceForTheProject() {
+ $job = $this->mockJob( "not-existing-project" );
$job->handle();
}
@@ -44,7 +47,7 @@
/**
* Mocks a job
*/
- protected function mockJob(string $project = "acme") : Job {
+ protected function mockJob( string $project = "acme" ): Job {
return new NotifyNewCommitsToDiffusion(
$project,
"ssh://acme/k2.git"
@@ -54,16 +57,17 @@
/**
* Provides API repository reply and associated API calls count
*/
- public function apiRepositoryReplyProvider () : array {
+ public function apiRepositoryReplyProvider(): array {
return [
// Regular behavior
- [[new class { public $callsign = "K2"; }], 2],
+ [ [ new class { public $callsign = "K2";
+ } ], 2 ],
// Phabricator doesn't know this repo
- [[], 1],
+ [ [], 1 ],
// Some error occurs and the API reply is null
- [null, 1],
+ [ null, 1 ],
];
}
diff --git a/tests/Notifications/DockerHubNotificationTest.php b/tests/Notifications/DockerHubNotificationTest.php
--- a/tests/Notifications/DockerHubNotificationTest.php
+++ b/tests/Notifications/DockerHubNotificationTest.php
@@ -2,12 +2,10 @@
namespace Nasqueron\Notifications\Tests\Notifications;
-use Nasqueron\Notifications\Notifications\DockerHubNotification;
-use Nasqueron\Notifications\Tests\TestCase;
-
use Keruald\Mailgun\Tests\WithMockHttpClient;
-
use Mockery;
+use Nasqueron\Notifications\Notifications\DockerHubNotification;
+use Nasqueron\Notifications\Tests\TestCase;
class DockerHubNotificationTest extends TestCase {
@@ -16,21 +14,21 @@
/**
* @return \Nasqueron\Notifications\Notifications\DockerHubNotification
*/
- protected function prepareNotification ($event) {
- $path = __DIR__ . '/../data/payloads/DockerHub' . ucfirst($event)
+ protected function prepareNotification( $event ) {
+ $path = __DIR__ . '/../data/payloads/DockerHub' . ucfirst( $event )
. 'Payload.json';
- $payload = json_decode(file_get_contents($path));
+ $payload = json_decode( file_get_contents( $path ) );
- return new DockerHubNotification("Acme", $event, $payload);
+ return new DockerHubNotification( "Acme", $event, $payload );
}
- public function testPropertiesForPush () {
- $notification = $this->prepareNotification("push");
+ public function testPropertiesForPush() {
+ $notification = $this->prepareNotification( "push" );
- $this->assertSame("DockerHub", $notification->service);
- $this->assertSame("Acme", $notification->project);
- $this->assertSame("docker", $notification->group);
- $this->assertSame("push", $notification->type);
+ $this->assertSame( "DockerHub", $notification->service );
+ $this->assertSame( "Acme", $notification->project );
+ $this->assertSame( "docker", $notification->group );
+ $this->assertSame( "push", $notification->type );
$this->assertSame(
"New image pushed to Docker Hub registry for svendowideit/testhook by trustedbuilder",
$notification->text
@@ -41,10 +39,10 @@
);
}
- public function testPropertiesForBuildFailure () {
+ public function testPropertiesForBuildFailure() {
$this->mockMailgunServiceProvider();
- $notification = $this->prepareNotification("buildFailure");
- $this->assertSame("buildFailure", $notification->type);
+ $notification = $this->prepareNotification( "buildFailure" );
+ $this->assertSame( "buildFailure", $notification->type );
$this->assertSame(
"Image build by Docker Hub registry failure for acme/foo",
@@ -63,18 +61,18 @@
/**
* Injects into our container a mock of MailgunMessageFactory
*/
- protected function mockMailgunServiceProvider () {
- $mock = Mockery::mock('Keruald\Mailgun\MailgunMessageFactory');
+ protected function mockMailgunServiceProvider() {
+ $mock = Mockery::mock( 'Keruald\Mailgun\MailgunMessageFactory' );
$payload = $this->mockMailgunResponse();
- $mock->shouldReceive('fetchMessageFromPayload')->once()->andReturn($payload);
- $this->app->instance('mailgun', $mock);
+ $mock->shouldReceive( 'fetchMessageFromPayload' )->once()->andReturn( $payload );
+ $this->app->instance( 'mailgun', $mock );
}
/**
* @return \stdClass
*/
- protected function mockMailgunResponse () {
- return json_decode($this->mockHttpClientResponseBody());
+ protected function mockMailgunResponse() {
+ return json_decode( $this->mockHttpClientResponseBody() );
}
}
diff --git a/tests/Notifications/JenkinsNotificationTest.php b/tests/Notifications/JenkinsNotificationTest.php
--- a/tests/Notifications/JenkinsNotificationTest.php
+++ b/tests/Notifications/JenkinsNotificationTest.php
@@ -16,9 +16,9 @@
*/
private $payload;
- public function prepareNotification ($payloadFile, $project = "Acme") {
+ public function prepareNotification( $payloadFile, $project = "Acme" ) {
$path = __DIR__ . '/../data/payloads/' . $payloadFile;
- $this->payload = json_decode(file_get_contents($path));
+ $this->payload = json_decode( file_get_contents( $path ) );
$this->notification = new JenkinsNotification(
$project,
@@ -26,14 +26,14 @@
);
}
- public function testProperties () {
- $this->prepareNotification('JenkinsPayload.json');
+ public function testProperties() {
+ $this->prepareNotification( 'JenkinsPayload.json' );
- $this->assertSame("Jenkins", $this->notification->service);
- $this->assertSame("Acme", $this->notification->project);
- $this->assertSame("ci", $this->notification->group);
- $this->assertSame($this->payload, $this->notification->rawContent);
- $this->assertSame("completed.success", $this->notification->type);
+ $this->assertSame( "Jenkins", $this->notification->service );
+ $this->assertSame( "Acme", $this->notification->project );
+ $this->assertSame( "ci", $this->notification->group );
+ $this->assertSame( $this->payload, $this->notification->rawContent );
+ $this->assertSame( "completed.success", $this->notification->type );
$this->assertSame(
"Jenkins job asgard has been completed: success",
$this->notification->text
@@ -44,23 +44,23 @@
);
}
- public function testPropertiesForIncompletePayload () {
- $this->prepareNotification('JenkinsStartedPayload.json');
+ public function testPropertiesForIncompletePayload() {
+ $this->prepareNotification( 'JenkinsStartedPayload.json' );
- $this->assertSame("started", $this->notification->type);
+ $this->assertSame( "started", $this->notification->type );
$this->assertSame(
"Jenkins job asgard has been started",
$this->notification->text
);
}
- public function testShouldNotifyOnDefaultConfiguration () {
- $this->prepareNotification('JenkinsPayload.json');
- $this->assertTrue($this->notification->shouldNotify());
+ public function testShouldNotifyOnDefaultConfiguration() {
+ $this->prepareNotification( 'JenkinsPayload.json' );
+ $this->assertTrue( $this->notification->shouldNotify() );
}
- public function testShouldNotifyWhenConfiguredNotTo () {
- $this->prepareNotification('JenkinsToIgnorePayload.json', 'Nasqueron');
- $this->assertFalse($this->notification->shouldNotify());
+ public function testShouldNotifyWhenConfiguredNotTo() {
+ $this->prepareNotification( 'JenkinsToIgnorePayload.json', 'Nasqueron' );
+ $this->assertFalse( $this->notification->shouldNotify() );
}
}
diff --git a/tests/Phabricator/PhabricatorAPIExceptionTest.php b/tests/Phabricator/PhabricatorAPIExceptionTest.php
--- a/tests/Phabricator/PhabricatorAPIExceptionTest.php
+++ b/tests/Phabricator/PhabricatorAPIExceptionTest.php
@@ -12,18 +12,18 @@
*/
private $exception;
- public function setUp () {
+ public function setUp(): void {
$this->exception = new PhabricatorAPIException(
100,
"Lorem ipsum dolor"
);
}
- public function testGetCode () {
- $this->assertSame(100, $this->exception->getCode());
+ public function testGetCode() {
+ $this->assertSame( 100, $this->exception->getCode() );
}
- public function testGetMessage () {
- $this->assertSame("Lorem ipsum dolor", $this->exception->getMessage());
+ public function testGetMessage() {
+ $this->assertSame( "Lorem ipsum dolor", $this->exception->getMessage() );
}
}
diff --git a/tests/Phabricator/PhabricatorAPIFactoryTest.php b/tests/Phabricator/PhabricatorAPIFactoryTest.php
--- a/tests/Phabricator/PhabricatorAPIFactoryTest.php
+++ b/tests/Phabricator/PhabricatorAPIFactoryTest.php
@@ -11,22 +11,22 @@
*/
private $factory;
- public function setUp () {
+ public function setUp(): void {
parent::setUp();
- $this->factory = $this->app->make('phabricator-api');
+ $this->factory = $this->app->make( 'phabricator-api' );
}
- public function testGetAPI () {
+ public function testGetAPI() {
$this->assertInstanceOf(
'\Nasqueron\Notifications\Phabricator\PhabricatorAPI',
- $this->factory->get("https://phabricator.acme.tld")
+ $this->factory->get( "https://phabricator.acme.tld" )
);
}
- public function testGetAPIForProject () {
+ public function testGetAPIForProject() {
$this->assertInstanceOf(
'\Nasqueron\Notifications\Phabricator\PhabricatorAPI',
- $this->factory->getForProject("Acme")
+ $this->factory->getForProject( "Acme" )
);
}
}
diff --git a/tests/Phabricator/PhabricatorAPITest.php b/tests/Phabricator/PhabricatorAPITest.php
--- a/tests/Phabricator/PhabricatorAPITest.php
+++ b/tests/Phabricator/PhabricatorAPITest.php
@@ -6,31 +6,27 @@
use Nasqueron\Notifications\Tests\TestCase;
class PhabricatorAPITest extends TestCase {
- public function testForInstance () {
+ public function testForInstance() {
$this->assertInstanceOf(
'\Nasqueron\Notifications\Phabricator\PhabricatorAPI',
- PhabricatorAPI::forInstance("https://phabricator.acme.tld")
+ PhabricatorAPI::forInstance( "https://phabricator.acme.tld" )
);
}
- public function testForProject () {
+ public function testForProject() {
$this->assertInstanceOf(
'\Nasqueron\Notifications\Phabricator\PhabricatorAPI',
- PhabricatorAPI::forInstance("https://phabricator.acme.tld")
+ PhabricatorAPI::forInstance( "https://phabricator.acme.tld" )
);
}
- /**
- * @expectedException \RuntimeException
- */
- public function testForInstanceWhere () {
- PhabricatorAPI::forInstance("https://notfound.acme.tld");
+ public function testForInstanceWhere() {
+ $this->expectException( \RuntimeException::class );
+ PhabricatorAPI::forInstance( "https://notfound.acme.tld" );
}
- /**
- * @expectedException \RuntimeException
- */
- public function testForProjectWhenProjectDoesNotExist () {
- PhabricatorAPI::forProject("NotFound");
+ public function testForProjectWhenProjectDoesNotExist() {
+ $this->expectException( \RuntimeException::class );
+ PhabricatorAPI::forProject( "NotFound" );
}
}
diff --git a/tests/Phabricator/PhabricatorStoryTest.php b/tests/Phabricator/PhabricatorStoryTest.php
--- a/tests/Phabricator/PhabricatorStoryTest.php
+++ b/tests/Phabricator/PhabricatorStoryTest.php
@@ -9,35 +9,35 @@
/**
* @dataProvider provideStories
*/
- public function testGetObjectType ($expected, $data) {
- $story = new PhabricatorStory('acme');
+ public function testGetObjectType( string $expected, ?array $data ) {
+ $story = new PhabricatorStory( 'acme' );
$story->data = $data;
- $this->assertEquals($expected, $story->getObjectType());
+ $this->assertEquals( $expected, $story->getObjectType() );
}
- public function provideStories () : iterable {
- yield ["VOID", null];
- yield ["VOID", []];
- yield ["VOID", ['foo' => 'bar']];
- yield ["TASK", ['objectPHID' => 'PHID-TASK-l34fw5wievp6n6rnvpuk']];
+ public function provideStories(): iterable {
+ yield [ "VOID", null ];
+ yield [ "VOID", [] ];
+ yield [ "VOID", [ 'foo' => 'bar' ] ];
+ yield [ "TASK", [ 'objectPHID' => 'PHID-TASK-l34fw5wievp6n6rnvpuk' ] ];
}
/**
* @dataProvider provideKeys
*/
- public function testMapPhabricatorFeedKey ($expected, $key) {
+ public function testMapPhabricatorFeedKey( string $expected, string $key ) {
$this->assertEquals(
$expected,
- PhabricatorStory::mapPhabricatorFeedKey($key)
+ PhabricatorStory::mapPhabricatorFeedKey( $key )
);
}
- public function provideKeys () : iterable {
- yield ['id', 'storyID'];
- yield ['id', 'storyId'];
- yield ['task', 'storyTask'];
- yield ['story', 'story'];
- yield ['', ''];
+ public function provideKeys(): iterable {
+ yield [ 'id', 'storyID' ];
+ yield [ 'id', 'storyId' ];
+ yield [ 'task', 'storyTask' ];
+ yield [ 'story', 'story' ];
+ yield [ '', '' ];
}
}
diff --git a/tests/Phabricator/ProjectsMapFactoryTest.php b/tests/Phabricator/ProjectsMapFactoryTest.php
--- a/tests/Phabricator/ProjectsMapFactoryTest.php
+++ b/tests/Phabricator/ProjectsMapFactoryTest.php
@@ -11,24 +11,24 @@
*/
private $factory;
- public function setUp () {
+ public function setUp(): void {
parent::setUp();
- $this->factory = $this->app->make('phabricator-projectsmap');
+ $this->factory = $this->app->make( 'phabricator-projectsmap' );
$this->mockPhabricatorAPIForProjectsMap();
}
- public function testLoadProjectsMap () {
+ public function testLoadProjectsMap() {
$this->assertInstanceOf(
'\Nasqueron\Notifications\Phabricator\ProjectsMap',
- $this->factory->load("Acme")
+ $this->factory->load( "Acme" )
);
}
- public function testFetchProjectsMap () {
+ public function testFetchProjectsMap() {
$this->assertInstanceOf(
'\Nasqueron\Notifications\Phabricator\ProjectsMap',
- $this->factory->fetch("Acme")
+ $this->factory->fetch( "Acme" )
);
}
diff --git a/tests/Phabricator/ProjectsMapTest.php b/tests/Phabricator/ProjectsMapTest.php
--- a/tests/Phabricator/ProjectsMapTest.php
+++ b/tests/Phabricator/ProjectsMapTest.php
@@ -6,8 +6,6 @@
use Nasqueron\Notifications\Phabricator\ProjectsMap;
use Nasqueron\Notifications\Tests\TestCase;
-use Mockery;
-
class ProjectsMapTest extends TestCase {
/**
@@ -15,7 +13,7 @@
*/
private $map;
- public function setUp () {
+ public function setUp(): void {
parent::setUp();
//
@@ -26,10 +24,10 @@
//
$this->mockPhabricatorAPIForProjectsMap();
- $this->map = ProjectsMap::fetch("http://phabricator.acme.tld");
+ $this->map = ProjectsMap::fetch( "http://phabricator.acme.tld" );
}
- public function testIteratorIsTraversable () {
+ public function testIteratorIsTraversable() {
$this->assertInstanceOf(
"Traversable",
$this->map->getIterator()
@@ -40,47 +38,45 @@
/// Tests for ArrayAccess
///
- public function testOffsetExistsWhenItDoes () {
+ public function testOffsetExistsWhenItDoes() {
$this->assertTrue(
- $this->map->offsetExists("PHID-PROJ-cztcgpvqr6smnnekotq7")
+ $this->map->offsetExists( "PHID-PROJ-cztcgpvqr6smnnekotq7" )
);
}
- public function testOffsetExistsWhenItDoesNot () {
+ public function testOffsetExistsWhenItDoesNot() {
$this->assertFalse(
- $this->map->offsetExists("non-existing-key")
+ $this->map->offsetExists( "non-existing-key" )
);
}
- public function testOffsetGetWhenItDoesExist () {
+ public function testOffsetGetWhenItDoesExist() {
$this->assertSame(
"Agora",
- $this->map->offsetGet("PHID-PROJ-cztcgpvqr6smnnekotq7")
+ $this->map->offsetGet( "PHID-PROJ-cztcgpvqr6smnnekotq7" )
);
}
- /**
- * @expectedException ErrorException
- */
- public function testOffsetGetWhenItDoesNotExist () {
- $this->map->offsetGet("non-existing-key");
+ public function testOffsetGetWhenItDoesNotExist() {
+ $this->expectException( \ErrorException::class );
+ $this->map->offsetGet( "non-existing-key" );
}
/**
* @covers Nasqueron\Notifications\Phabricator\ProjectsMap::offsetSet
*/
- public function testOffsetSet () {
- $this->map->offsetSet("newkey", "quux");
- $this->assertSame("quux", $this->map->offsetGet("newkey"));
+ public function testOffsetSet() {
+ $this->map->offsetSet( "newkey", "quux" );
+ $this->assertSame( "quux", $this->map->offsetGet( "newkey" ) );
}
/**
* @covers Nasqueron\Notifications\Phabricator\ProjectsMap::offsetUnset
*/
- public function testOffsetUnset () {
- unset($this->map["PHID-PROJ-cztcgpvqr6smnnekotq7"]);
+ public function testOffsetUnset() {
+ unset( $this->map["PHID-PROJ-cztcgpvqr6smnnekotq7"] );
$this->assertFalse(
- $this->map->offsetExists("PHID-PROJ-cztcgpvqr6smnnekotq7")
+ $this->map->offsetExists( "PHID-PROJ-cztcgpvqr6smnnekotq7" )
);
}
@@ -88,29 +84,29 @@
/// Tests for cache
///
- public function testCache () {
- $this->assertFalse($this->map->isCached());
+ public function testCache() {
+ $this->assertFalse( $this->map->isCached() );
$this->map->saveToCache();
- $this->assertTrue($this->map->isCached());
+ $this->assertTrue( $this->map->isCached() );
}
- public function testLoadFromCache () {
+ public function testLoadFromCache() {
$this->map->saveToCache();
- $map = new ProjectsMap("http://phabricator.acme.tld");
+ $map = new ProjectsMap( "http://phabricator.acme.tld" );
$map->loadFromCache();
$this->assertTrue(
- $map->offsetExists("PHID-PROJ-cztcgpvqr6smnnekotq7")
+ $map->offsetExists( "PHID-PROJ-cztcgpvqr6smnnekotq7" )
);
}
- public function testLoadWhenInCache () {
+ public function testLoadWhenInCache() {
$this->map->saveToCache();
- $map = ProjectsMap::load("http://phabricator.acme.tld");
+ $map = ProjectsMap::load( "http://phabricator.acme.tld" );
$this->assertTrue(
- $map->offsetExists("PHID-PROJ-cztcgpvqr6smnnekotq7")
+ $map->offsetExists( "PHID-PROJ-cztcgpvqr6smnnekotq7" )
);
}
@@ -118,47 +114,47 @@
/// Tests for helper methods
///
- public function testGetProjectName () {
+ public function testGetProjectName() {
$this->assertSame(
"Agora",
- $this->map->getProjectName("PHID-PROJ-cztcgpvqr6smnnekotq7")
+ $this->map->getProjectName( "PHID-PROJ-cztcgpvqr6smnnekotq7" )
);
}
- public function testGetProjectNameForNewInstance () {
- $map = new ProjectsMap("http://phabricator.acme.tld");
+ public function testGetProjectNameForNewInstance() {
+ $map = new ProjectsMap( "http://phabricator.acme.tld" );
$this->assertSame(
"Agora",
- $map->getProjectName("PHID-PROJ-cztcgpvqr6smnnekotq7")
+ $map->getProjectName( "PHID-PROJ-cztcgpvqr6smnnekotq7" )
);
}
- public function testGetProjectNameWhenItDoesNotExist () {
+ public function testGetProjectNameWhenItDoesNotExist() {
$this->assertSame(
"",
- $this->map->getProjectName("non-existing-key")
+ $this->map->getProjectName( "non-existing-key" )
);
}
- public function testToArrayProducesArray () {
+ public function testToArrayProducesArray() {
$array = $this->map->toArray();
$this->assertTrue(
- is_array($array),
+ is_array( $array ),
"Test if toArray return an array"
);
}
- public function testThatArrayCount () {
+ public function testThatArrayCount() {
$array = $this->map->toArray();
- $this->assertSame(3, count($array));
+ $this->assertCount( 3, $array );
}
- public function testThatArrayContainsExpectedData () {
+ public function testThatArrayContainsExpectedData() {
$this->assertSame(
[
- ["PHID-PROJ-6dg6ogx5pjmk24ur4tp4", "Accounts"],
- ["PHID-PROJ-cztcgpvqr6smnnekotq7", "Agora"],
- ["PHID-PROJ-3iew3cqf3htpazfyzb5a", "architecture"]
+ [ "PHID-PROJ-6dg6ogx5pjmk24ur4tp4", "Accounts" ],
+ [ "PHID-PROJ-cztcgpvqr6smnnekotq7", "Agora" ],
+ [ "PHID-PROJ-3iew3cqf3htpazfyzb5a", "architecture" ]
],
$this->map->toArray()
);
@@ -168,36 +164,33 @@
/// Tests API
///
- private function mockPhabricatorAPIWithReply ($reply) : APIClient {
- return (new class($reply) implements APIClient {
+ private function mockPhabricatorAPIWithReply( $reply ): APIClient {
+ return ( new class( $reply ) implements APIClient {
private $reply;
- public function __construct ($reply) {
+ public function __construct( $reply ) {
$this->reply = $reply;
}
- public function setEndPoint ($url) : void { }
+ public function setEndPoint( $url ): void {
+ }
- public function call ($method, $arguments = []) {
+ public function call( $method, $arguments = [] ) {
return $this->reply;
}
- });
+ } );
}
- /**
- * @expectedException Exception
- */
- public function testFetchFromAPIWithoutReply () {
- $mock = $this->mockPhabricatorAPIWithReply(false);
- ProjectsMap::fetch("http://phabricator.acme.tld", $mock);
+ public function testFetchFromAPIWithoutReply() {
+ $this->expectException( \Exception::class );
+ $mock = $this->mockPhabricatorAPIWithReply( false );
+ ProjectsMap::fetch( "http://phabricator.acme.tld", $mock );
}
- /**
- * @expectedException Exception
- */
- public function testFetchFromAPIInvalidReply () {
- $mock = $this->mockPhabricatorAPIWithReply(new \stdClass);
- ProjectsMap::fetch("http://phabricator.acme.tld", $mock);
+ public function testFetchFromAPIInvalidReply() {
+ $this->expectException( \Exception::class );
+ $mock = $this->mockPhabricatorAPIWithReply( new \stdClass );
+ ProjectsMap::fetch( "http://phabricator.acme.tld", $mock );
}
}
diff --git a/tests/Providers/AppServiceProviderTest.php b/tests/Providers/AppServiceProviderTest.php
--- a/tests/Providers/AppServiceProviderTest.php
+++ b/tests/Providers/AppServiceProviderTest.php
@@ -4,7 +4,7 @@
class AppServiceProviderTest extends TestCase {
- public function testType () {
+ public function testType() {
$this->assertServiceInstanceOf(
'Illuminate\Contracts\Foundation\Application',
'app'
diff --git a/tests/Providers/BrokerServiceProviderTest.php b/tests/Providers/BrokerServiceProviderTest.php
--- a/tests/Providers/BrokerServiceProviderTest.php
+++ b/tests/Providers/BrokerServiceProviderTest.php
@@ -4,7 +4,7 @@
class BrokerServiceProviderTest extends TestCase {
- public function testType () {
+ public function testType() {
$this->assertServiceInstanceOf(
'Keruald\Broker\Broker',
'broker'
diff --git a/tests/Providers/ConfigTest.php b/tests/Providers/ConfigTest.php
--- a/tests/Providers/ConfigTest.php
+++ b/tests/Providers/ConfigTest.php
@@ -20,19 +20,19 @@
*/
private $namespace;
- public function setUp () {
+ public function setUp(): void {
parent::setUp();
- $this->providers = Config::get('app.providers');
+ $this->providers = Config::get( 'app.providers' );
$this->namespace = $this->app->getInstance()->getNamespace()
. 'Providers\\';
}
- public function testOmittedFiles () {
- $files = File::allFiles(app_path('Providers'));
+ public function testOmittedFiles() {
+ $files = File::allFiles( app_path( 'Providers' ) );
- foreach ($files as $file) {
- $class = $this->namespace . $file->getBasename('.php');
+ foreach ( $files as $file ) {
+ $class = $this->namespace . $file->getBasename( '.php' );
$this->assertContains(
$class, $this->providers,
"The class $class should be added to config/app.php in the " .
diff --git a/tests/Providers/DockerHubServiceProviderTest.php b/tests/Providers/DockerHubServiceProviderTest.php
--- a/tests/Providers/DockerHubServiceProviderTest.php
+++ b/tests/Providers/DockerHubServiceProviderTest.php
@@ -2,33 +2,32 @@
namespace Nasqueron\Notifications\Tests\Providers;
-use Nasqueron\Notifications\Providers\DockerHubServiceProvider;
-
use Config;
+use Nasqueron\Notifications\Providers\DockerHubServiceProvider;
class DockerHubServiceProviderTest extends TestCase {
- public function testType () {
+ public function testType() {
$this->assertServiceInstanceOf(
'Keruald\DockerHub\Build\TriggerBuildFactory',
'dockerhub'
);
}
- public function testGetTokens () {
+ public function testGetTokens() {
$this->assertSame(
- ['acme/foo' => '0000'],
- DockerHubServiceProvider::getTokens($this->app),
+ [ 'acme/foo' => '0000' ],
+ DockerHubServiceProvider::getTokens( $this->app ),
"The service provider should deserialize DockerHubTokens.json."
);
}
- public function testGetTokensWhenFileDoesNotExist () {
- Config::set('services.dockerhub.tokens', 'notexisting.json');
+ public function testGetTokensWhenFileDoesNotExist() {
+ Config::set( 'services.dockerhub.tokens', 'notexisting.json' );
$this->assertSame(
[],
- DockerHubServiceProvider::getTokens($this->app),
+ DockerHubServiceProvider::getTokens( $this->app ),
"When no tokens file exists, an empty array is used instead."
);
}
diff --git a/tests/Providers/EventServiceProviderTest.php b/tests/Providers/EventServiceProviderTest.php
--- a/tests/Providers/EventServiceProviderTest.php
+++ b/tests/Providers/EventServiceProviderTest.php
@@ -7,7 +7,7 @@
class EventServiceProviderTest extends TestCase {
- public function testType () {
+ public function testType() {
$this->assertServiceInstanceOf(
'Illuminate\Contracts\Events\Dispatcher',
'events'
@@ -18,22 +18,23 @@
/// Tests specific to this service provider
///
- public function testOmittedFiles () {
+ public function testOmittedFiles() {
$subscribe = [];
$namespace = $this->app->getInstance()->getNamespace() . 'Listeners\\';
- $files = File::allFiles(app_path('Listeners'));
- foreach ($files as $file) {
- $class = $namespace . $file->getBasename('.php');
+ $files = File::allFiles( app_path( 'Listeners' ) );
+ foreach ( $files as $file ) {
+ $class = $namespace . $file->getBasename( '.php' );
$subscribe[] = $class;
}
$this->assertEquals(
- $subscribe, Config::get('app.listeners'),
+ $subscribe, Config::get( 'app.listeners' ),
'The files in the app/Listeners folder and the array of classes ' .
- 'defined in config/app.php at listeners key diverge.',
- 0.0, 10, true // delta, maxDepth, canonicalize
+ 'defined in config/app.php at listeners key diverge.' // delta, maxDepth, canonicalize
);
+ $this->assertEqualsCanonicalizing( $subscribe, Config::get( 'app.listeners' ), 'The files in the app/Listeners folder and the array of classes ' .
+ 'defined in config/app.php at listeners key diverge.' );
}
}
diff --git a/tests/Providers/MailgunServiceProviderTest.php b/tests/Providers/MailgunServiceProviderTest.php
--- a/tests/Providers/MailgunServiceProviderTest.php
+++ b/tests/Providers/MailgunServiceProviderTest.php
@@ -4,7 +4,7 @@
class MailgunServiceProviderTest extends TestCase {
- public function testType () {
+ public function testType() {
$this->assertServiceInstanceOf(
'Keruald\Mailgun\MailgunMessageFactory',
'mailgun'
diff --git a/tests/Providers/PhabricatorAPIServiceProviderTest.php b/tests/Providers/PhabricatorAPIServiceProviderTest.php
--- a/tests/Providers/PhabricatorAPIServiceProviderTest.php
+++ b/tests/Providers/PhabricatorAPIServiceProviderTest.php
@@ -4,7 +4,7 @@
class PhabricatorAPIServiceProviderTest extends TestCase {
- public function testType () {
+ public function testType() {
$this->assertServiceInstanceOf(
'Nasqueron\Notifications\Phabricator\PhabricatorAPIFactory',
'phabricator-api'
diff --git a/tests/Providers/PhabricatorProjectsMapServiceProviderTest.php b/tests/Providers/PhabricatorProjectsMapServiceProviderTest.php
--- a/tests/Providers/PhabricatorProjectsMapServiceProviderTest.php
+++ b/tests/Providers/PhabricatorProjectsMapServiceProviderTest.php
@@ -4,7 +4,7 @@
class PhabricatorProjectsMapServiceProviderTest extends TestCase {
- public function testType () {
+ public function testType() {
$this->assertServiceInstanceOf(
'Nasqueron\Notifications\Phabricator\ProjectsMapFactory',
'phabricator-projectsmap'
diff --git a/tests/Providers/ReportServiceProviderTest.php b/tests/Providers/ReportServiceProviderTest.php
--- a/tests/Providers/ReportServiceProviderTest.php
+++ b/tests/Providers/ReportServiceProviderTest.php
@@ -4,7 +4,7 @@
class ReportServiceProviderTest extends TestCase {
- public function testType () {
+ public function testType() {
$this->assertServiceInstanceOf(
'Nasqueron\Notifications\Actions\ActionsReport',
'report'
@@ -15,16 +15,16 @@
/// Tests specific to this service provider
///
- public function testEvents () {
- $dispatcher = $this->app->make('events');
+ public function testEvents() {
+ $dispatcher = $this->app->make( 'events' );
$type = 'Nasqueron\Notifications\Events\ReportEvent';
// Currently, we don't have listener for ReportEvent.
- $this->assertFalse($dispatcher->hasListeners($type));
+ $this->assertFalse( $dispatcher->hasListeners( $type ) );
// When we resolve an instance of our object in the container, we have.
- $this->app->make('report');
- $this->assertTrue($dispatcher->hasListeners($type));
+ $this->app->make( 'report' );
+ $this->assertTrue( $dispatcher->hasListeners( $type ) );
}
}
diff --git a/tests/Providers/RouteServiceProviderTest..php b/tests/Providers/RouteServiceProviderTest.php
rename from tests/Providers/RouteServiceProviderTest..php
rename to tests/Providers/RouteServiceProviderTest.php
--- a/tests/Providers/RouteServiceProviderTest..php
+++ b/tests/Providers/RouteServiceProviderTest.php
@@ -2,9 +2,9 @@
namespace Nasqueron\Notifications\Tests\Providers;
-class BrokerServiceProviderTest extends TestCase {
+class RouteServiceProviderTest extends TestCase {
- public function testType () {
+ public function testType() {
$this->assertServiceInstanceOf(
'Illuminate\Routing\Router',
'router'
diff --git a/tests/Providers/SentryServiceProviderTest.php b/tests/Providers/SentryServiceProviderTest.php
--- a/tests/Providers/SentryServiceProviderTest.php
+++ b/tests/Providers/SentryServiceProviderTest.php
@@ -4,7 +4,7 @@
class SentryServiceProviderTest extends TestCase {
- public function testType () {
+ public function testType() {
$this->assertServiceInstanceOf(
'Raven_Client',
'raven'
diff --git a/tests/Providers/ServicesServiceProviderTest.php b/tests/Providers/ServicesServiceProviderTest.php
--- a/tests/Providers/ServicesServiceProviderTest.php
+++ b/tests/Providers/ServicesServiceProviderTest.php
@@ -2,13 +2,11 @@
namespace Nasqueron\Notifications\Tests\Providers;
-use Nasqueron\Notifications\Providers\ServicesServiceProvider;
-
use Config;
class ServicesServiceProviderTest extends TestCase {
- public function testType () {
+ public function testType() {
$this->assertServiceInstanceOf(
"Nasqueron\Notifications\Config\Services\Services",
'services'
@@ -19,23 +17,23 @@
/// Tests specific to this service provider
///
- public function testWithCredentialsFile () {
- $services = $this->app->make('services');
+ public function testWithCredentialsFile() {
+ $services = $this->app->make( 'services' );
- $this->assertGreaterThan(0, count($services->services));
+ $this->assertGreaterThan( 0, count( $services->services ) );
}
- public function testWithoutCredentialsFile () {
- Config::set('services.gate.credentials', null);
- $services = $this->app->make('services');
+ public function testWithoutCredentialsFile() {
+ Config::set( 'services.gate.credentials', null );
+ $services = $this->app->make( 'services' );
- $this->assertSame(0, count($services->services));
+ $this->assertCount( 0, $services->services );
}
- public function testWithNontFoundCredentialsFile () {
- Config::set('services.gate.credentials', 'notfound.json');
- $services = $this->app->make('services');
+ public function testWithNontFoundCredentialsFile() {
+ Config::set( 'services.gate.credentials', 'notfound.json' );
+ $services = $this->app->make( 'services' );
- $this->assertSame(0, count($services->services));
+ $this->assertCount( 0, $services->services );
}
}
diff --git a/tests/Providers/TestCase.php b/tests/Providers/TestCase.php
--- a/tests/Providers/TestCase.php
+++ b/tests/Providers/TestCase.php
@@ -12,9 +12,9 @@
* @param $expectedType The type to check
* @param $serviceName The service name to use as application container key
*/
- public function assertServiceInstanceOf ($expectedType, $serviceName) {
- $service = $this->app->make($serviceName);
- $this->assertInstanceOf($expectedType, $service);
+ public function assertServiceInstanceOf( $expectedType, $serviceName ) {
+ $service = $this->app->make( $serviceName );
+ $this->assertInstanceOf( $expectedType, $service );
}
}
diff --git a/tests/TestCase.php b/tests/TestCase.php
--- a/tests/TestCase.php
+++ b/tests/TestCase.php
@@ -2,16 +2,12 @@
namespace Nasqueron\Notifications\Tests;
-use Nasqueron\Notifications\Config\Services\Service;
-
use Illuminate\Contracts\Console\Kernel;
use Keruald\Broker\BlackholeBroker;
-use Keruald\Broker\Broker;
-
use Mockery;
+use Nasqueron\Notifications\Config\Services\Service;
-class TestCase extends \Illuminate\Foundation\Testing\TestCase
-{
+class TestCase extends \Illuminate\Foundation\Testing\TestCase {
/**
* The base URL to use while testing the application.
*
@@ -24,11 +20,10 @@
*
* @return \Illuminate\Foundation\Application
*/
- public function createApplication()
- {
- $app = require __DIR__.'/../bootstrap/app.php';
+ public function createApplication() {
+ $app = require __DIR__ . '/../bootstrap/app.php';
- $app->make(Kernel::class)->bootstrap();
+ $app->make( Kernel::class )->bootstrap();
return $app;
}
@@ -40,36 +35,36 @@
/**
* Mocks the events dispatcher
*/
- public function disableEvents () {
+ public function disableEvents() {
// Disables events
// This allows to test a single component and not all the application
- $mock = Mockery::mock('Illuminate\Contracts\Events\Dispatcher');
+ $mock = Mockery::mock( 'Illuminate\Contracts\Events\Dispatcher' );
- $mock->shouldReceive('fire');
- $mock->shouldReceive('listen');
+ $mock->shouldReceive( 'fire' );
+ $mock->shouldReceive( 'listen' );
- $this->app->instance('events', $mock);
+ $this->app->instance( 'events', $mock );
}
/**
* Mocks the broker
*/
- public function disableBroker () {
+ public function disableBroker() {
$broker = new BlackholeBroker();
$broker->acceptAllMethodCalls(); // allows to be used as a mock
- $this->app->instance('broker', $broker);
+ $this->app->instance( 'broker', $broker );
}
/**
* Mocks the broker, throwing an exception when sendMessage is called.
*/
- public function mockNotOperationalBroker () {
- $mock = Mockery::mock('Keruald\Broker\Broker');
- $mock->shouldReceive('connect');
- $mock->shouldReceive('setExchangeTarget->routeTo->sendMessage')
- ->andThrow(new \RuntimeException);
+ public function mockNotOperationalBroker() {
+ $mock = Mockery::mock( 'Keruald\Broker\Broker' );
+ $mock->shouldReceive( 'connect' );
+ $mock->shouldReceive( 'setExchangeTarget->routeTo->sendMessage' )
+ ->andThrow( new \RuntimeException );
- $this->app->instance('broker', $mock);
+ $this->app->instance( 'broker', $mock );
}
/**
@@ -77,42 +72,42 @@
*
* @return \Nasqueron\Notifications\Phabricator\PhabricatorAPIFactory The mock
*/
- protected function mockPhabricatorAPI () {
+ protected function mockPhabricatorAPI() {
// Inject into our container a mock of PhabricatorAPI
- $mock = Mockery::mock('Nasqueron\Notifications\Phabricator\PhabricatorAPIFactory');
- $this->app->instance('phabricator-api', $mock);
+ $mock = Mockery::mock( 'Nasqueron\Notifications\Phabricator\PhabricatorAPIFactory' );
+ $this->app->instance( 'phabricator-api', $mock );
return $mock;
}
- private function mockPhabricatorAPIProjectsQueryReply () {
- $json = file_get_contents('tests/data/PhabricatorProjetsQueryReply.json');
- return json_decode($json);
+ private function mockPhabricatorAPIProjectsQueryReply() {
+ $json = file_get_contents( 'tests/data/PhabricatorProjetsQueryReply.json' );
+ return json_decode( $json );
}
/**
* Mocks the Phabricator API
*/
- protected function mockPhabricatorAPIForProjectsMap () {
+ protected function mockPhabricatorAPIForProjectsMap() {
$mock = $this->mockPhabricatorAPI();
$reply = $this->mockPhabricatorAPIProjectsQueryReply();
- $mock->shouldReceive('getForProject->call')->andReturn($reply);
+ $mock->shouldReceive( 'getForProject->call' )->andReturn( $reply );
}
///
/// Helper methods to mock services
///
- protected function mockServices () {
+ protected function mockServices() {
// Inject into our container a mock of Services
- $mock = Mockery::mock('Nasqueron\Notifications\Config\Services\Services');
- $this->app->instance('services', $mock);
+ $mock = Mockery::mock( 'Nasqueron\Notifications\Config\Services\Services' );
+ $this->app->instance( 'services', $mock );
return $mock;
}
- protected function mockService ($gate = 'Storm') {
+ protected function mockService( $gate = 'Storm' ) {
$service = new Service;
$service->gate = $gate;
$service->door = 'Acme';
@@ -128,37 +123,30 @@
/**
* Visits the given URI with a JSON request.
*
- * @param string $uri
- * @param mixed $data
- * @param string $method
- * @param array $headers
+ * @param mixed $data
* @return $this
*/
- public function sendJsonPayload ($uri, $data, $method = 'POST', array $headers = []) {
- $content = json_encode($data);
- $headers = array_merge([
+ public function sendJsonPayload( string $uri, $data, string $method = 'POST', array $headers = [] ) {
+ $content = json_encode( $data );
+ $headers = array_merge( [
'CONTENT_TYPE' => 'application/json',
'Accept' => 'application/json',
- ], $headers);
- return $this->sendPayload($uri, $content, $method, $headers);
+ ], $headers );
+ return $this->sendPayload( $uri, $content, $method, $headers );
}
/**
* Visits the given URI with a raw request.
*
- * @param string $uri
- * @param string $content
- * @param string $method
- * @param array $headers
* @return $this
*/
- public function sendPayload ($uri, $content, $method = 'POST', array $headers = []) {
- $headers = array_merge([
- 'CONTENT_LENGTH' => mb_strlen($content, '8bit'),
- ], $headers);
+ public function sendPayload( string $uri, string $content, string $method = 'POST', array $headers = [] ) {
+ $headers = array_merge( [
+ 'CONTENT_LENGTH' => mb_strlen( $content, '8bit' ),
+ ], $headers );
$this->call(
- $method, $uri, [], [], [], $this->transformHeadersToServerVars($headers), $content
+ $method, $uri, [], [], [], $this->transformHeadersToServerVars( $headers ), $content
);
return $this;

File Metadata

Mime Type
text/plain
Expires
Tue, Nov 19, 12:38 (22 h, 9 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2252491
Default Alt Text
D2674.id6766.diff (356 KB)

Event Timeline