Passed
Push — master ( 0a3947...bfb42c )
by
unknown
18:00
created

PDOStatementImplementation   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 3
eloc 8
c 2
b 0
f 0
dl 0
loc 17
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A fetchAll() 0 12 3
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the TYPO3 CMS project.
7
 *
8
 * It is free software; you can redistribute it and/or modify it under
9
 * the terms of the GNU General Public License, either version 2
10
 * of the License, or any later version.
11
 *
12
 * For the full copyright and license information, please read the
13
 * LICENSE.txt file that was distributed with this source code.
14
 *
15
 * The TYPO3 project - inspiring people to share!
16
 */
17
18
namespace TYPO3\CMS\Core\Database\Driver;
19
20
use Doctrine\DBAL\Driver\PDO\Exception as PDOException;
21
22
if (PHP_VERSION_ID >= 80000) {
23
    trait PDOStatementImplementation
24
    {
25
        /**
26
         * {@inheritdoc}
27
         */
28
        public function fetchAll($mode = null, ...$args)
29
        {
30
            try {
31
                $records = parent::fetchAll($mode, ...$args);
32
33
                if ($records !== false) {
34
                    $records = array_map([$this, 'mapResourceToString'], $records);
35
                }
36
37
                return $records;
38
            } catch (\PDOException $exception) {
39
                throw new PDOException($exception);
40
            }
41
        }
42
    }
43
} else {
44
    trait PDOStatementImplementation
45
    {
46
        /**
47
         * {@inheritdoc}
48
         */
49
        public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = null)
50
        {
51
            try {
52
                $records = parent::fetchAll($fetchMode, $fetchArgument, $ctorArgs);
53
54
                if ($records !== false) {
55
                    $records = array_map([$this, 'mapResourceToString'], $records);
56
                }
57
58
                return $records;
59
            } catch (\PDOException $exception) {
60
                throw new PDOException($exception);
61
            }
62
        }
63
    }
64
}
65