Passed
Push — v7 ( ebd842...f31319 )
by Georges
01:32
created

PhpfastcacheIOException   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 14
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 2
1
<?php
2
/**
3
 *
4
 * This file is part of phpFastCache.
5
 *
6
 * @license MIT License (MIT)
7
 *
8
 * For full copyright and license information, please see the docs/CREDITS.txt file.
9
 *
10
 * @author Khoa Bui (khoaofgod)  <[email protected]> http://www.phpfastcache.com
11
 * @author Georges.L (Geolim4)  <[email protected]>
12
 *
13
 */
14
declare(strict_types=1);
15
16
namespace Phpfastcache\Exceptions;
17
18
/**
19
 * Class PhpfastcacheIOException
20
 * @package Phpfastcache\Exceptions
21
 * @since v6
22
 */
23
class PhpfastcacheIOException extends PhpfastcacheCoreException
24
{
25
    /**
26
     * @inheritdoc
27
     */
28
    public function __construct($message = "", $code = 0, $previous = null)
29
    {
30
        $lastError = error_get_last();
31
        if($lastError){
0 ignored issues
show
Bug Best Practice introduced by
The expression $lastError of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
32
            $message .= "\n";
33
            $message .= "Additional information provided by error_get_last():\n";
34
            $message .= "{$lastError['message']} in {$lastError['file']} line {$lastError['line']}";
35
        }
36
        parent::__construct($message, $code, $previous);
37
    }
38
}