Code Duplication    Length = 18-18 lines in 2 locations

models/User.php 2 locations

@@ 484-501 (lines=18) @@
481
     * If null, use global setting Module::$enableBlockingEmail
482
     * @return bool return false if user already blocked or not confirmed
483
     */
484
    public function block($sendMail = null)
485
    {
486
        if ($this->isBlocked() || !$this->isConfirmed()) {
487
            return false;
488
        }
489
        if ($sendMail === null) {
490
            $sendMail = $this->module->enableBlockingEmail;
491
        }
492
        $this->updateAttributes([
493
            'status' => self::STATUS_BLOCKED
494
        ]);
495
        if ($sendMail) {
496
            $this->module->sendMessage('block', [
497
                'user' => $this,
498
            ]);
499
        }
500
        return true;
501
    }
502
503
    /**
504
     * Unblock user
@@ 509-526 (lines=18) @@
506
     * If null, use global setting Module::$enableUnblockingEmail
507
     * @return bool return false if user not blocked
508
     */
509
    public function unblock($sendMail = null)
510
    {
511
        if (!$this->isBlocked()) {
512
            return false;
513
        }
514
        if ($sendMail === null) {
515
            $sendMail = $this->module->enableBlockingEmail;
516
        }
517
        $this->updateAttributes([
518
            'status' => self::STATUS_ACTIVE
519
        ]);
520
        if ($sendMail) {
521
            $this->module->sendMessage('unblock', [
522
                'user' => $this,
523
            ]);
524
        }
525
        return true;
526
    }
527
528
    /**
529
     * Change the user password