Skip to content
This repository was archived by the owner on Aug 12, 2022. It is now read-only.

Commit 2ada4eb

Browse files
committed
merge master in develop
2 parents 6052e58 + 3a442a2 commit 2ada4eb

File tree

2 files changed

+50
-8
lines changed

2 files changed

+50
-8
lines changed

src/Conversation.php

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,15 @@ public function __construct($json)
1414
// var_dump($json);
1515
$response = json_decode($json->body);
1616

17-
$this->raw = $response->results;
17+
$this->raw = $response->results;
1818
$this->replies = $response->results->replies;
1919
$this->action = $response->results->action;
2020
$this->nextActions = $response->results->next_actions;
21+
$this->sentiment = $response->results->sentiment;
2122
$this->memory = $response->results->memory;
2223
$this->conversationToken = $response->results->conversation_token;
24+
$this->language = $response->results->language;
25+
$this->processing_language = $response->results->processing_language;
2326
}
2427

2528
/**
@@ -92,6 +95,49 @@ public function memory($name = null)
9295
}
9396
}
9497

98+
/**
99+
* SENTIMENT HELPERS
100+
* Returns whether or not the response sentiment corresponds to the checked one
101+
* @return {boolean}: true or false
102+
*/
103+
104+
public function isPositive()
105+
{
106+
return ($this->sentiment === Constants::SENTIMENT_POSITIVE);
107+
}
108+
109+
/**
110+
* @return bool
111+
*/
112+
public function isNeutral()
113+
{
114+
return ($this->sentiment === Constants::SENTIMENT_NEUTRAL);
115+
}
116+
117+
/**
118+
* @return bool
119+
*/
120+
public function isNegative()
121+
{
122+
return ($this->sentiment === Constants::SENTIMENT_NEGATIVE);
123+
}
124+
125+
/**
126+
* @return bool
127+
*/
128+
public function isVPositive()
129+
{
130+
return ($this->sentiment === Constants::SENTIMENT_VPOSITIVE);
131+
}
132+
133+
/**
134+
* @return bool
135+
*/
136+
public function isVNegative()
137+
{
138+
return ($this->sentiment === Constants::SENTIMENT_VNEGATIVE);
139+
}
140+
95141
/**
96142
* Merge the conversation memory with the one in parameter
97143
* Returns the memory updated

src/Response.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,10 @@ class Response
1515
*/
1616
public function __construct($json)
1717
{
18-
var_dump($json);
1918
$response = json_decode($json->body);
2019
$this->entities = [];
2120

22-
$this->raw = $response->results;
21+
$this->raw = $response->results;
2322
$this->act = $response->results->act;
2423
$this->type = $response->results->type;
2524
$this->source = $response->results->source;
@@ -34,6 +33,7 @@ public function __construct($json)
3433

3534
$this->uuid = $response->results->uuid;
3635
$this->language = $response->results->language;
36+
$this->processing_language = $response->results->processing_language;
3737
$this->version = $response->results->version;
3838
$this->timestamp = $response->results->timestamp;
3939
$this->status = $response->results->status;
@@ -82,11 +82,7 @@ public function all($name)
8282
*/
8383
public function intent()
8484
{
85-
if ($this->intents[0]) {
86-
return ($this->intents[0]);
87-
}
88-
89-
return (null);
85+
return ($this->intents[0] || null);
9086
}
9187

9288
/**

0 commit comments

Comments
 (0)