Code Duplication    Length = 9-10 lines in 4 locations

Query.php 4 locations

@@ 104-113 (lines=10) @@
101
     * If this parameter is not given, the `db` application component will be used.
102
     * @return array the query results. If the query results in nothing, an empty array will be returned.
103
     */
104
    public function all($db = null)
105
    {
106
        if ($db === null) {
107
            $db = Yii::$app->get('ldap');
108
        }
109
        
110
        /** @var $result DataReader */
111
        $result = $this->execute($db);        
112
        return $this->populate($result->toArray());
113
    }
114
115
    /**
116
     * Converts the raw query results into the format as specified by this query.
@@ 146-155 (lines=10) @@
143
     * @return array|boolean the first row (in terms of an array) of the query result. False is returned if the query
144
     * results in nothing.
145
     */
146
    public function one($db = null)
147
    {
148
        if ($db === null) {
149
            $db = Yii::$app->get('ldap');
150
        }
151
152
        $this->limit = 1;
153
        $result = $this->execute($db);
154
        return $result->toArray();
155
    }
156
157
    /**
158
     * Returns the number of entries in a search.
@@ 163-171 (lines=9) @@
160
     * If this parameter is not given (or null), the `db` application component will be used.
161
     * @return integer number of entries.
162
     */
163
    public function count($db = null)
164
    {
165
        if ($db === null) {
166
            $db = Yii::$app->get('ldap');
167
        }
168
        
169
        $result = $this->execute($db);
170
        return $result->count();
171
    }
172
    
173
174
    /**
@@ 180-188 (lines=9) @@
177
     * If this parameter is not given, the `db` application component will be used.
178
     * @return boolean whether the query result contains any row of entries.
179
     */
180
    public function exists($db = null)
181
    {
182
        if ($db === null) {
183
            $db = Yii::$app->get('ldap');
184
        }
185
        
186
        $result = $this->execute($db);
187
        return (boolean)$result->count();
188
    }
189
190
    /**
191
     * Sets the SELECT part of the query.