Code Duplication    Length = 24-24 lines in 2 locations

htdocs/src/Oc/Page/PageRepository.php 1 location

@@ 49-72 (lines=24) @@
46
     *
47
     * @throws RecordNotFoundException Thrown when no record is found
48
     */
49
    public function fetchOneBy(array $where = [])
50
    {
51
        $queryBuilder = $this->connection->createQueryBuilder()
52
            ->select('*')
53
            ->from(self::TABLE)
54
            ->setMaxResults(1);
55
56
57
        if (count($where) > 0) {
58
            foreach ($where as $column => $value) {
59
                $queryBuilder->andWhere($column . ' = ' .  $queryBuilder->createNamedParameter($value));
60
            }
61
        }
62
63
        $statement = $queryBuilder->execute();
64
65
        $result = $statement->fetch();
66
67
        if ($statement->rowCount() === 0) {
68
            throw new RecordNotFoundException('Record with given where clause not found');
69
        }
70
71
        return $this->getEntityFromDatabaseArray($result);
72
    }
73
74
    /**
75
     * Creates a page in the database.

htdocs/src/Oc/User/UserRepository.php 1 location

@@ 88-111 (lines=24) @@
85
     *
86
     * @throws RecordNotFoundException Thrown when no record is found
87
     */
88
    public function fetchOneBy(array $where = [])
89
    {
90
        $queryBuilder = $this->connection->createQueryBuilder()
91
            ->select('*')
92
            ->from(self::TABLE)
93
            ->setMaxResults(1);
94
95
96
        if (count($where) > 0) {
97
            foreach ($where as $column => $value) {
98
                $queryBuilder->andWhere($column . ' = ' .  $queryBuilder->createNamedParameter($value));
99
            }
100
        }
101
102
        $statement = $queryBuilder->execute();
103
104
        $result = $statement->fetch();
105
106
        if ($statement->rowCount() === 0) {
107
            throw new RecordNotFoundException('Record with given where clause not found');
108
        }
109
110
        return $this->getEntityFromDatabaseArray($result);
111
    }
112
113
    /**
114
     * Creates a user in the database.