StatsTrait   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 8 1
A compileForLetter() 0 2 1
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