Code Duplication    Length = 11-12 lines in 2 locations

src/Post/QueryBuilder.php 1 location

@@ 121-131 (lines=11) @@
118
     *
119
     * @return Collection
120
     */
121
    protected function collectModels()
122
    {
123
        $this->query->set('post_type', $this->model->post_type);
124
        $this->query->set('fields', ''); // as WP_Post objects
125
        $modelClass = get_class($this->model);
126
127
        return Collection::make($this->query->get_posts())
128
            ->map(function ($post) use ($modelClass) {
129
                return new $modelClass($post);
130
            });
131
    }
132
133
    /**
134
     * Set a query variable on the query

src/Term/QueryBuilder.php 1 location

@@ 106-117 (lines=12) @@
103
     *
104
     * @return Collection
105
     */
106
    protected function collectModels()
107
    {
108
        $this->args->put('taxonomy', $this->model->taxonomy);
109
        $this->args->put('fields', 'all');
110
111
        $modelClass = get_class($this->model);
112
113
        return Collection::make($this->fetchTerms())
114
            ->map(function (WP_Term $term) use ($modelClass) {
115
                return new $modelClass($term);
116
            });
117
    }
118
119
    /**
120
     * Set the model for this query.