Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Introduce a RequirementType enum #1112

Merged
merged 1 commit into from
Oct 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/RequirementChecker/Requirement.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
final class Requirement
{
public function __construct(
private readonly string $type,
private readonly RequirementType $type,
private readonly string $condition,
private readonly string $message,
private readonly string $helpMessage,
Expand All @@ -30,7 +30,7 @@ public function __construct(
public static function forPHP(string $requiredPhpVersion, ?string $packageName): self
{
return new self(
'php',
RequirementType::PHP,
$requiredPhpVersion,
null === $packageName
? sprintf(
Expand Down Expand Up @@ -58,7 +58,7 @@ public static function forPHP(string $requiredPhpVersion, ?string $packageName):
public static function forRequiredExtension(string $extension, ?string $packageName): self
{
return new self(
'extension',
RequirementType::EXTENSION,
$extension,
null === $packageName
? sprintf(
Expand Down Expand Up @@ -86,7 +86,7 @@ public static function forRequiredExtension(string $extension, ?string $packageN
public static function forConflictingExtension(string $extension, ?string $packageName): self
{
return new self(
'extension-conflict',
RequirementType::EXTENSION_CONFLICT,
$extension,
null === $packageName
? sprintf(
Expand Down Expand Up @@ -114,7 +114,7 @@ public static function forConflictingExtension(string $extension, ?string $packa
public function toArray(): array
{
return [
'type' => $this->type,
'type' => $this->type->value,
'condition' => $this->condition,
'message' => $this->message,
'helpMessage' => $this->helpMessage,
Expand Down
22 changes: 22 additions & 0 deletions src/RequirementChecker/RequirementType.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

declare(strict_types=1);

/*
* This file is part of the box project.
*
* (c) Kevin Herrera <[email protected]>
* Théo Fidry <[email protected]>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/

namespace KevinGH\Box\RequirementChecker;

enum RequirementType: string
{
case PHP = 'php';
case EXTENSION = 'extension';
case EXTENSION_CONFLICT = 'extension-conflict';
}
Loading