ArticleLikeForm   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 8
c 1
b 0
f 0
dl 0
loc 15
ccs 0
cts 9
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A handleInternal() 0 11 3
1
<?php
2
namespace App\Http\Api\Form;
3
4
use App\Factory\ArticleLikeFactory;
5
6
class ArticleLikeForm extends BaseArticleLikeForm
7
{
8
    use UserTrait;
9
    
10
    protected function handleInternal()
11
    {
12
        $like = $this->getLike();
13
        if ($like) {
14
            return;
15
        }
16
17
        // creates new like record
18
        $like = ArticleLikeFactory::create((int) $this->id, (int) $this->getUser()->getId());
19
        if (!$like->save()) {
20
            $this->addErrors($like->getErrors());
21
        }
22
    }
23
}
24