Passed
Pull Request — final (#555)
by Georges
02:24
created

phpFastCacheIOException::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 7
nc 2
nop 3
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
15
namespace phpFastCache\Exceptions;
16
17
/**
18
 * Class phpFastCacheIOException
19
 * @package phpFastCache\Exceptions
20
 * @since v6
21
 */
22
class phpFastCacheIOException extends phpFastCacheCoreException
23
{
24
    /**
25
     * @inheritdoc
26
     */
27
    public function __construct($message = "", $code = 0, $previous = null)
28
    {
29
        $lastError = error_get_last();
30
        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...
31
            $message .= "\n";
32
            $message .= "Additional information provided by error_get_last():\n";
33
            $message .= "{$lastError['message']} in {$lastError['file']} line {$lastError['line']}";
34
        }
35
        parent::__construct($message, $code, $previous);
36
    }
37
}