Skip to content

Commit d2caa71

Browse files
author
Andreas Frömer
committed
Add new exception and update interfaces
1 parent 1b256e7 commit d2caa71

File tree

5 files changed

+52
-0
lines changed

5 files changed

+52
-0
lines changed

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,20 @@
22

33
## [Unreleased] - TBA
44
### Added
5+
### Changed
6+
### Removed
7+
8+
## [0.2.0] - TBA
9+
### Added
10+
- Added `LinkInterface::getLineNumber(): int`
11+
- Added `PackageInterface::getRequire(string $name): LinkInterface`
12+
- Added `ContractsExceptionInterface`
13+
- Added `LinkNotFoundException`
14+
### Changed
15+
### Removed
16+
17+
## [0.1.0]
18+
### Added
519
- Added `LinkInterface`
620
- Added `PackageInterface`
721
- Added `RepositoryInterface`
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace ComposerUnused\Contracts\Exception;
6+
7+
use Throwable;
8+
9+
interface ContractsExceptionInterface extends Throwable
10+
{
11+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace ComposerUnused\Contracts\Exception;
6+
7+
use RuntimeException;
8+
9+
final class LinkNotFoundException extends RuntimeException implements ContractsExceptionInterface
10+
{
11+
public static function fromMissingLink(string $name): self
12+
{
13+
return new self(sprintf('Link with name "%s" is not required', $name));
14+
}
15+
}

src/LinkInterface.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,9 @@
77
interface LinkInterface
88
{
99
public function getTarget(): string;
10+
11+
/**
12+
* Returns the line number of the target from composer.json
13+
*/
14+
public function getLineNumber(): int;
1015
}

src/PackageInterface.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
namespace ComposerUnused\Contracts;
66

7+
use ComposerUnused\Contracts\Exception\LinkNotFoundException;
8+
79
interface PackageInterface
810
{
911
/**
@@ -22,4 +24,9 @@ public function getRequires(): array;
2224
* @return array<string>
2325
*/
2426
public function getSuggests(): array;
27+
28+
/**
29+
* @throws LinkNotFoundException
30+
*/
31+
public function getRequire(string $name): LinkInterface;
2532
}

0 commit comments

Comments
 (0)