Skip to content

Commit

Permalink
image from string
Browse files Browse the repository at this point in the history
  • Loading branch information
bpasfinsight committed Nov 25, 2020
1 parent f044f45 commit 9166f29
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/Core/Container/Image/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,15 @@ public static function fromName(string $name)
{
return new self($name, null, null);
}

public static function fromString(string $string)
{
if(preg_match('#(.+)/(.+):(.+)#', $string, $matches)) {
return new self($matches[2], $matches[1], $matches[3]);
}
if(preg_match('#(.+):(.+)#', $string, $matches)) {
return new self($matches[1], null, $matches[2]);
}
return new self($string, null, null);
}
}

0 comments on commit 9166f29

Please sign in to comment.