Skip to content

Commit bbf8142

Browse files
authored
Merge pull request #2 from noplanman/develop
Add latest changes, check commit messages...
2 parents 852ed19 + 8429eaf commit bbf8142

File tree

9 files changed

+906
-400
lines changed

9 files changed

+906
-400
lines changed

.travis.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
dist: trusty
2+
sudo: required
3+
language: php
4+
5+
addons:
6+
apt:
7+
packages:
8+
- mysql-server-5.6
9+
- mysql-client-core-5.6
10+
- mysql-client-5.6
11+
12+
cache:
13+
directories:
14+
- $HOME/.composer/cache
15+
16+
php:
17+
- 5.6
18+
- 7.0
19+
- nightly
20+
- hhvm
21+
22+
matrix:
23+
allow_failures:
24+
- php: nightly
25+
- php: hhvm
26+
fast_finish: true
27+
28+
notifications:
29+
on_success: never
30+
on_failure: always
31+
32+
git:
33+
depth: 1
34+
35+
install:
36+
- travis_retry composer install --prefer-dist --no-interaction
37+
38+
before_script:
39+
- mysql -u root -e 'create database telegrambot; use telegrambot; source ./vendor/longman/telegram-bot/structure.sql;'
40+
41+
script:
42+
- |
43+
if [[ "$TRAVIS_PHP_VERSION" == "7.0" ]] ; then
44+
./vendor/bin/phpunit --coverage-clover=coverage.xml
45+
else
46+
./vendor/bin/phpunit
47+
fi
48+
49+
after_success:
50+
- if [[ "$TRAVIS_PHP_VERSION" == "7.0" ]]; then bash <(curl -s https://codecov.io/bash); fi
51+
52+
env:
53+
global:
54+
- secure: GBCpDTilQLXC7eLvAWLWu/NofSvC9jRDVXqNsNQMVyeoCLj0BIneHe0Tbuz6AHGbI6iRcr+ft9ZraUUAmQ2NSuIG3XpPwSUz/Qt0DQVDqYrTYTHiiThAC/UkvdWnGtHteds46MGAnh0B1IPpQF7XCaFxb8qT2+z+icOoZcAOJ4Exr/tL0opidN/8AJGRt3bXUOm7UgGQ+5HCLKvx/oGAqeafpYLlayzTFw/CBYR2Gp5vbo43yYO6MstMsgpHg+CR8iPLB0P5PXoKme5z7jDtJVmC8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CSrpVR/2zFzFWw=

phpunit.xml.dist

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,9 @@
1616
<ini name="date.timezone" value="UTC"/>
1717
<ini name="error_reporting" value="-1" />
1818
<const name="PHPUNIT_TEST" value="true" />
19+
<const name="PHPUNIT_DB_HOST" value="127.0.0.1"/>
20+
<const name="PHPUNIT_DB_NAME" value="telegrambot"/>
21+
<const name="PHPUNIT_DB_USER" value="root"/>
22+
<const name="PHPUNIT_DB_PASS" value=""/>
1923
</php>
2024
</phpunit>

src/Action.php

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<?php
2+
/**
3+
* This file is part of the TelegramBotManager package.
4+
*
5+
* (c) Armando Lüscher <armando@noplanman.ch>
6+
*
7+
* For the full copyright and license information, please view the LICENSE
8+
* file that was distributed with this source code.
9+
*/
10+
11+
namespace NPM\TelegramBotManager;
12+
13+
class Action
14+
{
15+
/**
16+
* @var array List of valid actions that can be called.
17+
*/
18+
private static $valid_actions = [
19+
'set',
20+
'unset',
21+
'reset',
22+
'handle',
23+
];
24+
25+
/**
26+
* @var string Action to be executed.
27+
*/
28+
private $action;
29+
30+
/**
31+
* Action constructor.
32+
*
33+
* @param string $action
34+
*
35+
* @throws \InvalidArgumentException
36+
*/
37+
public function __construct($action = 'handle')
38+
{
39+
$this->action = $action ?: 'handle';
40+
41+
if (!$this->isAction(self::$valid_actions)) {
42+
throw new \InvalidArgumentException('Invalid action');
43+
}
44+
}
45+
46+
/**
47+
* Check if the current action is one of the passed ones.
48+
*
49+
* @param string|array $actions
50+
*
51+
* @return bool
52+
*/
53+
public function isAction($actions)
54+
{
55+
return in_array($this->action, (array)$actions, true);
56+
}
57+
58+
/**
59+
* Return the current action.
60+
*
61+
* @return string
62+
*/
63+
public function getAction()
64+
{
65+
return $this->action;
66+
}
67+
}

0 commit comments

Comments
 (0)