Code Duplication    Length = 25-26 lines in 2 locations

src/APIAccess/Group.php 1 location

@@ 370-395 (lines=26) @@
367
     * @return object|bool Object with new group data or false if the group was not found
368
     * @see \FreeIPA\APIAccess\Connection\buildRequest()
369
     */
370
    public function modify($cn = null, $data = array())
371
    {
372
        if (!$cn || !$data) {
373
            return false;
374
        }
375
376
        // Obtained with the command: ipa -vv group_mod tobias --first="testaaaaaa"
377
        $args = array($cn);
378
        $default_options = array(
379
            'all' => false,
380
            'no_members' => false,
381
            'posix' => false,
382
            'raw' => false,
383
            'external' => false,
384
            'rights' => false,
385
        );
386
        $final_options = array_merge($default_options, $data);
387
388
        // The buildRequest() method already checks the field 'error', which is the only relevant to this API method
389
        $return_request = $this->getConnection()->buildRequest('group_mod', $args, $final_options); //returns json and http code of response
390
        if (!$return_request) {
391
            return false;
392
        }
393
394
        return $return_request[0]->result->result;
395
    }
396
}
397

src/APIAccess/User.php 1 location

@@ 240-264 (lines=25) @@
237
     * @link https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Identity_Management_Guide/changing-pwds.html
238
     * @link http://docs.fedoraproject.org/en-US/Fedora/17/html/FreeIPA_Guide/pwd-expiration.html
239
     */
240
    public function modify($login = null, $data = array())
241
    {
242
        if (!$login || !$data) {
243
            return false;
244
        }
245
246
        // Obtained with the command: ipa -vv user_mod tobias --first="testaaaaaa"
247
        $args = array($login);
248
        $default_options = array(
249
            'all' => false,
250
            'no_members' => false,
251
            'random' => false,
252
            'raw' => false,
253
            'rights' => false,
254
        );
255
        $final_options = array_merge($default_options, $data);
256
257
        // The buildRequest() method already checks the field 'error', which is the only relevant to this API method
258
        $return_request = $this->getConnection()->buildRequest('user_mod', $args, $final_options); //returns json and http code of response
259
        if (!$return_request) {
260
            return false;
261
        }
262
263
        return $return_request[0]->result->result;
264
    }
265
    
266
}
267