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

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