Skip to content

Commit

Permalink
Merge pull request #7 from ksimka/fix_strlen
Browse files Browse the repository at this point in the history
Replace `strlen` with `mb_strlen`, require `mbstring`.
  • Loading branch information
tgallice committed May 24, 2016
2 parents b2c4023 + 7fadb09 commit 4628305
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
},
"require": {
"php": ">=5.5.9",
"ext-mbstring": "*",
"guzzlehttp/guzzle": "^6.2"
},
"require-dev": {
Expand Down
2 changes: 1 addition & 1 deletion src/Message/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function __construct($recipientId, $messageData, $notificationType = Noti
{
$this->recipient = $recipientId;

if (is_string($messageData) && strlen($messageData) > 320) {
if (is_string($messageData) && mb_strlen($messageData) > 320) {
throw new \InvalidArgumentException('The text message should not exceed 320 characters');
}

Expand Down
2 changes: 1 addition & 1 deletion src/Model/Button.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function getTitle()
*/
protected function validateTitleSize($title)
{
if (strlen($title) > 20) {
if (mb_strlen($title) > 20) {
throw new \InvalidArgumentException('A call to action title field should not exceed 20 characters');
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Model/Generic/Element.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,11 @@ public function jsonSerialize()

private function validateElement()
{
if (strlen($this->title) > 45) {
if (mb_strlen($this->title) > 45) {
throw new \InvalidArgumentException('In a generic element, the "title" field should not exceed 45 characters');
}

if (!empty($this->subtitle) && strlen($this->subtitle) > 80) {
if (!empty($this->subtitle) && mb_strlen($this->subtitle) > 80) {
throw new \InvalidArgumentException('In a generic element, the "subtitle" field should not exceed 80 characters');
}

Expand Down

0 comments on commit 4628305

Please sign in to comment.