Tag   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
eloc 10
dl 0
loc 22
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A find_all() 0 10 1
A find_one_by_term() 0 8 2
1
<?php declare(strict_types = 1);
0 ignored issues
show
introduced by
Expected 1 line before declare statement, found 0.
Loading history...
2
3
namespace App\Repositories;
4
5
use App\Entities\Tag as Entity;
6
use App\Entities\Tags;
7
use WPSteak\Repositories\AbstractTerm;
8
9
class Tag extends AbstractTerm {
10
11 2
	public function find_one_by_term( \WP_Term $term ): ?Entity {
12 2
		$term = $this->get_term( $term );
13
14 2
		if ( ! $term ) {
0 ignored issues
show
introduced by
$term is of type WP_Term, thus it always evaluated to true.
Loading history...
15 1
			return null;
16
		}
17
18 1
		return ( new Entity() )->set_term( $term );
19
	}
20
21 1
	public function find_all(): Tags {
22 1
		$terms = $this->get_terms(
23
			[
24 1
				'taxonomy' => Entity::TAXONOMY,
25
				'hide_empty' => false,
26
			],
0 ignored issues
show
introduced by
Trailing comma after the last parameter in function call is disallowed.
Loading history...
27
		);
28
29 1
		return new Tags(
30 1
			...array_map( static fn ( $term ) => ( new Entity() )->set_term( $term ), $terms ),
0 ignored issues
show
introduced by
Trailing comma after the last parameter in function call is disallowed.
Loading history...
31
		);
32
	}
33
34
}
35