Test Setup Failed
Push — develop ( 67f164...d5fe8d )
by Elvis Henrique
03:02
created

Category   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
eloc 12
dl 0
loc 38
c 0
b 0
f 0
ccs 12
cts 12
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A find_all() 0 15 2
A find_one() 0 8 2
1
<?php
2
/**
3
 * Category.
4
 *
5
 * @package App
6
 */
7
8
declare(strict_types=1);
9
10
namespace App\Repositories;
11
12
use App\Entities\Category as Entity;
13
use WPSteak\Entities\Collection;
0 ignored issues
show
Bug introduced by
The type WPSteak\Entities\Collection was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
14
use WPSteak\Repositories\AbstractTerm;
0 ignored issues
show
Bug introduced by
The type WPSteak\Repositories\AbstractTerm was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
15
16
/**
17
 * Category class.
18
 */
19
class Category extends AbstractTerm {
20
21
	/**
22
	 * Find one.
23
	 *
24
	 * @param \WP_Term|int $term The term object or id.
25
	 * @return Entity|null
26 2
	 */
27 2
	public function find_one( $term ) : ?Entity {
28
		$term = $this->get_term( $term );
29 2
30 1
		if ( empty( $term ) ) {
31
			return null;
32
		}
33 1
34
		return ( new Entity() )->set_term( $term );
35
	}
36
37
	/**
38
	 * Find all.
39
	 *
40
	 * @return Collection
41 1
	 */
42 1
	public function find_all() : Collection {
43
		$terms = $this->get_terms(
44 1
			[
45
				'taxonomy'   => Entity::TAXONOMY,
46
				'hide_empty' => false,
47
			]
48
		);
49 1
50
		$collection = new Collection();
51 1
52 1
		foreach ( $terms as $term ) {
53
			$collection->add_entity( ( new Entity() )->set_term( $term ) );
54
		}
55 1
56
		return $collection;
57
	}
58
}
59