| Total Complexity | 5 |
| Total Lines | 65 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 10 | class ImageName |
||
| 11 | { |
||
| 12 | /** |
||
| 13 | * @var string |
||
| 14 | */ |
||
| 15 | private $name; |
||
| 16 | |||
| 17 | /** |
||
| 18 | * validate image name |
||
| 19 | * |
||
| 20 | * Is a Docker image name (optionally with a tag or digest) |
||
| 21 | * syntactically valid? |
||
| 22 | * |
||
| 23 | * @see doc/DOCKER-NAME-TAG.md |
||
| 24 | * |
||
| 25 | * @param string $name of docker image |
||
| 26 | * |
||
| 27 | * @return bool |
||
| 28 | */ |
||
| 29 | 12 | public static function validate($name) |
|
| 41 | } |
||
| 42 | |||
| 43 | /** |
||
| 44 | * @param string $name |
||
| 45 | * |
||
| 46 | * @throws ParseException |
||
| 47 | */ |
||
| 48 | 3 | public function __construct($name) |
|
| 49 | { |
||
| 50 | 3 | $this->parse($name); |
|
| 51 | } |
||
| 52 | |||
| 53 | 1 | public function __toString() |
|
| 54 | { |
||
| 55 | 1 | return $this->name; |
|
| 56 | } |
||
| 57 | |||
| 58 | /** |
||
| 59 | * @param string $name |
||
| 60 | * |
||
| 61 | * @throws ParseException |
||
| 62 | * |
||
| 63 | * @return void |
||
| 64 | */ |
||
| 65 | 3 | private function parse($name) |
|
| 75 | } |
||
| 76 | } |
||
| 77 |