Code Duplication    Length = 20-21 lines in 5 locations

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

@@ 917-936 (lines=20) @@
914
     *
915
     * @return array(int=>array(string=>mixed)) Data rows.
916
     */
917
    public function loadTypeDataByIdentifier($identifier, $status)
918
    {
919
        $q = $this->getLoadTypeQuery();
920
        $q->where(
921
            $q->expr->lAnd(
922
                $q->expr->eq(
923
                    $this->dbHandler->quoteColumn('identifier', 'ezcontentclass'),
924
                    $q->bindValue($identifier)
925
                ),
926
                $q->expr->eq(
927
                    $this->dbHandler->quoteColumn('version', 'ezcontentclass'),
928
                    $q->bindValue($status)
929
                )
930
            )
931
        );
932
        $stmt = $q->prepare();
933
        $stmt->execute();
934
935
        return $stmt->fetchAll(\PDO::FETCH_ASSOC);
936
    }
937
938
    /**
939
     * Loads an array with data about the type referred to by $remoteId in
@@ 947-966 (lines=20) @@
944
     *
945
     * @return array(int=>array(string=>mixed)) Data rows.
946
     */
947
    public function loadTypeDataByRemoteId($remoteId, $status)
948
    {
949
        $q = $this->getLoadTypeQuery();
950
        $q->where(
951
            $q->expr->lAnd(
952
                $q->expr->eq(
953
                    $this->dbHandler->quoteColumn('remote_id', 'ezcontentclass'),
954
                    $q->bindValue($remoteId)
955
                ),
956
                $q->expr->eq(
957
                    $this->dbHandler->quoteColumn('version', 'ezcontentclass'),
958
                    $q->bindValue($status)
959
                )
960
            )
961
        );
962
        $stmt = $q->prepare();
963
        $stmt->execute();
964
965
        return $stmt->fetchAll(\PDO::FETCH_ASSOC);
966
    }
967
968
    /**
969
     * Returns a basic query to retrieve Type data.

eZ/Publish/Core/Persistence/Legacy/Content/Location/Gateway/DoctrineDatabase.php 3 locations

@@ 72-92 (lines=21) @@
69
     *
70
     * @return array
71
     */
72
    public function getBasicNodeData($nodeId)
73
    {
74
        $query = $this->handler->createSelectQuery();
75
        $query
76
            ->select('*')
77
            ->from($this->handler->quoteTable('ezcontentobject_tree'))
78
            ->where(
79
                $query->expr->eq(
80
                    $this->handler->quoteColumn('node_id'),
81
                    $query->bindValue($nodeId)
82
                )
83
            );
84
        $statement = $query->prepare();
85
        $statement->execute();
86
87
        if ($row = $statement->fetch(\PDO::FETCH_ASSOC)) {
88
            return $row;
89
        }
90
91
        throw new NotFound('location', $nodeId);
92
    }
93
94
    /**
95
     * Returns an array with basic node data.
@@ 103-123 (lines=21) @@
100
     *
101
     * @return array
102
     */
103
    public function getBasicNodeDataByRemoteId($remoteId)
104
    {
105
        $query = $this->handler->createSelectQuery();
106
        $query
107
            ->select('*')
108
            ->from($this->handler->quoteTable('ezcontentobject_tree'))
109
            ->where(
110
                $query->expr->eq(
111
                    $this->handler->quoteColumn('remote_id'),
112
                    $query->bindValue($remoteId)
113
                )
114
            );
115
        $statement = $query->prepare();
116
        $statement->execute();
117
118
        if ($row = $statement->fetch(\PDO::FETCH_ASSOC)) {
119
            return $row;
120
        }
121
122
        throw new NotFound('location', $remoteId);
123
    }
124
125
    /**
126
     * Loads data for all Locations for $contentId, optionally only in the
@@ 1247-1267 (lines=21) @@
1244
     *
1245
     * @return array
1246
     */
1247
    public function loadTrashByLocation($locationId)
1248
    {
1249
        $query = $this->handler->createSelectQuery();
1250
        $query
1251
            ->select('*')
1252
            ->from($this->handler->quoteTable('ezcontentobject_trash'))
1253
            ->where(
1254
                $query->expr->eq(
1255
                    $this->handler->quoteColumn('node_id'),
1256
                    $query->bindValue($locationId)
1257
                )
1258
            );
1259
        $statement = $query->prepare();
1260
        $statement->execute();
1261
1262
        if ($row = $statement->fetch(\PDO::FETCH_ASSOC)) {
1263
            return $row;
1264
        }
1265
1266
        throw new NotFound('trash', $locationId);
1267
    }
1268
1269
    /**
1270
     * List trashed items.