/** * Resolve the problem dilemma. * * @param \FindBrok\TradeoffAnalytics\Support\DataCollection\Problem $problem * @param bool $generateVisualization * * @throws \FindBrok\WatsonBridge\Exceptions\WatsonBridgeException * * @return \FindBrok\TradeoffAnalytics\Support\DataCollection\Dilemma */ public function getDilemma(Problem $problem, $generateVisualization = true) { //Get Response from Watson $response = $this->makeBridge()->post('v1/dilemmas?generate_visualization=' . var_export($generateVisualization, true), $problem->statement()); //Get Response content return make_tradeoff_dilemma(json_decode($response->getBody()->getContents(), true)); }
/** * Test that we can add ProblemOption to Problem object. * * @return void */ public function testAddOptionsToProblemObject() { $options = [$this->app->make('TradeoffProblemOption', ['key' => '123', 'name' => 'Some name']), $this->app->make('TradeoffProblemOption', ['key' => '456', 'name' => 'Another name'])]; $this->problem->addOptions($options); $this->assertCount(2, $this->problem->get('options')); $this->problem->addOptions($this->app->make('TradeoffProblemOption', ['key' => '789', 'name' => 'My name'])); $this->assertCount(3, $this->problem->get('options')); }