-
-
Notifications
You must be signed in to change notification settings - Fork 951
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Code rewrited on PSR-2 standard. Added CONTRIBUTING.md for contributors
- Loading branch information
1 parent
e12787a
commit 80ce398
Showing
19 changed files
with
1,269 additions
and
1,385 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
Contributing | ||
------------- | ||
|
||
Before you contribute code to php-telegram-bot, please make sure it conforms to the PHPCS coding standard and that the php-telegram-bot unit tests still pass. The easiest way to contribute is to work on a checkout of the repository, or your own fork, rather than an installed PEAR version. If you do this, you can run the following commands to check if everything is ready to submit: | ||
|
||
cd php-telegram-bot | ||
composer update | ||
vendor/bin/phpcs --report=full --extensions=php -p --standard=build/phpcs . | ||
|
||
Which should give you no output, indicating that there are no coding standard errors. And then: | ||
|
||
phpunit | ||
|
||
Which should give you no failures or errors. You can ignore any skipped tests as these are for external tools. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,67 +1,25 @@ | ||
<?xml version="1.0"?> | ||
<ruleset name="Package"> | ||
<description>The Package coding standard.</description> | ||
<description>The Package coding standard.</description> | ||
|
||
<!-- Exclude folders not containing production code --> | ||
<exclude-pattern type="relative">build/*</exclude-pattern> | ||
<exclude-pattern type="relative">docs/*</exclude-pattern> | ||
<exclude-pattern type="relative">tests/*</exclude-pattern> | ||
<exclude-pattern type="relative">cache/*</exclude-pattern> | ||
<exclude-pattern type="relative">tmp/*</exclude-pattern> | ||
<exclude-pattern type="relative">logs/*</exclude-pattern> | ||
<!-- Exclude folders not containing production code --> | ||
<exclude-pattern type="relative">build/*</exclude-pattern> | ||
<exclude-pattern type="relative">docs/*</exclude-pattern> | ||
<exclude-pattern type="relative">tests/*</exclude-pattern> | ||
<exclude-pattern type="relative">cache/*</exclude-pattern> | ||
<exclude-pattern type="relative">tmp/*</exclude-pattern> | ||
<exclude-pattern type="relative">logs/*</exclude-pattern> | ||
|
||
<!-- Exclude 3rd party libraries and Framework code. --> | ||
<exclude-pattern type="relative">vendor/*</exclude-pattern> | ||
<!-- Exclude 3rd party libraries and Framework code. --> | ||
<exclude-pattern type="relative">vendor/*</exclude-pattern> | ||
|
||
<!-- Include all sniffs in an external standard directory --> | ||
<!-- Include all sniffs in an external standard directory --> | ||
|
||
<!-- Include some additional sniffs from the Generic standard --> | ||
<!-- Include some additional sniffs from the Generic standard --> | ||
|
||
<rule ref="PEAR.Classes.ClassDeclaration"/> | ||
<rule ref="Squiz.Classes.SelfMemberReference"/> | ||
|
||
<rule ref="PEAR.Commenting.InlineComment"/> | ||
|
||
<rule ref="Generic.Files.LineEndings"/> | ||
|
||
<rule ref="PEAR.Formatting.MultiLineAssignment"/> | ||
|
||
<rule ref="Generic.Functions.FunctionCallArgumentSpacing"/> | ||
|
||
<rule ref="PEAR.NamingConventions.ValidClassName"/> | ||
|
||
<rule ref="Generic.NamingConventions.UpperCaseConstantName"/> | ||
|
||
<rule ref="Generic.PHP.DisallowShortOpenTag"/> | ||
<rule ref="Generic.PHP.DeprecatedFunctions"/> | ||
<rule ref="Generic.PHP.ForbiddenFunctions"/> | ||
|
||
<rule ref="Squiz.Operators.IncrementDecrementUsage"> | ||
<exclude name="Squiz.Operators.IncrementDecrementUsage.processAssignment"/> | ||
</rule> | ||
|
||
<rule ref="Squiz.Scope.StaticThisUsage"/> | ||
|
||
<rule ref="Squiz.WhiteSpace.ScopeClosingBrace"/> | ||
|
||
<!-- Lines can be 85 chars long, but never show errors --> | ||
<rule ref="Generic.Files.LineLength"> | ||
<properties> | ||
<property name="lineLimit" value="150"/> | ||
<property name="absoluteLineLimit" value="0"/> | ||
</properties> | ||
</rule> | ||
|
||
<!-- Use Unix newlines --> | ||
<rule ref="Generic.Files.LineEndings"> | ||
<properties> | ||
<property name="eolChar" value="\n"/> | ||
</properties> | ||
</rule> | ||
|
||
<!-- This message is not required as spaces are allowed for alignment --> | ||
<rule ref="Generic.Functions.FunctionCallArgumentSpacing.TooMuchSpaceAfterComma"> | ||
<severity>0</severity> | ||
</rule> | ||
<rule ref="PSR2"> | ||
<exclude name="PEAR.Functions.FunctionCallSignature"/> | ||
<exclude name="PEAR.Functions.FunctionCallSignature.SpaceAfterCloseBracket"/> | ||
</rule> | ||
|
||
</ruleset> |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,78 +1,87 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the TelegramBot package. | ||
* | ||
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
*/ | ||
namespace Longman\TelegramBot; | ||
|
||
use Longman\TelegramBot\Entities\Update; | ||
|
||
abstract class Command | ||
{ | ||
protected $telegram; | ||
protected $update; | ||
protected $message; | ||
protected $command; | ||
|
||
protected $description = 'Command help'; | ||
protected $usage = 'Command usage'; | ||
protected $version = '1.0.0'; | ||
protected $enabled = true; | ||
protected $name = ''; | ||
|
||
public function __construct(Telegram $telegram) { | ||
$this->telegram = $telegram; | ||
} | ||
|
||
public function setUpdate(Update $update) { | ||
$this->update = $update; | ||
$this->message = $this->update->getMessage(); | ||
return $this; | ||
} | ||
|
||
|
||
public abstract function execute(); | ||
|
||
|
||
public function getUpdate() { | ||
return $this->update; | ||
} | ||
|
||
public function getMessage() { | ||
return $this->message; | ||
} | ||
|
||
|
||
public function getTelegram() { | ||
return $this->telegram; | ||
} | ||
|
||
public function setCommand($command) { | ||
$this->command = $command; | ||
return $this; | ||
} | ||
|
||
public function getUsage() { | ||
return $this->usage; | ||
} | ||
|
||
public function getVersion() { | ||
return $this->version; | ||
} | ||
|
||
public function getDescription() { | ||
return $this->description; | ||
} | ||
|
||
public function getName() { | ||
return $this->name; | ||
} | ||
|
||
public function isEnabled() { | ||
return $this->enabled; | ||
} | ||
protected $telegram; | ||
protected $update; | ||
protected $message; | ||
protected $command; | ||
|
||
protected $description = 'Command help'; | ||
protected $usage = 'Command usage'; | ||
protected $version = '1.0.0'; | ||
protected $enabled = true; | ||
protected $name = ''; | ||
|
||
public function __construct(Telegram $telegram) | ||
{ | ||
$this->telegram = $telegram; | ||
} | ||
|
||
public function setUpdate(Update $update) | ||
{ | ||
$this->update = $update; | ||
$this->message = $this->update->getMessage(); | ||
return $this; | ||
} | ||
|
||
abstract public function execute(); | ||
|
||
public function getUpdate() | ||
{ | ||
return $this->update; | ||
} | ||
|
||
public function getMessage() | ||
{ | ||
return $this->message; | ||
} | ||
|
||
public function getTelegram() | ||
{ | ||
return $this->telegram; | ||
} | ||
|
||
public function setCommand($command) | ||
{ | ||
$this->command = $command; | ||
return $this; | ||
} | ||
|
||
public function getUsage() | ||
{ | ||
return $this->usage; | ||
} | ||
|
||
public function getVersion() | ||
{ | ||
return $this->version; | ||
} | ||
|
||
public function getDescription() | ||
{ | ||
return $this->description; | ||
} | ||
|
||
public function getName() | ||
{ | ||
return $this->name; | ||
} | ||
|
||
public function isEnabled() | ||
{ | ||
return $this->enabled; | ||
} | ||
} |
Oops, something went wrong.