Absolute.php
54 lines
| 1 | <?php |
| 2 | |
| 3 | namespace AC\Asset\Location; |
| 4 | |
| 5 | use AC\Asset\Location; |
| 6 | |
| 7 | final class Absolute implements Location { |
| 8 | |
| 9 | /** |
| 10 | * @var string |
| 11 | */ |
| 12 | private $url; |
| 13 | |
| 14 | /** |
| 15 | * @var string |
| 16 | */ |
| 17 | private $path; |
| 18 | |
| 19 | /** |
| 20 | * @param string $url |
| 21 | * @param string $path |
| 22 | */ |
| 23 | public function __construct( $url, $path ) { |
| 24 | $this->url = (string) $url; |
| 25 | $this->path = (string) $path; |
| 26 | } |
| 27 | |
| 28 | /** |
| 29 | * @param string $suffix |
| 30 | * |
| 31 | * @return self |
| 32 | */ |
| 33 | public function with_suffix( $suffix ) { |
| 34 | $url = $this->get_url() . $suffix; |
| 35 | $path = $this->get_path() . $suffix; |
| 36 | |
| 37 | return new self( $url, $path ); |
| 38 | } |
| 39 | |
| 40 | /** |
| 41 | * @return string |
| 42 | */ |
| 43 | public function get_url() { |
| 44 | return $this->url; |
| 45 | } |
| 46 | |
| 47 | /** |
| 48 | * @return string |
| 49 | */ |
| 50 | public function get_path() { |
| 51 | return $this->path; |
| 52 | } |
| 53 | |
| 54 | } |