Code Duplication    Length = 18-18 lines in 10 locations

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

@@ 99-116 (lines=18) @@
96
     *
97
     * @throws RecordNotPersistedException
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.
@@ 127-144 (lines=18) @@
124
     *
125
     * @throws RecordNotPersistedException
126
     */
127
    public function remove(CountryEntity $entity)
128
    {
129
        if ($entity->isNew()) {
130
            throw new RecordNotPersistedException('The entity does not exist.');
131
        }
132
133
        $databaseArray = $this->getDatabaseArrayFromEntity($entity);
134
135
        $this->connection->delete(
136
            self::TABLE,
137
            $databaseArray,
138
            ['short' => $entity->short]
139
        );
140
141
        $entity->short = null;
142
143
        return $entity;
144
    }
145
146
    /**
147
     * Maps the given entity to the database array.

htdocs/src/Oc/Language/LanguageRepository.php 2 locations

@@ 117-134 (lines=18) @@
114
     *
115
     * @throws RecordNotPersistedException
116
     */
117
    public function update(LanguageEntity $entity)
118
    {
119
        if ($entity->isNew()) {
120
            throw new RecordNotPersistedException('The entity does not exist.');
121
        }
122
123
        $databaseArray = $this->getDatabaseArrayFromEntity($entity);
124
125
        $this->connection->update(
126
            self::TABLE,
127
            $databaseArray,
128
            ['short' => $entity->short]
129
        );
130
131
        $entity->short = $this->connection->lastInsertId();
132
133
        return $entity;
134
    }
135
136
    /**
137
     * Removes a language from the database.
@@ 145-162 (lines=18) @@
142
     *
143
     * @throws RecordNotPersistedException
144
     */
145
    public function remove(LanguageEntity $entity)
146
    {
147
        if ($entity->isNew()) {
148
            throw new RecordNotPersistedException('The entity does not exist.');
149
        }
150
151
        $databaseArray = $this->getDatabaseArrayFromEntity($entity);
152
153
        $this->connection->delete(
154
            self::TABLE,
155
            $databaseArray,
156
            ['short' => $entity->short]
157
        );
158
159
        $entity->short = null;
160
161
        return $entity;
162
    }
163
164
    /**
165
     * Converts database array to entity array.

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

@@ 108-125 (lines=18) @@
105
     *
106
     * @throws RecordNotPersistedException
107
     */
108
    public function update(BlockEntity $entity)
109
    {
110
        if ($entity->isNew()) {
111
            throw new RecordNotPersistedException('The entity does not exist.');
112
        }
113
114
        $databaseArray = $this->getDatabaseArrayFromEntity($entity);
115
116
        $this->connection->update(
117
            self::TABLE,
118
            $databaseArray,
119
            ['id' => $entity->id]
120
        );
121
122
        $entity->id = (int) $this->connection->lastInsertId();
123
124
        return $entity;
125
    }
126
127
    /**
128
     * Removes a page from the database.
@@ 136-153 (lines=18) @@
133
     *
134
     * @throws RecordNotPersistedException
135
     */
136
    public function remove(BlockEntity $entity)
137
    {
138
        if ($entity->isNew()) {
139
            throw new RecordNotPersistedException('The entity does not exist.');
140
        }
141
142
        $databaseArray = $this->getDatabaseArrayFromEntity($entity);
143
144
        $this->connection->delete(
145
            self::TABLE,
146
            $databaseArray,
147
            ['id' => $entity->id]
148
        );
149
150
        $entity->id = null;
151
152
        return $entity;
153
    }
154
155
    /**
156
     * Maps the given entity to the database array.

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

@@ 106-123 (lines=18) @@
103
     *
104
     * @throws RecordNotPersistedException
105
     */
106
    public function update(PageEntity $entity)
107
    {
108
        if ($entity->isNew()) {
109
            throw new RecordNotPersistedException('The entity does not exist.');
110
        }
111
112
        $databaseArray = $this->getDatabaseArrayFromEntity($entity);
113
114
        $this->connection->update(
115
            self::TABLE,
116
            $databaseArray,
117
            ['id' => $entity->id]
118
        );
119
120
        $entity->id = (int) $this->connection->lastInsertId();
121
122
        return $entity;
123
    }
124
125
    /**
126
     * Removes a page from the database.
@@ 134-151 (lines=18) @@
131
     *
132
     * @throws RecordNotPersistedException
133
     */
134
    public function remove(PageEntity $entity)
135
    {
136
        if ($entity->isNew()) {
137
            throw new RecordNotPersistedException('The entity does not exist.');
138
        }
139
140
        $databaseArray = $this->getDatabaseArrayFromEntity($entity);
141
142
        $this->connection->delete(
143
            self::TABLE,
144
            $databaseArray,
145
            ['id' => $entity->id]
146
        );
147
148
        $entity->id = null;
149
150
        return $entity;
151
    }
152
153
    /**
154
     * Maps the given entity to the database array.

htdocs/src/Oc/User/UserRepository.php 2 locations

@@ 120-137 (lines=18) @@
117
     *
118
     * @throws RecordNotPersistedException
119
     */
120
    public function update(UserEntity $entity)
121
    {
122
        if ($entity->isNew()) {
123
            throw new RecordNotPersistedException('The entity does not exist.');
124
        }
125
126
        $databaseArray = $this->getDatabaseArrayFromEntity($entity);
127
128
        $this->connection->update(
129
            self::TABLE,
130
            $databaseArray,
131
            ['id' => $entity->id]
132
        );
133
134
        $entity->id = (int) $this->connection->lastInsertId();
135
136
        return $entity;
137
    }
138
139
    /**
140
     * Removes a user from the database.
@@ 148-165 (lines=18) @@
145
     *
146
     * @throws RecordNotPersistedException
147
     */
148
    public function remove(UserEntity $entity)
149
    {
150
        if ($entity->isNew()) {
151
            throw new RecordNotPersistedException('The entity does not exist.');
152
        }
153
154
        $databaseArray = $this->getDatabaseArrayFromEntity($entity);
155
156
        $this->connection->delete(
157
            self::TABLE,
158
            $databaseArray,
159
            ['id' => $entity->id]
160
        );
161
162
        $entity->id = null;
163
164
        return $entity;
165
    }
166
167
    /**
168
     * Converts database array to entity array.