| Conditions | 4 |
| Paths | 1 |
| Total Lines | 38 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 15 |
| CRAP Score | 4 |
| Changes | 0 | ||
| 1 | <?php |
||
| 39 | 17 | public function register(Container $dic) |
|
| 40 | { |
||
| 41 | |||
| 42 | /** |
||
| 43 | * @return int |
||
| 44 | */ |
||
| 45 | 44 | $dic['PDO.ErrorMode'] = function($dic) { |
|
|
|
|||
| 46 | 55 | return $this->pdo_error_mode; |
|
| 47 | }; |
||
| 48 | |||
| 49 | |||
| 50 | /** |
||
| 51 | * @return array |
||
| 52 | */ |
||
| 53 | 28 | $dic['PDO.Options'] = function( $dic ) { |
|
| 54 | return array( |
||
| 55 | 35 | \PDO::ATTR_ERRMODE => $dic['PDO.ErrorMode'] |
|
| 56 | 7 | ); |
|
| 57 | }; |
||
| 58 | |||
| 59 | |||
| 60 | /** |
||
| 61 | * @return Callable |
||
| 62 | */ |
||
| 63 | 85 | $dic['PDO.Factory'] = $dic->protect(function( $db ) use ($dic) { |
|
| 64 | |||
| 65 | // Parameter check |
||
| 66 | 25 | if ($db instanceOf \StdClass): |
|
| 67 | 5 | $db = (array) $db; |
|
| 68 | 21 | elseif (!is_array($db) and !$db instanceOf \ArrayAccess): |
|
| 69 | 10 | throw new \InvalidArgumentException("Array or StdClass or ArrayAccess expected"); |
|
| 70 | endif; |
||
| 71 | |||
| 72 | // Setup |
||
| 73 | 15 | $pdo_options = $dic['PDO.Options']; |
|
| 74 | 15 | return new \PDO( $db['dsn'], $db['user'], $db['pass'], $pdo_options); |
|
| 75 | 85 | }); |
|
| 76 | 85 | } |
|
| 77 | |||
| 81 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.