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

Rework contracts to be compatible with spatie/ignition #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"require-dev": {
"friendsofphp/php-cs-fixer": "^v2.15.8",
"phpunit/phpunit": "^9.3.11",
"spatie/ignition": "^0.0.6",
"vimeo/psalm": "^3.17.1"
},
"autoload": {
Expand Down
51 changes: 1 addition & 50 deletions src/BaseSolution.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,55 +2,6 @@

namespace Facade\IgnitionContracts;

class BaseSolution implements Solution
class BaseSolution extends \Spatie\Ignition\Contracts\BaseSolution implements Solution
{
protected $title;
protected $description;
protected $links = [];

public static function create(string $title)
{
return new static($title);
}

public function __construct(string $title)
{
$this->title = $title;
}

public function getSolutionTitle(): string
{
return $this->title;
}

public function setSolutionTitle(string $title): self
{
$this->title = $title;

return $this;
}

public function getSolutionDescription(): string
{
return $this->description;
}

public function setSolutionDescription(string $description): self
{
$this->description = $description;

return $this;
}

public function getDocumentationLinks(): array
{
return $this->links;
}

public function setDocumentationLinks(array $links): self
{
$this->links = $links;

return $this;
}
}
8 changes: 1 addition & 7 deletions src/HasSolutionsForThrowable.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@

namespace Facade\IgnitionContracts;

use Throwable;

interface HasSolutionsForThrowable
interface HasSolutionsForThrowable extends \Spatie\Ignition\Contracts\HasSolutionsForThrowable
{
public function canSolve(Throwable $throwable): bool;

/** \Facade\IgnitionContracts\Solution[] */
public function getSolutions(Throwable $throwable): array;
}
3 changes: 1 addition & 2 deletions src/ProvidesSolution.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Facade\IgnitionContracts;

interface ProvidesSolution
interface ProvidesSolution extends \Spatie\Ignition\Contracts\ProvidesSolution
{
public function getSolution(): Solution;
}
9 changes: 1 addition & 8 deletions src/RunnableSolution.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,6 @@

namespace Facade\IgnitionContracts;

interface RunnableSolution extends Solution
interface RunnableSolution extends \Spatie\Ignition\Contracts\RunnableSolution, Solution
{
public function getSolutionActionDescription(): string;

public function getRunButtonText(): string;

public function run(array $parameters = []);

public function getRunParameters(): array;
}
7 changes: 1 addition & 6 deletions src/Solution.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@

namespace Facade\IgnitionContracts;

interface Solution
interface Solution extends \Spatie\Ignition\Contracts\Solution
{
public function getSolutionTitle(): string;

public function getSolutionDescription(): string;

public function getDocumentationLinks(): array;
}
15 changes: 1 addition & 14 deletions src/SolutionProviderRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,6 @@

namespace Facade\IgnitionContracts;

use Throwable;

interface SolutionProviderRepository
interface SolutionProviderRepository extends \Spatie\Ignition\Contracts\SolutionProviderRepository
{
public function registerSolutionProvider(string $solutionProviderClass): self;

public function registerSolutionProviders(array $solutionProviderClasses): self;

/**
* @param Throwable $throwable
* @return \Facade\IgnitionContracts\Solution[]
*/
public function getSolutionsForThrowable(Throwable $throwable): array;

public function getSolutionForClass(string $solutionClass): ?Solution;
}
8 changes: 7 additions & 1 deletion tests/SolutionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,21 @@
namespace Facade\IgnitionContracts\Tests;

use Facade\IgnitionContracts\BaseSolution;
use Facade\IgnitionContracts\Solution;
use PHPUnit\Framework\TestCase;

class SolutionTest extends TestCase
{
/** @test */
public function it_can_instanciate_a_base_solution()
public function it_can_instantiate_a_base_solution()
{
$solution = BaseSolution::create('my title');

$this->assertInstanceOf(BaseSolution::class, $solution);
$this->assertInstanceOf(Solution::class, $solution);

// Make sure these old contracts still work for the new spatie/ignition.
$this->assertInstanceOf(\Spatie\Ignition\Contracts\BaseSolution::class, $solution);
$this->assertInstanceOf(\Spatie\Ignition\Contracts\Solution::class, $solution);
}
}