Skip to content

Commit 2ba59e0

Browse files
authored
Housekeeping (#3)
1 parent a339f88 commit 2ba59e0

16 files changed

+57
-109
lines changed

.gitattributes

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
/.gitattributes export-ignore
22
/.editorconfig export-ignore
33
/.gitignore export-ignore
4-
/.travis.yml export-ignore
54
/composer.lock export-ignore
6-
/CODE_OF_CONDUCT.md export-ignore
7-
/CONTRIBUTING.md export-ignore
85
/phpunit.xml.dist export-ignore
6+
/phpunit.xml export-ignore
7+
/phpstan.neon export-ignore
98
/tests export-ignore
109
/.github export-ignore
1110

CODE_OF_CONDUCT.md renamed to .github/CODE_OF_CONDUCT.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ Violating these terms may lead to a permanent ban.
106106
### 4. Permanent Ban
107107

108108
**Community Impact**: Demonstrating a pattern of violation of community
109-
standards, including sustained inappropriate behavior, harassment of an
109+
standards, including sustained inappropriate behavior, harassment of an
110110
individual, or aggression toward or disparagement of classes of individuals.
111111

112112
**Consequence**: A permanent ban from any sort of public interaction within

CONTRIBUTING.md renamed to .github/CONTRIBUTING.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ Please be considerate towards maintainers when raising issues or presenting pull
1414
world that developers are civilized and selfless people.
1515

1616
It's the duty of the maintainer to ensure that all submissions to the project are of sufficient
17-
quality to benefit the project. Many developers have different skillsets, strengths, and weaknesses. Respect the maintainer's decision, and do not be upset or abusive if your submission is not used.
17+
quality to benefit the project. Many developers have different skillsets, strengths, and weaknesses. Respect the
18+
maintainer's decision, and do not be upset or abusive if your submission is not used.
1819

1920
## Viability
2021

@@ -40,16 +41,23 @@ Before submitting a pull request:
4041

4142
If the project maintainer has any additional requirements, you will find them listed here.
4243

43-
- **[PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** - The easiest way to apply the conventions is to install [PHP Code Sniffer](https://pear.php.net/package/PHP_CodeSniffer).
44+
- **[PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)**
45+
- The easiest way to apply the conventions is to
46+
install [PHP Code Sniffer](https://pear.php.net/package/PHP_CodeSniffer).
4447

4548
- **Add tests!** - Your patch won't be accepted if it doesn't have tests.
4649

47-
- **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date.
50+
- **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept
51+
up-to-date.
4852

49-
- **Consider our release cycle** - We try to follow [SemVer v2.0.0](https://semver.org/). Randomly breaking public APIs is not an option.
53+
- **Consider our release cycle** - We try to follow [SemVer v2.0.0](https://semver.org/). Randomly breaking public APIs
54+
is not an option.
5055

5156
- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests.
5257

53-
- **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](https://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting.
58+
- **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make
59+
multiple intermediate commits while developing,
60+
please [squash them](https://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages)
61+
before submitting.
5462

5563
**Happy coding**!

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ A clear and concise description of what the bug is.
1212

1313
**To Reproduce**
1414
Steps to reproduce the behavior:
15+
1516
1. Go to '...'
1617
2. Click on '....'
1718
3. Scroll down to '....'

.github/ISSUE_TEMPLATE/feature_request.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ assignees: ''
88
---
99

1010
**Is your feature request related to a problem? Please describe.**
11-
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
11+
A clear and concise description of what the issue is. Ex. I'm always frustrated when [...]
1212

1313
**Describe the solution you'd like**
1414
A clear and concise description of what you want to happen.

.github/workflows/php.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
name: Tests
22

3-
on: [ push, pull_request ]
3+
on:
4+
push:
5+
pull_request:
6+
schedule:
7+
- cron: '0 0 1 * *'
48

59
jobs:
610
test:
711
runs-on: ${{ matrix.os }}
12+
timeout-minutes: 5
813
strategy:
914
fail-fast: true
1015
matrix:
@@ -16,7 +21,7 @@ jobs:
1621

1722
steps:
1823
- name: Checkout code
19-
uses: actions/checkout@v2
24+
uses: actions/checkout@v3
2025

2126
- name: Setup PHP
2227
uses: shivammathur/setup-php@v2

README.md

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,18 @@
55
[![Total Downloads](http://poser.pugx.org/phpjuice/paypal-http-client/downloads)](https://packagist.org/packages/phpjuice/paypal-http-client)
66
[![License](http://poser.pugx.org/phpjuice/paypal-http-client/license)](https://packagist.org/packages/phpjuice/paypal-http-client)
77

8-
This Package is a PHP Http Client. It provides a simple, fluent API to interact with PayPal rest API with both sandbox
9-
and production environments supported.
8+
This Package is a PHP Http Client. It provides a simple, fluent API to interact with PayPal rest API.
109

1110
To learn all about it, head over to the extensive [documentation](https://phpjuice.gitbook.io/paypal-checkout-sdk).
1211

1312
## Installation
1413

15-
PayPal HTTP Client Package requires PHP 7.4 or higher.
14+
This Package requires PHP 7.4 or higher.
1615

17-
> **INFO:** If you are using an older version of php this package may not function correctly.
18-
19-
The supported way of installing PayPal HTTP Client package is via Composer.
16+
One can install this package via Composer.
2017

2118
```bash
22-
composer require phpjuice/paypal-http-client
19+
composer require "phpjuice/paypal-http-client"
2320
```
2421

2522
## Setup
@@ -28,18 +25,19 @@ PayPal HTTP Client is designed to simplify using the new PayPal checkout api in
2825

2926
### Setup Credentials
3027

31-
Get client ID and client secret by going
32-
to [https://developer.paypal.com/developer/applications](https://developer.paypal.com/developer/applications) and
33-
generating a REST API app. Get Client ID and Secret from there.
28+
Get client ID and client secret by visiting
29+
the [PayPal Developer Account](https://developer.paypal.com/developer/applications) and
30+
generating a REST API app.
3431

35-
### Setup a Paypal Client
32+
### Setup Paypal Client
3633

37-
Inorder to communicate with PayPal platform we need to set up a client first :
34+
In order to communicate with PayPal platform we need to set up a client first :
3835

3936
#### Create a client with sandbox environment:
4037

4138
```php
42-
// import namespace
39+
<?php
40+
4341
use PayPal\Http\Environment\SandboxEnvironment;
4442
use PayPal\Http\PayPalClient;
4543

@@ -57,7 +55,8 @@ $client = new PayPalClient($environment);
5755
#### Create a client with production environment:
5856

5957
```php
60-
// import namespace
58+
<?php
59+
6160
use PayPal\Http\Environment\ProductionEnvironment;
6261
use PayPal\Http\PayPalClient;
6362

@@ -74,11 +73,11 @@ $client = new PayPalClient($environment);
7473

7574
## Changelog
7675

77-
Please see the [changelog](changelog.md) for more information on what has changed recently.
76+
Please see the [CHANGELOG](changelog.md) for more information on what has changed recently.
7877

7978
## Contributing
8079

81-
Please see [CONTRIBUTING.md](./CONTRIBUTING.md) for details and a todo list.
80+
Please see [CONTRIBUTING](./.github/CONTRIBUTING.md) for details and a todo list.
8281

8382
## Security
8483

@@ -91,10 +90,4 @@ If you discover any security related issues, please email author instead of usin
9190

9291
## License
9392

94-
license. Please see the [Licence](https://github.com/phpjuice/paypal-http-client/blob/main/LICENSE) for more
95-
information.
96-
97-
![Tests](https://github.com/phpjuice/paypal-http-client/workflows/Tests/badge.svg?branch=main)
98-
[![Latest Stable Version](http://poser.pugx.org/phpjuice/paypal-http-client/v)](https://packagist.org/packages/phpjuice/paypal-http-client)
99-
[![Total Downloads](http://poser.pugx.org/phpjuice/paypal-http-client/downloads)](https://packagist.org/packages/phpjuice/paypal-http-client)
100-
[![License](http://poser.pugx.org/phpjuice/paypal-http-client/license)](https://packagist.org/packages/phpjuice/paypal-http-client)
93+
Please see the [Licence](./LICENSE) file.

composer.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818
}
1919
],
2020
"require": {
21-
"php": "^7.4|^8.0|^8.1",
21+
"php": "^7.4 || ^8.0 || ^8.1",
2222
"ext-json": "*",
23-
"guzzlehttp/psr7": "^1.6|^2.0",
23+
"guzzlehttp/psr7": "^1.6 || ^2.0",
2424
"guzzlehttp/guzzle": "^7.0"
2525
},
2626
"require-dev": {
@@ -49,6 +49,9 @@
4949
]
5050
},
5151
"config": {
52-
"sort-packages": true
52+
"sort-packages": true,
53+
"allow-plugins": {
54+
"pestphp/pest-plugin": true
55+
}
5356
}
5457
}

src/AccessToken.php

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,22 @@ class AccessToken
66
{
77
/**
88
* Access token returned by PayPal.
9-
*
10-
* @var string
119
*/
1210
protected string $token;
1311

1412
/**
1513
* Access token type.
1614
*
17-
* @var string
1815
*/
1916
protected string $token_type;
2017

2118
/**
22-
* time for access token to expires in seconds.
23-
*
24-
* @var int
19+
* Time for access token to expires in seconds.
2520
*/
2621
protected int $expires_in;
2722

2823
/**
29-
* time for creating access token to expires in seconds.
30-
*
31-
* @var int
24+
* Time for creating access token to expires in seconds.
3225
*/
3326
protected int $created_at;
3427

@@ -41,34 +34,34 @@ public function __construct(string $token, string $token_type, int $expires_in)
4134
}
4235

4336
/**
44-
* gets the token.
37+
* Get the token.
4538
*/
4639
public function getToken(): ?string
4740
{
4841
return $this->token;
4942
}
5043

5144
/**
52-
* gets the token.
45+
* Get the token type.
5346
*/
5447
public function getTokenType(): ?string
5548
{
5649
return $this->token_type;
5750
}
5851

5952
/**
60-
* returns authorization string.
53+
* Returns authorization string.
6154
*/
6255
public function authorizationString(): string
6356
{
6457
return $this->token_type.' '.$this->token;
6558
}
6659

6760
/**
68-
* returns if a token is expired or not.
61+
* Determines if the token is expired or not.
6962
*/
7063
public function isExpired(): bool
7164
{
72-
return time() >= $this->created_at + $this->expires_in;
65+
return time() >= ($this->created_at + $this->expires_in);
7366
}
7467
}

src/Environment/Environment.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,9 @@
44

55
interface Environment
66
{
7-
/**
8-
* @return string
9-
*/
107
public function name(): string;
118

12-
/**
13-
* @return string
14-
*/
159
public function baseUrl(): string;
1610

17-
/**
18-
* @return string
19-
*/
2011
public function basicAuthorizationString(): string;
2112
}

src/Environment/PayPalEnvironment.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,11 @@ abstract class PayPalEnvironment implements Environment
66
{
77
/**
88
* Paypal client id.
9-
*
10-
* @var string
119
*/
1210
protected string $clientId;
1311

1412
/**
1513
* PayPal client secret.
16-
*
17-
* @var string
1814
*/
1915
protected string $clientSecret;
2016

@@ -24,9 +20,6 @@ public function __construct(string $clientId, string $clientSecret)
2420
$this->clientSecret = $clientSecret;
2521
}
2622

27-
/**
28-
* @return string
29-
*/
3023
public function basicAuthorizationString(): string
3124
{
3225
return base64_encode($this->clientId.':'.$this->clientSecret);

src/Environment/ProductionEnvironment.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,11 @@
44

55
class ProductionEnvironment extends PayPalEnvironment
66
{
7-
/**
8-
* @return string
9-
*/
107
public function baseUrl(): string
118
{
129
return 'https://api.paypal.com';
1310
}
1411

15-
/**
16-
* @return string
17-
*/
1812
public function name(): string
1913
{
2014
return 'production';

src/Environment/SandboxEnvironment.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,11 @@
44

55
class SandboxEnvironment extends PayPalEnvironment
66
{
7-
/**
8-
* @return string
9-
*/
107
public function baseUrl(): string
118
{
129
return 'https://api.sandbox.paypal.com';
1310
}
1411

15-
/**
16-
* @return string
17-
*/
1812
public function name(): string
1913
{
2014
return 'sandbox';

src/Exceptions/JsonEncodingException.php

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)