class UnknownFileModel extends iDokladAbstractModel
13
{
14
/**
15
* RAW content of file (should be saved to disc with some filename+extension).
16
*
17
* @var string
18
*/
19
protected $content;
20
21
/**
22
* MIME-type detected of raw content. You can check extension by this MIME.
23
*
24
* @var string
25
*/
26
protected $mime;
27
28
/**
29
* @throws \RuntimeException
30
*/
31
public function __construct()
32
{
33
if (!\function_exists('mime_content_type')) {
34
throw new \RuntimeException('Function `mime_content_type` does not exists, please install PHP extension `fileinfo` (php_fileinfo.so or php_fileinfo.dll).');
35
}
36
}
37
38
/**
39
* @param ResponseInterface $response
40
*
41
* @throws \Exception
42
*
43
* @return iDokladModelInterface
44
*/
45
public static function createFromResponse(ResponseInterface $response): iDokladModelInterface
46
{
47
return (new static())->init($response->getBody()->getContents());
48
}
49
50
/**
51
* @param string $raw
52
*
53
* @throws \Exception
54
*
55
* @return iDokladModelInterface
56
*/
57
public function init(string $raw): iDokladModelInterface
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.
If you suppress an error, we recommend checking for the error condition explicitly:
// For example instead of@mkdir($dir);// Better useif(@mkdir($dir)===false){thrownew\RuntimeException('The directory '.$dir.' could not be created.');}
If you suppress an error, we recommend checking for the error condition explicitly: