Test Setup Failed
Push — master ( b47f60...e53ccf )
by Georgi
03:15
created

HasEpesiConnection::addCrits()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 3
nc 2
nop 1
dl 0
loc 7
rs 10
c 1
b 0
f 0
1
<?php
2
3
namespace Epesi\Core\Data;
4
5
trait HasEpesiConnection
6
{
7
	/**
8
	 * Create atk4 model and assign default persistence
9
	 * 
10
	 * @param array $defaults
11
	 * 
12
	 * @return \atk4\data\Model
13
	 */
14
	public static function create($defaults = [])
15
	{
16
		$atkDb = app()->make(Persistence\SQL::class);
17
		
18
		return new static($atkDb, $defaults);
0 ignored issues
show
Unused Code introduced by
The call to Epesi\Core\Data\HasEpesiConnection::__construct() has too many arguments starting with $atkDb. ( Ignorable by Annotation )

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

18
		return /** @scrutinizer ignore-call */ new static($atkDb, $defaults);

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...
Bug Best Practice introduced by
The expression return new static($atkDb, $defaults) returns the type Epesi\Core\Data\HasEpesiConnection which is incompatible with the documented return type atk4\data\Model.
Loading history...
19
	}
20
	
21
	public static function migrate()
22
	{
23
		return (new \atk4\schema\Migration(static::create()))->create();
24
	}
25
	
26
	/**
27
	 * Get the values of a given key.
28
	 *
29
	 * @param  string|array  $value
30
	 * @param  string|null  $key
31
	 * @return static
32
	 */
33
	public static function pluck($value, $key = null)
34
	{
35
	    return collect(self::create()->export())->pluck($value, $key);
0 ignored issues
show
Bug Best Practice introduced by
The expression return collect(self::cre...))->pluck($value, $key) returns the type Illuminate\Support\Collection which is incompatible with the documented return type Epesi\Core\Data\HasEpesiConnection.
Loading history...
36
	}
37
}