Code Duplication    Length = 19-24 lines in 3 locations

eZ/Publish/Core/Persistence/Legacy/Content/Section/Gateway/DoctrineDatabase.php 2 locations

@@ 75-94 (lines=20) @@
72
     * @param string $name
73
     * @param string $identifier
74
     */
75
    public function updateSection($id, $name, $identifier)
76
    {
77
        $query = $this->dbHandler->createUpdateQuery();
78
        $query->update(
79
            $this->dbHandler->quoteTable('ezsection')
80
        )->set(
81
            $this->dbHandler->quoteColumn('name'),
82
            $query->bindValue($name)
83
        )->set(
84
            $this->dbHandler->quoteColumn('identifier'),
85
            $query->bindValue($identifier)
86
        )->where(
87
            $query->expr->eq(
88
                $this->dbHandler->quoteColumn('id'),
89
                $query->bindValue($id, null, \PDO::PARAM_INT)
90
            )
91
        );
92
93
        $query->prepare()->execute();
94
    }
95
96
    /**
97
     * Loads data for section with $id.
@@ 183-206 (lines=24) @@
180
     *
181
     * @return int
182
     */
183
    public function countContentObjectsInSection($id)
184
    {
185
        $query = $this->dbHandler->createSelectQuery();
186
        $query->select(
187
            $query->alias(
188
                $query->expr->count(
189
                    $this->dbHandler->quoteColumn('id')
190
                ),
191
                'content_count'
192
            )
193
        )->from(
194
            $this->dbHandler->quoteTable('ezcontentobject')
195
        )->where(
196
            $query->expr->eq(
197
                $this->dbHandler->quoteColumn('section_id'),
198
                $query->bindValue($id, null, \PDO::PARAM_INT)
199
            )
200
        );
201
202
        $statement = $query->prepare();
203
        $statement->execute();
204
205
        return (int)$statement->fetchColumn();
206
    }
207
208
    /**
209
     * Counts the number of role policies using section with $id in their limitations.

eZ/Publish/Core/Persistence/Legacy/Content/Gateway/DoctrineDatabase.php 1 location

@@ 1287-1305 (lines=19) @@
1284
     *
1285
     * @return int
1286
     */
1287
    public function getLastVersionNumber($contentId)
1288
    {
1289
        $query = $this->dbHandler->createSelectQuery();
1290
        $query->select(
1291
            $query->expr->max($this->dbHandler->quoteColumn('version'))
1292
        )->from(
1293
            $this->dbHandler->quoteTable('ezcontentobject_version')
1294
        )->where(
1295
            $query->expr->eq(
1296
                $this->dbHandler->quoteColumn('contentobject_id'),
1297
                $query->bindValue($contentId, null, \PDO::PARAM_INT)
1298
            )
1299
        );
1300
1301
        $statement = $query->prepare();
1302
        $statement->execute();
1303
1304
        return (int)$statement->fetchColumn();
1305
    }
1306
1307
    /**
1308
     * Returns all IDs for locations that refer to $contentId.