add() public method

public add ( GraphAware\Common\Type\Node $item, string $name, SingleScore $singleScore )
$item GraphAware\Common\Type\Node
$name string
$singleScore SingleScore
 public function testResultGetTwoScoresIfDiscoveredTwice()
 {
     $node = FakeNode::createDummy();
     $list = new Recommendations();
     $list->add($node, 'e1', new SingleScore(1));
     $list->add($node, 'e2', new SingleScore(1));
     $this->assertEquals(1, $list->size());
     $this->assertEquals(2, $list->getItems()[0]->totalScore());
     $this->assertCount(2, $list->get(0)->getScores());
     $this->assertArrayHasKey('e1', $list->get(0)->getScores());
     $this->assertArrayHasKey('e2', $list->get(0)->getScores());
 }
 public function testReasons()
 {
     $node = FakeNode::createDummy();
     $list = new Recommendations(new SimpleContext());
     $list->add($node, 'disc1', new SingleScore(1, 'reason1'));
     $list->add($node, 'disc1', new SingleScore(1, 'reason2'));
     $list->add($node, 'disc2', new SingleScore(3, 'reason3'));
     for ($i = 0; $i < 10; ++$i) {
         $list->add($node, 'disc3', new SingleScore(1, 'reasond' . $i));
     }
     $reco = $list->get(0);
     $this->assertEquals(15, $reco->totalScore());
     $this->assertArrayHasKey('disc3', $reco->getScores());
     $this->assertCount(10, $reco->getScore('disc3')->getScores());
 }
 public function getRecommendationsFromResult(NodeInterface $input, ResultCollection $resultCollection, DiscoveryEngine $engine, Recommendations $recommendations)
 {
     $result = $resultCollection->get($engine->name());
     foreach ($result->records() as $record) {
         $recommendations->add($record->value('reco'), new Score($engine->buildScore($input, $record->value($engine->recoResultName()), $record)));
     }
 }
 public final function produceRecommendations(NodeInterface $input, ResultCollection $resultCollection)
 {
     $result = $resultCollection->get($this->name());
     $recommendations = new Recommendations($this->name());
     foreach ($result->records() as $record) {
         if ($record->hasValue($this->recoResultName())) {
             $recommendations->add($record->value($this->recoResultName()), $this->name(), $this->buildScore($input, $record->value($this->recoResultName()), $record));
         }
     }
     return $recommendations;
 }