Test Failed
Push — v2 ( 737a06 )
by Berend
03:55
created

Address   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 90
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 9
lcom 1
cbo 0
dl 0
loc 90
rs 10
c 0
b 0
f 0

9 Methods

Rating   Name   Duplication   Size   Complexity  
A initAddress() 0 39 1
A getAddress() 0 4 1
A setAddress() 0 4 1
A getZipcode() 0 4 1
A setZipcode() 0 4 1
A getCity() 0 4 1
A setCity() 0 4 1
A getCountry() 0 4 1
A setCountry() 0 4 1
1
<?php
2
3
namespace miBadger\ActiveRecord\Traits;
4
5
use miBadger\ActiveRecord\ColumnProperty;
6
7
const TRAIT_ADDRESS_FIELD_ADDRESS = "address_address";
8
const TRAIT_ADDRESS_FIELD_ZIPCODE = "address_zipcode";
9
const TRAIT_ADDRESS_FIELD_CITY = "address_city";
10
const TRAIT_ADDRESS_FIELD_COUNTRY = "address_country";
11
12
trait Address
13
{
14
	protected $address;
15
16
	protected $zipcode;
17
18
	protected $city;
19
20
	protected $country;
21
22
	protected function initAddress() 
23
	{
24
		$this->extendTableDefinition(TRAIT_ADDRESS_FIELD_ADDRESS, [
0 ignored issues
show
Bug introduced by
It seems like extendTableDefinition() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
25
			'value' => &$this->address,
26
			'validate' => null,
27
			'type' => 'VARCHAR',
28
			'length' => 1024,
29
			'properties' => null
30
		]);
31
32
		$this->extendTableDefinition(TRAIT_ADDRESS_FIELD_ZIPCODE, [
0 ignored issues
show
Bug introduced by
It seems like extendTableDefinition() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
33
			'value' => &$this->zipcode,
34
			'validate' => null,
35
			'type' => 'VARCHAR',
36
			'length' => 1024,
37
			'properties' => null
38
		]);
39
40
		$this->extendTableDefinition(TRAIT_ADDRESS_FIELD_CITY, [
0 ignored issues
show
Bug introduced by
It seems like extendTableDefinition() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
41
			'value' => &$this->city,
42
			'validate' => null,
43
			'type' => 'VARCHAR',
44
			'length' => 1024,
45
			'properties' => null
46
		]);
47
48
		$this->extendTableDefinition(TRAIT_ADDRESS_FIELD_COUNTRY, [
0 ignored issues
show
Bug introduced by
It seems like extendTableDefinition() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
49
			'value' => &$this->country,
50
			'validate' => null,
51
			'type' => 'VARCHAR',
52
			'length' => 1024,
53
			'properties' => null
54
		]);
55
56
		$this->address = null;
57
		$this->zipcode = null;
58
		$this->city = null;
59
		$this->country = null;
60
	}
61
62
	public function getAddress()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
63
	{
64
		return $this->address;
65
	}
66
	
67
	public function setAddress($address)
68
	{
69
		$this->address = $address;
70
	}
71
72
	public function getZipcode()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
73
	{
74
		return $this->zipcode;
75
	}
76
	
77
	public function setZipcode($zipcode)
78
	{
79
		$this->zipcode = $zipcode;
80
	}
81
82
	public function getCity()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
83
	{
84
		return $this->city;
85
	}
86
	
87
	public function setCity($city)
88
	{
89
		$this->city = $city;
90
	}
91
92
	public function getCountry()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
93
	{
94
		return $this->country;
95
	}
96
	
97
	public function setCountry($country)
98
	{
99
		$this->country = $country;
100
	}
101
}