public function setExtension(string $extension): void
    {
        if (!preg_match('/^[a-zA-Z0-9]{2,4}$/', $extension)) {
            throw new InvalidArgumentException(
                'Extension should be only be composed of alphanumeric characters'
                . ' and should be at least 2 but no more than 4 characters'
            );
        }

        $this->extension = $extension;
    }
public function setExtension(string $extension): void
    {
        if (!preg_match('/^[a-zA-Z0-9]{2,4}$/', $extension)) {
            throw new InvalidArgumentException(
                'Extension should be only be composed of alphanumeric characters'
                . ' and should be at least 2 but no more than 4 characters'
            );
        }

        $this->extension = $extension;
    }
public function setExtension ( string $ extension ) : void { if ( ! preg_match ( '/^[a-zA-Z0-9]{2,4}$/' , $ extension ) ) { throw new InvalidArgumentException ( 'Extension should be only be composed of alphanumeric characters' . ' and should be at least 2 but no more than 4 characters' ) ; } $ this -> extension = $ extension ; }
Sets the file extension used to determine the template filename.

The file extension of the destination format needs to be set. This is used to retrieve the correct template.

@param string $extension an extension (thus only containing alphanumeric characters and be between 2 and 4
characters in size).

@throws InvalidArgumentException if the extension does not match the validation restrictions mentioned above.
Sets the file extension used to determine the template filename .