StatsTrait::create()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 6
c 1
b 0
f 1
dl 0
loc 8
ccs 0
cts 7
cp 0
rs 10
cc 1
nc 1
nop 3
crap 2
1
<?php
2
3
namespace ByTIC\DocumentGenerator\PdfLetters\Models\Stats;
4
5
use ByTIC\DocumentGenerator\Tests\Fixtures\Models\PdfLetters\PdfLetter;
6
use Nip\Records\AbstractModels\Record;
7
use Nip\Records\Traits\AbstractTrait\RecordsTrait as AbstractRecordsTrait;
8
9
/**
10
 * Class StatsTrait
11
 * @package ByTIC\DocumentGenerator\PdfLetters\Models\Stats
12
 *
13
 * @method StatTrait getNew
14
 */
15
trait StatsTrait
16
{
17
    use AbstractRecordsTrait;
18
19
    /**
20
     * @param PdfLetter|Record $letter
21
     */
22
    public function compileForLetter($letter)
0 ignored issues
show
Unused Code introduced by
The parameter $letter is not used and could be removed. ( Ignorable by Annotation )

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

22
    public function compileForLetter(/** @scrutinizer ignore-unused */ $letter)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
23
    {
24
    }
25
26
    /**
27
     * @param $letter
28
     * @param $related
29
     * @param $value
30
     * @return StatTrait
31
     */
32
    public function create($letter, $related, $value)
33
    {
34
        $stat = $this->getNew();
35
        $stat->populateFromLetter($letter);
36
        $stat->populateFromRelated($related);
37
        $stat->value = $value;
38
        $stat->insert();
0 ignored issues
show
Bug introduced by
It seems like insert() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

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

38
        $stat->/** @scrutinizer ignore-call */ 
39
               insert();
Loading history...
39
        return $stat;
40
    }
41
}
42