fkooman\RemoteStorage\Path::__construct PHP Method

__construct() public method

public __construct ( $p )
    public function __construct($p)
    {
        if (!is_string($p)) {
            throw new PathException('invalid path: not a string');
        }
        // MUST contain at least one slash and start with it
        if (0 !== strpos($p, '/')) {
            throw new PathException('invalid path: does not start with /');
        }
        // MUST NOT contain encoded "/"
        if (false !== stripos($p, '%2f')) {
            throw new PathException('invalid path: contains encoded "/"');
        }
        // MUST NOT contain encoded "\0"
        if (false !== strpos($p, '%00')) {
            throw new PathException('invalid path: contains encoded "\\0"');
        }
        // MUST NOT contain ".."
        if (false !== strpos($p, '..')) {
            throw new PathException('invalid path: contains ..');
        }
        // MUST NOT contain "%2e%2e"
        if (false !== stripos($p, '%2e%2e')) {
            throw new PathException('invalid path: contains encoded ".."');
        }
        // MUST NOT contain "//"
        if (false !== strpos($p, '//')) {
            throw new PathException('invalid path: contains //');
        }
        // MUST contain a user
        $pathParts = explode('/', $p);
        if (count($pathParts) < 3) {
            throw new PathException('invalid path: no user specified');
        }
        foreach ($pathParts as $pathPart) {
            $this->pathParts[] = rawurldecode($pathPart);
        }
        $this->p = implode('/', $this->pathParts);
    }