Passed
Push — hypernext ( d18b5c...96a12c )
by Nico
12:00
created

InsertTagsTrait   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 8
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 8
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A insertTags() 0 5 2
1
<?php declare(strict_types=1);
2
/**
3
 * @author Nicolas CARPi <[email protected]>
4
 * @copyright 2012 Nicolas CARPi
5
 * @see https://www.elabftw.net Official website
6
 * @license AGPL-3.0
7
 * @package elabftw
8
 */
9
10
namespace Elabftw\Traits;
11
12
use Elabftw\Elabftw\ContentParams;
13
14
/**
15
 * For inserting tags during creation
16
 */
17
trait InsertTagsTrait
18
{
19
    // insert the tags from the extraParams
20
    private function insertTags(array $tags, int $id): void
21
    {
22
        $newEntity = new self($this->Users, $id);
0 ignored issues
show
Unused Code introduced by
The call to Elabftw\Traits\InsertTagsTrait::__construct() has too many arguments starting with $this->Users. ( Ignorable by Annotation )

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

22
        $newEntity = /** @scrutinizer ignore-call */ new self($this->Users, $id);

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
23
        foreach ($tags as $tag) {
24
            $newEntity->Tags->create(new ContentParams($tag));
25
        }
26
    }
27
}
28