Code Duplication    Length = 17-18 lines in 9 locations

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

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

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

@@ 110-127 (lines=18) @@
107
     *
108
     * @throws RecordNotPersistedException
109
     */
110
    public function update(PageEntity $entity)
111
    {
112
        if ($entity->isNew()) {
113
            throw new RecordNotPersistedException('The entity does not exist.');
114
        }
115
116
        $databaseArray = $this->getDatabaseArrayFromEntity($entity);
117
118
        $this->connection->update(
119
            self::TABLE,
120
            $databaseArray,
121
            ['id' => $entity->id]
122
        );
123
124
        $entity->id = (int) $this->connection->lastInsertId();
125
126
        return $entity;
127
    }
128
129
    /**
130
     * Removes a page from the database.

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

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

htdocs/src/Oc/Country/CountryRepository.php 2 locations

@@ 77-93 (lines=17) @@
74
     *
75
     * @throws RecordAlreadyExistsException
76
     */
77
    public function create(CountryEntity $entity)
78
    {
79
        if (!$entity->isNew()) {
80
            throw new RecordAlreadyExistsException('The entity does already exist.');
81
        }
82
83
        $databaseArray = $this->getDatabaseArrayFromEntity($entity);
84
85
        $this->connection->insert(
86
            self::TABLE,
87
            $databaseArray
88
        );
89
90
        $entity->short = $this->connection->lastInsertId();
91
92
        return $entity;
93
    }
94
95
    /**
96
     * Update a country in the database.
@@ 104-121 (lines=18) @@
101
     *
102
     * @throws RecordNotPersistedException
103
     */
104
    public function update(CountryEntity $entity)
105
    {
106
        if ($entity->isNew()) {
107
            throw new RecordNotPersistedException('The entity does not exist.');
108
        }
109
110
        $databaseArray = $this->getDatabaseArrayFromEntity($entity);
111
112
        $this->connection->update(
113
            self::TABLE,
114
            $databaseArray,
115
            ['short' => $entity->short]
116
        );
117
118
        $entity->short = $this->connection->lastInsertId();
119
120
        return $entity;
121
    }
122
123
    /**
124
     * Removes a country from the database.

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

@@ 189-205 (lines=17) @@
186
     *
187
     * @throws RecordAlreadyExistsException
188
     */
189
    public function create(FieldNoteEntity $entity)
190
    {
191
        if (!$entity->isNew()) {
192
            throw new RecordAlreadyExistsException('The entity does already exist.');
193
        }
194
195
        $databaseArray = $this->getDatabaseArrayFromEntity($entity);
196
197
        $this->connection->insert(
198
            self::TABLE,
199
            $databaseArray
200
        );
201
202
        $entity->id = $this->connection->lastInsertId();
203
204
        return $entity;
205
    }
206
207
    /**
208
     * Update a field note in the database.

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

@@ 211-228 (lines=18) @@
208
     *
209
     * @throws RecordNotPersistedException
210
     */
211
    public function update(GeoCacheEntity $entity)
212
    {
213
        if ($entity->isNew()) {
214
            throw new RecordNotPersistedException('The entity does not exist.');
215
        }
216
217
        $databaseArray = $this->getDatabaseArrayFromEntity($entity);
218
219
        $this->connection->update(
220
            self::TABLE,
221
            $databaseArray,
222
            ['cache_id' => $entity->cacheId]
223
        );
224
225
        $entity->cacheId = $this->connection->lastInsertId();
226
227
        return $entity;
228
    }
229
230
    /**
231
     * Removes a GeoCache from the database.

htdocs/src/Oc/Page/BlockRepository.php 2 locations

@@ 87-103 (lines=17) @@
84
     *
85
     * @throws RecordAlreadyExistsException
86
     */
87
    public function create(BlockEntity $entity)
88
    {
89
        if (!$entity->isNew()) {
90
            throw new RecordAlreadyExistsException('The entity does already exist.');
91
        }
92
93
        $databaseArray = $this->getDatabaseArrayFromEntity($entity);
94
95
        $this->connection->insert(
96
            self::TABLE,
97
            $databaseArray
98
        );
99
100
        $entity->id = (int) $this->connection->lastInsertId();
101
102
        return $entity;
103
    }
104
105
    /**
106
     * Update a page in the database.
@@ 114-131 (lines=18) @@
111
     *
112
     * @throws RecordNotPersistedException
113
     */
114
    public function update(BlockEntity $entity)
115
    {
116
        if ($entity->isNew()) {
117
            throw new RecordNotPersistedException('The entity does not exist.');
118
        }
119
120
        $databaseArray = $this->getDatabaseArrayFromEntity($entity);
121
122
        $this->connection->update(
123
            self::TABLE,
124
            $databaseArray,
125
            ['id' => $entity->id]
126
        );
127
128
        $entity->id = (int) $this->connection->lastInsertId();
129
130
        return $entity;
131
    }
132
133
    /**
134
     * Removes a page from the database.