Code Duplication    Length = 28-28 lines in 3 locations

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

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

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

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

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

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