UserMapper::createEntity()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
/*
3
 * To change this license header, choose License Headers in Project Properties.
4
 * To change this template file, choose Tools | Templates
5
 * and open the template in the editor.
6
 */
7
8
namespace Test\Domain\User;
9
10
use 
0 ignored issues
show
Coding Style introduced by
There must be a single space after the USE keyword
Loading history...
11
	SimpleORM\AbstractDataMapper;
12
13
/**
14
 * Description of PriceMapper
15
 *
16
 * @author d.lanec
17
 */
18
class UserMapper extends AbstractDataMapper
19
{
20
	/**
21
	 * таблица
22
	 * @var type 
23
	 */
24
	protected $table = '__test_user';
25
	
26
	/**
27
	 * создаем сущность
28
	 * 
29
	 * @param array $row
30
	 * @return type
31
	 */
32
	public function createEntity(array $row) {
33
		$Group = $this->DI->get('UserGroupMapper')->createEntity([]);
34
		return $this->buildEntity(new User('testname','[email protected]','asdftyasdvh21267g',$Group), $row);
35
	}	
36
	
37
	/**
38
	 * Настройка полей
39
	 */
40
	protected function setMappingFields() {
41
		
42
		//вариант 1
43
		$this
44
				->addMappingField('id', [
45
					'field'		 => 'usr_id',
46
					'primary'	 => true
47
					]
48
				)
49
				->addMappingField('name','usr_name')
50
				->addMappingField('email', 'usr_email')
51
				->addMappingField('password', 'usr_password')
52
				->addMappingField('group', [
53
					'field'		=> 'usr_grp_id',
54
					'relation'	=> 'UserGroupMapper'
55
				])
56
				->addMappingField('address', [
57
					'field'		=> 'usr_adr_id',
58
					'relation'	=> 'UserAddressMapper'
59
				])
60
			;
61
62
	}	
63
	
64
	
65
}
66