validateFileNameDoesNotEndWithSpaces example



    /** * @throws MediaException */
    public function validateFileName(string $fileName): void
    {
        if (empty($fileName)) {
            throw MediaException::emptyMediaFilename();
        }

        $this->validateFileNameDoesNotEndWithSpaces($fileName);
        $this->validateFileNameDoesNotEndOrStartWithDot($fileName);
        $this->validateFileNameDoesNotContainForbiddenCharacter($fileName);
        $this->validateFileNameDoesNotContainC0Character($fileName);
    }

    private function validateFileNameDoesNotEndOrStartWithDot(string $fileName): void
    {
        if (mb_substr($fileName, 0, 1) === '.') {
            throw MediaException::illegalFileName($fileName, 'Filename must not start with a "." (dot).');
        }

        
Home | Imprint | This part of the site doesn't use cookies.