Skip to content

Commit

Permalink
Release v1.5
Browse files Browse the repository at this point in the history
+ Deprecated Invoice::extract() and Client::extract() method
  • Loading branch information
faizanakram99 committed Apr 5, 2019
1 parent dbd1828 commit d73a64d
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/vendor/
.idea/
.php_cs.cache
11 changes: 10 additions & 1 deletion src/Qbil/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,17 @@ protected function request(string $method, string $route, array $options = [])
return $this->client->request($method, $route, array_merge($options, ['headers' => $this->headers]));
}

/**
* @param array $property
* @param $key
* @param string $subKey
*
* @return mixed
*
* @deprecated This method is only for backward compatibility and will be removed in v2.0, use Util::extract() instead
*/
protected function extract(array $property, $key, $subKey = 'Text')
{
return $property[array_search($key, array_column($property, 'Type'))][$subKey];
return Util::extract($property, $key, $subKey);
}
}
13 changes: 12 additions & 1 deletion src/Qbil/Models/Invoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

namespace Qbil\ReadSoftOnline\Models;

use Qbil\ReadSoftOnline\Util;

class Invoice
{
public function __construct(Document $document)
Expand Down Expand Up @@ -146,9 +148,18 @@ public function getInvoiceLines()
return $this->invoiceLines;
}

/**
* @param array $property
* @param $key
* @param string $subKey
*
* @return mixed
*
* @deprecated This method is only for backward compatibility and will be removed in v2.0, use Util::extract() instead
*/
private function extract(array $property, $key, $subKey = 'Text')
{
return $property[array_search($key, array_column($property, 'Type'))][$subKey];
return Util::extract($property, $key, $subKey);
}

/**
Expand Down
11 changes: 11 additions & 0 deletions src/Qbil/Util.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace Qbil\ReadSoftOnline;

class Util
{
public static function extract(array $property, $key, $subKey = 'Text')
{
return $property[array_search($key, array_column($property, 'Type'))][$subKey];
}
}

0 comments on commit d73a64d

Please sign in to comment.