Skip to content

Commit

Permalink
Method scope public missing from functions
Browse files Browse the repository at this point in the history
  • Loading branch information
lsolesen committed Apr 30, 2016
1 parent be6506e commit 31517d4
Show file tree
Hide file tree
Showing 23 changed files with 82 additions and 103 deletions.
6 changes: 3 additions & 3 deletions lib/Sendworks/Address.php
Expand Up @@ -17,7 +17,7 @@ class Address
public $lat;
public $lng;

function __construct($data = [])
public function __construct($data = [])
{
foreach (['id', 'residential', 'name', 'street1', 'street2', 'post_code', 'city', 'region', 'country_code', 'phone', 'email', 'lat', 'lng'] as $prop) {
if (isset($data[$prop])) {
Expand All @@ -26,7 +26,7 @@ function __construct($data = [])
}
}

function toHash()
public function toHash()
{
return [
'id' => $this->id,
Expand All @@ -45,7 +45,7 @@ function toHash()
];
}

static function import($mixed)
public static function import($mixed)
{
if ($mixed instanceof Address) {
return $mixed;
Expand Down
2 changes: 1 addition & 1 deletion lib/Sendworks/Carrier.php
Expand Up @@ -5,7 +5,7 @@ class Carrier
{
public $id;
public $name;
function __construct($data = [])
public function __construct($data = [])
{
foreach (['id', 'name'] as $prop) {
if (isset($data[$prop])) {
Expand Down
4 changes: 2 additions & 2 deletions lib/Sendworks/Connection.php
Expand Up @@ -12,7 +12,7 @@ class Connection
public $orders;
public $shipments;

function __construct($api_token, $domain = 'api.sandbox.sendworks.com', $http_options = [])
public function __construct($api_token, $domain = 'api.sandbox.sendworks.com', $http_options = [])
{
$this->api_token = $api_token;
$this->domain = $domain;
Expand All @@ -24,7 +24,7 @@ function __construct($api_token, $domain = 'api.sandbox.sendworks.com', $http_op
$this->labels = new LabelsCollection($this);
}

function client()
public function client()
{
if (!$this->client) {
$options = $this->http_options;
Expand Down
4 changes: 2 additions & 2 deletions lib/Sendworks/Http/BadResponseException.php
Expand Up @@ -5,12 +5,12 @@ class BadResponseException extends \Exception
{
protected $response;

function setResponse($response)
public function setResponse($response)
{
$this->response = $response;
}

function getResponse()
public function getResponse()
{
return $this->response;
}
Expand Down
10 changes: 5 additions & 5 deletions lib/Sendworks/Http/Client.php
Expand Up @@ -9,7 +9,7 @@ class Client

protected $curl;

function __construct($options = [])
public function __construct($options = [])
{
if (!extension_loaded('curl')) {
trigger_error("curl extension required", E_USER_ERROR);
Expand All @@ -24,22 +24,22 @@ function __construct($options = [])
$this->user_agent .= ' PHP/' . PHP_VERSION;
}

function get($path, $options = [])
public function get($path, $options = [])
{
return $this->send('GET', $path, $options);
}

function post($path, $options = [])
public function post($path, $options = [])
{
return $this->send('POST', $path, $options);
}

function put($path, $options = [])
public function put($path, $options = [])
{
return $this->send('PUT', $path, $options);
}

function delete($path, $options = [])
public function delete($path, $options = [])
{
return $this->send('DELETE', $path, $options);
}
Expand Down
8 changes: 4 additions & 4 deletions lib/Sendworks/Http/Response.php
Expand Up @@ -3,19 +3,19 @@

class Response
{
function __construct($raw_header, $body, $curl_info)
public function __construct($raw_header, $body, $curl_info)
{
$this->raw_header = $raw_header;
$this->body = $body;
$this->curl_info = $curl_info;
}

function getStatusCode()
public function getStatusCode()
{
return $this->curl_info['http_code'];
}

function getHeader($name)
public function getHeader($name)
{
$result = [];
if (preg_match('/^'.$name.': (.+)$/im', $this->raw_header, $mm)) {
Expand All @@ -24,7 +24,7 @@ function getHeader($name)
return $result;
}

function getBody()
public function getBody()
{
return $this->body;
}
Expand Down
4 changes: 2 additions & 2 deletions lib/Sendworks/Item.php
Expand Up @@ -10,7 +10,7 @@ class Item
public $quantity;
public $value;

function __construct($data = [])
public function __construct($data = [])
{
foreach (['id', 'description', 'sku', 'weight_in_g', 'quantity'] as $prop) {
if (isset($data[$prop])) {
Expand All @@ -20,7 +20,7 @@ function __construct($data = [])
$this->value = isset($data['value']) ? Money::import($data['value']) : null;
}

function toHash()
public function toHash()
{
return [
'id' => $this->id,
Expand Down
6 changes: 3 additions & 3 deletions lib/Sendworks/Label.php
Expand Up @@ -7,19 +7,19 @@ class Label
public $filename;
public $content;

function __construct($data, $connection)
public function __construct($data, $connection)
{
$this->connection = $connection;
$this->filename = $data['filename'];
$this->content = $data['content'];
}

function write($destination)
public function write($destination)
{
file_put_contents($destination, $this->content);
}

static function import($mixed, $connection = null)
public static function import($mixed, $connection = null)
{
if (is_array($mixed)) {
return new self($mixed, $connection);
Expand Down
10 changes: 5 additions & 5 deletions lib/Sendworks/LabelRef.php
Expand Up @@ -6,31 +6,31 @@ class LabelRef
protected $connection;
protected $label;
public $url;
function __construct($url, $connection = null)
public function __construct($url, $connection = null)
{
$this->connection = $connection;
$this->url = $url;
}

function __get($prop)
public function __get($prop)
{
return $this->resolve()->$prop;
}

function __call($fn, $args)
public function __call($fn, $args)
{
return call_user_func_array([$this->resolve(), $fn], $args);
}

function resolve()
public function resolve()
{
if (!$this->label) {
$this->label = $this->connection->labels->fetch($this);
}
return $this->label;
}

function toHash()
public function toHash()
{
return [
'url' => $this->url
Expand Down
6 changes: 3 additions & 3 deletions lib/Sendworks/LabelsCollection.php
Expand Up @@ -5,12 +5,12 @@ class LabelsCollection
{
protected $connection;

function __construct($connection)
public function __construct($connection)
{
$this->connection = $connection;
}

function fetch($mixed)
public function fetch($mixed)
{
if ($mixed instanceof LabelRef) {
$path = $mixed->url;
Expand All @@ -30,7 +30,7 @@ function fetch($mixed)
}
}

protected function client()
public protected function client()
{
return $this->connection->client();
}
Expand Down
8 changes: 4 additions & 4 deletions lib/Sendworks/Money.php
Expand Up @@ -6,26 +6,26 @@ class Money
public $cents;
public $currency;

function __construct($data)
public function __construct($data)
{
$this->cents = $data['cents'];
$this->currency = $data['currency'];
}

function toHash()
public function toHash()
{
return [
'cents' => $this->cents,
'currency' => $this->currency,
];
}

function toFloat()
public function toFloat()
{
return $this->cents / 100;
}

static function import($mixed)
public static function import($mixed)
{
if (is_array($mixed)) {
return new self($mixed);
Expand Down
11 changes: 5 additions & 6 deletions lib/Sendworks/Order.php
Expand Up @@ -17,7 +17,7 @@ class Order
public $tax_value;
public $shipments;

function __construct($data = [], $connection = null)
public function __construct($data = [], $connection = null)
{
$this->connection = $connection;
foreach (['id', 'order_reference', 'customer_number', 'service_point_reference'] as $prop) {
Expand Down Expand Up @@ -46,17 +46,17 @@ function __construct($data = [], $connection = null)
}
}

function save()
public function save()
{
return $this->connection->orders->save($this);
}

function delete()
public function delete()
{
return $this->connection->orders->delete($this);
}

function toHash()
public function toHash()
{
$items = [];
foreach ($this->items as $item) {
Expand All @@ -74,12 +74,11 @@ function toHash()
];
}

static function import($mixed, $connection = null)
public static function import($mixed, $connection = null)
{
if (is_string($mixed)) {
return new OrderRef($mixed, $connection);
}
return new self($mixed, $connection);
}

}
8 changes: 4 additions & 4 deletions lib/Sendworks/OrderRef.php
Expand Up @@ -6,26 +6,26 @@ class OrderRef
protected $connection;
protected $order;
public $url;
function __construct($url, $connection = null)
public function __construct($url, $connection = null)
{
$this->connection = $connection;
$this->url = $url;
}

function __get($prop)
public function __get($prop)
{
return $this->resolve()->$prop;
}

function resolve()
public function resolve()
{
if (!$this->order) {
$this->order = $this->connection->orders->fetch($this);
}
return $this->order;
}

function toHash()
public function toHash()
{
return [
'url' => $this->url
Expand Down
10 changes: 5 additions & 5 deletions lib/Sendworks/OrdersCollection.php
Expand Up @@ -5,12 +5,12 @@ class OrdersCollection
{
protected $connection;

function __construct($connection)
public function __construct($connection)
{
$this->connection = $connection;
}

function select()
public function select()
{
$response = $this->client()->get('orders');
$result = array();
Expand All @@ -20,7 +20,7 @@ function select()
return $result;
}

function save($order)
public function save($order)
{
if ($order->id) {
$path = "orders/" . $order->id;
Expand All @@ -33,7 +33,7 @@ function save($order)
}
}

function fetch($mixed)
public function fetch($mixed)
{
if ($mixed instanceof OrderRef) {
$path = $mixed->url;
Expand All @@ -46,7 +46,7 @@ function fetch($mixed)
}
}

function delete($mixed)
public function delete($mixed)
{
if ($mixed instanceof OrderRef) {
$path = $mixed->url;
Expand Down

0 comments on commit 31517d4

Please sign in to comment.