ArticleLikeForm::handleInternal()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 11
ccs 0
cts 9
cp 0
rs 10
cc 3
nc 3
nop 0
crap 12
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