@@ -25,63 +25,63 @@ |
||
25 | 25 | */ |
26 | 26 | class PdoResolver implements ResolverInterface |
27 | 27 | { |
28 | - /** |
|
29 | - * @var \PDO |
|
30 | - */ |
|
31 | - protected $pdo; |
|
28 | + /** |
|
29 | + * @var \PDO |
|
30 | + */ |
|
31 | + protected $pdo; |
|
32 | 32 | |
33 | - /** |
|
34 | - * @var string |
|
35 | - */ |
|
36 | - protected $sql; |
|
33 | + /** |
|
34 | + * @var string |
|
35 | + */ |
|
36 | + protected $sql; |
|
37 | 37 | |
38 | - /** |
|
39 | - * Constructor. |
|
40 | - * |
|
41 | - * @param \PDO PDO Instance |
|
42 | - * @param string $sql SQL String |
|
43 | - */ |
|
44 | - public function __construct(PDO $pdo, string $sql) |
|
45 | - { |
|
46 | - $this->pdo = $pdo; |
|
47 | - $this->sql = $sql; |
|
48 | - } |
|
38 | + /** |
|
39 | + * Constructor. |
|
40 | + * |
|
41 | + * @param \PDO PDO Instance |
|
42 | + * @param string $sql SQL String |
|
43 | + */ |
|
44 | + public function __construct(PDO $pdo, string $sql) |
|
45 | + { |
|
46 | + $this->pdo = $pdo; |
|
47 | + $this->sql = $sql; |
|
48 | + } |
|
49 | 49 | |
50 | - /** |
|
51 | - * Builds the statement |
|
52 | - * |
|
53 | - * @return \PDOStatement |
|
54 | - */ |
|
55 | - protected function buildStatement(): PDOStatement |
|
56 | - { |
|
57 | - $statement = $this->pdo->prepare($this->sql); |
|
50 | + /** |
|
51 | + * Builds the statement |
|
52 | + * |
|
53 | + * @return \PDOStatement |
|
54 | + */ |
|
55 | + protected function buildStatement(): PDOStatement |
|
56 | + { |
|
57 | + $statement = $this->pdo->prepare($this->sql); |
|
58 | 58 | |
59 | - $error = $this->pdo->errorInfo(); |
|
60 | - if ($error[0] !== '00000') { |
|
61 | - throw new PDOException($error[2], (int)$error[0]); |
|
62 | - } |
|
59 | + $error = $this->pdo->errorInfo(); |
|
60 | + if ($error[0] !== '00000') { |
|
61 | + throw new PDOException($error[2], (int)$error[0]); |
|
62 | + } |
|
63 | 63 | |
64 | - return $statement; |
|
65 | - } |
|
64 | + return $statement; |
|
65 | + } |
|
66 | 66 | |
67 | - /** |
|
68 | - * {@inheritDoc} |
|
69 | - */ |
|
70 | - public function find(array $conditions): ?ArrayAccess |
|
71 | - { |
|
72 | - foreach ($conditions as $key => $value) { |
|
73 | - unset($conditions[$key]); |
|
74 | - $conditions[':' . $key] = $value; |
|
75 | - } |
|
67 | + /** |
|
68 | + * {@inheritDoc} |
|
69 | + */ |
|
70 | + public function find(array $conditions): ?ArrayAccess |
|
71 | + { |
|
72 | + foreach ($conditions as $key => $value) { |
|
73 | + unset($conditions[$key]); |
|
74 | + $conditions[':' . $key] = $value; |
|
75 | + } |
|
76 | 76 | |
77 | - $statement = $this->buildStatement(); |
|
78 | - $statement->execute($conditions); |
|
79 | - $result = $statement->fetchAll(); |
|
77 | + $statement = $this->buildStatement(); |
|
78 | + $statement->execute($conditions); |
|
79 | + $result = $statement->fetchAll(); |
|
80 | 80 | |
81 | - if (empty($result)) { |
|
82 | - return null; |
|
83 | - } |
|
81 | + if (empty($result)) { |
|
82 | + return null; |
|
83 | + } |
|
84 | 84 | |
85 | - return new ArrayObject($result[0]); |
|
86 | - } |
|
85 | + return new ArrayObject($result[0]); |
|
86 | + } |
|
87 | 87 | } |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | |
59 | 59 | $error = $this->pdo->errorInfo(); |
60 | 60 | if ($error[0] !== '00000') { |
61 | - throw new PDOException($error[2], (int)$error[0]); |
|
61 | + throw new PDOException($error[2], (int) $error[0]); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | return $statement; |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | { |
72 | 72 | foreach ($conditions as $key => $value) { |
73 | 73 | unset($conditions[$key]); |
74 | - $conditions[':' . $key] = $value; |
|
74 | + $conditions[':'.$key] = $value; |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | $statement = $this->buildStatement(); |