Verified Commit dfdb0a3e authored by Elias Häußler's avatar Elias Häußler 🐛
Browse files

[TASK] Move `getIdentifier()` method to ServiceInterface

parent 272c2903
Pipeline #777 passed with stages
in 2 minutes and 47 seconds
......@@ -66,8 +66,6 @@ abstract class AbstractService implements ServiceInterface
return is_array($extra) && (bool) ($extra['enable'] ?? false);
}
abstract protected static function getIdentifier(): string;
abstract protected static function getName(): string;
public function report(UpdateCheckResult $result): bool
......
......@@ -67,6 +67,16 @@ class Email extends AbstractService
$this->validateSender();
}
public static function getIdentifier(): string
{
return 'email';
}
protected static function getName(): string
{
return 'E-mail';
}
public static function fromConfiguration(array $configuration): ServiceInterface
{
$extra = $configuration['email'] ?? null;
......@@ -101,16 +111,6 @@ class Email extends AbstractService
return new self($dsn, array_map('trim', array_filter($receivers)), $sender);
}
protected static function getIdentifier(): string
{
return 'email';
}
protected static function getName(): string
{
return 'E-mail';
}
/**
* {@inheritDoc}
*
......
......@@ -64,6 +64,16 @@ class GitLab extends AbstractService
$this->validateAuthorizationKey();
}
public static function getIdentifier(): string
{
return 'gitlab';
}
protected static function getName(): string
{
return 'GitLab';
}
public static function fromConfiguration(array $configuration): ServiceInterface
{
$extra = $configuration['gitlab'] ?? null;
......@@ -89,16 +99,6 @@ class GitLab extends AbstractService
return new self($uri, $authKey);
}
protected static function getIdentifier(): string
{
return 'gitlab';
}
protected static function getName(): string
{
return 'GitLab';
}
/**
* {@inheritDoc}
*
......
......@@ -70,6 +70,16 @@ class Mattermost extends AbstractService
$this->validateChannelName();
}
public static function getIdentifier(): string
{
return 'mattermost';
}
protected static function getName(): string
{
return 'Mattermost';
}
public static function fromConfiguration(array $configuration): ServiceInterface
{
$extra = $configuration['mattermost'] ?? null;
......@@ -103,16 +113,6 @@ class Mattermost extends AbstractService
return new self($uri, $channelName, $username);
}
protected static function getIdentifier(): string
{
return 'mattermost';
}
protected static function getName(): string
{
return 'Mattermost';
}
/**
* {@inheritDoc}
*
......
......@@ -35,6 +35,8 @@ use EliasHaeussler\ComposerUpdateCheck\Package\UpdateCheckResult;
*/
interface ServiceInterface
{
public static function getIdentifier(): string;
/**
* @param array<string, mixed> $configuration
*/
......
......@@ -57,6 +57,16 @@ class Slack extends AbstractService
$this->validateUri();
}
public static function getIdentifier(): string
{
return 'slack';
}
protected static function getName(): string
{
return 'Slack';
}
public static function fromConfiguration(array $configuration): ServiceInterface
{
$extra = $configuration['slack'] ?? null;
......@@ -73,16 +83,6 @@ class Slack extends AbstractService
return new self($uri);
}
protected static function getIdentifier(): string
{
return 'slack';
}
protected static function getName(): string
{
return 'Slack';
}
/**
* {@inheritDoc}
*
......
......@@ -57,6 +57,16 @@ class Teams extends AbstractService
$this->validateUri();
}
public static function getIdentifier(): string
{
return 'teams';
}
protected static function getName(): string
{
return 'MS Teams';
}
public static function fromConfiguration(array $configuration): ServiceInterface
{
$extra = $configuration['teams'] ?? null;
......@@ -73,16 +83,6 @@ class Teams extends AbstractService
return new self($uri);
}
protected static function getIdentifier(): string
{
return 'teams';
}
protected static function getName(): string
{
return 'MS Teams';
}
/**
* {@inheritDoc}
*
......
......@@ -62,6 +62,16 @@ class DummyService extends AbstractService
*/
public static $customOptions;
public static function getIdentifier(): string
{
return 'dummy';
}
protected static function getName(): string
{
return 'Dummy';
}
public static function fromConfiguration(array $configuration): ServiceInterface
{
return new self();
......@@ -126,14 +136,4 @@ class DummyService extends AbstractService
{
return $this->options;
}
protected static function getIdentifier(): string
{
return 'dummy';
}
protected static function getName(): string
{
return 'Dummy';
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment