/
Alexsey-VR
/
php-project-9
Обзор
Документация
Войти
/
Alexsey-VR
/
php-project-9
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/Url/Url.php
67 строк
1 KB
Alexsey-VR
added url exception
09 апр 2026, 06:42
09 апр 2026, 06:42
606e6d7
Код
Авторство
О чём код?
<?php namespace Analyzer\Url; use Analyzer\Interfaces\UrlInterface; use Analyzer\Exceptions\UrlException; class Url implements UrlInterface { private int|null $id; private string|null $url; private string|null $timestamp; public function __construct() { $this->id = null; $this->url = null; $this->timestamp = null; } public static function fromArray(array $urlInfo): UrlInterface { ['name' => $urlData] = $urlInfo; $url = new Url(); $url->setUrl( is_string($urlData) ? $urlData : throw new UrlException('Internal error: URL has a wrong type') ); return $url; } public function setId(int $id): void { $this->id = $id; } public function getId(): ?int { return $this->id; } public function setUrl(string $url): void { $this->url = $url; } public function getUrl(): ?string { return $this->url; } public function setTimestamp(string $timestamp): void { $this->timestamp = $timestamp; } public function getTimestamp(): ?string { return $this->timestamp; } public function exists(): bool { return !is_null($this->getId()); } }