src/Matcher.php
public function getMatchingScoreByAttributeScore(AttributeScore $attributeScore): Collection
    {
        $attribute  = $attributeScore->getAttribute();
        $scoreValue = $attributeScore->getScoreValue();

        $scores = $this->getScoresByAttribute($attribute);

        if (!$scores->max()) {
            return $this->candidates->map(function () {
                return 0;
            });
        }

        $scoreToCompareTo = $scoreValue / $scores->max();

        return $this->getNormalizedScoresByAttribute($attribute)->map(function ($normalizedScore) use ($scoreToCompareTo) {
            if ($normalizedScore === null) {
                return null;
            }

            return 1 - abs($normalizedScore - $scoreToCompareTo);
        });
    }
public function getMatchingScoreByAttributeScore(AttributeScore $attributeScore): Collection
    {
        $attribute  = $attributeScore->getAttribute();
        $scoreValue = $attributeScore->getScoreValue();

        $scores = $this->getScoresByAttribute($attribute);

        if (!$scores->max()) {
            return $this->candidates->map(function () {
                return 0;
            });
        }

        $scoreToCompareTo = $scoreValue / $scores->max();

        return $this->getNormalizedScoresByAttribute($attribute)->map(function ($normalizedScore) use ($scoreToCompareTo) {
            if ($normalizedScore === null) {
                return null;
            }

            return 1 - abs($normalizedScore - $scoreToCompareTo);
        });
    }
public function getMatchingScoreByAttributeScore ( AttributeScore $ attributeScore ) : Collection { $ attribute = $ attributeScore -> getAttribute ( ) ; $ scoreValue = $ attributeScore -> getScoreValue ( ) ; $ scores = $ this -> getScoresByAttribute ( $ attribute ) ; if ( ! $ scores -> max ( ) ) { return $ this -> candidates -> map ( function ( ) { return 0 ; } ) ; } $ scoreToCompareTo = $ scoreValue / $ scores -> max ( ) ; return $ this -> getNormalizedScoresByAttribute ( $ attribute ) -> map ( function ( $ normalizedScore ) use ( $ scoreToCompareTo ) { if ( $ normalizedScore === null ) { return null ; } return 1 - abs ( $ normalizedScore - $ scoreToCompareTo ) ; } ) ; }
Returns a collection where the keys matches the keys of the
candidates Collection but contain the normalized score compaired
to the given AttributeScore.

@param  \Pbmedia\Specifications\AttributeScore  $attributeScore
@return \Illuminate\Support\Collection
Returns a collection where the keys matches the keys of the candidates Collection but contain the normalized score compaired to the given AttributeScore .