Alexandr Kozlov преди 8 години
родител
ревизия
dfbf436c7e

+ 2 - 0
.gitignore

@@ -0,0 +1,2 @@
+vendor/
+composer.lock

+ 2 - 1
composer.json

@@ -12,10 +12,11 @@
         "php": ">= 5.4"
     },
     "require-dev": {
+        "phpdocumentor/phpdocumentor": "dev-master"
     },
     "autoload": {
         "psr-4": {
             "Ipol\\DPD\\": "src/lib"
         }
     }
-}
+}

+ 23 - 3
src/lib/DB/AbstractTable.php

@@ -1,16 +1,26 @@
 <?php
 namespace Ipol\DPD\DB;
 
+/**
+ * Абстрактный класс реализующий взаимодействие с одной таблицей
+ */
 abstract class AbstractTable implements TableInterface
 {
     protected $connection;
 
+    /**
+     * Конструктор класса
+     * 
+     * @param \Ipol\DPD\DB\ConnectionInterface
+     */
     public function __construct(ConnectionInterface $connection)
     {
         $this->connection = $connection;
     }
 
     /**
+     * Возвращает соединение с БД
+     * 
      * @return \Ipol\DPD\DB\ConnectionInterface
      */
     public function getConnection() 
@@ -19,6 +29,8 @@ abstract class AbstractTable implements TableInterface
     }
 
     /**
+     * Возвращает конфиг
+     * 
      * @return \Ipol\DPD\Config\ConfigInterface
      */
     public function getConfig()
@@ -27,6 +39,8 @@ abstract class AbstractTable implements TableInterface
     }
 
     /**
+     * Возвращает инстанс PDO
+     * 
      * @return \PDO
      */
     public function getPDO()
@@ -36,14 +50,16 @@ abstract class AbstractTable implements TableInterface
 
     /**
      * Возвращает имя класса модели
+     * 
+     * @return array
      */
     public function getModelClass()
     {
-        return '\\Ipol\\DPD\\DB\\Model';
+        return \Ipol\DPD\DB\Model::class;
     }
 
     /**
-     * Создает модель
+     * Возвращает инстанс модели ассоциированной с таблицой
      * 
      * @return \Ipol\DPD\DB\Model
      */
@@ -56,6 +72,8 @@ abstract class AbstractTable implements TableInterface
 
     /**
      * Создание таблицы при необходимости
+     * 
+     * @return void
      */
     public function checkTableSchema()
 	{
@@ -100,7 +118,7 @@ abstract class AbstractTable implements TableInterface
     }
 
     /**
-     * Обновление
+     * Обновление записи
      * 
      * @param int   $id
      * @param array $values
@@ -205,6 +223,8 @@ abstract class AbstractTable implements TableInterface
     }
 
     /**
+     * Составляет массив bind-values для передачи в PDO
+     * 
      * @param array $parms
      * 
      * @return array

+ 18 - 3
src/lib/DB/Connection.php

@@ -4,19 +4,30 @@ namespace Ipol\DPD\DB;
 use \PDO;
 use \Ipol\DPD\Config\ConfigInterface;
 
+/**
+ * Класс реализует соединения с БД и организует доступ к таблицами
+ */
 class Connection implements ConnectionInterface
 {
     protected static $instance;
     
+    /**
+     * @var array
+     */
     protected static $classmap = array(
         'location' => '\\Ipol\\DPD\\DB\\Location\\Table',
 		'terminal' => '\\Ipol\\DPD\\DB\\Terminal\\Table',
 		'order'    => '\\Ipol\\DPD\\DB\\Order\\Table',
     );
 
+    /**
+     * @var array
+     */
     protected $tables = array();
     
     /**
+     * Возвращает инстанс подключения
+     * 
      * @return \Ipol\DPD\DB\ConnectionInterface
      */
     public static function getInstance(ConfigInterface $config)
@@ -25,7 +36,7 @@ class Connection implements ConnectionInterface
     }
 
     /**
-     * Constructor
+     * Конструктор класса
      * 
      * @param   string  $dsn        The DSN string
      * @param   string  $username   (optional) Username
@@ -48,7 +59,9 @@ class Connection implements ConnectionInterface
     }
 
     /**
-     * @return ConfigInterface
+     * Возвращает конфиг
+     * 
+     * @return \Ipol\DPD\Config\ConfigInterface
      */
     public function getConfig()
     {
@@ -81,7 +94,7 @@ class Connection implements ConnectionInterface
     /**
      * Returns the PDO object associated with this connection
      *
-     * @return PDO
+     * @return \PDO
      */
     public function getPDO()
     {
@@ -97,6 +110,8 @@ class Connection implements ConnectionInterface
     /**
      * Возвращает маппер для таблицы
      * 
+     * @param string $tableName имя маппера/таблицы
+     * 
      * @return \Ipol\DPD\DB\TableInterface
      */
     public function getTable($tableName)

+ 5 - 0
src/lib/DB/ConnectionInterface.php

@@ -1,9 +1,14 @@
 <?php
 namespace Ipol\DPD\DB;
 
+/**
+ * Интерфейс соединения с БД
+ */
 interface ConnectionInterface
 {
     /**
+     * Возвращает инстанс PDO
+     * 
      * @return \PDO
      */
     public function getPDO();

+ 19 - 6
src/lib/DB/Location/Agent.php

@@ -2,12 +2,13 @@
 namespace Ipol\DPD\DB\Location;
 
 use \Ipol\DPD\Config\ConfigInterface;
-
 use \Ipol\DPD\API\User\UserInterface;
 use \Ipol\DPD\DB\TableInterface;
 use \Ipol\DPD\Utils;
 
-
+/**
+ * Класс реализует методы обновления информации о городах в которых работает DPD
+ */
 class Agent
 {
 	protected static $cityFilePath = 'ftp://intergration:xYUX~7W98@ftp.dpd.ru:22/integration/GeographyDPD_20171125.csv';
@@ -15,6 +16,12 @@ class Agent
 	protected $api;
 	protected $table;
 
+	/**
+	 * Конструктор
+	 * 
+	 * @param \Ipol\DPD\User\UserInterface $api   инстанс API
+	 * @param \Ipol\DPD\DB\TableInterface  $table инстанс таблицы для записи данных в БД
+	 */
 	public function __construct(UserInterface $api, TableInterface $table)
 	{
 		$this->api   = $api;
@@ -38,16 +45,20 @@ class Agent
 	}
 
 	/**
+	 * Возвращает normalizer адресов
+	 * 
 	 * @return \Ipol\DPD\DB\Location\Normilizer
 	 */
-	public function getNormilizer()
+	public function getNormalizer()
 	{
-		return $this->getTable()->getNormilizer();
+		return $this->getTable()->getNormalizer();
 	}
 
 	/**
 	 * Обновляет список всех городов обслуживания
 	 * 
+	 * @param integer $position Стартовая позиция курсора в файле
+	 * 
 	 * @return void
 	 */
 	public function loadAll($position = 0)
@@ -67,7 +78,7 @@ class Agent
 			}
 
 			$this->loadLocation(
-				$this->getNormilizer()->normilize(
+				$this->getNormalizer()->normilize(
 					$country    = $row[5],
 					$regionName = end(explode(',', $row[4])),
 					$cityName   = $row[2] .' '. $row[3]
@@ -86,6 +97,8 @@ class Agent
 	/**
 	 * Обновляет города в которых доступен НПП
 	 * 
+	 * @param string $position Стартовая позиция импорта
+	 * 
 	 * @return void
 	 */
 	public function loadCashPay($position = 'RU:0')
@@ -113,7 +126,7 @@ class Agent
 				}
 
 				$this->loadLocation(
-					$this->getNormilizer()->normilize(
+					$this->getNormalizer()->normilize(
 						$country = $arCity['COUNTRY_NAME'],
 						$region  = $arCity['REGION_NAME'],
 						$city    = $arCity['ABBREVIATION'] .' '. $arCity['CITY_NAME']

+ 28 - 1
src/lib/DB/Location/Normilizer.php → src/lib/DB/Location/Normalizer.php

@@ -1,10 +1,19 @@
 <?php
 namespace Ipol\DPD\DB\Location;
 
-class Normilizer
+/**
+ * Класс обеспечивающий приведение различных адресов к единой форме
+ */
+class Normalizer
 {      
     /**
      * Возвращает нормализованную информацию о нас. пункте
+     * 
+     * @param string $country  Название страны
+     * @param string $region   Название региона
+     * @param string $locality Название населенного пункта
+     * 
+     * @return array
      */
     public function normilize($country, $region, $locality)
     {
@@ -18,6 +27,8 @@ class Normilizer
     /**
      * Возвращает информацию о стране
      * 
+     * @param string $country  Название страны
+     * 
      * @return array
      */
     public function normilizeCountry($country)
@@ -54,6 +65,8 @@ class Normilizer
      * 
      * @param string $city
      * @param array  $region
+     * 
+     * @return array
      */
     public function normilizeCity($city, $region)
     {
@@ -76,6 +89,8 @@ class Normilizer
      * 
      * @param string $city
      * @param array  $region
+     * 
+     * @return string
      */
     public function checkAnalog($city, $region)
     {
@@ -126,6 +141,8 @@ class Normilizer
     
     /**
      * Возвращает список стран
+     * 
+     * @return array
      */
     protected function getCountryList()
     {
@@ -138,6 +155,8 @@ class Normilizer
 
     /**
      * Возвращает аббревиатуру региона
+     * 
+     * @return array
      */
     protected function getRegionAbbrList()
     {
@@ -159,6 +178,8 @@ class Normilizer
      * 
      * @param string $region
      * @param string $countryCode
+     * 
+     * @return array
      */
     protected function getRegionCodeList($countryCode)
     {
@@ -173,6 +194,8 @@ class Normilizer
 
     /**
      * Возвращает аббревиатуру города
+     * 
+     * @return array
      */
     protected function getCityAbbrList()
     {
@@ -184,6 +207,8 @@ class Normilizer
 
     /**
      * Возвращает аббревиатуру нас. пункта
+     * 
+     * @return array
      */
     protected function getVillageAbbrList()
     {
@@ -208,6 +233,8 @@ class Normilizer
 
     /**
      * Возвращает список городов аналогов
+     * 
+     * @return array
      */
     protected function getCityAnalogs()
     {

+ 31 - 2
src/lib/DB/Location/Table.php

@@ -3,13 +3,26 @@ namespace Ipol\DPD\DB\Location;
 
 use Ipol\DPD\DB\AbstractTable;
 
+/**
+ * Класс для работы с таблицей местоположений
+ */
 class Table extends AbstractTable
 {
+	/**
+	 * Возвращает имя таблицы
+	 * 
+	 * @return string
+	 */
 	public function getTableName()
 	{
 		return 'b_ipol_dpd_location';
 	}
 
+	/**
+	 * Возвращает список полей и их значения по умолчанию
+	 * 
+	 * @return array
+	 */
 	public function getFields()
 	{
 		return [
@@ -26,9 +39,14 @@ class Table extends AbstractTable
 		];
 	}
 
-	public function getNormilizer()
+	/**
+	 * Возвращает normalizer адресов
+	 * 
+	 * @return \Ipol\DPD\DB\Location\Normalizer
+	 */
+	public function getNormalizer()
 	{
-		return new Normilizer();
+		return new Normalizer();
 	}
 
 	/**
@@ -36,6 +54,7 @@ class Table extends AbstractTable
 	 * 
 	 * @param  int $locationId
 	 * @param  array  $select
+	 * 
 	 * @return array|false
 	 */
 	public static function getByCityId($cityId, $select = '*')
@@ -49,6 +68,16 @@ class Table extends AbstractTable
 		]);
 	}
 
+	/**
+	 * Производит поиск города по текстовому названию в БД
+	 * 
+	 * @param string $country Название страны
+	 * @param string $region  Название региона
+	 * @param string $city    Название города
+	 * @param string $select  список полей которые необходимо выбрать
+	 * 
+	 * @return array
+	 */
 	public function getByAddress($country, $region, $city, $select = '*')
 	{
 		$city = $this->getNormilizer()->normilize($country, $region, $city);

+ 28 - 1
src/lib/DB/Model.php

@@ -5,7 +5,7 @@ use \Bitrix\Main\SystemException;
 use \Ipol\DPD\Utils;
 
 /**
- * Абстрактный класс модели таблицы
+ * Класс модели таблицы
  * Каждый экземпляр класса - одна строка из таблицы
  *
  * К значениям полей можно обратиться двумя способами
@@ -54,6 +54,7 @@ class Model implements \ArrayAccess
 	 * Получает поля сущности из БД
 	 * 
 	 * @param  mixed $id ID или массив полей сущности
+	 * 
 	 * @return bool
 	 */
 	public function load($id)
@@ -79,6 +80,7 @@ class Model implements \ArrayAccess
 
 	/**
 	 * Вызывается после получения полей сущности из БД
+	 * 
 	 * @return void
 	 */
 	public function afterLoad()
@@ -181,6 +183,8 @@ class Model implements \ArrayAccess
 	 * Удаляет св-во сущности
 	 * 
 	 * @param string $prop
+	 * 
+	 * @return void
 	 */
 	public function __unset($prop)
 	{
@@ -191,6 +195,7 @@ class Model implements \ArrayAccess
 	 * Получает значение св-ва сущности
 	 * 
 	 * @param  string $prop
+	 * 
 	 * @return mixed
 	 */
 	public function __get($prop)
@@ -213,6 +218,8 @@ class Model implements \ArrayAccess
 	 * 
 	 * @param string $prop
 	 * @param mixed $value
+	 * 
+	 * @return void
 	 */
 	public function __set($prop, $value)
 	{
@@ -229,16 +236,31 @@ class Model implements \ArrayAccess
 		$this->fields[$prop] = $value;
 	}
 
+	/**
+	 * @param string $prop
+	 * 
+	 * @return bool
+	 */
 	public function offsetExists($prop)
 	{
 		return $this->__isset($prop);
 	}
 
+	/**
+	 * @param string $prop
+	 * 
+	 * @return void
+	 */
 	public function offsetUnset($prop)
 	{
 		throw new \Exception("Can\'t be removed property {$prop}");
 	}
 
+	/**
+	 * @param string $prop
+	 * 
+	 * @return mixed
+	 */
 	public function offsetGet($prop)
 	{
 		if (!$this->offsetExists($prop)) {
@@ -248,6 +270,11 @@ class Model implements \ArrayAccess
 		return $this->fields[$prop];
 	}
 
+	/**
+	 * @param string $prop
+	 * 
+	 * @return void
+	 */
 	public function offsetSet($prop, $value)
 	{
 		if (!$this->offsetExists($prop)) {

+ 53 - 6
src/lib/DB/Order/Model.php

@@ -5,6 +5,9 @@ use \Ipol\DPD\Order as DpdOrder;
 use \Ipol\DPD\DB\Model as BaseModel;
 use \Ipol\DPD\Shipment;
 
+/**
+ * Модель одной записи таблицы заказов
+ */
 class Model extends BaseModel
 {
 	const SERVICE_VARIANT_D = 'Д';
@@ -18,6 +21,8 @@ class Model extends BaseModel
 
 	/**
 	 * Возвращает список статусов и их описаний
+	 * 
+	 * @return array
 	 */
 	public static function StatusList()
 	{
@@ -46,7 +51,7 @@ class Model extends BaseModel
 	/**
 	 * Возвращает отправку
 	 *
-	 * @param bool $forced
+	 * @param bool $forced true - создает новый инстанс на основе полей записи
 	 * 
 	 * @return \Ipol\DPD\Shipment
 	 */
@@ -75,7 +80,12 @@ class Model extends BaseModel
 	}
 
 	/**
+	 * Ассоциирует внешнюю отправку с записью
+	 * Происходит заполнение полей записи на основе данных отправки
+	 * 
 	 * @param \Ipol\DPD\Shipment $shipment
+	 * 
+	 * @return self
 	 */
 	public function setShipment(Shipment $shipment)
 	{
@@ -95,17 +105,25 @@ class Model extends BaseModel
 			'SELF_PICKUP'   => $shipment->getSelfPickup(),
 			'SELF_DELIVERY' => $shipment->getSelfDelivery(),
 		];
+
+		return $this;
 	}
 
 	/**
+	 * Сеттер св-ва ORDER_ITEMS
+	 * 
 	 * @param array $items
 	 */
 	public function setOrderItems($items)
 	{
 		$this->fields['ORDER_ITEMS'] = \serialize($items);
+
+		return $this;
 	}
 
 	/**
+	 * Геттер св-ва ORDER_ITEMS
+	 * 
 	 * @return array
 	 */
 	public function getOrderItems()
@@ -114,18 +132,26 @@ class Model extends BaseModel
 	}
 
 	/**
+	 * Сеттер св-ва NPP
+	 * 
 	 * @param float $npp
+	 * 
+	 * @return self
 	 */
 	public function setNpp($npp)
 	{
 		$this->fields['NPP']     = $npp;
 		$this->fields['SUM_NPP'] = $npp == 'Y' ? $this->price : 0;
+
+		return $this;
 	}
 
 	/**
 	 * Устанавливает вариант доставки
 	 *
 	 * @param string $variant
+	 * 
+	 * @return self
 	 */
 	public function setServiceVariant($variant)
 	{
@@ -163,12 +189,22 @@ class Model extends BaseModel
 		);
 	}
 
+	/**
+	 * Возвращает флаг доставка от ТЕРМИНАЛА или ДВЕРИ
+	 * 
+	 * @return bool
+	 */
 	public function isSelfPickup()
 	{
 		$serviceVariant = $this->getServiceVariant();
 		return $serviceVariant['SELF_PICKUP'];
 	}
 
+	/**
+	 * Возвращает флаг доставка до ТЕРМИНАЛА или ДВЕРИ
+	 * 
+	 * @return bool
+	 */
 	public function isSelfDelivery()
 	{
 		$serviceVariant = $this->getServiceVariant();
@@ -195,9 +231,9 @@ class Model extends BaseModel
 	/**
 	 * Возвращает ифнормацию о тарифе
 	 *
-	 * @param  boolean $forced пересоздать ли экземпляр отгрузки
+	 * @param  bool $forced пересоздать ли экземпляр отгрузки
 	 *
-	 * @return \Ipol\DPD\Result
+	 * @return array
 	 */
 	public function getTariffDelivery($forced = false)
 	{
@@ -224,15 +260,24 @@ class Model extends BaseModel
 	 * Сеттер для номера заказа, попутно устанавливаем номер отправления
 	 *
 	 * @param $orderNum
+	 * 
+	 * @return self
 	 */
 	public function setOrderNum($orderNum)
 	{
 		$this->fields['ORDER_NUM']         = $orderNum;
 		$this->fields['ORDER_DATE_CREATE'] = $orderNum ? date('Y-m-d H:i:s') : null;
+
+		return $this;
 	}
 
 	/**
 	 * Сеттер для статуса заказа
+	 * 
+	 * @param $orderStatus
+	 * @param $orderStatusDate
+	 * 
+	 * @return self
 	 */
 	public function setOrderStatus($orderStatus, $orderStatusDate = false)
 	{
@@ -253,7 +298,9 @@ class Model extends BaseModel
 	}
 
 	/**
-	 * @return boolean
+	 * Возвращает флаг новый заказ
+	 * 
+	 * @return bool
 	 */
 	public function isNew()
 	{
@@ -263,7 +310,7 @@ class Model extends BaseModel
 	/**
 	 * Проверяет отправлялся ли заказ в DPD
 	 *
-	 * @return boolean
+	 * @return bool
 	 */
 	public function isCreated()
 	{
@@ -274,7 +321,7 @@ class Model extends BaseModel
 	/**
 	 * Проверяет отправлялся ли заказ в DPD и был ли он там успешно создан
 	 *
-	 * @return boolean
+	 * @return bool
 	 */
 	public function isDpdCreated()
 	{

+ 23 - 3
src/lib/DB/Order/Table.php

@@ -3,18 +3,36 @@ namespace Ipol\DPD\DB\Order;
 
 use Ipol\DPD\DB\AbstractTable;
 
+/**
+ * Класс для работы с таблицей заказов
+ */
 class Table extends AbstractTable
 {
+	/**
+	 * Возвращает имя таблицы
+	 * 
+	 * @return string
+	 */
 	public function getTableName()
 	{
 		return 'b_ipol_dpd_order';
 	}
 
+	/**
+	 * Возвращает название класса модели
+	 * 
+	 * @return string
+	 */
 	public function getModelClass()
 	{
-		return '\\Ipol\\DPD\\DB\\Order\Model';
+		return \Ipol\DPD\DB\Order\Model::class;
 	}
 	
+	/**
+	 * Возвращает список полей и их значения по умолчанию
+	 * 
+	 * @return array
+	 */
 	public function getFields()
     {
 		return [
@@ -96,9 +114,11 @@ class Table extends AbstractTable
     }
 
 	/**
-	 * Возвращает одну запись по ID
+	 * Возвращает модель по ID
+	 * 
+	 * @param integer $orderId
+	 * @param bool    $autoCreate создавать пустую модель, если не найдена
 	 * 
-	 * @param  $orderId
 	 * @return \Ipol\DPD\DB\Order\Model
 	 */
 	public function getByOrderId($orderId, $autoCreate = false)

+ 12 - 1
src/lib/DB/TableInterface.php

@@ -1,14 +1,21 @@
 <?php
 namespace Ipol\DPD\DB;
 
+/**
+ * Интерфейс работы с таблицой БД
+ */
 interface TableInterface
 {
     /**
+     * Возвращает соединение ассоциированное с таблицей
+     * 
      * @return \Ipol\DPD\DB\ConnectionInterface
      */
     public function getConnection();
 
     /**
+     * Возвращает инстанс PDO
+     * 
      * @return \PDO
      */
     public function getPDO();
@@ -22,6 +29,8 @@ interface TableInterface
 
     /**
      * Возвращает имя класса модели
+     * 
+     * @return string
      */
     public function getModelClass();
 
@@ -45,7 +54,7 @@ interface TableInterface
     public function add($values);
 
     /**
-     * Обновление
+     * Обновление записи
      * 
      * @param int   $id
      * @param array $values
@@ -92,6 +101,8 @@ interface TableInterface
 
     /**
      * Проверка и создание таблицы по необходимости
+     * 
+     * @return void
      */
     public function checkTableSchema();
 }

+ 32 - 5
src/lib/DB/Terminal/Agent.php

@@ -5,11 +5,16 @@ use \Ipol\DPD\API\User\UserInterface;
 use \Ipol\DPD\DB\TableInterface;
 use \Ipol\DPD\Utils;
 
+/**
+ * Класс реализует методы обновления информации о ПВЗ
+ */
 class Agent
 {
 	/**
-	 * @param UserInterface $api
-	 * @param TableInterface $table
+	 * Конструктор
+	 * 
+	 * @param \Ipol\DPD\API\User\UserInterface $api   инстанс API
+	 * @param \Ipol\DPD\DB\TableInterface      $table инстанс таблицы для записи данных в БД
 	 */
 	public function __construct(UserInterface $api, TableInterface $table)
 	{
@@ -34,6 +39,10 @@ class Agent
 	}
 
 	/**
+	 * Загружает терминалы без ограничений по габаритам
+	 * 
+	 * @param string $position Стартовая позиция импорта
+	 * 
 	 * @return bool|string
 	 */
 	public function loadUnlimited($position = 0)
@@ -59,6 +68,10 @@ class Agent
 	}
 
 	/**
+	 * Загружает терминалы с ограничениями по габаритам
+	 * 
+	 * @param string $position Стартовая позиция импорта
+	 * 
 	 * @return bool|string
 	 */
 	public function loadLimited($position = 'RU:0')
@@ -93,6 +106,10 @@ class Agent
 	}
 
 	/**
+	 * Сохраняет информацию о терминале в БД
+	 * 
+	 * @param array $item
+	 * 
 	 * @return bool|int
 	 */
 	protected function loadTerminal($item)
@@ -155,7 +172,9 @@ class Agent
 	/**
 	 * Возвращает адрес терминала в виде строки
 	 * 
-	 * @param  array  $address
+	 * @param array $address
+	 * @param bool  $short
+	 * 
 	 * @return string
 	 */
 	protected function normalizeAddress($address, $short = false)
@@ -196,8 +215,9 @@ class Agent
 	/**
 	 * Возвращает график работы терминала в виде строки
 	 * 
-	 * @param  array  $schedule  график работы
-	 * @param  string $operation операция для фильтрации
+	 * @param array  $schedule  график работы
+	 * @param string $operation операция для фильтрации
+	 * 
 	 * @return string
 	 */
 	protected function normalizeSchedule($schedule, $operation)
@@ -264,6 +284,13 @@ class Agent
 		return $ret;
 	}
 
+	/**
+	 * Возвращает макс. сумму наложенного платежа
+	 * 
+	 * @param array $item
+	 * 
+	 * @return double
+	 */
 	protected function getMaxNppAmount($item)
 	{
 		if (isset($item['EXTRA_SERVICE'])) {

+ 20 - 12
src/lib/DB/Terminal/Model.php

@@ -2,17 +2,22 @@
 namespace Ipol\DPD\DB\Terminal;
 
 use \Ipol\DPD\DB\Model as BaseModel;
+use Ipol\DPD\Shipment;
 
+/**
+ * Модель одной записи таблицы терминалов
+ */
 class Model extends BaseModel
 {
 	/**
-	 * Проверяет параметры посылки
+	 * Проверяет может ли терминал принять посылку
+	 * 
+	 * @param  \Ipol\DPD\Shipment $shipment
+	 * @param  bool               $checkLocation
 	 * 
-	 * @param  Shipment $shipment
-	 * @param  boolean  $checkLocation
 	 * @return bool
 	 */
-	public function checkShipment(\Ipol\DPD\Shipment $shipment, $checkLocation = true)
+	public function checkShipment(Shipment $shipment, $checkLocation = true)
 	{
 		if ($checkLocation 
 			&& !$this->checkLocation($shipment->getReceiver())
@@ -34,23 +39,25 @@ class Model extends BaseModel
 	}
 
 	/**
-	 * Проверяет местоположение терминала и переданного местоположения
+	 * Сверяет местоположение терминала и переданного местоположения
 	 * 
 	 * @param  array  $location
+	 * 
 	 * @return bool
 	 */
 	public function checkLocation(array $location)
 	{
-		return $this->fields['LOCATION_ID'] == $location['ID'];
+		return $this->fields['LOCATION_ID'] == $location['CITY_ID'];
 	}
 
 	/**
-	 * Возвращает возможность НПП на терминале
+	 * Проверяет возможность принять НПП на терминале
+	 * 
+	 * @param \Ipol\DPD\Shipment $shipment
 	 * 
-	 * @param  Shipment $shipment
 	 * @return bool
 	 */
-	public function checkShipmentPayment(\Ipol\DPD\Shipment $shipment)
+	public function checkShipmentPayment(Shipment $shipment)
 	{
 		if ($this->fields['NPP_AVAILABLE'] != 'Y')  {
 			return false;
@@ -60,12 +67,13 @@ class Model extends BaseModel
 	}
 
 	/**
-	 * Проверяет габариты посылки
+	 * Проверяет габариты посылки на возможность ее принятия на терминале
+	 * 
+	 * @param \Ipol\DPD\Shipment $shipment
 	 * 
-	 * @param  Shipment $shipment
 	 * @return bool
 	 */
-	public function checkShipmentDimessions(\Ipol\DPD\Shipment $shipment)
+	public function checkShipmentDimessions(Shipment $shipment)
 	{
 		if ($this->fields['IS_LIMITED'] != 'Y') {
 			return true;

+ 29 - 3
src/lib/DB/Terminal/Table.php

@@ -3,13 +3,36 @@ namespace Ipol\DPD\DB\Terminal;
 
 use \Ipol\DPD\DB\AbstractTable;
 
+/**
+ * Класс для работы с таблицей терминалов
+ */
 class Table extends AbstractTable
 {
+	/**
+	 * Возвращает имя таблицы
+	 * 
+	 * @return string
+	 */
 	public function getTableName()
 	{
 		return 'b_ipol_dpd_terminal';
 	}
+	
+	/**
+	 * Возвращает название класса модели
+	 * 
+	 * @return string
+	 */
+	public function getModelClass()
+	{
+		return \Ipol\DPD\DB\Terminal\Model::class;
+	}
 
+	/**
+	 * Возвращает список полей и их значения по умолчанию
+	 * 
+	 * @return array
+	 */
 	public function getFields()
 	{
 		return [
@@ -41,11 +64,12 @@ class Table extends AbstractTable
 	}
 
 	/**
-	 * Возвращает записи по местоположению
+	 * Ищет терминалы по местоположению
 	 * 
 	 * @param  int $locationId
 	 * @param  array  $select
-	 * @return array|false
+	 * 
+	 * @return \PDOStatement
 	 */
 	public function findByLocationId($locationId, $select = '*')
 	{	
@@ -59,7 +83,9 @@ class Table extends AbstractTable
 	}
 
 	/**
-	 * Возвращает запись по коду
+	 * Возвращает запись о терминале по его коду
+	 * 
+	 * @return array
 	 */
 	public function getByCode($code, $select = '*')
 	{

+ 8 - 0
src/lib/Utils.php

@@ -11,6 +11,7 @@ class Utils
 	 * 
 	 * @param  string  $string                   строка для преобразования
 	 * @param  boolean $capitalizeFirstCharacter первый символ строчный или прописной
+	 * 
 	 * @return string
 	 */
 	public static function underScoreToCamelCase($string, $capitalizeFirstCharacter = false)
@@ -37,6 +38,7 @@ class Utils
 	 * 
 	 * @param  string  $string    строка для преобразования
 	 * @param  boolean $uppercase
+	 * 
 	 * @return string
 	 */
 	public static function camelCaseToUnderScore($string, $uppercase = true)
@@ -62,6 +64,8 @@ class Utils
 	 * @param mixed $data
 	 * @param string $fromEncoding
 	 * @param string $toEncoding
+	 * 
+	 * @return mixed
 	 */
 	public static function convertEncoding($data, $fromEncoding, $toEncoding)
 	{
@@ -78,6 +82,10 @@ class Utils
 
 	/**
 	 * Вычисляет необходимость прерывания скрипта в долгих операциях
+	 * 
+	 * @param integer $start_time
+	 * 
+	 * @return bool
 	 */
 	public static function isNeedBreak($start_time)
 	{