Completed
Push — master ( c75724...87d358 )
by Razon
03:04
created

ArticleLikeForm::handleInternal()   A

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($this->id, $this->getUser()->getId());
0 ignored issues
show
Bug introduced by
It seems like $this->getUser()->getId() can also be of type string; however, parameter $userId of App\Factory\ArticleLikeFactory::create() does only seem to accept integer, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

18
        $like = ArticleLikeFactory::create($this->id, /** @scrutinizer ignore-type */ $this->getUser()->getId());
Loading history...
19
        if (!$like->save()) {
20
            $this->addErrors($like->getErrors());
21
        }
22
    }
23
}