Code Duplication    Length = 28-28 lines in 3 locations

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

@@ 105-132 (lines=28) @@
102
     * @throws RecordsNotFoundException Thrown when no records are found
103
     * @return GeoCacheEntity[]
104
     */
105
    public function fetchBy(array $where = [])
106
    {
107
        $queryBuilder = $this->connection->createQueryBuilder()
108
             ->select('*')
109
             ->from(self::TABLE);
110
111
        if (count($where) > 0) {
112
            foreach ($where as $column => $value) {
113
                $queryBuilder->andWhere($column . ' = ' . $queryBuilder->createNamedParameter($value));
114
            }
115
        }
116
117
        $statement = $queryBuilder->execute();
118
119
        $result = $statement->fetchAll();
120
121
        if ($statement->rowCount() === 0) {
122
            throw new RecordsNotFoundException('No records with given where clause found');
123
        }
124
125
        $geoCaches = [];
126
127
        foreach ($result as $item) {
128
            $geoCaches[] = $this->getEntityFromDatabaseArray($item);
129
        }
130
131
        return $geoCaches;
132
    }
133
134
    /**
135
     * Fetches a GeoCache by given where clause.

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

@@ 104-131 (lines=28) @@
101
     * @throws RecordsNotFoundException Thrown when no records are found
102
     * @return GeoCacheLogEntity[]
103
     */
104
    public function fetchBy(array $where = [])
105
    {
106
        $queryBuilder = $this->connection->createQueryBuilder()
107
             ->select('*')
108
             ->from(self::TABLE);
109
110
        if (count($where) > 0) {
111
            foreach ($where as $column => $value) {
112
                $queryBuilder->andWhere($column . ' = ' . $queryBuilder->createNamedParameter($value));
113
            }
114
        }
115
116
        $statement = $queryBuilder->execute();
117
118
        $result = $statement->fetchAll();
119
120
        if ($statement->rowCount() === 0) {
121
            throw new RecordsNotFoundException('No records with given where clause found');
122
        }
123
124
        $geoCaches = [];
125
126
        foreach ($result as $item) {
127
            $geoCaches[] = $this->getEntityFromDatabaseArray($item);
128
        }
129
130
        return $geoCaches;
131
    }
132
133
    /**
134
     * Fetch latest user geo cache log.

htdocs/src/Oc/Page/Persistence/BlockRepository.php 1 location

@@ 46-73 (lines=28) @@
43
     * @throws RecordsNotFoundException Thrown when no records are found
44
     * @return BlockEntity[]
45
     */
46
    public function fetchBy(array $where = [])
47
    {
48
        $queryBuilder = $this->connection->createQueryBuilder()
49
            ->select('*')
50
            ->from(self::TABLE);
51
52
        if (count($where) > 0) {
53
            foreach ($where as $column => $value) {
54
                $queryBuilder->andWhere($column . ' = ' . $queryBuilder->createNamedParameter($value));
55
            }
56
        }
57
58
        $statement = $queryBuilder->execute();
59
60
        $result = $statement->fetchAll();
61
62
        if ($statement->rowCount() === 0) {
63
            throw new RecordsNotFoundException('No records with given where clause found');
64
        }
65
66
        $blocks = [];
67
68
        foreach ($result as $item) {
69
            $blocks[] = $this->getEntityFromDatabaseArray($item);
70
        }
71
72
        return $blocks;
73
    }
74
75
    /**
76
     * Creates a block in the database.