Skip to content

Commit

Permalink
Apply fixes from StyleCI
Browse files Browse the repository at this point in the history
  • Loading branch information
davidvandertuijn authored and StyleCIBot committed Mar 26, 2019
1 parent 6b66628 commit 6e71966
Show file tree
Hide file tree
Showing 22 changed files with 54 additions and 54 deletions.
8 changes: 4 additions & 4 deletions example/example.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

// Autoload composer installed libraries
require __DIR__.'/../vendor/autoload.php';
require __DIR__ . '/../vendor/autoload.php';

/**
* Function to retrieve persisted data for the example.
Expand Down Expand Up @@ -100,7 +100,7 @@ function connect()
try {
$connection->connect();
} catch (\Exception $e) {
throw new Exception('Could not connect to Exact: '.$e->getMessage());
throw new Exception('Could not connect to Exact: ' . $e->getMessage());
}

return $connection;
Expand All @@ -124,8 +124,8 @@ function connect()
$journals = new \Picqer\Financials\Exact\Journal($connection);
$result = $journals->get();
foreach ($result as $journal) {
echo 'Journal: '.$journal->Description.'<br>';
echo 'Journal: ' . $journal->Description . '<br>';
}
} catch (\Exception $e) {
echo get_class($e).' : '.$e->getMessage();
echo get_class($e) . ' : ' . $e->getMessage();
}
2 changes: 1 addition & 1 deletion src/Picqer/Financials/Exact/BankEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class BankEntry extends Model

public function addItem(array $array)
{
if (!isset($this->attributes['BankEntryLines']) || $this->attributes['BankEntryLines'] == null) {
if ( ! isset($this->attributes['BankEntryLines']) || $this->attributes['BankEntryLines'] == null) {
$this->attributes['BankEntryLines'] = [];
}
$this->attributes['BankEntryLines'][] = $array;
Expand Down
2 changes: 1 addition & 1 deletion src/Picqer/Financials/Exact/BillOfMaterialMaterials.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
/*
* Added deprecated BillOfMaterialMaterials class for backward compatibility
*/
class_alias(__NAMESPACE__.'\BillOfMaterialMaterial', __NAMESPACE__.'\BillOfMaterialMaterials');
class_alias(__NAMESPACE__ . '\BillOfMaterialMaterial', __NAMESPACE__ . '\BillOfMaterialMaterials');
2 changes: 1 addition & 1 deletion src/Picqer/Financials/Exact/BillOfMaterialVersions.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
/*
* Added deprecated BillOfMaterialVersions class for backward compatibility
*/
class_alias(__NAMESPACE__.'\BillOfMaterialVersion', __NAMESPACE__.'\BillOfMaterialVersions');
class_alias(__NAMESPACE__ . '\BillOfMaterialVersion', __NAMESPACE__ . '\BillOfMaterialVersions');
2 changes: 1 addition & 1 deletion src/Picqer/Financials/Exact/CashEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class CashEntry extends Model

public function addItem(array $array)
{
if (!isset($this->attributes['CashEntryLines']) || $this->attributes['CashEntryLines'] == null) {
if ( ! isset($this->attributes['CashEntryLines']) || $this->attributes['CashEntryLines'] == null) {
$this->attributes['CashEntryLines'] = [];
}
$this->attributes['CashEntryLines'][] = $array;
Expand Down
36 changes: 18 additions & 18 deletions src/Picqer/Financials/Exact/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class Connection
private $accessToken;

/**
* @var int The Unix timestamp at which the access token expires.
* @var int the Unix timestamp at which the access token expires
*/
private $tokenExpires;

Expand Down Expand Up @@ -174,13 +174,13 @@ private function createRequest($method, $endpoint, $body = null, array $params =
}

// If we have a token, sign the request
if (!$this->needsAuthentication() && !empty($this->accessToken)) {
$headers['Authorization'] = 'Bearer '.$this->accessToken;
if ( ! $this->needsAuthentication() && ! empty($this->accessToken)) {
$headers['Authorization'] = 'Bearer ' . $this->accessToken;
}

// Create param string
if (!empty($params)) {
$endpoint .= '?'.http_build_query($params);
if ( ! empty($params)) {
$endpoint .= '?' . http_build_query($params);
}

// Create the request
Expand Down Expand Up @@ -282,7 +282,7 @@ public function delete($url)
*/
public function getAuthUrl()
{
return $this->baseUrl.$this->authUrl.'?'.http_build_query([
return $this->baseUrl . $this->authUrl . '?' . http_build_query([
'client_id' => $this->exactClientId,
'redirect_uri' => $this->redirectUrl,
'response_type' => 'code',
Expand Down Expand Up @@ -332,7 +332,7 @@ public function setRefreshToken($refreshToken)
public function redirectForAuthorization()
{
$authUrl = $this->getAuthUrl();
header('Location: '.$authUrl);
header('Location: ' . $authUrl);
exit;
}

Expand Down Expand Up @@ -465,10 +465,10 @@ private function acquireAccessToken()
call_user_func($this->tokenUpdateCallback, $this);
}
} else {
throw new ApiException('Could not acquire tokens, json decode failed. Got response: '.$response->getBody()->getContents());
throw new ApiException('Could not acquire tokens, json decode failed. Got response: ' . $response->getBody()->getContents());
}
} catch (BadResponseException $ex) {
throw new ApiException('Could not acquire or refresh tokens [http '.$ex->getResponse()->getStatusCode().']', 0, $ex);
throw new ApiException('Could not acquire or refresh tokens [http ' . $ex->getResponse()->getStatusCode() . ']', 0, $ex);
} finally {
if (is_callable($this->acquireAccessTokenUnlockCallback)) {
call_user_func($this->acquireAccessTokenUnlockCallback, $this);
Expand All @@ -479,29 +479,29 @@ private function acquireAccessToken()
/**
* Translates expires_in to a Unix timestamp.
*
* @param string $expiresIn Number of seconds until the token expires.
* @param string $expiresIn number of seconds until the token expires
*
* @return int
*/
private function getTimestampFromExpiresIn($expiresIn)
{
if (!ctype_digit($expiresIn)) {
if ( ! ctype_digit($expiresIn)) {
throw new \InvalidArgumentException('Function requires a numeric expires value');
}

return time() + $expiresIn;
}

/**
* @return int The Unix timestamp at which the access token expires.
* @return int the Unix timestamp at which the access token expires
*/
public function getTokenExpires()
{
return $this->tokenExpires;
}

/**
* @param int $tokenExpires The Unix timestamp at which the access token expires.
* @param int $tokenExpires the Unix timestamp at which the access token expires
*/
public function setTokenExpires($tokenExpires)
{
Expand Down Expand Up @@ -586,7 +586,7 @@ public function setTokenUpdateCallback($callback)
*/
private function parseExceptionForErrorMessages(Exception $e)
{
if (!$e instanceof BadResponseException) {
if ( ! $e instanceof BadResponseException) {
throw new ApiException($e->getMessage());
}

Expand All @@ -595,13 +595,13 @@ private function parseExceptionForErrorMessages(Exception $e)
$responseBody = $response->getBody()->getContents();
$decodedResponseBody = json_decode($responseBody, true);

if (!is_null($decodedResponseBody) && isset($decodedResponseBody['error']['message']['value'])) {
if ( ! is_null($decodedResponseBody) && isset($decodedResponseBody['error']['message']['value'])) {
$errorMessage = $decodedResponseBody['error']['message']['value'];
} else {
$errorMessage = $responseBody;
}

throw new ApiException('Error '.$response->getStatusCode().': '.$errorMessage);
throw new ApiException('Error ' . $response->getStatusCode() . ': ' . $errorMessage);
}

/**
Expand All @@ -617,15 +617,15 @@ protected function getBaseUrl()
*/
private function getApiUrl()
{
return $this->baseUrl.$this->apiUrl;
return $this->baseUrl . $this->apiUrl;
}

/**
* @return string
*/
private function getTokenUrl()
{
return $this->baseUrl.$this->tokenUrl;
return $this->baseUrl . $this->tokenUrl;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Picqer/Financials/Exact/DocumentAttachment.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ class DocumentAttachment extends Model
*/
public function getDownloadUrl()
{
return $this->Url.'&Download=1';
return $this->Url . '&Download=1';
}
}
2 changes: 1 addition & 1 deletion src/Picqer/Financials/Exact/GeneralJournalEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class GeneralJournalEntry extends Model

public function addItem(array $array)
{
if (!isset($this->attributes['GeneralJournalEntryLines']) || $this->attributes['GeneralJournalEntryLines'] == null) {
if ( ! isset($this->attributes['GeneralJournalEntryLines']) || $this->attributes['GeneralJournalEntryLines'] == null) {
$this->attributes['GeneralJournalEntryLines'] = [];
}
$this->attributes['GeneralJournalEntryLines'][] = $array;
Expand Down
2 changes: 1 addition & 1 deletion src/Picqer/Financials/Exact/InvoiceSalesOrders.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
/*
* Added deprecated InvoiceSalesOrder class for backward compatibility
*/
class_alias(__NAMESPACE__.'\InvoiceSalesOrder', __NAMESPACE__.'\InvoiceSalesOrders');
class_alias(__NAMESPACE__ . '\InvoiceSalesOrder', __NAMESPACE__ . '\InvoiceSalesOrders');
8 changes: 4 additions & 4 deletions src/Picqer/Financials/Exact/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ protected function lazyLoad($key)

try {
if (array_key_exists($key, $this->attributes) && is_array($this->attributes[$key]) && array_key_exists('__deferred', $this->attributes[$key])) {
$class = preg_replace('/(.+?)s?$/', __NAMESPACE__.'\\\$1', $key); // Filter plural 's' and add namespace
$class = preg_replace('/(.+?)s?$/', __NAMESPACE__ . '\\\$1', $key); // Filter plural 's' and add namespace
$deferred = new $class($this->connection());
$uri = $this->attributes[$key]['__deferred']['uri'];
$deferred->connection()->nextUrl = $uri; // $uri is complete, by setting it to nextUrl Connection->formatUrl leaves it as is.
Expand Down Expand Up @@ -206,11 +206,11 @@ public function __call($name, $arguments)
*/
public function exists()
{
if (!array_key_exists($this->primaryKey, $this->attributes)) {
if ( ! array_key_exists($this->primaryKey, $this->attributes)) {
return false;
}

return !empty($this->attributes[$this->primaryKey]);
return ! empty($this->attributes[$this->primaryKey]);
}

/**
Expand All @@ -231,7 +231,7 @@ public function json($options = 0, $withDeferred = false)

$attributes[$attribute] = [];
foreach ($collection as $value) {
if (!empty($value->deferred)) {
if ( ! empty($value->deferred)) {
$value->attributes = array_merge($value->attributes, $value->deferred);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Picqer/Financials/Exact/Persistance/Downloadable.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function download()
'Accept' => 'application/json',
'Content-Type' => 'application/json',
'Prefer' => 'return=representation',
'Authorization' => 'Bearer '.$this->connection()->getAccessToken(),
'Authorization' => 'Bearer ' . $this->connection()->getAccessToken(),
];

$res = $client->get($this->getDownloadUrl(), [
Expand Down
4 changes: 2 additions & 2 deletions src/Picqer/Financials/Exact/Persistance/Storable.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@ public function update()
{
$primaryKey = $this->primaryKeyContent();

return $this->connection()->put($this->url()."(guid'$primaryKey')", $this->json());
return $this->connection()->put($this->url() . "(guid'$primaryKey')", $this->json());
}

public function delete()
{
$primaryKey = $this->primaryKeyContent();

return $this->connection()->delete($this->url()."(guid'$primaryKey')");
return $this->connection()->delete($this->url() . "(guid'$primaryKey')");
}
}
4 changes: 2 additions & 2 deletions src/Picqer/Financials/Exact/PurchaseEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,10 @@ class PurchaseEntry extends Model

public function addItem(array $array)
{
if (!isset($this->attributes['PurchaseEntryLines']) || $this->attributes['PurchaseEntryLines'] == null) {
if ( ! isset($this->attributes['PurchaseEntryLines']) || $this->attributes['PurchaseEntryLines'] == null) {
$this->attributes['PurchaseEntryLines'] = [];
}
if (!isset($array['LineNumber'])) {
if ( ! isset($array['LineNumber'])) {
$array['LineNumber'] = count($this->attributes['PurchaseEntryLines']) + 1;
}
$this->attributes['PurchaseEntryLines'][] = $array;
Expand Down
4 changes: 2 additions & 2 deletions src/Picqer/Financials/Exact/PurchaseOrder.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,10 @@ class PurchaseOrder extends Model
*/
public function addItem(array $array)
{
if (!isset($this->attributes['PurchaseOrderLines']) || $this->attributes['PurchaseOrderLines'] == null) {
if ( ! isset($this->attributes['PurchaseOrderLines']) || $this->attributes['PurchaseOrderLines'] == null) {
$this->attributes['PurchaseOrderLines'] = [];
}
if (!isset($array['LineNumber'])) {
if ( ! isset($array['LineNumber'])) {
$array['LineNumber'] = count($this->attributes['PurchaseOrderLines']) + 1;
}
$this->attributes['PurchaseOrderLines'][] = $array;
Expand Down
8 changes: 4 additions & 4 deletions src/Picqer/Financials/Exact/Query/Findable.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ abstract public function primaryKey();

public function find($id)
{
$filter = $this->primaryKey()." eq guid'$id'";
$filter = $this->primaryKey() . " eq guid'$id'";

if ($this->primaryKey() === 'Code') {
$filter = $this->primaryKey()." eq $id";
$filter = $this->primaryKey() . " eq $id";
}

$records = $this->connection()->get($this->url(), [
Expand All @@ -45,7 +45,7 @@ public function findWithSelect($id, $select = '')
{
//eg: $oAccounts->findWithSelect('5b7f4515-b7a0-4839-ac69-574968677d96', 'Code, Name');
$result = $this->connection()->get($this->url(), [
'$filter' => $this->primaryKey()." eq guid'$id'",
'$filter' => $this->primaryKey() . " eq guid'$id'",
'$select' => $select,
]);

Expand Down Expand Up @@ -108,7 +108,7 @@ public function filter($filter, $expand = '', $select = '', $system_query_option

$result = $this->connection()->get($this->url(), $request, $headers);

if (!empty($divisionId)) {
if ( ! empty($divisionId)) {
$this->connection()->setDivision($originalDivision); // Restore division
}

Expand Down
4 changes: 2 additions & 2 deletions src/Picqer/Financials/Exact/Quotation.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,10 @@ class Quotation extends Model
*/
public function addItem(array $array)
{
if (!isset($this->attributes['QuotationLines']) || $this->attributes['QuotationLines'] == null) {
if ( ! isset($this->attributes['QuotationLines']) || $this->attributes['QuotationLines'] == null) {
$this->attributes['QuotationLines'] = [];
}
if (!isset($array['LineNumber'])) {
if ( ! isset($array['LineNumber'])) {
$array['LineNumber'] = count($this->attributes['QuotationLines']) + 1;
}
$this->attributes['QuotationLines'][] = $array;
Expand Down
4 changes: 2 additions & 2 deletions src/Picqer/Financials/Exact/SalesEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,10 @@ class SalesEntry extends Model

public function addItem(array $array)
{
if (!isset($this->attributes['SalesEntryLines']) || $this->attributes['SalesEntryLines'] == null) {
if ( ! isset($this->attributes['SalesEntryLines']) || $this->attributes['SalesEntryLines'] == null) {
$this->attributes['SalesEntryLines'] = [];
}
if (!isset($array['LineNumber'])) {
if ( ! isset($array['LineNumber'])) {
$array['LineNumber'] = count($this->attributes['SalesEntryLines']) + 1;
}
$this->attributes['SalesEntryLines'][] = $array;
Expand Down
4 changes: 2 additions & 2 deletions src/Picqer/Financials/Exact/SalesOrder.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,10 @@ class SalesOrder extends Model
*/
public function addItem(array $array)
{
if (!isset($this->attributes['SalesOrderLines']) || $this->attributes['SalesOrderLines'] == null) {
if ( ! isset($this->attributes['SalesOrderLines']) || $this->attributes['SalesOrderLines'] == null) {
$this->attributes['SalesOrderLines'] = [];
}
if (!isset($array['LineNumber'])) {
if ( ! isset($array['LineNumber'])) {
$array['LineNumber'] = count($this->attributes['SalesOrderLines']) + 1;
}
$this->attributes['SalesOrderLines'][] = $array;
Expand Down
2 changes: 1 addition & 1 deletion src/Picqer/Financials/Exact/SubscriptionLines.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
/*
* Added deprecated SubscriptionLines class for backward compatibility
*/
class_alias(__NAMESPACE__.'\SubscriptionLine', __NAMESPACE__.'\SubscriptionLines');
class_alias(__NAMESPACE__ . '\SubscriptionLine', __NAMESPACE__ . '\SubscriptionLines');
2 changes: 1 addition & 1 deletion src/Picqer/Financials/Exact/SubscriptionTypes.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
/*
* Added deprecated SubscriptionTypes class for backward compatibility
*/
class_alias(__NAMESPACE__.'\SubscriptionType', __NAMESPACE__.'\SubscriptionTypes');
class_alias(__NAMESPACE__ . '\SubscriptionType', __NAMESPACE__ . '\SubscriptionTypes');
2 changes: 1 addition & 1 deletion src/Picqer/Financials/Exact/Subscriptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
/*
* Added deprecated Subscriptions class for backward compatibility
*/
class_alias(__NAMESPACE__.'\Subscription', __NAMESPACE__.'\Subscriptions');
class_alias(__NAMESPACE__ . '\Subscription', __NAMESPACE__ . '\Subscriptions');
2 changes: 1 addition & 1 deletion src/Picqer/Financials/Exact/Transactions.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
/*
* Added deprecated Transactions class for backward compatibility
*/
class_alias(__NAMESPACE__.'\Transaction', __NAMESPACE__.'\Transactions');
class_alias(__NAMESPACE__ . '\Transaction', __NAMESPACE__ . '\Transactions');

0 comments on commit 6e71966

Please sign in to comment.