Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
3 / 3 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
| Funding | |
100.00% |
3 / 3 |
|
100.00% |
3 / 3 |
3 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getType | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getUrl | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | /** |
| 6 | * Fast Forward Development Tools for PHP projects. |
| 7 | * |
| 8 | * This file is part of fast-forward/dev-tools project. |
| 9 | * |
| 10 | * @author Felipe Sayão Lobato Abreu <github@mentordosnerds.com> |
| 11 | * @license https://opensource.org/licenses/MIT MIT License |
| 12 | * |
| 13 | * @see https://github.com/php-fast-forward/ |
| 14 | * @see https://github.com/php-fast-forward/dev-tools |
| 15 | * @see https://github.com/php-fast-forward/dev-tools/issues |
| 16 | * @see https://php-fast-forward.github.io/dev-tools/ |
| 17 | * @see https://datatracker.ietf.org/doc/html/rfc2119 |
| 18 | */ |
| 19 | |
| 20 | namespace FastForward\DevTools\Composer\Json\Schema; |
| 21 | |
| 22 | /** |
| 23 | * Represents a single funding entry from the optional "funding" section of a |
| 24 | * composer.json file. |
| 25 | * |
| 26 | * A funding entry identifies a funding platform or mechanism and the URL through |
| 27 | * which users MAY financially support package maintenance and future development. |
| 28 | * |
| 29 | * This class is an immutable value object. All promoted properties are assigned |
| 30 | * at construction time and MUST NOT be modified afterward. |
| 31 | * |
| 32 | * The type property SHOULD contain a meaningful funding platform identifier such |
| 33 | * as "patreon", "opencollective", "tidelift", "github", or "other". |
| 34 | * |
| 35 | * The url property MUST contain the funding destination URL and SHOULD be a |
| 36 | * fully qualified URL. |
| 37 | */ |
| 38 | class Funding implements FundingInterface |
| 39 | { |
| 40 | /** |
| 41 | * Constructs a new funding entry. |
| 42 | * |
| 43 | * The provided values SHALL be stored exactly as received. |
| 44 | * |
| 45 | * @param string $type the funding platform or mechanism identifier |
| 46 | * @param string $url the URL that provides funding details and support options |
| 47 | */ |
| 48 | public function __construct( |
| 49 | private string $type, |
| 50 | private string $url, |
| 51 | ) {} |
| 52 | |
| 53 | /** |
| 54 | * Retrieves the funding type. |
| 55 | * |
| 56 | * This method MUST return the funding platform or mechanism identifier |
| 57 | * associated with this entry. |
| 58 | * |
| 59 | * @return string the funding type identifier |
| 60 | */ |
| 61 | public function getType(): string |
| 62 | { |
| 63 | return $this->type; |
| 64 | } |
| 65 | |
| 66 | /** |
| 67 | * Retrieves the funding URL. |
| 68 | * |
| 69 | * This method MUST return the URL that provides funding details and a way |
| 70 | * to financially support the package. |
| 71 | * |
| 72 | * @return string the funding URL |
| 73 | */ |
| 74 | public function getUrl(): string |
| 75 | { |
| 76 | return $this->url; |
| 77 | } |
| 78 | } |