Skip to content

Commit

Permalink
Add new exception and update interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
Andreas Frömer committed Feb 3, 2022
1 parent 1b256e7 commit d2caa71
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 0 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@

## [Unreleased] - TBA
### Added
### Changed
### Removed

## [0.2.0] - TBA
### Added
- Added `LinkInterface::getLineNumber(): int`
- Added `PackageInterface::getRequire(string $name): LinkInterface`
- Added `ContractsExceptionInterface`
- Added `LinkNotFoundException`
### Changed
### Removed

## [0.1.0]
### Added
- Added `LinkInterface`
- Added `PackageInterface`
- Added `RepositoryInterface`
Expand Down
11 changes: 11 additions & 0 deletions src/Exception/ContractsExceptionInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

declare(strict_types=1);

namespace ComposerUnused\Contracts\Exception;

use Throwable;

interface ContractsExceptionInterface extends Throwable
{
}
15 changes: 15 additions & 0 deletions src/Exception/LinkNotFoundException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

declare(strict_types=1);

namespace ComposerUnused\Contracts\Exception;

use RuntimeException;

final class LinkNotFoundException extends RuntimeException implements ContractsExceptionInterface
{
public static function fromMissingLink(string $name): self
{
return new self(sprintf('Link with name "%s" is not required', $name));
}
}
5 changes: 5 additions & 0 deletions src/LinkInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,9 @@
interface LinkInterface
{
public function getTarget(): string;

/**
* Returns the line number of the target from composer.json
*/
public function getLineNumber(): int;
}
7 changes: 7 additions & 0 deletions src/PackageInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

namespace ComposerUnused\Contracts;

use ComposerUnused\Contracts\Exception\LinkNotFoundException;

interface PackageInterface
{
/**
Expand All @@ -22,4 +24,9 @@ public function getRequires(): array;
* @return array<string>
*/
public function getSuggests(): array;

/**
* @throws LinkNotFoundException
*/
public function getRequire(string $name): LinkInterface;
}

0 comments on commit d2caa71

Please sign in to comment.