UserAddressMapper   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 2
c 2
b 0
f 0
lcom 1
cbo 2
dl 0
loc 43
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A createEntity() 0 4 1
A setMappingFields() 0 18 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\UserAddress;
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 UserAddressMapper extends AbstractDataMapper
19
{
20
	/**
21
	 * таблица
22
	 * @var type 
23
	 */
24
	protected $table = '__test_address';
25
	
26
	/**
27
	 * создаем сущность
28
	 * 
29
	 * @param array $row
30
	 * @return type
31
	 */
32
	public function createEntity(array $row) {
33
		$City =  $this->DI->get('CityMapper')->createEntity([]);
34
		return $this->buildEntity(new UserAddress( $City ,'201000','Lenina 63'), $row);
35
	}	
36
	
37
	/**
38
	 * Настройка полей
39
	 */
40
	protected function setMappingFields() {
41
		
42
		//вариант 1
43
		$this
44
				->addMappingField('id', [
45
					'field'		 => 'adr_id',
46
					'primary'	 => true
47
					]
48
				)
49
				->addMappingField('code','adr_code')
50
				->addMappingField('street', 'adr_street')
51
				->addMappingField('city', [
52
					'field'		=> 'adr_cty_id',
53
					'relation'	=> 'CityMapper'
54
				])
55
			;
56
57
	}	
58
	
59
	
60
}
61