Passed
Push — unix_timestamp_zero ( ffeb94...021a5e )
by Jonathan
15:06 queued 04:49
created

FakePDO   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 0
dl 0
loc 27
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Vectorface\Tests\MySQLite\Util;
4
5
/**
6
 * Work around mocking issue in PDO.
7
 *
8
 * Credit: http://erichogue.ca/2013/02/best-practices/mocking-pdo-in-phpunit/
9
 */
10
class FakePDO extends \PDO
11
{
12
    /**
13
     * Empty constructor.
14
     */
15
    public function __construct()
16
    {
17
    }
18
19
    /**
20
     * A map of attributes to be passed back from getAttribute.
21
     *
22
     * @var mixed[]
23
     */
24
    public $attributes = [];
25
26
    /**
27
     * Get the value of an attribute. Uses an element of the Attributes array if available, falling back to parent.
28
     *
29
     * @param mixed $attr The attribute whose value is to be fetched.
30
     * @return mixed The value of the attribute.
31
     */
32
    public function getAttribute($attr): mixed
33
    {
34
        return isset($this->attributes[$attr]) ? $this->attributes[$attr] : parent::getAttribute($attr);
35
    }
36
}
37