Skip to content

Commit

Permalink
Full tests coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
Ilya S. Zobenko committed Aug 24, 2019
1 parent 1abe486 commit 7ddf4dd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
],
"require": {
"php": ">=7.2",
"telegram-bot/api": "^2.3"
"telegram-bot/api": "^2.3",
"ext-curl": "^7.2"
},
"require-dev": {
"phpunit/phpunit": "^8"
Expand Down
18 changes: 11 additions & 7 deletions src/Telegram/Messenger.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,22 +182,26 @@ public function sendScreen(MessengerScreen $screen): bool
return $result;
}

/**
* @param ScreenItemInterface $item
* @param array $buttons
* @return bool
* @throws AccessTokenException
* @throws AttachmentNotFoundException
* @throws TargetUserException
*/
private function workWithScreenItem(ScreenItemInterface $item, array $buttons = []): bool
{
$class = get_class($item);
switch ($class) {
case \He110\CommunicationTools\ScreenItems\Message::class:
return $this->sendMessage($item->getText(), $buttons);
break;
case File::class:
$method = $item->getType() == File::FILE_TYPE_IMAGE ? "sendImage" : "sendDocument";
return $this->{$method}($item->getPath(), $item->getDescription());
break;
case Voice::class:
return $this->sendVoice($item->getPath());
break;
default:
$method = $item->getType() == File::FILE_TYPE_IMAGE ? "sendImage" : "sendDocument";
return $this->{$method}($item->getPath(), $item->getDescription());
}
return false;
}

/**
Expand Down

0 comments on commit 7ddf4dd

Please sign in to comment.