ConnectionWrapper::__call()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
ccs 0
cts 4
cp 0
cc 1
eloc 2
nc 1
nop 2
crap 2
1
<?php
2
3
/**
4
 * TechDivision\Import\App\ConnectionWrapper
5
 *
6
 * NOTICE OF LICENSE
7
 *
8
 * This source file is subject to the Open Software License (OSL 3.0)
9
 * that is available through the world-wide-web at this URL:
10
 * http://opensource.org/licenses/osl-3.0.php
11
 *
12
 * PHP version 5
13
 *
14
 * @author    Tim Wagner <[email protected]>
15
 * @copyright 2016 TechDivision GmbH <[email protected]>
16
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
 * @link      https://github.com/techdivision/import-app-simple
18
 * @link      http://www.techdivision.com
19
 */
20
21
namespace TechDivision\Import\App;
22
23
use Magento\Framework\App\ResourceConnection;
24
25
/**
26
 * A connection wrapper that wraps a PDO connection.
27
 *
28
 * @author    Tim Wagner <[email protected]>
29
 * @copyright 2016 TechDivision GmbH <[email protected]>
30
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
31
 * @link      https://github.com/techdivision/import-app-simple
32
 * @link      http://www.techdivision.com
33
 */
34
class ConnectionWrapper
35
{
36
37
    /**
38
     * The wrapped PDO connection.
39
     *
40
     * @var \PDO
41
     */
42
    protected $connection;
43
44
    /**
45
     * Initialize the wrapper with the Magento resource connection.
46
     *
47
     * @param \Magento\Framework\App\ResourceConnection $connection The Magento resource connection
48
     */
49
    public function __construct(ResourceConnection $connection)
50
    {
51
52
        // initialize the PDO connection
53
        $this->connection = $connection->getConnection(ResourceConnection::DEFAULT_CONNECTION)
54
                                       ->getConnection();
55
    }
56
57
    /**
58
     * Delegate all method calls to the PDO connection.
59
     *
60
     * @param string $name      The method name
61
     * @param array  $arguments The method arguments
62
     *
63
     * @return mixed The result of the method call
64
     */
65
    public function __call($name, array $arguments = array())
66
    {
67
        return call_user_func_array(array($this->connection, $name), $arguments);
68
    }
69
}
70