Skip to content

Commit 7729835

Browse files
committed
changes in method names
1 parent 132b653 commit 7729835

3 files changed

Lines changed: 34 additions & 43 deletions

File tree

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@ Here is an example on how to use it:
2222
$chat->disableSendEmailTranscript();
2323
$chat->enableRating('advanced', true);
2424
$chat->setBoxPosition('left', 'side', 20, 120);
25-
$chat->setUserBasicInformation('Johny Depp', 'johny@depp.com');
26-
$chat->addUserExtraInformation('orderTotal', 'Total orders', 150);
27-
$chat->addUserExtraInformation('lastOrder', 'Last ordered', '2015-07-09');
25+
$chat->setName('Johny Depp');
26+
$chat->setEmail('johny@depp.com');
27+
$chat->setVariable('orderTotal', 'Total orders', 150);
28+
$chat->setVariable('lastOrder', 'Last ordered', '2015-07-09');
2829
$chat->setGoogleAnalytics('UA-123456');
2930
$data = $chat->render();
3031
```

src/Smartsupp/ChatGenerator.php

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,6 @@
1515
*/
1616
class ChatGenerator
1717
{
18-
/**
19-
* @var array Values which are allowed for language param.
20-
*/
21-
protected $allowed_languages = array('en', 'fr', 'es', 'de', 'ru', 'cs', 'sk', 'pl', 'hu', 'cn', 'da', 'nl', 'it',
22-
'pt', 'hi', 'ro', 'no');
23-
2418
/**
2519
* @var array Values which are allowed for ratingType param.
2620
*/
@@ -52,7 +46,7 @@ class ChatGenerator
5246
protected $cookie_domain = null;
5347

5448
/**
55-
* @var string Chat language. Can have any value from $this->allowed_language.
49+
* @var string Chat language.
5650
*/
5751
protected $language = 'en';
5852

@@ -150,11 +144,6 @@ public function __construct($key = null)
150144
*/
151145
public function setLanguage($language)
152146
{
153-
if (!in_array($language, $this->allowed_languages)) {
154-
throw new \Exception("Language $language is not allowed value. You can use only one of values: " .
155-
implode(', ', $this->allowed_languages) . ".");
156-
}
157-
158147
$this->language = $language;
159148
}
160149

@@ -225,16 +214,24 @@ public function enableRating($rating_type = 'simple', $rating_comment = false)
225214
}
226215

227216
/**
228-
* You can send basic information about web visitors from your database to Smartsupp (name, email). So your visitors
229-
* won't be anonymous and your chat agents will see info about every visitor, enabling agents to better focus on VIP
230-
* visitors and provide customized answers.
217+
* You can send visitor name. So your visitors won't be anonymous and your chat agents will see info about every
218+
* visitor, enabling agents to better focus on VIP visitors and provide customized answers.
231219
*
232-
* @param $name User name.
233-
* @param $email User e-mail address.
220+
* @param string $name
234221
*/
235-
public function setUserBasicInformation($name, $email)
222+
public function setName($name)
236223
{
237224
$this->name = $name;
225+
}
226+
227+
/**
228+
* You can send visitor email. So your visitors won't be anonymous and your chat agents will see info about every
229+
* visitor, enabling agents to better focus on VIP visitors and provide customized answers.
230+
*
231+
* @param string $name
232+
*/
233+
public function setEmail($email)
234+
{
238235
$this->email = $email;
239236
}
240237

@@ -245,7 +242,7 @@ public function setUserBasicInformation($name, $email)
245242
* @param $label Parameter label.
246243
* @param $value Parameter value.
247244
*/
248-
public function addUserExtraInformation($id, $label, $value)
245+
public function setVariable($id, $label, $value)
249246
{
250247
$variable = array('id' => $id, 'label' => $label, 'value' => $value);
251248

@@ -262,7 +259,7 @@ public function addUserExtraInformation($id, $label, $value)
262259
* @param int $offset_y Offset from top.
263260
* @throws \Exception When params are not correct.
264261
*/
265-
public function setBoxPosition($align_x = 'right', $align_y = 'bottom', $offset_x = 10, $offset_y = 100)
262+
public function setAlign($align_x = 'right', $align_y = 'bottom', $offset_x = 10, $offset_y = 100)
266263
{
267264
if (!in_array($align_x, $this->allowed_align_x)) {
268265
throw new \Exception("AllignX value $align_x is not allowed value. You can use only one of values: " .

tests/ChatGeneratorTest.php

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public function test_widget_badParam()
7777

7878
public function test_setBoxPosition()
7979
{
80-
$this->chat->setBoxPosition('left', 'side', 20, 120);
80+
$this->chat->setAlign('left', 'side', 20, 120);
8181

8282
$this->assertEquals('left', self::getPrivateField($this->chat, 'align_x'));
8383
$this->assertEquals('side', self::getPrivateField($this->chat, 'align_y'));
@@ -91,7 +91,7 @@ public function test_setBoxPosition()
9191
*/
9292
public function test_setBoxPosition_badParam()
9393
{
94-
$this->chat->setBoxPosition('foo', 'side', 20, 120);
94+
$this->chat->setAlign('foo', 'side', 20, 120);
9595
}
9696

9797
/**
@@ -100,13 +100,13 @@ public function test_setBoxPosition_badParam()
100100
*/
101101
public function test_setBoxPosition_badParam2()
102102
{
103-
$this->chat->setBoxPosition('left', 'foo', 20, 120);
103+
$this->chat->setAlign('left', 'foo', 20, 120);
104104
}
105105

106-
public function test_addUserExtraInformation()
106+
public function test_setVariable()
107107
{
108-
$this->chat->addUserExtraInformation('userId', 'User ID', 123);
109-
$this->chat->addUserExtraInformation('orderedPrice', 'Ordered Price in Eshop', '128 000');
108+
$this->chat->setVariable('userId', 'User ID', 123);
109+
$this->chat->setVariable('orderedPrice', 'Ordered Price in Eshop', '128 000');
110110

111111
$this->assertEquals(
112112
array(
@@ -119,7 +119,8 @@ public function test_addUserExtraInformation()
119119

120120
public function test_setUserBasicInformation()
121121
{
122-
$this->chat->setUserBasicInformation('Johny Depp', 'johny@depp.com');
122+
$this->chat->setName('Johny Depp');
123+
$this->chat->setEmail('johny@depp.com');
123124

124125
$this->assertEquals('Johny Depp', self::getPrivateField($this->chat, 'name'));
125126
$this->assertEquals('johny@depp.com', self::getPrivateField($this->chat, 'email'));
@@ -178,15 +179,6 @@ public function test_setLanguage()
178179
$this->assertEquals('cs', self::getPrivateField($this->chat, 'language'));
179180
}
180181

181-
/**
182-
* @expectedException \Exception
183-
* @expectedExceptionMessage Language us is not allowed value. You can use only one of values: en, fr, es, de, ru, cs, sk, pl, hu, cn, da, nl, it, pt, hi, ro, no.
184-
*/
185-
public function test_setLanguage_badParam()
186-
{
187-
$this->chat->setLanguage('us');
188-
}
189-
190182
/**
191183
* @expectedException \Exception
192184
* @expectedExceptionMessage At least KEY param must be set!
@@ -235,11 +227,12 @@ public function test_render_allParams()
235227
$this->chat->setCookieDomain('.foo.bar');
236228
$this->chat->disableSendEmailTranscript();
237229
$this->chat->enableRating('advanced', true);
238-
$this->chat->setBoxPosition('left', 'side', 20, 120);
230+
$this->chat->setAlign('left', 'side', 20, 120);
239231
$this->chat->setWidget('button');
240-
$this->chat->setUserBasicInformation('Johny Depp', 'johny@depp.com');
241-
$this->chat->addUserExtraInformation('orderTotal', 'Total orders', 150);
242-
$this->chat->addUserExtraInformation('lastOrder', 'Last ordered', '2015-07-09');
232+
$this->chat->setName('Johny Depp');
233+
$this->chat->setEmail('johny@depp.com');
234+
$this->chat->setVariable('orderTotal', 'Total orders', 150);
235+
$this->chat->setVariable('lastOrder', 'Last ordered', '2015-07-09');
243236
$this->chat->setGoogleAnalytics('UA-123456', array('cookieDomain' => '.foo.bar'));
244237
$this->chat->hideWidget();
245238

0 commit comments

Comments
 (0)