GuesserManager   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 1
cbo 1
dl 0
loc 23
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A addGuesser() 0 6 1
A find() 0 10 3
1
<?php
2
3
namespace Knp\FriendlyContexts\Guesser;
4
5
class GuesserManager
6
{
7
    protected $classes = [];
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 2 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
8
    protected $guessers = [];
9
10
    public function addGuesser(GuesserInterface $guesser)
11
    {
12
        $guesser->setManager($this);
13
14
        array_unshift($this->guessers, $guesser);
15
    }
16
17
    public function find($mapping)
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
18
    {
19
        foreach ($this->guessers as $g) {
20
            if ($g->supports($mapping)) {
21
                return $g;
22
            }
23
        }
24
25
        return false;
26
    }
27
}
28