Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
<?php declare(strict_types = 1);
2
/*
3
 * This file is part of PharIo\Manifest.
4
 *
5
 * (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
namespace PharIo\Manifest;
11
 
12
class Url {
13
    /** @var string */
14
    private $url;
15
 
16
    public function __construct(string $url) {
17
        $this->ensureUrlIsValid($url);
18
 
19
        $this->url = $url;
20
    }
21
 
22
    public function asString(): string {
23
        return $this->url;
24
    }
25
 
26
    /**
27
     * @param string $url
28
     *
29
     * @throws InvalidUrlException
30
     */
31
    private function ensureUrlIsValid($url): void {
32
        if (\filter_var($url, \FILTER_VALIDATE_URL) === false) {
33
            throw new InvalidUrlException;
34
        }
35
    }
36
}