| Total Complexity | 9 |
| Total Lines | 87 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 7 | class Url |
||
| 8 | { |
||
| 9 | /** |
||
| 10 | * @var string |
||
| 11 | */ |
||
| 12 | protected $location; |
||
| 13 | |||
| 14 | /** |
||
| 15 | * @var string |
||
| 16 | */ |
||
| 17 | protected $providerName; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * @var array |
||
| 21 | */ |
||
| 22 | protected $options; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * Url constructor. |
||
| 26 | * |
||
| 27 | * @param string $location |
||
| 28 | * @param string $providerName |
||
| 29 | * @param array $options |
||
| 30 | */ |
||
| 31 | public function __construct(string $location, string $providerName, array $options = []) |
||
| 32 | { |
||
| 33 | $this->location = $location; |
||
| 34 | $this->providerName = $providerName; |
||
| 35 | $this->options = $options; |
||
| 36 | } |
||
| 37 | |||
| 38 | public function serialize(): string |
||
| 39 | { |
||
| 40 | return serialize([ |
||
| 41 | 'location' => $this->location, |
||
| 42 | 'providerName' => $this->providerName, |
||
| 43 | 'options' => $this->options, |
||
| 44 | ]); |
||
| 45 | } |
||
| 46 | |||
| 47 | public static function deserialize(string $serialized): Url |
||
| 48 | { |
||
| 49 | $data = unserialize($serialized); |
||
| 50 | |||
| 51 | return new Url( |
||
| 52 | $data['location'], |
||
| 53 | $data['providerName'], |
||
| 54 | $data['options'] |
||
| 55 | ); |
||
| 56 | } |
||
| 57 | |||
| 58 | /** |
||
| 59 | * @return string |
||
| 60 | */ |
||
| 61 | public function getLocation(): string |
||
| 62 | { |
||
| 63 | return $this->location; |
||
| 64 | } |
||
| 65 | |||
| 66 | /** |
||
| 67 | * @return string |
||
| 68 | */ |
||
| 69 | public function getProviderName(): string |
||
| 70 | { |
||
| 71 | return $this->providerName; |
||
| 72 | } |
||
| 73 | |||
| 74 | /** |
||
| 75 | * @return array |
||
| 76 | */ |
||
| 77 | public function getOptions(): array |
||
| 78 | { |
||
| 79 | return $this->options; |
||
| 80 | } |
||
| 81 | |||
| 82 | public function hasOption(string $name): bool |
||
| 83 | { |
||
| 84 | return key_exists($name, $this->options); |
||
| 85 | } |
||
| 86 | |||
| 87 | public function getOption(string $name) |
||
| 94 | } |
||
| 95 | } |
||
| 96 |