Completed
Push — IncomprehensibleFinder/SandraA... ( c60dee )
by Albert
02:20
created

FindCoupleByAgeDifference   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 20
c 0
b 0
f 0
wmc 3
lcom 1
cbo 1
ccs 0
cts 7
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A find() 0 8 2
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace Kata\Algorithm;
6
7
final class FindCoupleByAgeDifference
8
{
9
    /** @var CoupleCollection[] */
10
    private $couples;
11
12
    public function __construct(array $people)
13
    {
14
        $this->couples = CoupleCollection::fromPeopleArray($people);
15
    }
16
17
    public function find(int $finder_criteria): Couple
18
    {
19
        if (count($this->couples) < 1) {
20
            return new Couple();
21
        }
22
23
        return $this->couples->getCoupleByAgeCriteria($finder_criteria);
0 ignored issues
show
Bug introduced by
The method getCoupleByAgeCriteria cannot be called on $this->couples (of type array<integer,object<Kat...ithm\CoupleCollection>>).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
24
    }
25
26
}
27