@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | */ |
| 32 | 32 | public function createEntity(array $row) { |
| 33 | 33 | $Group = $this->DI->get('UserGroupMapper')->createEntity([]); |
| 34 | - return $this->buildEntity(new User('testname','[email protected]','asdftyasdvh21267g',$Group), $row); |
|
| 34 | + return $this->buildEntity(new User('testname', '[email protected]', 'asdftyasdvh21267g', $Group), $row); |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | /** |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | 'primary' => true |
| 47 | 47 | ] |
| 48 | 48 | ) |
| 49 | - ->addMappingField('name','usr_name') |
|
| 49 | + ->addMappingField('name', 'usr_name') |
|
| 50 | 50 | ->addMappingField('email', 'usr_email') |
| 51 | 51 | ->addMappingField('password', 'usr_password') |
| 52 | 52 | ->addMappingField('group', [ |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | * @return type |
| 31 | 31 | */ |
| 32 | 32 | public function createEntity(array $row) { |
| 33 | - return $this->buildEntity(new UserGroup('admin','admin test'), $row); |
|
| 33 | + return $this->buildEntity(new UserGroup('admin', 'admin test'), $row); |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | /** |
@@ -45,8 +45,8 @@ discard block |
||
| 45 | 45 | 'primary' => true |
| 46 | 46 | ] |
| 47 | 47 | ) |
| 48 | - ->addMappingField('title','grp_title') |
|
| 49 | - ->addMappingField('code','grp_code') |
|
| 48 | + ->addMappingField('title', 'grp_title') |
|
| 49 | + ->addMappingField('code', 'grp_code') |
|
| 50 | 50 | ; |
| 51 | 51 | |
| 52 | 52 | } |
@@ -24,20 +24,20 @@ |
||
| 24 | 24 | |
| 25 | 25 | $db = new \SimpleORM\Adapter\CodeigniterQueryBuilder(get_instance()->db); |
| 26 | 26 | |
| 27 | - $this->getContainer()->add('UserMapper','Test\Domain\User\UserMapper') |
|
| 27 | + $this->getContainer()->add('UserMapper', 'Test\Domain\User\UserMapper') |
|
| 28 | 28 | ->withArgument($this->getContainer()) |
| 29 | 29 | ->withArgument($db) |
| 30 | 30 | ->withArgument($__AR2['autoresource_db']); |
| 31 | 31 | |
| 32 | - $this->getContainer()->add('UserGroupMapper','Test\Domain\UserGroup\UserGroupMapper') |
|
| 32 | + $this->getContainer()->add('UserGroupMapper', 'Test\Domain\UserGroup\UserGroupMapper') |
|
| 33 | 33 | ->withArgument($this->getContainer()) |
| 34 | 34 | ->withArgument($db) |
| 35 | 35 | ->withArgument($__AR2['autoresource_db']); |
| 36 | - $this->getContainer()->add('UserAddressMapper','Test\Domain\UserAddress\UserAddressMapper') |
|
| 36 | + $this->getContainer()->add('UserAddressMapper', 'Test\Domain\UserAddress\UserAddressMapper') |
|
| 37 | 37 | ->withArgument($this->getContainer()) |
| 38 | 38 | ->withArgument($db) |
| 39 | 39 | ->withArgument($__AR2['autoresource_db']); |
| 40 | - $this->getContainer()->add('CityMapper','Test\Domain\City\CityMapper') |
|
| 40 | + $this->getContainer()->add('CityMapper', 'Test\Domain\City\CityMapper') |
|
| 41 | 41 | ->withArgument($this->getContainer()) |
| 42 | 42 | ->withArgument($db) |
| 43 | 43 | ->withArgument($__AR2['autoresource_db']); |
@@ -10,29 +10,29 @@ |
||
| 10 | 10 | abstract class AbstractEntity implements EntityInterface |
| 11 | 11 | { |
| 12 | 12 | |
| 13 | - protected $id; |
|
| 13 | + protected $id; |
|
| 14 | 14 | |
| 15 | 15 | protected $deleted; |
| 16 | 16 | |
| 17 | 17 | public function getId() |
| 18 | - { |
|
| 19 | - return $this->id; |
|
| 20 | - } |
|
| 18 | + { |
|
| 19 | + return $this->id; |
|
| 20 | + } |
|
| 21 | 21 | |
| 22 | - public function setId($id) |
|
| 23 | - { |
|
| 24 | - if ($this->id !== null) { |
|
| 25 | - throw new BadMethodCallException( |
|
| 26 | - "Идентификатор у сущности уже установлен"); |
|
| 27 | - } |
|
| 22 | + public function setId($id) |
|
| 23 | + { |
|
| 24 | + if ($this->id !== null) { |
|
| 25 | + throw new BadMethodCallException( |
|
| 26 | + "Идентификатор у сущности уже установлен"); |
|
| 27 | + } |
|
| 28 | 28 | |
| 29 | - if (empty($id)) {//$id < 1 |
|
| 30 | - throw new InvalidArgumentException("Неверный индентификатор"); |
|
| 31 | - } |
|
| 29 | + if (empty($id)) {//$id < 1 |
|
| 30 | + throw new InvalidArgumentException("Неверный индентификатор"); |
|
| 31 | + } |
|
| 32 | 32 | |
| 33 | - $this->id = $id; |
|
| 34 | - return $this; |
|
| 35 | - } |
|
| 33 | + $this->id = $id; |
|
| 34 | + return $this; |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | 37 | public function setDeleted($deleted){ |
| 38 | 38 | $this->deleted = $deleted; |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | |
| 24 | 24 | public function setId($id) |
| 25 | 25 | { |
| 26 | - if ($this->id !== null) { |
|
| 26 | + if ($this->id!==null) { |
|
| 27 | 27 | throw new BadMethodCallException( |
| 28 | 28 | "Идентификатор у сущности уже установлен"); |
| 29 | 29 | } |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | return $this; |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | - public function setDeleted($deleted){ |
|
| 39 | + public function setDeleted($deleted) { |
|
| 40 | 40 | $this->deleted = $deleted; |
| 41 | 41 | } |
| 42 | 42 | |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | * @param type $value |
| 50 | 50 | * @param type $rule |
| 51 | 51 | */ |
| 52 | - protected function validate($value,$rule){ |
|
| 52 | + protected function validate($value, $rule) { |
|
| 53 | 53 | |
| 54 | 54 | $is_valid = GUMP::is_valid([ |
| 55 | 55 | 'value' => $value |
@@ -16,6 +16,9 @@ |
||
| 16 | 16 | |
| 17 | 17 | protected $name; |
| 18 | 18 | |
| 19 | + /** |
|
| 20 | + * @param string $name |
|
| 21 | + */ |
|
| 19 | 22 | function __construct($name) { |
| 20 | 23 | $this->setName($name); |
| 21 | 24 | } |
@@ -22,6 +22,11 @@ |
||
| 22 | 22 | protected $group; |
| 23 | 23 | protected $address; |
| 24 | 24 | |
| 25 | + /** |
|
| 26 | + * @param string $name |
|
| 27 | + * @param string $email |
|
| 28 | + * @param string $password |
|
| 29 | + */ |
|
| 25 | 30 | function __construct($name, $email, $password, UserGroup $Group) { |
| 26 | 31 | $this->setName($name); |
| 27 | 32 | $this->setEmail($email); |
@@ -22,6 +22,10 @@ |
||
| 22 | 22 | |
| 23 | 23 | protected $city; |
| 24 | 24 | |
| 25 | + /** |
|
| 26 | + * @param string $code |
|
| 27 | + * @param string $street |
|
| 28 | + */ |
|
| 25 | 29 | function __construct(City $City,$code,$street) { |
| 26 | 30 | $this->setCity($City); |
| 27 | 31 | $this->setCode($code); |
@@ -22,7 +22,7 @@ |
||
| 22 | 22 | |
| 23 | 23 | protected $city; |
| 24 | 24 | |
| 25 | - function __construct(City $City,$code,$street) { |
|
| 25 | + function __construct(City $City, $code, $street) { |
|
| 26 | 26 | $this->setCity($City); |
| 27 | 27 | $this->setCode($code); |
| 28 | 28 | $this->setStreet($street); |
@@ -30,8 +30,8 @@ discard block |
||
| 30 | 30 | * @return type |
| 31 | 31 | */ |
| 32 | 32 | public function createEntity(array $row) { |
| 33 | - $City = $this->DI->get('CityMapper')->createEntity([]); |
|
| 34 | - return $this->buildEntity(new UserAddress( $City ,'201000','Lenina 63'), $row); |
|
| 33 | + $City = $this->DI->get('CityMapper')->createEntity([]); |
|
| 34 | + return $this->buildEntity(new UserAddress($City, '201000', 'Lenina 63'), $row); |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | /** |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | 'primary' => true |
| 47 | 47 | ] |
| 48 | 48 | ) |
| 49 | - ->addMappingField('code','adr_code') |
|
| 49 | + ->addMappingField('code', 'adr_code') |
|
| 50 | 50 | ->addMappingField('street', 'adr_street') |
| 51 | 51 | ->addMappingField('city', [ |
| 52 | 52 | 'field' => 'adr_cty_id', |
@@ -16,7 +16,7 @@ |
||
| 16 | 16 | |
| 17 | 17 | /** |
| 18 | 18 | * Перед сохранением извелкаем объект и дополняем массив для записи, недостающими полями |
| 19 | - * @param \Autoprice\Domain\Price\EntityInterface $Entity |
|
| 19 | + * @param EntityInterface $Entity |
|
| 20 | 20 | * @param type $data |
| 21 | 21 | */ |
| 22 | 22 | protected function onPrepareData(\SimpleORM\EntityInterface $Entity, &$data) { |
@@ -80,8 +80,7 @@ |
||
| 80 | 80 | $o = $$_mc; |
| 81 | 81 | eval($set_path); |
| 82 | 82 | } |
| 83 | - } |
|
| 84 | - elseif(is_object($o) ){ |
|
| 83 | + } elseif(is_object($o) ){ |
|
| 85 | 84 | $$_mc = $o->{$_mc}(); |
| 86 | 85 | $o = $$_mc; |
| 87 | 86 | } |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | */ |
| 22 | 22 | protected function onPrepareData(\SimpleORM\EntityInterface $Entity, &$data) { |
| 23 | 23 | foreach ($this->mapping_fields as $field => $cfg) { |
| 24 | - if (isset($cfg['null']) && $cfg['null'] === false && empty($data[$cfg['field']])) { |
|
| 24 | + if (isset($cfg['null']) && $cfg['null']===false && empty($data[$cfg['field']])) { |
|
| 25 | 25 | $data[$cfg['field']] = $cfg['default']; |
| 26 | 26 | } |
| 27 | 27 | } |
@@ -35,8 +35,8 @@ discard block |
||
| 35 | 35 | foreach ($this->relations as $alias => $cfg) { |
| 36 | 36 | $mapper = $cfg['mapper']; |
| 37 | 37 | //если связь один к одному то удаляем сущность |
| 38 | - if ($cgg['reltype'] == 'has_one') { |
|
| 39 | - $Entity = $Entity->{'get' . $alias}(); |
|
| 38 | + if ($cgg['reltype']=='has_one') { |
|
| 39 | + $Entity = $Entity->{'get'.$alias}(); |
|
| 40 | 40 | if (!$mapper->delete($Entity)) { |
| 41 | 41 | throw new \Autoprice\Exceptions\EntityNotDeleteException('Unable to delete Entity!'); |
| 42 | 42 | } |
@@ -62,25 +62,25 @@ discard block |
||
| 62 | 62 | |
| 63 | 63 | $set_path = str_replace(['#', '();'], ['->set', '($o);'], $call_obj); |
| 64 | 64 | |
| 65 | - $ar_path = explode('()',$obj_path); |
|
| 65 | + $ar_path = explode('()', $obj_path); |
|
| 66 | 66 | |
| 67 | 67 | $o = $Entity; |
| 68 | 68 | |
| 69 | - foreach ($ar_path as $_m){ |
|
| 69 | + foreach ($ar_path as $_m) { |
|
| 70 | 70 | |
| 71 | - $_mc = str_replace('#','get',mb_ucfirst($_m)); |
|
| 71 | + $_mc = str_replace('#', 'get', mb_ucfirst($_m)); |
|
| 72 | 72 | |
| 73 | 73 | //Set logic |
| 74 | - if(empty($_m)){ |
|
| 74 | + if (empty($_m)) { |
|
| 75 | 75 | |
| 76 | - $_mc = ltrim( $ar_path[(count($ar_path)-2)] , '#'); |
|
| 76 | + $_mc = ltrim($ar_path[(count($ar_path) - 2)], '#'); |
|
| 77 | 77 | |
| 78 | - if (is_object($$_mc) && is_a($$_mc,'SimpleORM\EntityInterface') && $this->DI->get($mapper)->saveWithoutEvents($o)) { |
|
| 78 | + if (is_object($$_mc) && is_a($$_mc, 'SimpleORM\EntityInterface') && $this->DI->get($mapper)->saveWithoutEvents($o)) { |
|
| 79 | 79 | $o = $$_mc; |
| 80 | 80 | eval($set_path); |
| 81 | 81 | } |
| 82 | 82 | } |
| 83 | - elseif(is_object($o) ){ |
|
| 83 | + elseif (is_object($o)) { |
|
| 84 | 84 | $$_mc = $o->{$_mc}(); |
| 85 | 85 | $o = $$_mc; |
| 86 | 86 | } |