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

ArticleLikeForm   A

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($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
}