Code Duplication    Length = 17-18 lines in 8 locations

htdocs/src/Oc/Country/CountryRepository.php 1 location

@@ 99-116 (lines=18) @@
96
     * @throws RecordNotPersistedException
97
     * @return CountryEntity
98
     */
99
    public function update(CountryEntity $entity)
100
    {
101
        if ($entity->isNew()) {
102
            throw new RecordNotPersistedException('The entity does not exist.');
103
        }
104
105
        $databaseArray = $this->getDatabaseArrayFromEntity($entity);
106
107
        $this->connection->update(
108
            self::TABLE,
109
            $databaseArray,
110
            ['short' => $entity->short]
111
        );
112
113
        $entity->short = $this->connection->lastInsertId();
114
115
        return $entity;
116
    }
117
118
    /**
119
     * Removes a country from the database.

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

@@ 204-221 (lines=18) @@
201
     * @throws RecordNotPersistedException
202
     * @return FieldNoteEntity
203
     */
204
    public function update(FieldNoteEntity $entity)
205
    {
206
        if ($entity->isNew()) {
207
            throw new RecordNotPersistedException('The entity does not exist.');
208
        }
209
210
        $databaseArray = $this->getDatabaseArrayFromEntity($entity);
211
212
        $this->connection->update(
213
            self::TABLE,
214
            $databaseArray,
215
            ['id' => $entity->id]
216
        );
217
218
        $entity->id = (int) $this->connection->lastInsertId();
219
220
        return $entity;
221
    }
222
223
    /**
224
     * Removes a field note from the database.

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

@@ 200-217 (lines=18) @@
197
     * @throws RecordNotPersistedException
198
     * @return GeoCacheEntity
199
     */
200
    public function update(GeoCacheEntity $entity)
201
    {
202
        if ($entity->isNew()) {
203
            throw new RecordNotPersistedException('The entity does not exist.');
204
        }
205
206
        $databaseArray = $this->getDatabaseArrayFromEntity($entity);
207
208
        $this->connection->update(
209
            self::TABLE,
210
            $databaseArray,
211
            ['cache_id' => $entity->cacheId]
212
        );
213
214
        $entity->cacheId = (int) $this->connection->lastInsertId();
215
216
        return $entity;
217
    }
218
219
    /**
220
     * Removes a GeoCache from the database.

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

@@ 196-213 (lines=18) @@
193
     * @throws RecordNotPersistedException
194
     * @return GeoCacheLogEntity
195
     */
196
    public function update(GeoCacheLogEntity $entity)
197
    {
198
        if ($entity->isNew()) {
199
            throw new RecordNotPersistedException('The entity does not exist.');
200
        }
201
202
        $databaseArray = $this->getDatabaseArrayFromEntity($entity);
203
204
        $this->connection->update(
205
            self::TABLE,
206
            $databaseArray,
207
            ['id' => $entity->id]
208
        );
209
210
        $entity->id = (int) $this->connection->lastInsertId();
211
212
        return $entity;
213
    }
214
215
    /**
216
     * Removes a GeoCacheLog from the database.

htdocs/src/Oc/Language/LanguageRepository.php 1 location

@@ 116-133 (lines=18) @@
113
     * @throws RecordNotPersistedException
114
     * @return LanguageEntity
115
     */
116
    public function update(LanguageEntity $entity)
117
    {
118
        if ($entity->isNew()) {
119
            throw new RecordNotPersistedException('The entity does not exist.');
120
        }
121
122
        $databaseArray = $this->getDatabaseArrayFromEntity($entity);
123
124
        $this->connection->update(
125
            self::TABLE,
126
            $databaseArray,
127
            ['short' => $entity->short]
128
        );
129
130
        $entity->short = $this->connection->lastInsertId();
131
132
        return $entity;
133
    }
134
135
    /**
136
     * Removes a language from the database.

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

@@ 123-140 (lines=18) @@
120
     * @throws RecordNotPersistedException
121
     * @return UserEntity
122
     */
123
    public function update(UserEntity $entity)
124
    {
125
        if ($entity->isNew()) {
126
            throw new RecordNotPersistedException('The entity does not exist.');
127
        }
128
129
        $databaseArray = $this->getDatabaseArrayFromEntity($entity);
130
131
        $this->connection->update(
132
            self::TABLE,
133
            $databaseArray,
134
            ['id' => $entity->id]
135
        );
136
137
        $entity->id = (int) $this->connection->lastInsertId();
138
139
        return $entity;
140
    }
141
142
    /**
143
     * Removes a user from the database.

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

@@ 83-99 (lines=17) @@
80
     * @throws RecordAlreadyExistsException
81
     * @return BlockEntity
82
     */
83
    public function create(BlockEntity $entity)
84
    {
85
        if (!$entity->isNew()) {
86
            throw new RecordAlreadyExistsException('The entity does already exist.');
87
        }
88
89
        $databaseArray = $this->getDatabaseArrayFromEntity($entity);
90
91
        $this->connection->insert(
92
            self::TABLE,
93
            $databaseArray
94
        );
95
96
        $entity->id = (int) $this->connection->lastInsertId();
97
98
        return $entity;
99
    }
100
101
    /**
102
     * Update a page in the database.

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

@@ 79-95 (lines=17) @@
76
     * @throws RecordAlreadyExistsException
77
     * @return PageEntity
78
     */
79
    public function create(PageEntity $entity)
80
    {
81
        if (!$entity->isNew()) {
82
            throw new RecordAlreadyExistsException('The entity does already exist.');
83
        }
84
85
        $databaseArray = $this->getDatabaseArrayFromEntity($entity);
86
87
        $this->connection->insert(
88
            self::TABLE,
89
            $databaseArray
90
        );
91
92
        $entity->id = (int) $this->connection->lastInsertId();
93
94
        return $entity;
95
    }
96
97
    /**
98
     * Update a page in the database.