| @@ -12,7 +12,7 @@ | ||
| 12 | 12 | const SEK = 'SEK'; | 
| 13 | 13 | const USD = 'USD'; | 
| 14 | 14 | |
| 15 | -    static function isValid(string $currency){ | |
| 15 | +    static function isValid(string $currency) { | |
| 16 | 16 | $currencies = self::getCurrencies(); | 
| 17 | 17 | return in_array($currency, $currencies); | 
| 18 | 18 | } | 
| @@ -2,7 +2,7 @@ | ||
| 2 | 2 | |
| 3 | 3 | namespace BPCI\SumUp\Exception; | 
| 4 | 4 | |
| 5 | -class FileNotFoundException extends \RuntimeException{ | |
| 5 | +class FileNotFoundException extends \RuntimeException { | |
| 6 | 6 | private $path; | 
| 7 | 7 | public function __construct(string $message, int $code = 0, \Exception $previous = null, string $path = null) | 
| 8 | 8 |      { | 
| @@ -6,7 +6,7 @@ | ||
| 6 | 6 | use BPCI\SumUp\OAuth\AccessToken; | 
| 7 | 7 | use BPCI\SumUp\Customer\CustomerInterface; | 
| 8 | 8 | |
| 9 | -interface CardClientInterface extends SumUpClientInterface{ | |
| 9 | +interface CardClientInterface extends SumUpClientInterface { | |
| 10 | 10 | |
| 11 | 11 | /** | 
| 12 | 12 | * Create a new card resource and fill the $card Object with response. | 
| @@ -19,12 +19,12 @@ discard block | ||
| 19 | 19 | * @param string $type | 
| 20 | 20 | * @param integer $expiresIn | 
| 21 | 21 | */ | 
| 22 | -    function __construct(string $token, string $type, int $expiresIn, string $scope = null){ | |
| 22 | +    function __construct(string $token, string $type, int $expiresIn, string $scope = null) { | |
| 23 | 23 | $this->token = $token; | 
| 24 | 24 | $this->type = $type; | 
| 25 | 25 | $this->expiration = time() + $expiresIn; | 
| 26 | 26 | |
| 27 | -        if($scope !== null) { | |
| 27 | +        if ($scope !== null) { | |
| 28 | 28 | $this->scope = $scope; | 
| 29 | 29 | } | 
| 30 | 30 | } | 
| @@ -85,9 +85,9 @@ discard block | ||
| 85 | 85 | * @param string $scope[,$scope[,$scope[,...]]] | 
| 86 | 86 | * @return boolean | 
| 87 | 87 | */ | 
| 88 | -    function canAccess(string $scope){ | |
| 88 | +    function canAccess(string $scope) { | |
| 89 | 89 | $scopes = func_get_args(); | 
| 90 | 90 | $diff = array_diff($scopes, $this->scope); | 
| 91 | - return count($diff)>0; | |
| 91 | + return count($diff) > 0; | |
| 92 | 92 | } | 
| 93 | 93 | } | 
| @@ -81,14 +81,14 @@ | ||
| 81 | 81 | */ | 
| 82 | 82 | public static function loadContextFromFile(string $filePath): ContextInterface | 
| 83 | 83 |      { | 
| 84 | -        if(!file_exists($filePath)){ | |
| 85 | -            throw new Exception\FileNotFoundException('Context file not found: '.$filePath, 404, null, $filePath); | |
| 84 | +        if (!file_exists($filePath)) { | |
| 85 | +            throw new Exception\FileNotFoundException('Context file not found: ' . $filePath, 404, null, $filePath); | |
| 86 | 86 | } | 
| 87 | 87 | |
| 88 | 88 | $contents = file_get_contents($filePath); | 
| 89 | 89 | $context_array = json_decode($contents, true); | 
| 90 | 90 | |
| 91 | -        if($context_array === null){ | |
| 91 | +        if ($context_array === null) { | |
| 92 | 92 |              throw new Exception\MalformedJsonException('JSON sintax error.'); | 
| 93 | 93 | } | 
| 94 | 94 | |
| @@ -11,48 +11,48 @@ | ||
| 11 | 11 | |
| 12 | 12 | trait PropertyHandler | 
| 13 | 13 |  { | 
| 14 | - /** | |
| 15 | - * @param array $data | |
| 16 | - */ | |
| 17 | - function fillProperties(array $data) | |
| 18 | -	{ | |
| 19 | - foreach ($data as $p => $v) | |
| 20 | -		{ | |
| 21 | - $this->fillProperty($p, $v); | |
| 22 | - } | |
| 23 | - } | |
| 14 | + /** | |
| 15 | + * @param array $data | |
| 16 | + */ | |
| 17 | + function fillProperties(array $data) | |
| 18 | +    { | |
| 19 | + foreach ($data as $p => $v) | |
| 20 | +        { | |
| 21 | + $this->fillProperty($p, $v); | |
| 22 | + } | |
| 23 | + } | |
| 24 | 24 | |
| 25 | - /** | |
| 26 | - * @param string $property | |
| 27 | - * @param mixed $value | |
| 28 | - */ | |
| 29 | - function fillProperty(string $property, $value) | |
| 30 | -	{ | |
| 31 | -		$property = lcfirst(str_replace('_', '', ucwords($property, '_'))); | |
| 32 | - if(property_exists(__CLASS__, $property)) | |
| 33 | -		{ | |
| 34 | -			$method = sprintf('set%s', ucfirst($property)); | |
| 35 | -			$this->{$method}($value); | |
| 36 | - } | |
| 37 | - } | |
| 25 | + /** | |
| 26 | + * @param string $property | |
| 27 | + * @param mixed $value | |
| 28 | + */ | |
| 29 | + function fillProperty(string $property, $value) | |
| 30 | +    { | |
| 31 | +        $property = lcfirst(str_replace('_', '', ucwords($property, '_'))); | |
| 32 | + if(property_exists(__CLASS__, $property)) | |
| 33 | +        { | |
| 34 | +            $method = sprintf('set%s', ucfirst($property)); | |
| 35 | +            $this->{$method}($value); | |
| 36 | + } | |
| 37 | + } | |
| 38 | 38 | |
| 39 | - /** | |
| 40 | - * @return array | |
| 41 | - */ | |
| 42 | - function getPropertyArray(): array | |
| 43 | -	{ | |
| 44 | - $reflection = new \ReflectionClass(__CLASS__); | |
| 45 | - $properties = $reflection->getProperties(\ReflectionProperty::IS_PROTECTED); | |
| 46 | - $data = []; | |
| 47 | -		foreach($properties as $property){ | |
| 48 | - $prop_name = $property->getName(); | |
| 49 | -			$method = sprintf('get%s', ucfirst($prop_name)); | |
| 50 | -			$form_name = strtolower(preg_replace('/[A-Z]/', '_$0', $prop_name)); | |
| 51 | -			if($reflection->hasMethod($method)){ | |
| 52 | -				$data[$form_name] = $this->{$method}(); | |
| 53 | - } | |
| 54 | - } | |
| 55 | - return $data; | |
| 56 | - } | |
| 39 | + /** | |
| 40 | + * @return array | |
| 41 | + */ | |
| 42 | + function getPropertyArray(): array | |
| 43 | +    { | |
| 44 | + $reflection = new \ReflectionClass(__CLASS__); | |
| 45 | + $properties = $reflection->getProperties(\ReflectionProperty::IS_PROTECTED); | |
| 46 | + $data = []; | |
| 47 | +        foreach($properties as $property){ | |
| 48 | + $prop_name = $property->getName(); | |
| 49 | +            $method = sprintf('get%s', ucfirst($prop_name)); | |
| 50 | +            $form_name = strtolower(preg_replace('/[A-Z]/', '_$0', $prop_name)); | |
| 51 | +            if($reflection->hasMethod($method)){ | |
| 52 | +                $data[$form_name] = $this->{$method}(); | |
| 53 | + } | |
| 54 | + } | |
| 55 | + return $data; | |
| 56 | + } | |
| 57 | 57 | |
| 58 | 58 | } | 
| @@ -29,7 +29,7 @@ discard block | ||
| 29 | 29 | function fillProperty(string $property, $value) | 
| 30 | 30 |  	{ | 
| 31 | 31 |  		$property = lcfirst(str_replace('_', '', ucwords($property, '_'))); | 
| 32 | - if(property_exists(__CLASS__, $property)) | |
| 32 | + if (property_exists(__CLASS__, $property)) | |
| 33 | 33 |  		{ | 
| 34 | 34 |  			$method = sprintf('set%s', ucfirst($property)); | 
| 35 | 35 |  			$this->{$method}($value); | 
| @@ -44,11 +44,11 @@ discard block | ||
| 44 | 44 | $reflection = new \ReflectionClass(__CLASS__); | 
| 45 | 45 | $properties = $reflection->getProperties(\ReflectionProperty::IS_PROTECTED); | 
| 46 | 46 | $data = []; | 
| 47 | -		foreach($properties as $property){ | |
| 47 | +		foreach ($properties as $property) { | |
| 48 | 48 | $prop_name = $property->getName(); | 
| 49 | 49 |  			$method = sprintf('get%s', ucfirst($prop_name)); | 
| 50 | 50 |  			$form_name = strtolower(preg_replace('/[A-Z]/', '_$0', $prop_name)); | 
| 51 | -			if($reflection->hasMethod($method)){ | |
| 51 | +			if ($reflection->hasMethod($method)) { | |
| 52 | 52 |  				$data[$form_name] = $this->{$method}(); | 
| 53 | 53 | } | 
| 54 | 54 | } | 
| @@ -5,11 +5,11 @@ discard block | ||
| 5 | 5 | |
| 6 | 6 | interface SumUpClientInterface | 
| 7 | 7 |  { | 
| 8 | - /** | |
| 9 | - * CheckoutClientInterface constructor. | |
| 10 | - * @param ContextInterface $context | |
| 11 | - */ | |
| 12 | - function __construct(ContextInterface $context); | |
| 8 | + /** | |
| 9 | + * CheckoutClientInterface constructor. | |
| 10 | + * @param ContextInterface $context | |
| 11 | + */ | |
| 12 | + function __construct(ContextInterface $context); | |
| 13 | 13 | |
| 14 | 14 | /** | 
| 15 | 15 | * Shows in an array all scopes required by the client | 
| @@ -18,15 +18,15 @@ discard block | ||
| 18 | 18 | */ | 
| 19 | 19 | static function getScopes(): array; | 
| 20 | 20 | |
| 21 | - /** | |
| 22 | - * Return last response of client | |
| 23 | - * @return ResponseInterface | |
| 24 | - */ | |
| 25 | - function getLastResponse(): ResponseInterface; | |
| 21 | + /** | |
| 22 | + * Return last response of client | |
| 23 | + * @return ResponseInterface | |
| 24 | + */ | |
| 25 | + function getLastResponse(): ResponseInterface; | |
| 26 | 26 | |
| 27 | - /** | |
| 28 | - * return the context used to created the client. | |
| 29 | - * @return ContextInterface | |
| 30 | - */ | |
| 31 | - function getContext(): ContextInterface; | |
| 27 | + /** | |
| 28 | + * return the context used to created the client. | |
| 29 | + * @return ContextInterface | |
| 30 | + */ | |
| 31 | + function getContext(): ContextInterface; | |
| 32 | 32 | } | 
| @@ -7,25 +7,25 @@ | ||
| 7 | 7 | |
| 8 | 8 | class SumUp | 
| 9 | 9 |  { | 
| 10 | - const VERSION = 'v0.1'; | |
| 11 | - const ENTRYPOINT = 'https://api.sumup.com/'; | |
| 10 | + const VERSION = 'v0.1'; | |
| 11 | + const ENTRYPOINT = 'https://api.sumup.com/'; | |
| 12 | 12 | |
| 13 | - /** | |
| 14 | - * @return ClientInterface | |
| 15 | - */ | |
| 16 | - static function getClient(): ClientInterface | |
| 17 | -	{ | |
| 18 | - return new Client( | |
| 19 | - [ | |
| 20 | - 'base_uri' => self::getEntrypoint(), | |
| 21 | - 'timeout' => 2 | |
| 22 | - ] | |
| 23 | - ); | |
| 24 | - } | |
| 13 | + /** | |
| 14 | + * @return ClientInterface | |
| 15 | + */ | |
| 16 | + static function getClient(): ClientInterface | |
| 17 | +    { | |
| 18 | + return new Client( | |
| 19 | + [ | |
| 20 | + 'base_uri' => self::getEntrypoint(), | |
| 21 | + 'timeout' => 2 | |
| 22 | + ] | |
| 23 | + ); | |
| 24 | + } | |
| 25 | 25 | |
| 26 | - static function getEntrypoint(): string | |
| 27 | -	{ | |
| 28 | - return self::ENTRYPOINT.self::VERSION.'/'; | |
| 29 | - } | |
| 26 | + static function getEntrypoint(): string | |
| 27 | +    { | |
| 28 | + return self::ENTRYPOINT.self::VERSION.'/'; | |
| 29 | + } | |
| 30 | 30 | } | 
| 31 | 31 | |
| @@ -25,7 +25,7 @@ | ||
| 25 | 25 | |
| 26 | 26 | static function getEntrypoint(): string | 
| 27 | 27 |  	{ | 
| 28 | - return self::ENTRYPOINT.self::VERSION.'/'; | |
| 28 | + return self::ENTRYPOINT . self::VERSION . '/'; | |
| 29 | 29 | } | 
| 30 | 30 | } | 
| 31 | 31 | |
| @@ -9,7 +9,7 @@ discard block | ||
| 9 | 9 | interface CheckoutClientInterface extends SumUpClientInterface | 
| 10 | 10 |  { | 
| 11 | 11 | |
| 12 | - /** | |
| 12 | + /** | |
| 13 | 13 | * Create a checkout | 
| 14 | 14 | * | 
| 15 | 15 | * @param CheckoutInterface $checkout | 
| @@ -44,12 +44,12 @@ discard block | ||
| 44 | 44 | */ | 
| 45 | 45 | static function getCheckoutBody(CheckoutInterface $checkout): array; | 
| 46 | 46 | |
| 47 | - /** | |
| 48 | - * Generate a body to a complete checkout request. | |
| 49 | - * | |
| 50 | - * @param CheckoutInterface $checkout | |
| 51 | - * @return array | |
| 52 | - */ | |
| 47 | + /** | |
| 48 | + * Generate a body to a complete checkout request. | |
| 49 | + * | |
| 50 | + * @param CheckoutInterface $checkout | |
| 51 | + * @return array | |
| 52 | + */ | |
| 53 | 53 | static function getCompleteCheckoutBody(CheckoutInterface $checkout): array; | 
| 54 | 54 | |
| 55 | 55 | } | 
| @@ -16,7 +16,7 @@ discard block | ||
| 16 | 16 | * @param AccessToken $accessToken | 
| 17 | 17 | * @return CheckoutInterface | 
| 18 | 18 | */ | 
| 19 | - public function create(CheckoutInterface $checkout, AccessToken $accessToken = null):? CheckoutInterface; | |
| 19 | + public function create(CheckoutInterface $checkout, AccessToken $accessToken = null): ? CheckoutInterface; | |
| 20 | 20 | |
| 21 | 21 | /** | 
| 22 | 22 | * Retrieve a checkout from sumup.com server | 
| @@ -25,7 +25,7 @@ discard block | ||
| 25 | 25 | * @param AccessToken $accessToken | 
| 26 | 26 | * @return CheckoutInterface | 
| 27 | 27 | */ | 
| 28 | - public function get(CheckoutInterface $checkout, AccessToken $accessToken = null):? CheckoutInterface; | |
| 28 | + public function get(CheckoutInterface $checkout, AccessToken $accessToken = null): ? CheckoutInterface; | |
| 29 | 29 | |
| 30 | 30 | /** | 
| 31 | 31 | * Complete a checkout | 
| @@ -34,7 +34,7 @@ discard block | ||
| 34 | 34 | * @param AccessToken $accessToken | 
| 35 | 35 | * @return CheckoutInterface | 
| 36 | 36 | */ | 
| 37 | - public function complete(CheckoutInterface $checkout, AccessToken $accessToken = null):? CheckoutInterface; | |
| 37 | + public function complete(CheckoutInterface $checkout, AccessToken $accessToken = null): ? CheckoutInterface; | |
| 38 | 38 | |
| 39 | 39 | /** | 
| 40 | 40 | * Generate body to request a new checkout. |