Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.1 #41

Open
wants to merge 2 commits into
base: 1.1
Choose a base branch
from
Open

1.1 #41

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 20 additions & 19 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ public function cleanVehicle($vehicle)
public function getBalance()
{
$response = $this->query($this->prepareUri('profile/balance'), [], self::METHOD_GET);
return (float) $response;
return (float)$response;
}

/**
Expand Down Expand Up @@ -288,7 +288,7 @@ protected function prepareUri($endpoint)
* Populates object with data.
*
* @param AbstractResponse $object
* @param array $data
* @param array $data
*
* @return AbstractResponse
* @throws \ReflectionException
Expand Down Expand Up @@ -319,22 +319,23 @@ protected function populate(AbstractResponse $object, array $data)
protected function populateParty(array $response)
{
$management = null;
$managementData = $response['data']['management'];
$managementData = isset($response['data']['management']) ? $response['data']['management'] : [];
if (is_array($managementData) && array_key_exists('name', $managementData) && array_key_exists('post', $managementData)) {
list($name, $post) = array_values($response['data']['management']);
$management = new Party\ManagementDto($name, $post);
}

list($code, $full, $short) = array_values($response['data']['opf']);

list($code, $full, $short) = array_values(isset($response['data']['opf']) ? $response['data']['opf'] : ['', '', '']);
$opf = new Party\OpfDto($code, $full, $short);

list($fullWithOpf, $shortWithOpf, $latin, $full, $short) = array_values($response['data']['name']);
list($fullWithOpf, $shortWithOpf, $latin, $full, $short) = array_values(isset($response['data']['name']) ? $response['data']['name'] : ['', '', '', '', '']);
$name = new Party\NameDto($fullWithOpf, $shortWithOpf, $latin, $full, $short);

list($status, $actualityDate, $registrationDate, $liquidationDate) = array_values($response['data']['state']);
list($status, $actualityDate, $registrationDate, $liquidationDate) = array_values(isset($response['data']['state']) ? $response['data']['state'] : ['', '', '', '']);
$state = new Party\StateDto($status, $actualityDate, $registrationDate, $liquidationDate);

list($value, $unrestrictedValue) = array_values($response['data']['address']);
list($value, $unrestrictedValue) = array_values(isset($response['data']['address']) ? $response['data']['address'] : ['', '']);
$simpleAddress = new Party\AddressDto($value, $unrestrictedValue);

$address = null;
Expand All @@ -343,18 +344,18 @@ protected function populateParty(array $response)
}

return new Party\Party(
$response['value'],
$response['unrestricted_value'],
$response['data']['kpp'],
isset($response['value']) ? $response['value'] : '',
isset($response['unrestricted_value']) ? $response['unrestricted_value'] : '',
isset($response['data']['kpp']) ? $response['data']['kpp'] : '',
$management,
$response['data']['branch_type'],
$response['data']['type'],
isset($response['data']['branch_type']) ? $response['data']['branch_type'] : '',
isset($response['data']['type']) ? $response['data']['type'] : '',
$opf,
$name,
$response['data']['inn'],
$response['data']['ogrn'],
$response['data']['okpo'],
$response['data']['okved'],
isset($response['data']['inn']) ? $response['data']['inn'] : '',
isset($response['data']['ogrn']) ? $response['data']['ogrn'] : '',
isset($response['data']['okpo']) ? $response['data']['okpo'] : '',
isset($response['data']['okved']) ? $response['data']['okved'] : '',
$state,
$simpleAddress,
$address
Expand All @@ -365,7 +366,7 @@ protected function populateParty(array $response)
* Guesses and converts property type by phpdoc comment.
*
* @param \ReflectionProperty $property
* @param mixed $value
* @param mixed $value
* @return mixed
*/
protected function getValueByAnnotatedType(\ReflectionProperty $property, $value)
Expand All @@ -375,10 +376,10 @@ protected function getValueByAnnotatedType(\ReflectionProperty $property, $value
switch ($matches[1]) {
case 'integer':
case 'int':
$value = (int) $value;
$value = (int)$value;
break;
case 'float':
$value = (float) $value;
$value = (float)$value;
break;
}
}
Expand Down