From a9d063c4163fcaf0d201ceb6375a6cad4f49a476 Mon Sep 17 00:00:00 2001 From: Jeroen Ketelaar Date: Mon, 10 Oct 2016 20:14:44 +0000 Subject: [PATCH] Applied fixes from StyleCI --- src/JKetelaar/fut/bot/API.php | 3 +- src/JKetelaar/fut/bot/ImprovedEnum.php | 9 +- src/JKetelaar/fut/bot/ResultParser.php | 3 +- src/JKetelaar/fut/bot/config/Comparisons.php | 3 +- .../fut/bot/config/Configuration.php | 4 +- src/JKetelaar/fut/bot/config/URL.php | 2 +- .../fut/bot/errors/CaptchaException.php | 3 +- .../bot/errors/NonExistingTokenFunction.php | 7 +- .../fut/bot/errors/NulledTokenFunction.php | 5 +- .../fut/bot/errors/UnknownPlatform.php | 5 +- .../bot/errors/login/BaseLoginException.php | 3 +- .../fut/bot/errors/login/MainLogin.php | 3 +- .../bot/errors/market/IncorrectEndpoint.php | 3 +- .../bot/errors/market/IncorrectHeaders.php | 3 +- .../fut/bot/errors/market/MarketError.php | 3 +- .../fut/bot/errors/market/UnknownEndpoint.php | 5 +- .../bot/errors/market/UnparsableEndpoint.php | 3 +- src/JKetelaar/fut/bot/market/Currency.php | 3 +- src/JKetelaar/fut/bot/market/Handler.php | 25 ++- .../fut/bot/market/handler/Method.php | 3 +- .../fut/bot/market/items/AbstractItemType.php | 3 +- .../fut/bot/market/items/ItemType.php | 3 +- .../fut/bot/market/items/misc/Formation.php | 6 +- .../fut/bot/market/items/misc/ItemState.php | 3 +- .../market/items/players/AttributeValue.php | 9 +- .../bot/market/items/players/InjuryType.php | 3 +- .../bot/market/items/players/PlayerType.php | 41 +++-- .../items/players/attributes/Attribute.php | 6 +- .../players/attributes/ChemistryStyle.php | 2 +- .../items/players/attributes/Nation.php | 2 +- .../items/players/attributes/Position.php | 3 +- .../fut/bot/market/trading/ItemData.php | 33 ++-- .../fut/bot/market/trading/Trade.php | 29 ++-- .../fut/bot/market/trading/TradeState.php | 3 +- src/JKetelaar/fut/bot/user/Hasher.php | 163 +++++++++--------- src/JKetelaar/fut/bot/user/Login.php | 59 ++++--- src/JKetelaar/fut/bot/user/User.php | 3 +- src/JKetelaar/fut/bot/web/Parser.php | 6 +- tests/Market/ApiTest.php | 3 +- tests/Requirements/RequirementsTest.php | 3 +- tests/bootstrap.php | 12 +- 41 files changed, 226 insertions(+), 267 deletions(-) diff --git a/src/JKetelaar/fut/bot/API.php b/src/JKetelaar/fut/bot/API.php index 2a50e9d..0f5f505 100644 --- a/src/JKetelaar/fut/bot/API.php +++ b/src/JKetelaar/fut/bot/API.php @@ -111,5 +111,4 @@ public function login($path = DATA_DIR . '/cookies.txt') { return $result; } - -} \ No newline at end of file +} diff --git a/src/JKetelaar/fut/bot/ImprovedEnum.php b/src/JKetelaar/fut/bot/ImprovedEnum.php index ad103c6..2089e27 100644 --- a/src/JKetelaar/fut/bot/ImprovedEnum.php +++ b/src/JKetelaar/fut/bot/ImprovedEnum.php @@ -8,18 +8,17 @@ use MyCLabs\Enum\Enum; /** - * Class ImprovedEnum + * Class ImprovedEnum. * @package JKetelaar\fut\bot * @method static ImprovedEnum _DEFAULT() */ class ImprovedEnum extends Enum { - /** * @param string $key * - * @param bool $returnObject + * @param bool $returnObject * - * @param null $default + * @param null $default * * @return null|ImprovedEnum|object */ @@ -64,4 +63,4 @@ public static function findByValue($value, $returnObject = false, $default = nul public function getName() { return ucwords(str_replace('_', ' ', strtolower($this->getKey()))); } -} \ No newline at end of file +} diff --git a/src/JKetelaar/fut/bot/ResultParser.php b/src/JKetelaar/fut/bot/ResultParser.php index 2a87192..3ff6002 100644 --- a/src/JKetelaar/fut/bot/ResultParser.php +++ b/src/JKetelaar/fut/bot/ResultParser.php @@ -6,11 +6,10 @@ namespace JKetelaar\fut\bot; interface ResultParser { - /** * @param array $result * * @return object */ public static function toObject($result); -} \ No newline at end of file +} diff --git a/src/JKetelaar/fut/bot/config/Comparisons.php b/src/JKetelaar/fut/bot/config/Comparisons.php index 5b3d870..2bc3298 100644 --- a/src/JKetelaar/fut/bot/config/Comparisons.php +++ b/src/JKetelaar/fut/bot/config/Comparisons.php @@ -6,7 +6,6 @@ namespace JKetelaar\fut\bot\config; abstract class Comparisons { - const MAIN_LOGIN_TITLE = 'Log In'; const LOGIN_FORM_TITLE = 'Login Verification'; const NO_AUTHENTICATOR_FORM_TITLE = 'Set Up an App Authenticator'; @@ -15,4 +14,4 @@ abstract class Comparisons { const CORRECT_ANSWER = 'Answer is correct.'; const CAPTCHA_BODY_CODE = 459; -} \ No newline at end of file +} diff --git a/src/JKetelaar/fut/bot/config/Configuration.php b/src/JKetelaar/fut/bot/config/Configuration.php index 244df8c..d91349e 100644 --- a/src/JKetelaar/fut/bot/config/Configuration.php +++ b/src/JKetelaar/fut/bot/config/Configuration.php @@ -42,9 +42,9 @@ abstract class Configuration { 'locale' => 'en-GB', 'method' => 'authcode', 'priorityLevel' => 4, - 'identification' => [ 'authCode' => '' ], + 'identification' => ['authCode' => ''], ]; // HTML Classes const SIGN_OUT_CLASS = 'eas-nav-global_text--login'; -} \ No newline at end of file +} diff --git a/src/JKetelaar/fut/bot/config/URL.php b/src/JKetelaar/fut/bot/config/URL.php index 2f47df5..d0e06d5 100644 --- a/src/JKetelaar/fut/bot/config/URL.php +++ b/src/JKetelaar/fut/bot/config/URL.php @@ -31,4 +31,4 @@ abstract class URL { const API_STATUS = '/ut/game/fifa17/trade/status?'; const API_ITEM = '/ut/game/fifa17/item'; const API_DEF = '/ut/game/fifa17/defid?type=player&count=35&start=0&defId=%s'; // Replaceable %s -} \ No newline at end of file +} diff --git a/src/JKetelaar/fut/bot/errors/CaptchaException.php b/src/JKetelaar/fut/bot/errors/CaptchaException.php index ed70647..19d2d13 100644 --- a/src/JKetelaar/fut/bot/errors/CaptchaException.php +++ b/src/JKetelaar/fut/bot/errors/CaptchaException.php @@ -6,11 +6,10 @@ namespace JKetelaar\fut\bot\errors; class CaptchaException extends \Exception { - /** * CaptchaException constructor. */ public function __construct() { parent::__construct('Your account received a captcha, unfortunately a solution is not yet implemented'); } -} \ No newline at end of file +} diff --git a/src/JKetelaar/fut/bot/errors/NonExistingTokenFunction.php b/src/JKetelaar/fut/bot/errors/NonExistingTokenFunction.php index c2eec23..8c2371c 100644 --- a/src/JKetelaar/fut/bot/errors/NonExistingTokenFunction.php +++ b/src/JKetelaar/fut/bot/errors/NonExistingTokenFunction.php @@ -6,13 +6,10 @@ namespace JKetelaar\fut\bot\errors; class NonExistingTokenFunction extends \Exception { - /** * NonExistingTokenFunction constructor. */ public function __construct() { - parent::__construct("Provided string is not a valid function to provide a token"); + parent::__construct('Provided string is not a valid function to provide a token'); } - - -} \ No newline at end of file +} diff --git a/src/JKetelaar/fut/bot/errors/NulledTokenFunction.php b/src/JKetelaar/fut/bot/errors/NulledTokenFunction.php index 3e91011..ea876bd 100644 --- a/src/JKetelaar/fut/bot/errors/NulledTokenFunction.php +++ b/src/JKetelaar/fut/bot/errors/NulledTokenFunction.php @@ -6,11 +6,10 @@ namespace JKetelaar\fut\bot\errors; class NulledTokenFunction extends \Exception { - /** * NulledTokenFunction constructor. */ public function __construct() { - parent::__construct("Token function gave a null value"); + parent::__construct('Token function gave a null value'); } -} \ No newline at end of file +} diff --git a/src/JKetelaar/fut/bot/errors/UnknownPlatform.php b/src/JKetelaar/fut/bot/errors/UnknownPlatform.php index 9883592..da9bad1 100644 --- a/src/JKetelaar/fut/bot/errors/UnknownPlatform.php +++ b/src/JKetelaar/fut/bot/errors/UnknownPlatform.php @@ -6,11 +6,10 @@ namespace JKetelaar\fut\bot\errors; class UnknownPlatform extends \Exception { - /** * UnknownPlatform constructor. */ public function __construct() { - parent::__construct("Platform provided is unknown"); + parent::__construct('Platform provided is unknown'); } -} \ No newline at end of file +} diff --git a/src/JKetelaar/fut/bot/errors/login/BaseLoginException.php b/src/JKetelaar/fut/bot/errors/login/BaseLoginException.php index 8125ba3..4aa8281 100644 --- a/src/JKetelaar/fut/bot/errors/login/BaseLoginException.php +++ b/src/JKetelaar/fut/bot/errors/login/BaseLoginException.php @@ -6,7 +6,6 @@ namespace JKetelaar\fut\bot\errors\login; class BaseLoginException extends \Exception { - /** * BaseLoginException constructor. * @@ -16,4 +15,4 @@ class BaseLoginException extends \Exception { public function __construct($message, $errorCode) { parent::__construct($message . "\n" . 'With error code: ' . $errorCode); } -} \ No newline at end of file +} diff --git a/src/JKetelaar/fut/bot/errors/login/MainLogin.php b/src/JKetelaar/fut/bot/errors/login/MainLogin.php index 4f4ffab..3682dc7 100644 --- a/src/JKetelaar/fut/bot/errors/login/MainLogin.php +++ b/src/JKetelaar/fut/bot/errors/login/MainLogin.php @@ -6,7 +6,6 @@ namespace JKetelaar\fut\bot\errors\login; class MainLogin extends BaseLoginException { - /** * MainLogin constructor. * @@ -19,4 +18,4 @@ public function __construct($errorCode, $message = null) { $errorCode ); } -} \ No newline at end of file +} diff --git a/src/JKetelaar/fut/bot/errors/market/IncorrectEndpoint.php b/src/JKetelaar/fut/bot/errors/market/IncorrectEndpoint.php index 2e1f2a9..f3a2d5f 100644 --- a/src/JKetelaar/fut/bot/errors/market/IncorrectEndpoint.php +++ b/src/JKetelaar/fut/bot/errors/market/IncorrectEndpoint.php @@ -6,7 +6,6 @@ namespace JKetelaar\fut\bot\errors\market; class IncorrectEndpoint extends \Exception { - /** * IncorrectEndpoint constructor. * @@ -15,4 +14,4 @@ class IncorrectEndpoint extends \Exception { public function __construct($url) { parent::__construct('Incorrect url given, should be without host. Path only; ' . $url); } -} \ No newline at end of file +} diff --git a/src/JKetelaar/fut/bot/errors/market/IncorrectHeaders.php b/src/JKetelaar/fut/bot/errors/market/IncorrectHeaders.php index c55550a..c864b1d 100644 --- a/src/JKetelaar/fut/bot/errors/market/IncorrectHeaders.php +++ b/src/JKetelaar/fut/bot/errors/market/IncorrectHeaders.php @@ -6,11 +6,10 @@ namespace JKetelaar\fut\bot\errors\market; class IncorrectHeaders extends \Exception { - /** * IncorrectHeaders constructor. */ public function __construct() { parent::__construct('Headers parameter should either be null or have associative keys'); } -} \ No newline at end of file +} diff --git a/src/JKetelaar/fut/bot/errors/market/MarketError.php b/src/JKetelaar/fut/bot/errors/market/MarketError.php index f2d2219..601ac65 100644 --- a/src/JKetelaar/fut/bot/errors/market/MarketError.php +++ b/src/JKetelaar/fut/bot/errors/market/MarketError.php @@ -6,7 +6,6 @@ namespace JKetelaar\fut\bot\errors\market; class MarketError extends \Exception { - /** * MarketError constructor. * @@ -29,4 +28,4 @@ public function __construct($message = null, $code = null, $response = null) { parent::__construct($message); } -} \ No newline at end of file +} diff --git a/src/JKetelaar/fut/bot/errors/market/UnknownEndpoint.php b/src/JKetelaar/fut/bot/errors/market/UnknownEndpoint.php index ceeef2b..d1fab0c 100644 --- a/src/JKetelaar/fut/bot/errors/market/UnknownEndpoint.php +++ b/src/JKetelaar/fut/bot/errors/market/UnknownEndpoint.php @@ -5,13 +5,10 @@ namespace JKetelaar\fut\bot\errors\market; -use Exception; - class UnknownEndpoint extends \Exception { public function __construct($endpoint) { parent::__construct( 'Endpoint given is unknown: ' . $endpoint ); } - -} \ No newline at end of file +} diff --git a/src/JKetelaar/fut/bot/errors/market/UnparsableEndpoint.php b/src/JKetelaar/fut/bot/errors/market/UnparsableEndpoint.php index 02029df..a6cc502 100644 --- a/src/JKetelaar/fut/bot/errors/market/UnparsableEndpoint.php +++ b/src/JKetelaar/fut/bot/errors/market/UnparsableEndpoint.php @@ -6,11 +6,10 @@ namespace JKetelaar\fut\bot\errors\market; class UnparsableEndpoint extends \Exception { - /** * UnparsableEndpoint constructor. */ public function __construct($url) { parent::__construct('Could not parse given path with the host; ' . $url); } -} \ No newline at end of file +} diff --git a/src/JKetelaar/fut/bot/market/Currency.php b/src/JKetelaar/fut/bot/market/Currency.php index e080391..ccf4c37 100644 --- a/src/JKetelaar/fut/bot/market/Currency.php +++ b/src/JKetelaar/fut/bot/market/Currency.php @@ -6,7 +6,6 @@ namespace JKetelaar\fut\bot\market; class Currency { - const TAG = 'currencies'; /** @@ -57,4 +56,4 @@ public function getFinalFunds() { public function getName() { return $this->name; } -} \ No newline at end of file +} diff --git a/src/JKetelaar/fut/bot/market/Handler.php b/src/JKetelaar/fut/bot/market/Handler.php index c944e06..221024b 100644 --- a/src/JKetelaar/fut/bot/market/Handler.php +++ b/src/JKetelaar/fut/bot/market/Handler.php @@ -19,7 +19,6 @@ use JKetelaar\fut\bot\user\User; class Handler { - /** * @var Curl */ @@ -42,7 +41,7 @@ public function __construct(Curl $curl, User $user) { } /** - * TODO: Still in development, throws errors + * TODO: Still in development, throws errors. * * @deprecated * @@ -51,7 +50,7 @@ public function __construct(Curl $curl, User $user) { * @return ItemData */ public function getDefinition($assetId) { - return ItemData::toObject($this->sendRequest(sprintf(URL::API_DEF, $assetId))[ ItemData::TAG ][ 0 ]); + return ItemData::toObject($this->sendRequest(sprintf(URL::API_DEF, $assetId))[ItemData::TAG][0]); } /** @@ -60,14 +59,14 @@ public function getDefinition($assetId) { * @param array $data * @param null $headers * - * @param bool $anonymous + * @param bool $anonymous * - * @return array|bool|null|string * @throws IncorrectEndpoint * @throws IncorrectHeaders * @throws MarketError * @throws UnknownEndpoint * @throws UnparsableEndpoint + * @return array|bool|null|string */ public function sendRequest($url, Method $method = null, $data = [], $headers = null, $anonymous = false) { if($method === null) { @@ -94,7 +93,7 @@ public function sendRequest($url, Method $method = null, $data = [], $headers = if(filter_var($url, FILTER_VALIDATE_URL) !== false) { throw new IncorrectEndpoint($url); } else { - $url = $this->user->getHeaders()[ Configuration::X_UT_ROUTE_PARAM ] . $url; + $url = $this->user->getHeaders()[Configuration::X_UT_ROUTE_PARAM] . $url; if(filter_var($url, FILTER_VALIDATE_URL) === false) { throw new UnparsableEndpoint($url); } @@ -129,7 +128,7 @@ public function sendRequest($url, Method $method = null, $data = [], $headers = */ public function getTradepile() { $auctions = []; - foreach(($request = $this->sendRequest(URL::API_TRADEPILE)[ Trade::TAG ]) as $auction) { + foreach(($request = $this->sendRequest(URL::API_TRADEPILE)[Trade::TAG]) as $auction) { $auctions[] = Trade::toObject($auction); } @@ -142,8 +141,8 @@ public function getWatchlist() { public function getCredits() { $result = $this->sendRequest(URL::API_CREDITS); - if(isset($result[ 'credits' ])) { - return $result[ 'credits' ]; + if(isset($result['credits'])) { + return $result['credits']; } return null; @@ -151,12 +150,12 @@ public function getCredits() { public function getCurrencies() { $result = $this->sendRequest(URL::API_CREDITS); - if(isset($result[ Currency::TAG ])) { + if(isset($result[Currency::TAG])) { $currencies = []; - foreach($result[ Currency::TAG ] as $currency) { + foreach($result[Currency::TAG] as $currency) { $currencies[] = new Currency( - $currency[ 'name' ], $currency[ 'funds' ], $currency[ 'finalFunds' ] + $currency['name'], $currency['funds'], $currency['finalFunds'] ); } @@ -165,4 +164,4 @@ public function getCurrencies() { return null; } -} \ No newline at end of file +} diff --git a/src/JKetelaar/fut/bot/market/handler/Method.php b/src/JKetelaar/fut/bot/market/handler/Method.php index c36f3b1..de380cc 100644 --- a/src/JKetelaar/fut/bot/market/handler/Method.php +++ b/src/JKetelaar/fut/bot/market/handler/Method.php @@ -8,10 +8,9 @@ use MyCLabs\Enum\Enum; class Method extends Enum { - const GET = 'GET'; const POST = 'POST'; const PUT = 'PUT'; const DELETE = 'DELETE'; -} \ No newline at end of file +} diff --git a/src/JKetelaar/fut/bot/market/items/AbstractItemType.php b/src/JKetelaar/fut/bot/market/items/AbstractItemType.php index d8de049..1a603a6 100644 --- a/src/JKetelaar/fut/bot/market/items/AbstractItemType.php +++ b/src/JKetelaar/fut/bot/market/items/AbstractItemType.php @@ -8,7 +8,6 @@ use JKetelaar\fut\bot\market\items\misc\Formation; abstract class AbstractItemType { - /** * @var int */ @@ -106,4 +105,4 @@ public function getMarketDataMaxPrice() { public function getFormation() { return $this->formation; } -} \ No newline at end of file +} diff --git a/src/JKetelaar/fut/bot/market/items/ItemType.php b/src/JKetelaar/fut/bot/market/items/ItemType.php index ed0c426..6a05f96 100644 --- a/src/JKetelaar/fut/bot/market/items/ItemType.php +++ b/src/JKetelaar/fut/bot/market/items/ItemType.php @@ -8,9 +8,8 @@ use JKetelaar\fut\bot\ImprovedEnum; class ItemType extends ImprovedEnum { - const PLAYER = 'player'; const TRAINING = 'training'; const BALL = 'ball'; -} \ No newline at end of file +} diff --git a/src/JKetelaar/fut/bot/market/items/misc/Formation.php b/src/JKetelaar/fut/bot/market/items/misc/Formation.php index 9167f33..ee94a64 100644 --- a/src/JKetelaar/fut/bot/market/items/misc/Formation.php +++ b/src/JKetelaar/fut/bot/market/items/misc/Formation.php @@ -8,15 +8,13 @@ use JKetelaar\fut\bot\ImprovedEnum; class Formation extends ImprovedEnum { - const F443 = '4-4-3'; const F41212 = '4-1-2-1-2'; const F4231 = '4-2-3-1'; - const _DEFAULT = Formation::F443; + const _DEFAULT = self::F443; public static function findByKey($value, $returnObject = false, $default = null) { return parent::findByKey($value, $returnObject, self::_DEFAULT()); } - -} \ No newline at end of file +} diff --git a/src/JKetelaar/fut/bot/market/items/misc/ItemState.php b/src/JKetelaar/fut/bot/market/items/misc/ItemState.php index cc743b5..1a22ea8 100644 --- a/src/JKetelaar/fut/bot/market/items/misc/ItemState.php +++ b/src/JKetelaar/fut/bot/market/items/misc/ItemState.php @@ -8,9 +8,8 @@ use JKetelaar\fut\bot\ImprovedEnum; class ItemState extends ImprovedEnum { - const FOR_SALE = 'forSale'; const FREE = 'free'; const _DEFAULT = self::FREE; -} \ No newline at end of file +} diff --git a/src/JKetelaar/fut/bot/market/items/players/AttributeValue.php b/src/JKetelaar/fut/bot/market/items/players/AttributeValue.php index eb97fd9..9ff4236 100644 --- a/src/JKetelaar/fut/bot/market/items/players/AttributeValue.php +++ b/src/JKetelaar/fut/bot/market/items/players/AttributeValue.php @@ -9,7 +9,6 @@ use JKetelaar\fut\bot\ResultParser; class AttributeValue implements ResultParser { - const TAG = 'attributeList'; /** @@ -53,10 +52,10 @@ public static function toObjects($result) { * @return AttributeValue */ public static function toObject($result) { - $index = $result[ 'index' ]; - $value = $result[ 'value' ]; + $index = $result['index']; + $value = $result['value']; - return new AttributeValue( + return new self( Attribute::findByValue($index, true), $value ); } @@ -74,4 +73,4 @@ public function getAttribute() { public function getValue() { return $this->value; } -} \ No newline at end of file +} diff --git a/src/JKetelaar/fut/bot/market/items/players/InjuryType.php b/src/JKetelaar/fut/bot/market/items/players/InjuryType.php index 68fb2ee..5c5d26e 100644 --- a/src/JKetelaar/fut/bot/market/items/players/InjuryType.php +++ b/src/JKetelaar/fut/bot/market/items/players/InjuryType.php @@ -8,7 +8,6 @@ use JKetelaar\fut\bot\ImprovedEnum; class InjuryType extends ImprovedEnum { - const NONE = 'none'; const _DEFAULT = self::NONE; -} \ No newline at end of file +} diff --git a/src/JKetelaar/fut/bot/market/items/players/PlayerType.php b/src/JKetelaar/fut/bot/market/items/players/PlayerType.php index f6e4d6c..742282c 100644 --- a/src/JKetelaar/fut/bot/market/items/players/PlayerType.php +++ b/src/JKetelaar/fut/bot/market/items/players/PlayerType.php @@ -13,12 +13,11 @@ use JKetelaar\fut\bot\ResultParser; /** - * Class PlayerType + * Class PlayerType. * @package JKetelaar\fut\bot\market\items\players * @AllArgsConstructor */ class PlayerType extends AbstractItemType implements ResultParser { - /** * @var int */ @@ -135,26 +134,26 @@ public function __construct( * @return object */ public static function toObject($result) { - $player = new PlayerType( - $result[ 'teamid' ], - $result[ 'leagueId' ], - $result[ 'rating' ], - $result[ 'marketDataMinPrice' ], - $result[ 'marketDataMaxPrice' ], - Formation::findByKey($result[ 'formation' ], true), - $result[ 'morale' ], - ChemistryStyle::findByValue($result[ 'playStyle' ], true), - $result[ 'fitness' ], - InjuryType::findByValue($result[ 'injuryType' ], true), - $result[ 'injuryGames' ], - Position::findByValue($result[ 'preferredPosition' ], true), - $result[ 'training' ], - $result[ 'contract' ], - $result[ 'suspension' ], - AttributeValue::toObjects($result[ AttributeValue::TAG ]), - Nation::findByValue($result[ 'nation' ], true) + $player = new self( + $result['teamid'], + $result['leagueId'], + $result['rating'], + $result['marketDataMinPrice'], + $result['marketDataMaxPrice'], + Formation::findByKey($result['formation'], true), + $result['morale'], + ChemistryStyle::findByValue($result['playStyle'], true), + $result['fitness'], + InjuryType::findByValue($result['injuryType'], true), + $result['injuryGames'], + Position::findByValue($result['preferredPosition'], true), + $result['training'], + $result['contract'], + $result['suspension'], + AttributeValue::toObjects($result[AttributeValue::TAG]), + Nation::findByValue($result['nation'], true) ); return $player; } -} \ No newline at end of file +} diff --git a/src/JKetelaar/fut/bot/market/items/players/attributes/Attribute.php b/src/JKetelaar/fut/bot/market/items/players/attributes/Attribute.php index 7fe66d5..0c136e4 100644 --- a/src/JKetelaar/fut/bot/market/items/players/attributes/Attribute.php +++ b/src/JKetelaar/fut/bot/market/items/players/attributes/Attribute.php @@ -8,7 +8,6 @@ use JKetelaar\fut\bot\ImprovedEnum; class Attribute extends ImprovedEnum { - const PACE = 0; const SHOOTING = 1; const PASSING = 2; @@ -24,8 +23,7 @@ class Attribute extends ImprovedEnum { * @return Attribute|null */ public static function findByValue($value, $returnObject = false, $default = null) { - /** @noinspection PhpIncompatibleReturnTypeInspection */ + /* @noinspection PhpIncompatibleReturnTypeInspection */ return parent::findByValue($value, $returnObject, $default); } - -} \ No newline at end of file +} diff --git a/src/JKetelaar/fut/bot/market/items/players/attributes/ChemistryStyle.php b/src/JKetelaar/fut/bot/market/items/players/attributes/ChemistryStyle.php index 5e49c13..bb2d423 100644 --- a/src/JKetelaar/fut/bot/market/items/players/attributes/ChemistryStyle.php +++ b/src/JKetelaar/fut/bot/market/items/players/attributes/ChemistryStyle.php @@ -33,4 +33,4 @@ class ChemistryStyle extends ImprovedEnum { const GLOVE = 272; const GK_BASIC = 273; const _DEFAULT = self::BASIC; -} \ No newline at end of file +} diff --git a/src/JKetelaar/fut/bot/market/items/players/attributes/Nation.php b/src/JKetelaar/fut/bot/market/items/players/attributes/Nation.php index aee683a..ae05b70 100644 --- a/src/JKetelaar/fut/bot/market/items/players/attributes/Nation.php +++ b/src/JKetelaar/fut/bot/market/items/players/attributes/Nation.php @@ -157,4 +157,4 @@ class Nation extends ImprovedEnum { public function getName() { return ucwords(str_replace('_', ' ', strtolower($this->getKey()))); } -} \ No newline at end of file +} diff --git a/src/JKetelaar/fut/bot/market/items/players/attributes/Position.php b/src/JKetelaar/fut/bot/market/items/players/attributes/Position.php index d92a71a..4c1d1b8 100644 --- a/src/JKetelaar/fut/bot/market/items/players/attributes/Position.php +++ b/src/JKetelaar/fut/bot/market/items/players/attributes/Position.php @@ -8,7 +8,6 @@ use JKetelaar\fut\bot\ImprovedEnum; class Position extends ImprovedEnum { - const DEFENDERS = 'defense'; const MIDFIELDERS = 'midfield'; const ATTACKERS = 'attacker'; @@ -34,4 +33,4 @@ class Position extends ImprovedEnum { const STRIKER = 'ST'; const LEFT_WINGER = 'LW'; -} \ No newline at end of file +} diff --git a/src/JKetelaar/fut/bot/market/trading/ItemData.php b/src/JKetelaar/fut/bot/market/trading/ItemData.php index 555f9fc..4d1dd6f 100644 --- a/src/JKetelaar/fut/bot/market/trading/ItemData.php +++ b/src/JKetelaar/fut/bot/market/trading/ItemData.php @@ -12,7 +12,6 @@ use JKetelaar\fut\bot\ResultParser; class ItemData implements ResultParser { - const TAG = 'itemData'; /** @@ -133,21 +132,21 @@ public function __construct( * @return ItemData */ public static function toObject($result) { - var_dump($result[ 'itemState' ]); - $itemData = new ItemData( - $result[ 'id' ], - $result[ 'timestamp' ], - $result[ 'untradeable' ], - $result[ 'assetId' ], - ItemType::findByKey($result[ 'itemType' ], true), + var_dump($result['itemState']); + $itemData = new self( + $result['id'], + $result['timestamp'], + $result['untradeable'], + $result['assetId'], + ItemType::findByKey($result['itemType'], true), null, - $result[ 'resourceId' ], - $result[ 'owners' ], - $result[ 'discardValue' ], - ItemState::findByKey($result[ 'itemState' ], true), - $result[ 'cardsubtypeid' ], - $result[ 'lastSalePrice' ], - $result[ 'rareflag' ] + $result['resourceId'], + $result['owners'], + $result['discardValue'], + ItemState::findByKey($result['itemState'], true), + $result['cardsubtypeid'], + $result['lastSalePrice'], + $result['rareflag'] ); $item = null; @@ -183,7 +182,7 @@ public function getTimestamp() { } /** - * @return boolean + * @return bool */ public function isUntradeable() { return $this->untradeable; @@ -251,4 +250,4 @@ public function getRareflag() { public function getItem() { return $this->item; } -} \ No newline at end of file +} diff --git a/src/JKetelaar/fut/bot/market/trading/Trade.php b/src/JKetelaar/fut/bot/market/trading/Trade.php index b270bbc..f9dd5fa 100644 --- a/src/JKetelaar/fut/bot/market/trading/Trade.php +++ b/src/JKetelaar/fut/bot/market/trading/Trade.php @@ -8,7 +8,6 @@ use JKetelaar\fut\bot\ResultParser; class Trade implements ResultParser { - const TAG = 'auctionInfo'; /** @@ -110,19 +109,19 @@ public function __construct( * @return Trade */ public static function toObject($result) { - $trade = new Trade( - $result[ 'tradeId' ], - $result[ 'tradeState' ], - $result[ 'buyNowPrice' ], - $result[ 'currentBid' ], - $result[ 'offers' ], - $result[ 'watched' ], - $result[ 'bidState' ], - $result[ 'startingBid' ], - $result[ 'confidenceValue' ], - $result[ 'expires' ] + $trade = new self( + $result['tradeId'], + $result['tradeState'], + $result['buyNowPrice'], + $result['currentBid'], + $result['offers'], + $result['watched'], + $result['bidState'], + $result['startingBid'], + $result['confidenceValue'], + $result['expires'] ); - $itemData = ItemData::toObject($result[ 'itemData' ]); + $itemData = ItemData::toObject($result['itemData']); $trade->setItemData($itemData); return $trade; @@ -171,7 +170,7 @@ public function getOffers() { } /** - * @return boolean + * @return bool */ public function isWatched() { return $this->watched; @@ -211,4 +210,4 @@ public function getExpires() { public function getItemData() { return $this->itemData; } -} \ No newline at end of file +} diff --git a/src/JKetelaar/fut/bot/market/trading/TradeState.php b/src/JKetelaar/fut/bot/market/trading/TradeState.php index 69e5b4d..a1ccfc1 100644 --- a/src/JKetelaar/fut/bot/market/trading/TradeState.php +++ b/src/JKetelaar/fut/bot/market/trading/TradeState.php @@ -8,10 +8,9 @@ use JKetelaar\fut\bot\ImprovedEnum; class TradeState extends ImprovedEnum { - const ACTIVE = 'active'; const EXPIRED = 'expired'; const NONE = null; const _DEFAULT = self::NONE; -} \ No newline at end of file +} diff --git a/src/JKetelaar/fut/bot/user/Hasher.php b/src/JKetelaar/fut/bot/user/Hasher.php index 4928be7..926eb7b 100644 --- a/src/JKetelaar/fut/bot/user/Hasher.php +++ b/src/JKetelaar/fut/bot/user/Hasher.php @@ -7,11 +7,10 @@ namespace JKetelaar\fut\bot\user; class Hasher { - - private static $r1Shifts = [ 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22 ]; - private static $r2Shifts = [ 5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20 ]; - private static $r3Shifts = [ 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23 ]; - private static $r4Shifts = [ 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21 ]; + private static $r1Shifts = [7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22]; + private static $r2Shifts = [5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20]; + private static $r3Shifts = [4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23]; + private static $r4Shifts = [6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21]; private static $hexChr = '0123456789abcdef'; public static function md5($string) { @@ -21,16 +20,16 @@ public static function md5($string) { $c = -1732584194; $d = 271733878; - for($i = 0; $i < sizeof($x); $i += 16) { + for($i = 0; $i < count($x); $i += 16) { $tempA = $a; $tempB = $b; $tempC = $c; $tempD = $d; - $a = self::md5_f($a, $b, $c, $d, $x[ $i + 0 ], self::$r1Shifts[ 0 ], -680876936); - $d = self::md5_f($d, $a, $b, $c, $x[ $i + 1 ], self::$r1Shifts[ 1 ], -389564586); - $c = self::md5_f($c, $d, $a, $b, $x[ $i + 2 ], self::$r1Shifts[ 2 ], 606105819); - $a = self::md5_f($a, $b, $c, $d, $x[ $i + 4 ], self::$r1Shifts[ 4 ], -176418897); + $a = self::md5_f($a, $b, $c, $d, $x[$i + 0], self::$r1Shifts[0], -680876936); + $d = self::md5_f($d, $a, $b, $c, $x[$i + 1], self::$r1Shifts[1], -389564586); + $c = self::md5_f($c, $d, $a, $b, $x[$i + 2], self::$r1Shifts[2], 606105819); + $a = self::md5_f($a, $b, $c, $d, $x[$i + 4], self::$r1Shifts[4], -176418897); var_dump($a); var_dump($b); @@ -38,69 +37,69 @@ public static function md5($string) { var_dump($d); die(); - $d = self::md5_f($d, $a, $b, $c, $x[ $i + 5 ], self::$r1Shifts[ 5 ], 1200080426); - $c = self::md5_f($c, $d, $a, $b, $x[ $i + 6 ], self::$r1Shifts[ 6 ], -1473231341); - $b = self::md5_f($b, $c, $d, $a, $x[ $i + 7 ], self::$r1Shifts[ 7 ], -45705983); - - $a = self::md5_f($a, $b, $c, $d, $x[ $i + 8 ], self::$r1Shifts[ 8 ], 1770035416); - $d = self::md5_f($d, $a, $b, $c, $x[ $i + 9 ], self::$r1Shifts[ 9 ], -1958414417); - $c = self::md5_f($c, $d, $a, $b, $x[ $i + 10 ], self::$r1Shifts[ 10 ], -42063); - - $b = self::md5_f($b, $c, $d, $a, $x[ $i + 11 ], self::$r1Shifts[ 11 ], -1990404162); - $a = self::md5_f($a, $b, $c, $d, $x[ $i + 12 ], self::$r1Shifts[ 12 ], 1804603682); - $d = self::md5_f($d, $a, $b, $c, $x[ $i + 13 ], self::$r1Shifts[ 13 ], -40341101); - $c = self::md5_f($c, $d, $a, $b, $x[ $i + 14 ], self::$r1Shifts[ 14 ], -1502002290); - $b = self::md5_f($b, $c, $d, $a, $x[ $i + 15 ], self::$r1Shifts[ 15 ], 1236535329); - $a = self::md5_g($a, $b, $c, $d, $x[ $i + 1 ], self::$r2Shifts[ 0 ], -165796510); - - $d = self::md5_g($d, $a, $b, $c, $x[ $i + 6 ], self::$r2Shifts[ 1 ], -1069501632); - $c = self::md5_g($c, $d, $a, $b, $x[ $i + 11 ], self::$r2Shifts[ 2 ], 643717713); - $b = self::md5_g($b, $c, $d, $a, $x[ $i + 0 ], self::$r2Shifts[ 3 ], -373897302); - $a = self::md5_g($a, $b, $c, $d, $x[ $i + 5 ], self::$r2Shifts[ 4 ], -701558691); - $d = self::md5_g($d, $a, $b, $c, $x[ $i + 10 ], self::$r2Shifts[ 5 ], 38016083); - $c = self::md5_g($c, $d, $a, $b, $x[ $i + 15 ], self::$r2Shifts[ 6 ], -660478335); - $b = self::md5_g($b, $c, $d, $a, $x[ $i + 4 ], self::$r2Shifts[ 7 ], -405537848); - $a = self::md5_g($a, $b, $c, $d, $x[ $i + 9 ], self::$r2Shifts[ 8 ], 568446438); - $d = self::md5_g($d, $a, $b, $c, $x[ $i + 14 ], self::$r2Shifts[ 9 ], -1019803690); - $c = self::md5_g($c, $d, $a, $b, $x[ $i + 3 ], self::$r2Shifts[ 10 ], -187363961); - $b = self::md5_g($b, $c, $d, $a, $x[ $i + 8 ], self::$r2Shifts[ 11 ], 1163531501); - $a = self::md5_g($a, $b, $c, $d, $x[ $i + 13 ], self::$r2Shifts[ 12 ], -1444681467); - $d = self::md5_g($d, $a, $b, $c, $x[ $i + 2 ], self::$r2Shifts[ 13 ], -51403784); - $c = self::md5_g($c, $d, $a, $b, $x[ $i + 7 ], self::$r2Shifts[ 14 ], 1735328473); - $b = self::md5_g($b, $c, $d, $a, $x[ $i + 12 ], self::$r2Shifts[ 15 ], -1926607734); - $a = self::md5_h($a, $b, $c, $d, $x[ $i + 5 ], self::$r3Shifts[ 0 ], -378558); - $d = self::md5_h($d, $a, $b, $c, $x[ $i + 8 ], self::$r3Shifts[ 1 ], -2022574463); - $c = self::md5_h($c, $d, $a, $b, $x[ $i + 11 ], self::$r2Shifts[ 2 ], 1839030562); - $b = self::md5_h($b, $c, $d, $a, $x[ $i + 14 ], self::$r3Shifts[ 3 ], -35309556); - $a = self::md5_h($a, $b, $c, $d, $x[ $i + 1 ], self::$r3Shifts[ 4 ], -1530992060); - $d = self::md5_h($d, $a, $b, $c, $x[ $i + 4 ], self::$r3Shifts[ 5 ], 1272893353); - $c = self::md5_h($c, $d, $a, $b, $x[ $i + 7 ], self::$r3Shifts[ 6 ], -155497632); - $b = self::md5_h($b, $c, $d, $a, $x[ $i + 10 ], self::$r3Shifts[ 7 ], -1094730640); - $a = self::md5_h($a, $b, $c, $d, $x[ $i + 13 ], self::$r3Shifts[ 8 ], 681279174); - $d = self::md5_h($d, $a, $b, $c, $x[ $i + 0 ], self::$r3Shifts[ 9 ], -358537222); - $c = self::md5_h($c, $d, $a, $b, $x[ $i + 3 ], self::$r3Shifts[ 10 ], -722521979); - $b = self::md5_h($b, $c, $d, $a, $x[ $i + 6 ], self::$r3Shifts[ 11 ], 76029189); - $a = self::md5_h($a, $b, $c, $d, $x[ $i + 9 ], self::$r3Shifts[ 12 ], -640364487); - $d = self::md5_h($d, $a, $b, $c, $x[ $i + 12 ], self::$r3Shifts[ 13 ], -421815835); - $c = self::md5_h($c, $d, $a, $b, $x[ $i + 15 ], self::$r3Shifts[ 14 ], 530742520); - $b = self::md5_h($b, $c, $d, $a, $x[ $i + 2 ], self::$r3Shifts[ 15 ], -995338651); - $a = self::md5_i($a, $b, $c, $d, $x[ $i + 0 ], self::$r4Shifts[ 0 ], -198630844); - $d = self::md5_i($d, $a, $b, $c, $x[ $i + 7 ], self::$r4Shifts[ 1 ], 1126891415); - $c = self::md5_i($c, $d, $a, $b, $x[ $i + 14 ], self::$r4Shifts[ 2 ], -1416354905); - $b = self::md5_i($b, $c, $d, $a, $x[ $i + 5 ], self::$r4Shifts[ 3 ], -57434055); - $a = self::md5_i($a, $b, $c, $d, $x[ $i + 12 ], self::$r4Shifts[ 4 ], 1700485571); - $d = self::md5_i($d, $a, $b, $c, $x[ $i + 3 ], self::$r4Shifts[ 5 ], -1894986606); - $c = self::md5_i($c, $d, $a, $b, $x[ $i + 10 ], self::$r4Shifts[ 6 ], -1051523); - $b = self::md5_i($b, $c, $d, $a, $x[ $i + 1 ], self::$r4Shifts[ 7 ], -2054922799); - $a = self::md5_i($a, $b, $c, $d, $x[ $i + 8 ], self::$r4Shifts[ 8 ], 1873313359); - $d = self::md5_i($d, $a, $b, $c, $x[ $i + 15 ], self::$r4Shifts[ 9 ], -30611744); - $c = self::md5_i($c, $d, $a, $b, $x[ $i + 6 ], self::$r4Shifts[ 10 ], -1560198380); - $b = self::md5_i($b, $c, $d, $a, $x[ $i + 13 ], self::$r4Shifts[ 11 ], 1309151649); - $a = self::md5_i($a, $b, $c, $d, $x[ $i + 4 ], self::$r4Shifts[ 12 ], -145523070); - $d = self::md5_i($d, $a, $b, $c, $x[ $i + 11 ], self::$r4Shifts[ 13 ], -1120210379); - $c = self::md5_i($c, $d, $a, $b, $x[ $i + 2 ], self::$r4Shifts[ 14 ], 718787259); - $b = self::md5_i($b, $c, $d, $a, $x[ $i + 9 ], self::$r4Shifts[ 15 ], -343485551); - $b = self::md5_i($b, $c, $d, $a, $x[ $i + 9 ], self::$r4Shifts[ 15 ], -343485551); + $d = self::md5_f($d, $a, $b, $c, $x[$i + 5], self::$r1Shifts[5], 1200080426); + $c = self::md5_f($c, $d, $a, $b, $x[$i + 6], self::$r1Shifts[6], -1473231341); + $b = self::md5_f($b, $c, $d, $a, $x[$i + 7], self::$r1Shifts[7], -45705983); + + $a = self::md5_f($a, $b, $c, $d, $x[$i + 8], self::$r1Shifts[8], 1770035416); + $d = self::md5_f($d, $a, $b, $c, $x[$i + 9], self::$r1Shifts[9], -1958414417); + $c = self::md5_f($c, $d, $a, $b, $x[$i + 10], self::$r1Shifts[10], -42063); + + $b = self::md5_f($b, $c, $d, $a, $x[$i + 11], self::$r1Shifts[11], -1990404162); + $a = self::md5_f($a, $b, $c, $d, $x[$i + 12], self::$r1Shifts[12], 1804603682); + $d = self::md5_f($d, $a, $b, $c, $x[$i + 13], self::$r1Shifts[13], -40341101); + $c = self::md5_f($c, $d, $a, $b, $x[$i + 14], self::$r1Shifts[14], -1502002290); + $b = self::md5_f($b, $c, $d, $a, $x[$i + 15], self::$r1Shifts[15], 1236535329); + $a = self::md5_g($a, $b, $c, $d, $x[$i + 1], self::$r2Shifts[0], -165796510); + + $d = self::md5_g($d, $a, $b, $c, $x[$i + 6], self::$r2Shifts[1], -1069501632); + $c = self::md5_g($c, $d, $a, $b, $x[$i + 11], self::$r2Shifts[2], 643717713); + $b = self::md5_g($b, $c, $d, $a, $x[$i + 0], self::$r2Shifts[3], -373897302); + $a = self::md5_g($a, $b, $c, $d, $x[$i + 5], self::$r2Shifts[4], -701558691); + $d = self::md5_g($d, $a, $b, $c, $x[$i + 10], self::$r2Shifts[5], 38016083); + $c = self::md5_g($c, $d, $a, $b, $x[$i + 15], self::$r2Shifts[6], -660478335); + $b = self::md5_g($b, $c, $d, $a, $x[$i + 4], self::$r2Shifts[7], -405537848); + $a = self::md5_g($a, $b, $c, $d, $x[$i + 9], self::$r2Shifts[8], 568446438); + $d = self::md5_g($d, $a, $b, $c, $x[$i + 14], self::$r2Shifts[9], -1019803690); + $c = self::md5_g($c, $d, $a, $b, $x[$i + 3], self::$r2Shifts[10], -187363961); + $b = self::md5_g($b, $c, $d, $a, $x[$i + 8], self::$r2Shifts[11], 1163531501); + $a = self::md5_g($a, $b, $c, $d, $x[$i + 13], self::$r2Shifts[12], -1444681467); + $d = self::md5_g($d, $a, $b, $c, $x[$i + 2], self::$r2Shifts[13], -51403784); + $c = self::md5_g($c, $d, $a, $b, $x[$i + 7], self::$r2Shifts[14], 1735328473); + $b = self::md5_g($b, $c, $d, $a, $x[$i + 12], self::$r2Shifts[15], -1926607734); + $a = self::md5_h($a, $b, $c, $d, $x[$i + 5], self::$r3Shifts[0], -378558); + $d = self::md5_h($d, $a, $b, $c, $x[$i + 8], self::$r3Shifts[1], -2022574463); + $c = self::md5_h($c, $d, $a, $b, $x[$i + 11], self::$r2Shifts[2], 1839030562); + $b = self::md5_h($b, $c, $d, $a, $x[$i + 14], self::$r3Shifts[3], -35309556); + $a = self::md5_h($a, $b, $c, $d, $x[$i + 1], self::$r3Shifts[4], -1530992060); + $d = self::md5_h($d, $a, $b, $c, $x[$i + 4], self::$r3Shifts[5], 1272893353); + $c = self::md5_h($c, $d, $a, $b, $x[$i + 7], self::$r3Shifts[6], -155497632); + $b = self::md5_h($b, $c, $d, $a, $x[$i + 10], self::$r3Shifts[7], -1094730640); + $a = self::md5_h($a, $b, $c, $d, $x[$i + 13], self::$r3Shifts[8], 681279174); + $d = self::md5_h($d, $a, $b, $c, $x[$i + 0], self::$r3Shifts[9], -358537222); + $c = self::md5_h($c, $d, $a, $b, $x[$i + 3], self::$r3Shifts[10], -722521979); + $b = self::md5_h($b, $c, $d, $a, $x[$i + 6], self::$r3Shifts[11], 76029189); + $a = self::md5_h($a, $b, $c, $d, $x[$i + 9], self::$r3Shifts[12], -640364487); + $d = self::md5_h($d, $a, $b, $c, $x[$i + 12], self::$r3Shifts[13], -421815835); + $c = self::md5_h($c, $d, $a, $b, $x[$i + 15], self::$r3Shifts[14], 530742520); + $b = self::md5_h($b, $c, $d, $a, $x[$i + 2], self::$r3Shifts[15], -995338651); + $a = self::md5_i($a, $b, $c, $d, $x[$i + 0], self::$r4Shifts[0], -198630844); + $d = self::md5_i($d, $a, $b, $c, $x[$i + 7], self::$r4Shifts[1], 1126891415); + $c = self::md5_i($c, $d, $a, $b, $x[$i + 14], self::$r4Shifts[2], -1416354905); + $b = self::md5_i($b, $c, $d, $a, $x[$i + 5], self::$r4Shifts[3], -57434055); + $a = self::md5_i($a, $b, $c, $d, $x[$i + 12], self::$r4Shifts[4], 1700485571); + $d = self::md5_i($d, $a, $b, $c, $x[$i + 3], self::$r4Shifts[5], -1894986606); + $c = self::md5_i($c, $d, $a, $b, $x[$i + 10], self::$r4Shifts[6], -1051523); + $b = self::md5_i($b, $c, $d, $a, $x[$i + 1], self::$r4Shifts[7], -2054922799); + $a = self::md5_i($a, $b, $c, $d, $x[$i + 8], self::$r4Shifts[8], 1873313359); + $d = self::md5_i($d, $a, $b, $c, $x[$i + 15], self::$r4Shifts[9], -30611744); + $c = self::md5_i($c, $d, $a, $b, $x[$i + 6], self::$r4Shifts[10], -1560198380); + $b = self::md5_i($b, $c, $d, $a, $x[$i + 13], self::$r4Shifts[11], 1309151649); + $a = self::md5_i($a, $b, $c, $d, $x[$i + 4], self::$r4Shifts[12], -145523070); + $d = self::md5_i($d, $a, $b, $c, $x[$i + 11], self::$r4Shifts[13], -1120210379); + $c = self::md5_i($c, $d, $a, $b, $x[$i + 2], self::$r4Shifts[14], 718787259); + $b = self::md5_i($b, $c, $d, $a, $x[$i + 9], self::$r4Shifts[15], -343485551); + $b = self::md5_i($b, $c, $d, $a, $x[$i + 9], self::$r4Shifts[15], -343485551); $a = self::add($a, $tempA); $b = self::add($b, $tempB); @@ -116,11 +115,11 @@ public static function chunkMessage($answer) { $blocks = array_fill(0, $numberOfBlocks * 16, 0); for($i = 0; $i < strlen($answer); $i++) { - $blocks[ $i >> 2 ] |= self::utf8_char_code_at($answer, $i) << (($i % 4) * 8); + $blocks[$i >> 2] |= self::utf8_char_code_at($answer, $i) << (($i % 4) * 8); } - $blocks[ strlen($answer) >> 2 ] |= 0x80 << ((strlen($answer) % 4) * 8); - $blocks[ $numberOfBlocks * 16 - 2 ] = strlen($answer) * 8; + $blocks[strlen($answer) >> 2] |= 0x80 << ((strlen($answer) % 4) * 8); + $blocks[$numberOfBlocks * 16 - 2] = strlen($answer) * 8; return $blocks; } @@ -154,10 +153,10 @@ private static function bitwiseRotate($x, $c) { } private static function _32bitleftshift($number, $steps) { - $binary = decbin($number) . str_repeat("0", $steps); - $binary = str_pad($binary, 32, "0", STR_PAD_LEFT); + $binary = decbin($number) . str_repeat('0', $steps); + $binary = str_pad($binary, 32, '0', STR_PAD_LEFT); $binary = substr($binary, strlen($binary) - 32); - if($binary{0} == "1") { + if($binary[0] == '1') { return -(pow(2, 31) - bindec(substr($binary, 1))); } else { return bindec($binary); @@ -199,10 +198,10 @@ private static function numToHex($num) { $str = ''; for($i = 0; $i <= 3; $i++) { - $str .= self::$hexChr[ ($num >> ($i * 8 + 4)) & 0x0F ]; - $str .= self::$hexChr[ ($num >> ($i * 8)) & 0x0F ]; + $str .= self::$hexChr[($num >> ($i * 8 + 4)) & 0x0F]; + $str .= self::$hexChr[($num >> ($i * 8)) & 0x0F]; } return $str; } -} \ No newline at end of file +} diff --git a/src/JKetelaar/fut/bot/user/Login.php b/src/JKetelaar/fut/bot/user/Login.php index 1397ec1..90ef495 100644 --- a/src/JKetelaar/fut/bot/user/Login.php +++ b/src/JKetelaar/fut/bot/user/Login.php @@ -16,7 +16,6 @@ use JKetelaar\fut\bot\web\Parser; class Login { - /** * @var Curl */ @@ -86,7 +85,7 @@ private function setupCurl() { public function login() { $result = false; if(($resultMain = $this->requestMain()) != null) { - if( ! is_bool($resultMain)) { + if(!is_bool($resultMain)) { $codeURL = $this->postLoginForm($resultMain); $result = $this->postTwoFactorForm($codeURL); @@ -95,7 +94,7 @@ public function login() { } } - if( ! is_bool($result)) { + if(!is_bool($result)) { throw new MainLogin(298175, 'Unknown result given by flow'); } @@ -134,7 +133,7 @@ private function getFUTPage() { } preg_match('/EASW_ID\W*=\W*\'(\d*)\'/', $this->curl->response, $matches); - if(sizeof($matches > 1) && ($id = $matches[ 1 ]) != null) { + if(count($matches > 1) && ($id = $matches[1]) != null) { $this->nucleusId = $id; return $this->getShards($id); @@ -149,7 +148,7 @@ private function getShards($id = null) { } $tempCurl = &$this->curl; - $tempCurl->setOpt(CURLOPT_HTTPHEADER, [ 'Content-Type:application/json' ]); + $tempCurl->setOpt(CURLOPT_HTTPHEADER, ['Content-Type:application/json']); $tempCurl->setHeaders( [ 'Easw-Session-Data-Nucleus-Id' => $id, @@ -168,8 +167,8 @@ private function getShards($id = null) { if(($response = $tempCurl->response) != null) { if(($shards = json_decode(json_encode($tempCurl->response), true)) != null) { - foreach($shards[ 'shardInfo' ] as $shard) { - foreach($shard[ 'platforms' ] as $platform) { + foreach($shards['shardInfo'] as $shard) { + foreach($shard['platforms'] as $platform) { if($platform === API::getPlatform($this->user->getPlatform())) { $this->shardInfos = $shard; } @@ -188,8 +187,8 @@ private function getShards($id = null) { /** * @param null $shards * - * @return bool * @throws MainLogin + * @return bool */ private function getAccountInformation($shards = null) { if($shards == null) { @@ -197,7 +196,7 @@ private function getAccountInformation($shards = null) { } $tempCurl = &$this->curl; - $tempCurl->setHeader('X-UT-Route', 'https://' . $shards[ 'clientFacingIpPort' ]); + $tempCurl->setHeader('X-UT-Route', 'https://' . $shards['clientFacingIpPort']); $tempCurl->get(URL::LOGIN_ACCOUNTS); if($tempCurl->error) { @@ -205,14 +204,14 @@ private function getAccountInformation($shards = null) { } $accounts = json_decode(json_encode($tempCurl->response), true); - if(sizeof($accounts) > 0 && sizeof($accounts[ 'userAccountInfo' ]) > 0 && sizeof( - $accounts[ 'userAccountInfo' ][ 'personas' ] + if(count($accounts) > 0 && count($accounts['userAccountInfo']) > 0 && count( + $accounts['userAccountInfo']['personas'] ) > 0 ) { $p = null; - foreach($accounts[ 'userAccountInfo' ][ 'personas' ] as $persona) { - foreach($persona[ 'userClubList' ] as $club) { - if($club[ 'year' ] == Configuration::FUT_YEAR && $club[ 'platform' ] == API::getPlatform( + foreach($accounts['userAccountInfo']['personas'] as $persona) { + foreach($persona['userClubList'] as $club) { + if($club['year'] == Configuration::FUT_YEAR && $club['platform'] == API::getPlatform( $this->user->getPlatform() ) ) { @@ -234,8 +233,8 @@ private function getAccountInformation($shards = null) { private function getSession() { $data = [ - 'nucleusPersonaId' => $this->persona[ 'personaId' ], - 'nucleusPersonaDisplayName' => $this->persona[ 'personaName' ], + 'nucleusPersonaId' => $this->persona['personaId'], + 'nucleusPersonaDisplayName' => $this->persona['personaName'], 'gameSku' => API::getGameSku($this->user->getPlatform()), 'nucleusPersonaPlatform' => API::getPlatform($this->user->getPlatform()), ]; @@ -258,7 +257,7 @@ private function getSession() { private function phishing() { $curl = &$this->curl; - $curl->setHeader('X-UT-SID', $this->session[ 'sid' ]); + $curl->setHeader('X-UT-SID', $this->session['sid']); $curl->get(URL::LOGIN_QUESTION); @@ -269,15 +268,15 @@ private function phishing() { // Check for other responses $question = json_decode(json_encode($curl->response), true); - if(isset($question[ 'code' ])) { - if($question[ 'code' ] === Comparisons::CAPTCHA_BODY_CODE) { + if(isset($question['code'])) { + if($question['code'] === Comparisons::CAPTCHA_BODY_CODE) { throw new CaptchaException(); } } - if(isset($question[ 'string' ])) { - if($question[ 'string' ] === Comparisons::ALREADY_LOGGED_IN) { - $this->setForFutureRequests($question[ 'token' ]); + if(isset($question['string'])) { + if($question['string'] === Comparisons::ALREADY_LOGGED_IN) { + $this->setForFutureRequests($question['token']); return true; } @@ -290,7 +289,7 @@ private function setForFutureRequests($token) { $headers = [ 'X-UT-PHISHING-TOKEN' => $token, 'X-HTTP-Method-Override' => 'GET', - Configuration::X_UT_ROUTE_PARAM => 'https://' . explode(':', $this->session[ 'ipPort' ])[ 0 ], + Configuration::X_UT_ROUTE_PARAM => 'https://' . explode(':', $this->session['ipPort'])[0], 'x-flash-version' => '20,0,0,272', ]; $this->user->setHeaders($headers); @@ -298,11 +297,11 @@ private function setForFutureRequests($token) { public function validate() { exec(NODE_LOCATION . ' "' . __DIR__ . '/../js/index.js" ' . $this->user->getSecret(), $output); - if(isset($output[ 0 ]) && strlen($output[ 0 ]) == 32) { + if(isset($output[0]) && strlen($output[0]) == 32) { $this->curl->setHeader('Content-Type', 'application/x-www-form-urlencoded'); - $this->curl->setHeader('X-UT-SID', $this->session[ 'sid' ]); + $this->curl->setHeader('X-UT-SID', $this->session['sid']); - $this->curl->post(URL::LOGIN_VALIDATE, [ 'answer' => $output[ 0 ] ]); + $this->curl->post(URL::LOGIN_VALIDATE, ['answer' => $output[0]]); } if($this->curl->error) { @@ -310,9 +309,9 @@ public function validate() { } $debug = json_decode($this->curl->response, true); - if(isset($debug[ 'debug' ])) { - if($debug[ 'debug' ] === Comparisons::CORRECT_ANSWER) { - $this->setForFutureRequests($debug[ 'token' ]); + if(isset($debug['debug'])) { + if($debug['debug'] === Comparisons::CORRECT_ANSWER) { + $this->setForFutureRequests($debug['token']); return true; } @@ -390,4 +389,4 @@ private function postTwoFactorForm($url) { public function getCurl() { return $this->curl; } -} \ No newline at end of file +} diff --git a/src/JKetelaar/fut/bot/user/User.php b/src/JKetelaar/fut/bot/user/User.php index f249578..13d53ff 100644 --- a/src/JKetelaar/fut/bot/user/User.php +++ b/src/JKetelaar/fut/bot/user/User.php @@ -9,7 +9,6 @@ use JKetelaar\fut\bot\errors\NulledTokenFunction; class User { - /** * @var string */ @@ -129,4 +128,4 @@ public function getHeaders() { public function setHeaders($headers) { $this->headers = $headers; } -} \ No newline at end of file +} diff --git a/src/JKetelaar/fut/bot/web/Parser.php b/src/JKetelaar/fut/bot/web/Parser.php index 46a3e89..9ac5726 100644 --- a/src/JKetelaar/fut/bot/web/Parser.php +++ b/src/JKetelaar/fut/bot/web/Parser.php @@ -27,8 +27,8 @@ public static function getHTML($string) { */ public static function getDocumentTitle(simple_html_dom $dom) { $head = $dom->find('head'); - if(sizeof($head) > 0) { - $title = $head[ 0 ]->find('title', 0); + if(count($head) > 0) { + $title = $head[0]->find('title', 0); if($title != null && ($text = $title->innertext) != null) { return $text; } @@ -36,4 +36,4 @@ public static function getDocumentTitle(simple_html_dom $dom) { return null; } -} \ No newline at end of file +} diff --git a/tests/Market/ApiTest.php b/tests/Market/ApiTest.php index 8b8a0e8..18c7f1d 100644 --- a/tests/Market/ApiTest.php +++ b/tests/Market/ApiTest.php @@ -8,7 +8,6 @@ use JKetelaar\fut\bot\API; class ApiTest extends \PHPUnit_Framework_TestCase { - public function testPlatformCorrectness() { $this->assertTrue(API::getPlatform('ps4') === 'ps3'); $this->assertTrue(API::getPlatform('ps3') === 'ps3'); @@ -28,4 +27,4 @@ public function testGameSKUCorrectness() { $this->assertNull(API::getGameSku('non existing')); } -} \ No newline at end of file +} diff --git a/tests/Requirements/RequirementsTest.php b/tests/Requirements/RequirementsTest.php index 6b760c0..3db6cb8 100644 --- a/tests/Requirements/RequirementsTest.php +++ b/tests/Requirements/RequirementsTest.php @@ -6,7 +6,6 @@ namespace Requirements; class RequirementsTest extends \PHPUnit_Framework_TestCase { - public function testDefinitionsExist() { $this->assertTrue(defined('NODE_LOCATION')); $this->assertTrue(defined('DATA_DIR')); @@ -18,4 +17,4 @@ public function testDefinitionLocationsExist() { $this->assertTrue(file_exists(DATA_DIR)); } -} \ No newline at end of file +} diff --git a/tests/bootstrap.php b/tests/bootstrap.php index a1822b4..f1711f7 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -3,12 +3,12 @@ * @author JKetelaar */ -require_once(__DIR__ . '/../vendor/autoload.php'); +require_once __DIR__ . '/../vendor/autoload.php'; define('NODE_LOCATION', '/usr/local/bin/node'); define('DATA_DIR', (($dir = drush_server_home()) === null ? __DIR__ : $dir) . '/.fut-bot/data/'); -if( ! file_exists(DATA_DIR)) { +if(!file_exists(DATA_DIR)) { mkdir(DATA_DIR, 0777, true); } @@ -17,12 +17,12 @@ */ function drush_server_home() { $home = getenv('HOME'); - if( ! empty($home)) { + if(!empty($home)) { $home = rtrim($home, '/'); - } elseif( ! empty($_SERVER[ 'HOMEDRIVE' ]) && ! empty($_SERVER[ 'HOMEPATH' ])) { - $home = $_SERVER[ 'HOMEDRIVE' ] . $_SERVER[ 'HOMEPATH' ]; + } elseif(!empty($_SERVER['HOMEDRIVE']) && !empty($_SERVER['HOMEPATH'])) { + $home = $_SERVER['HOMEDRIVE'] . $_SERVER['HOMEPATH']; $home = rtrim($home, '\\/'); } return empty($home) ? null : $home; -} \ No newline at end of file +}