Code Duplication    Length = 23-24 lines in 4 locations

htdocs/src/Oc/FieldNotes/Persistence/FieldNoteRepository.php 1 location

@@ 126-148 (lines=23) @@
123
     *
124
     * @throws RecordNotFoundException Thrown when no record is found
125
     */
126
    public function fetchOneBy(array $where = [])
127
    {
128
        $queryBuilder = $this->connection->createQueryBuilder()
129
            ->select('*')
130
            ->from(self::TABLE)
131
            ->setMaxResults(1);
132
133
        if (count($where) > 0) {
134
            foreach ($where as $column => $value) {
135
                $queryBuilder->andWhere($column . ' = ' .  $queryBuilder->createNamedParameter($value));
136
            }
137
        }
138
139
        $statement = $queryBuilder->execute();
140
141
        $result = $statement->fetch();
142
143
        if ($statement->rowCount() === 0) {
144
            throw new RecordNotFoundException('Record with given where clause not found');
145
        }
146
147
        return $this->getEntityFromDatabaseArray($result);
148
    }
149
150
    /**
151
     * Fetch latest user field note.

htdocs/src/Oc/GeoCache/Persistence/GeoCache/GeoCacheRepository.php 1 location

@@ 80-102 (lines=23) @@
77
     *
78
     * @throws RecordNotFoundException Thrown when no record is found
79
     */
80
    public function fetchOneBy(array $where = [])
81
    {
82
        $queryBuilder = $this->connection->createQueryBuilder()
83
             ->select('*')
84
             ->from(self::TABLE)
85
             ->setMaxResults(1);
86
87
        if (count($where) > 0) {
88
            foreach ($where as $column => $value) {
89
                $queryBuilder->andWhere($column . ' = ' .  $queryBuilder->createNamedParameter($value));
90
            }
91
        }
92
93
        $statement = $queryBuilder->execute();
94
95
        $result = $statement->fetch();
96
97
        if ($statement->rowCount() === 0) {
98
            throw new RecordNotFoundException('Record with given where clause not found');
99
        }
100
101
        return $this->getEntityFromDatabaseArray($result);
102
    }
103
104
    /**
105
     * Fetches all GeoCaches by given where clause.

htdocs/src/Oc/GeoCache/Persistence/GeoCacheLog/GeoCacheLogRepository.php 1 location

@@ 79-101 (lines=23) @@
76
     *
77
     * @throws RecordNotFoundException Thrown when no record is found
78
     */
79
    public function fetchOneBy(array $where = [])
80
    {
81
        $queryBuilder = $this->connection->createQueryBuilder()
82
             ->select('*')
83
             ->from(self::TABLE)
84
             ->setMaxResults(1);
85
86
        if (count($where) > 0) {
87
            foreach ($where as $column => $value) {
88
                $queryBuilder->andWhere($column . ' = ' .  $queryBuilder->createNamedParameter($value));
89
            }
90
        }
91
92
        $statement = $queryBuilder->execute();
93
94
        $result = $statement->fetch();
95
96
        if ($statement->rowCount() === 0) {
97
            throw new RecordNotFoundException('Record with given where clause not found');
98
        }
99
100
        return $this->getEntityFromDatabaseArray($result);
101
    }
102
103
    /**
104
     * Fetches all GeoCacheLogs by given where clause.

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.