1 | <?php |
||
11 | class Matcher implements CanBeSpecified |
||
12 | { |
||
13 | use HasSpecifications; |
||
14 | |||
15 | /** |
||
16 | * Collection instance. |
||
17 | * |
||
18 | * @var \Illuminate\Support\Collection |
||
19 | */ |
||
20 | protected $candidates; |
||
21 | |||
22 | /** |
||
23 | * Create a new Matches instance and instantiates a new Collection. |
||
24 | */ |
||
25 | public function __construct() |
||
29 | |||
30 | /** |
||
31 | * Add an object that implements the CanBeSpecified interface. |
||
32 | * |
||
33 | * @param \Pbmedia\Specifications\Interfaces\CanBeSpecified $candidate |
||
34 | * @return $this |
||
35 | */ |
||
36 | public function addCandidate(CanBeSpecified $candidate): Matcher |
||
42 | |||
43 | /** |
||
44 | * Helper method to add multiple candidates at once. |
||
45 | * |
||
46 | * @param mixed $candidates |
||
47 | * @return $this |
||
48 | */ |
||
49 | public function addCandidates($candidates): Matcher |
||
59 | |||
60 | /** |
||
61 | * Returns a collection containing all candidates. |
||
62 | * |
||
63 | * @return \Illuminate\Support\Collection |
||
64 | */ |
||
65 | public function getCandidates(): Collection |
||
69 | |||
70 | /** |
||
71 | * Returns a collection where the keys matches the keys of the |
||
72 | * candidates Collection but contain the score of the given |
||
73 | * Attribute object. |
||
74 | * |
||
75 | * @param \Pbmedia\Specifications\Interfaces\Attribute $attribute |
||
76 | * @return \Illuminate\Support\Collection |
||
77 | */ |
||
78 | public function getScoresByAttribute(Attribute $attribute): Collection |
||
90 | |||
91 | /** |
||
92 | * This method does the same as the 'getScoresByAttribute' method |
||
93 | * but has the scores normalized. |
||
94 | * |
||
95 | * @param \Pbmedia\Specifications\Interfaces\Attribute $attribute |
||
96 | * @return \Illuminate\Support\Collection |
||
97 | */ |
||
98 | public function getNormalizedScoresByAttribute(Attribute $attribute): Collection |
||
108 | |||
109 | /** |
||
110 | * Returns a collection where the keys matches the keys of the |
||
111 | * candidates Collection but contain the normalized score compaired |
||
112 | * to the given AttributeScore. |
||
113 | * |
||
114 | * @param \Pbmedia\Specifications\AttributeScore $attributeScore |
||
115 | * @return \Illuminate\Support\Collection |
||
116 | */ |
||
117 | public function getMatchingScoreByAttributeScore(AttributeScore $attributeScore): Collection |
||
140 | |||
141 | /** |
||
142 | * Returns a collection where the candidaties are sorted based |
||
143 | * on how close they are to the specifications. |
||
144 | * |
||
145 | * @return \Illuminate\Support\Collection |
||
146 | */ |
||
147 | public function get(): Collection |
||
175 | } |
||
176 |