Code Duplication    Length = 8-10 lines in 5 locations

src/Controller/BlogController.php 4 locations

@@ 520-529 (lines=10) @@
517
518
        $json = [];
519
520
        if (!is_null($checkLike)) {
521
            $json['message'] = __('You already like this article !');
522
            $json['error'] = true;
523
524
            $this->set(compact('json'));
525
526
            $this->set('_serialize', 'json');
527
528
            return;
529
        }
530
531
        //Check if the article exist.
532
        $this->loadModel('BlogArticles');
@@ 541-549 (lines=9) @@
538
            ])
539
            ->first();
540
541
        if (is_null($checkArticle)) {
542
            $json['message'] = __("This article doesn't exist !");
543
            $json['error'] = true;
544
545
            $this->set(compact('json'));
546
            $this->set('_serialize', 'json');
547
548
            return;
549
        }
550
551
        //Prepare data to be saved.
552
        $data = [];
@@ 614-623 (lines=10) @@
611
612
        $json = [];
613
614
        if (is_null($like)) {
615
            $json['message'] = __("You don't like this article !");
616
            $json['error'] = true;
617
618
            $this->set(compact('json'));
619
620
            $this->set('_serialize', 'json');
621
622
            return;
623
        }
624
625
        if ($this->BlogArticlesLikes->delete($like)) {
626
            //Update the Statistics
@@ 732-739 (lines=8) @@
729
            'errorMessage' => ''
730
        ];
731
732
        if (is_null($comment)) {
733
            $json['error'] = true;
734
            $json['errorMessage'] = __("This comment doesn't exist or has been deleted !");
735
736
            $this->set(compact('json'));
737
738
            return;
739
        }
740
741
        //Current user.
742
        $this->loadModel('Users');

src/Controller/ConversationsController.php 1 location

@@ 569-576 (lines=8) @@
566
            'errorMessage' => ''
567
        ];
568
569
        if (is_null($message)) {
570
            $json['error'] = true;
571
            $json['errorMessage'] = __d('conversations', "This message doesn't exist or has been deleted !");
572
573
            $this->set(compact('json'));
574
575
            return;
576
        }
577
578
        //Current user.
579
        $this->loadModel('Users');