Code Duplication    Length = 19-21 lines in 2 locations

src/BenGorFile/File/Infrastructure/Persistence/Sql/SqlFileRepository.php 2 locations

@@ 73-93 (lines=21) @@
70
    /**
71
     * {@inheritdoc}
72
     */
73
    public function query($aSpecification)
74
    {
75
        $query = $aSpecification->buildQuery();
76
        $preparedStatement = $this->pdo->prepare($query[0]);
77
        foreach ($query[1] as $param => $value) {
78
            if (is_int($value)) {
79
                $preparedStatement->bindValue($param, $value, \PDO::PARAM_INT);
80
            } else {
81
                $preparedStatement->bindValue($param, $value, \PDO::PARAM_STR);
82
            }
83
        }
84
        $preparedStatement->execute();
85
        $rows = $preparedStatement->fetchAll();
86
        if ($rows === null) {
87
            return [];
88
        }
89
90
        return array_map(function ($row) {
91
            return $this->buildFile($row);
92
        }, $rows);
93
    }
94
95
    /**
96
     * {@inheritdoc}
@@ 98-116 (lines=19) @@
95
    /**
96
     * {@inheritdoc}
97
     */
98
    public function singleResultQuery($aSpecification)
99
    {
100
        $query = $aSpecification->buildQuery();
101
        $preparedStatement = $this->pdo->prepare($query[0]);
102
        foreach ($query[1] as $param => $value) {
103
            if (is_int($value)) {
104
                $preparedStatement->bindValue($param, $value, \PDO::PARAM_INT);
105
            } else {
106
                $preparedStatement->bindValue($param, $value, \PDO::PARAM_STR);
107
            }
108
        }
109
        $preparedStatement->execute();
110
        $row = $preparedStatement->fetch();
111
        if ($row === null) {
112
            return [];
113
        }
114
115
        return $this->buildFile($row);
116
    }
117
118
    /**
119
     * {@inheritdoc}