Skip to content

Commit e6f8446

Browse files
authored
Merge pull request #240 from kubawerlos/improvements
Improvements: composer.json, coding style, PHPUnit and Travis CI
2 parents b8bf1ee + 07e2887 commit e6f8446

31 files changed

+114
-81
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,5 @@ script/*
88
/build
99
/test/reports
1010
.env
11+
/.php_cs
12+
/.php_cs.cache

.php_cs.dist

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
return PhpCsFixer\Config::create()
3+
->setFinder(
4+
PhpCsFixer\Finder::create()
5+
->files()
6+
->in(__DIR__ . '/src')
7+
->in(__DIR__ . '/test')
8+
)
9+
->setRules([
10+
'@PSR2' => true,
11+
]);

.travis.yml

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,36 @@
1+
sudo: false
2+
3+
cache:
4+
directories:
5+
- $HOME/.composer
6+
7+
git:
8+
depth: 1
9+
110
language: php
2-
php:
3-
- 7.2
4-
- 7.1
5-
- 7.0
6-
before_script:
7-
- composer install --dev --optimize-autoloader
8-
- mkdir -p build/logs
9-
after_script:
10-
- php vendor/bin/coveralls -v
11-
env:
12-
global:
13-
- secure: esQlDAcdxPtpwlOIFrC6d7/ejoOQyJJGeY/lhPv0qiWJ974+XxjLU7vGn0lKS5K4Z5WlZkGClEsfNok51Bm4JPnMsAZHTAO9f6bR7YpNrynmTyrwdv2NMUfAID8cJ9pUVZpbuT91M9aCuxUy4i2s+lx88myOVVr2r1YxQVcV1OA=
14-
- secure: c9AOiucZTzzQu5QSLycx5CnQObIvkLiGrAv7yZg9gEouCDd3p4InOrW28WwMJjvVlTSN5BzEe1FLDh+rvatO2q4dwTTbx6NQ2QMTfM4W/L3M/Iv5yBt7VjuqlPXb4oHIvydvr/GXoRL/hNtn9wL/EdU5sKfSu+n0xVwsmCql/3U=
15-
- secure: VKJgrYDePSIbdux5NodegW3vhLa3YSWLEkeTlScrGHBZVGK7K4F73s3v+32TeSNz/RYM8/MnSq2r9DUA7uPdms4UAWAFcz8uC36sOl1hkBy2gJAvYJJB5oLylR9TWXe+j20sDShdeGgfpFLcy/POcqdwQcJAx5XitDY4pw2ZwBI=
11+
12+
before_install:
13+
- composer self-update
14+
- phpenv config-rm xdebug.ini || return 0
15+
- composer global show hirak/prestissimo -q || composer global require hirak/prestissimo
16+
17+
matrix:
18+
include:
19+
- name: PHP 7.0 with lowest versions of dependencies
20+
php: '7.0'
21+
install: composer update --prefer-lowest
22+
- name: PHP 7.0
23+
php: '7.0'
24+
install: composer update
25+
- name: PHP 7.1
26+
php: '7.1'
27+
install: composer update
28+
- name: PHP 7.2
29+
php: '7.2'
30+
install: composer update
31+
after_script:
32+
- php vendor/bin/coveralls -v
33+
34+
script:
35+
- vendor/bin/php-cs-fixer fix --diff --dry-run -v
36+
- vendor/bin/phpunit

composer.json

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@
22
"name": "bigcommerce/api",
33
"type": "library",
44
"description": "Enables PHP applications to communicate with the Bigcommerce API.",
5-
"keywords": ["api", "http", "rest", "ecommerce", "business"],
5+
"keywords": [
6+
"api",
7+
"http",
8+
"rest",
9+
"ecommerce",
10+
"business"
11+
],
612
"homepage": "http://developer.bigcommerce.com",
713
"license": "MIT",
814
"authors": [
@@ -13,22 +19,22 @@
1319
],
1420
"require": {
1521
"php": ">=7.0",
16-
"firebase/php-jwt": "~3.0|~5.0"
22+
"firebase/php-jwt": "~3.0 || ~5.0"
1723
},
1824
"require-dev": {
19-
"phpunit/phpunit": "^4.8.35",
25+
"codeless/jugglecode": "1.0",
26+
"friendsofphp/php-cs-fixer": "^2.13",
2027
"php-coveralls/php-coveralls": "2.1",
21-
"codeless/jugglecode": "1.0"
28+
"phpunit/phpunit": "^6.4 || ^7.4"
2229
},
2330
"autoload": {
2431
"psr-0": {
2532
"Bigcommerce": "src/"
26-
},
33+
}
34+
},
35+
"autoload-dev": {
2736
"psr-4": {
2837
"Bigcommerce\\Test\\": "test/"
2938
}
30-
},
31-
"scripts": {
32-
"test": "phpunit"
3339
}
3440
}

phpunit.xml.dist

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3-
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.8/phpunit.xsd"
3+
xsi:noNamespaceSchemaLocation='vendor/phpunit/phpunit/phpunit.xsd'
44
backupGlobals="true"
55
backupStaticAttributes="true"
66
colors="true"
@@ -15,18 +15,15 @@
1515
<log type="coverage-php" target="build/logs/coverage.cov"/>
1616
<log type="coverage-text" target="build/logs/coverage.txt" showUncoveredFiles="false"/>
1717
<log type="coverage-html" target="test/reports/coverage/" showUncoveredFiles="true"/>
18-
<log type="junit" target="test/reports/junit.xml" logIncompleteSkipped="false"/>
18+
<log type="junit" target="test/reports/junit.xml"/>
1919
</logging>
2020
<testsuites>
21-
<testsuite>
21+
<testsuite name="test">
2222
<directory>test/</directory>
2323
</testsuite>
2424
</testsuites>
2525
<filter>
26-
<blacklist>
27-
<directory suffix=".php">vendor/</directory>
28-
</blacklist>
29-
<whitelist addUncoveredFilesFromWhitelist="true">
26+
<whitelist>
3027
<directory suffix=".php">src/</directory>
3128
</whitelist>
3229
</filter>

src/Bigcommerce/Api/Client.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,56 +15,56 @@ class Client
1515
*
1616
* @var string
1717
*/
18-
static private $store_url;
18+
private static $store_url;
1919

2020
/**
2121
* Username to connect to the store API with
2222
*
2323
* @var string
2424
*/
25-
static private $username;
25+
private static $username;
2626

2727
/**
2828
* API key
2929
*
3030
* @var string
3131
*/
32-
static private $api_key;
32+
private static $api_key;
3333

3434
/**
3535
* Connection instance
3636
*
3737
* @var Connection
3838
*/
39-
static private $connection;
39+
private static $connection;
4040

4141
/**
4242
* Resource class name
4343
*
4444
* @var string
4545
*/
46-
static private $resource;
46+
private static $resource;
4747

4848
/**
4949
* API path prefix to be added to store URL for requests
5050
*
5151
* @var string
5252
*/
53-
static private $path_prefix = '/api/v2';
53+
private static $path_prefix = '/api/v2';
5454

5555
/**
5656
* Full URL path to the configured store API.
5757
*
5858
* @var string
5959
*/
60-
static public $api_path;
61-
static private $client_id;
62-
static private $store_hash;
63-
static private $auth_token;
64-
static private $client_secret;
65-
static private $stores_prefix = '/stores/%s/v2';
66-
static private $api_url = 'https://api.bigcommerce.com';
67-
static private $login_url = 'https://login.bigcommerce.com';
60+
public static $api_path;
61+
private static $client_id;
62+
private static $store_hash;
63+
private static $auth_token;
64+
private static $client_secret;
65+
private static $stores_prefix = '/stores/%s/v2';
66+
private static $api_url = 'https://api.bigcommerce.com';
67+
private static $login_url = 'https://login.bigcommerce.com';
6868

6969
/**
7070
* Configure the API client with the required settings to access

src/Bigcommerce/Api/ClientError.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
*/
88
class ClientError extends Error
99
{
10-
1110
public function __toString()
1211
{
1312
return "Client Error ({$this->code}): " . $this->message;

src/Bigcommerce/Api/Connection.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,6 @@ private function followRedirectPath()
340340
}
341341

342342
$this->get($url);
343-
344343
} else {
345344
$errorString = "Too many redirects when trying to follow location.";
346345
throw new NetworkError($errorString, CURLE_TOO_MANY_REDIRECTS);

src/Bigcommerce/Api/Resources/Address.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,4 @@
77

88
class Address extends Resource
99
{
10-
11-
}
10+
}

src/Bigcommerce/Api/Resources/DiscountRule.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,4 @@
1010
*/
1111
class DiscountRule extends Resource
1212
{
13-
1413
}

0 commit comments

Comments
 (0)