Skip to content

Commit

Permalink
Fixing PSR2 camel format
Browse files Browse the repository at this point in the history
  • Loading branch information
lsolesen committed May 4, 2016
1 parent 5b1d195 commit a8620df
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 40 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ before_script:
script:
- phpunit --coverage-clover build/logs/clover.xml ./tests
- ./vendor/bin/phpcs --standard=PSR2 src
- ./vendor/bin/phpcs --standard=PSR2 tests

after_script:
- php vendor/bin/coveralls -v
19 changes: 12 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
PostNord [![Build Status](https://travis-ci.org/lsolesen/postnord-sdk.svg?branch=master)](https://travis-ci.org/lsolesen/postnord-sdk) [![Coverage Status](https://coveralls.io/repos/lsolesen/postnord-sdk/badge.svg)](https://coveralls.io/r/lsolesen/postnord-sdk)
PostNord [![Build Status](https://travis-ci.org/lsolesen/postnord-php-sdk.svg?branch=master)](https://travis-ci.org/lsolesen/postnord-php-sdk) [![Coverage Status](https://coveralls.io/repos/lsolesen/postnord-php-sdk/badge.svg)](https://coveralls.io/r/lsolesen/postnord-php-sdk)
==

PHP-SDK for [PostNord webservices](http://www.postdanmark.dk/da/Logistik/netbutikker/login/Sider/webservices.aspx). You need an [API-key](http://www.postdanmark.dk/da/Logistik/netbutikker/login/Sider/Opret.aspx) to use the service.
PHP-SDK for [PostNord webservices](http://www.postdanmark.dk/da/erhverv/faa-raadgivning/e-handel/webservices/Sider/webservices.aspx). You need an [API-key](http://www.postdanmark.dk/da/erhverv/faa-raadgivning/e-handel/webservices/login/Sider/api-og-widgets.aspx) to use the service.

<?php
$request = new PostNord_Request($apiKey);
$client = new PostNord_Client($request);
```php5
<?php
use PostNord\Client\Request;
use PostNord\Client\Client;

$result = $client->findNearestByZipCode(7100);
$request = new Request($apiKey);
$client = new Client($request);

Check out the full API for [Pick location](http://logistics.postennorden.com/wsp/rest-services/api-doc/PublicApiDoc-publicapi.html) and for [Track'n'Trace](http://logistics.postennorden.com/wsp/rest-services/ntt-service-rest/api/shipment/menu.html)
$result = $client->findNearestByZipCode(7100);
```

Check out the full API for [servicepoints](http://logistics.postennorden.com/wsp/docs/servicepoints/index.html), [Track'n'Trace](http://logistics.postennorden.com/wsp/rest-services/ntt-service-rest/api/shipment/menu.html) and [Transit time](http://logistics.postennorden.com/wsp/rest-services/notis-rest/api/transitTimeInfo/menu.html).
6 changes: 6 additions & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0"?>
<!--suppress XmlUnboundNsPrefix -->
<ruleset name="PHP-SDK">
<description>Coding standards based on the PSR-2 coding standard.</description>
<rule ref="PSR2"/>
</ruleset>
13 changes: 5 additions & 8 deletions src/Client/PostNord_Client.php → src/Client/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@
* @package PostNord
* @author Lars Olesen <lars@intraface.dk>
* @copyright 2014 Lars Olesen
* @license http://opensource.org/licenses/bsd-license.php New BSD License
* @version GIT: <git_id>
* @link http://github.com/lsolesen/PostNord
* @license For licensing, see LICENSE.md distributed with this source code.
* @link http://github.com/lsolesen/postnord-php-sdk
*/

namespace PostNord\Client;

use PostNord\Exception\PostNord_Exception;
use PostNord\Exception\PostNordException;

/**
* PostNord: client.
Expand All @@ -24,10 +23,8 @@
* @package PostNord
* @author Lars Olesen <lars@intraface.dk>
* @copyright 2014 Lars Olesen
* @license http://opensource.org/licenses/bsd-license.php New BSD License
* @link http://github.com/lsolesen/PostNord
*/
class PostNord_Client
class Client
{
/**
* Request object.
Expand Down Expand Up @@ -107,7 +104,7 @@ public function findNearestByZipCode($zip_code)
{
$result = $this->request->call('GET', '', $zip_code);
if (!empty($result->info['http_code']) && $result->info['http_code'] != 200) {
throw new PostNord_Exception(
throw new PostNordException(
'Error with http_code: ' . $result->info['http_code']
);
}
Expand Down
13 changes: 6 additions & 7 deletions src/Client/PostNord_Request.php → src/Client/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,23 @@
* @package PostNord
* @author Lars Olesen <lars@intraface.dk>
* @copyright 2014 Lars Olesen
* @license http://opensource.org/licenses/bsd-license.php New BSD License
* @version GIT: <git_id>
* @link http://github.com/lsolesen/PostNord
* @license For licensing, see LICENSE.md distributed with this source code.
* @link http://github.com/lsolesen/postnord-php-sdk
*/

namespace PostNord\Client;

use PostNord\Client\Response;

/**
* PostNord: request.
*
* @category PostNord
* @package PostNord
* @author Lars Olesen <lars@intraface.dk>
* @copyright 2014 Lars Olesen
* @license http://opensource.org/licenses/bsd-license.php New BSD License
* @link http://github.com/lsolesen/PostNord
*/
class PostNord_Request
class Request
{

protected $apiKey;
Expand Down Expand Up @@ -69,6 +68,6 @@ public function call($method, $url, $postcode)
$res = curl_exec($curl);
$info = curl_getinfo($curl);
curl_close($curl);
return new PostNord_Response($info, $res);
return new Response($info, $res);
}
}
11 changes: 4 additions & 7 deletions src/Client/PostNord_Response.php → src/Client/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@
* @package PostNord
* @author Lars Olesen <lars@intraface.dk>
* @copyright 2014 Lars Olesen
* @license http://opensource.org/licenses/bsd-license.php New BSD License
* @version GIT: <git_id>
* @link http://github.com/lsolesen/PostNord
* @license For licensing, see LICENSE.md distributed with this source code.
* @link http://github.com/lsolesen/postnord-php-sdk
*/

namespace PostNord\Client;

use PostNord\Exception\PostNord_Exception;
use PostNord\Exception\PostNordException;

/**
* PostNord: response.
Expand All @@ -24,10 +23,8 @@
* @package PostNord
* @author Lars Olesen <lars@intraface.dk>
* @copyright 2014 Lars Olesen
* @license http://opensource.org/licenses/bsd-license.php New BSD License
* @link http://github.com/lsolesen/PostNord
*/
class PostNord_Response
class Response
{
protected $status;
protected $body;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
* @package PostNord
* @author Lars Olesen <lars@intraface.dk>
* @copyright 2014 Lars Olesen
* @license http://opensource.org/licenses/bsd-license.php New BSD License
* @version GIT: <git_id>
* @link http://github.com/lsolesen/PostNord
* @license For licensing, see LICENSE.md distributed with this source code.
* @link http://github.com/lsolesen/postnord-php-sdk
*/

namespace PostNord\Exception;
Expand All @@ -22,10 +21,8 @@
* @package PostNord
* @author Lars Olesen <lars@intraface.dk>
* @copyright 2014 Lars Olesen
* @license http://opensource.org/licenses/bsd-license.php New BSD License
* @link http://github.com/lsolesen/PostNord
*/
class PostNord_Exception extends \Exception
class PostNordException extends \Exception
{
/**
* Service help URL in reference to error.
Expand Down
10 changes: 5 additions & 5 deletions tests/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace PostNord\Tests;

use PostNord\Client\PostNord_Client;
use PostNord\Client\PostNord_Request;
use PostNord\Client\Client as PostNord_Client;
use PostNord\Client\Request as PostNord_Request;

/**
* Class ClientTest
Expand All @@ -17,20 +17,20 @@ class ClientTest extends \PHPUnit_Framework_TestCase
protected $contactId;
protected $organizationId;

function getClient($key)
public function getClient($key)
{
$request = new PostNord_Request($key);
return new PostNord_Client($request);
}

function testConstructor()
public function testConstructor()
{
$invalid_api_key = 'invalid';
$client = $this->getClient($invalid_api_key);
$this->assertTrue(is_object($client));
}

function testFindNearest()
public function testFindNearest()
{
$client = $this->getClient($this->api_key);
$result = $client->findNearestByZipCode(7100);
Expand Down

0 comments on commit a8620df

Please sign in to comment.