GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Account::getName()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace prgTW\BaseCRM\Service;
4
5
use prgTW\BaseCRM\Resource\InstanceResource;
6
use prgTW\BaseCRM\Service\Enum\Currency;
7
8
/**
9
 * @property-read int      id
10
 * @property string        name
11
 * @property string        timezone
12
 * @property-read Currency currency
13
 */
14
class Account extends InstanceResource
15
{
16
	/** {@inheritdoc} */
17
	protected function getEndpoint()
18
	{
19
		return self::ENDPOINT_SALES;
20
	}
21
22
	/**
23
	 * @return int
24
	 */
25
	protected function getId()
26
	{
27
		return $this->data['id'];
28
	}
29
30
	/**
31
	 * @param Currency $currency
32
	 *
33
	 * @return $this
34
	 */
35
	public function setCurrency(Currency $currency)
36
	{
37
		$this->data['currency_id']   = $currency->getValue();
38
		$this->data['currency_name'] = $currency->getName();
39
40
		return $this;
41
	}
42
43
	/**
44
	 * @return Currency
45
	 */
46
	protected function getCurrency()
47
	{
48
		return new Currency($this->data['currency_id']);
49
	}
50
51
	/**
52
	 * @return string
53
	 */
54
	protected function getName()
55
	{
56
		return $this->data['name'];
57
	}
58
59
	/**
60
	 * @return string
61
	 */
62
	protected function getTimezone()
63
	{
64
		return $this->data['timezone'];
65
	}
66
67
	/** {@inheritdoc} */
68
	public function save(array $fieldNames = [])
69
	{
70
		$fieldNames = array_intersect($fieldNames, [
71
			'name',
72
			'timezone',
73
			'currency_id',
74
		]);
75
76
		return parent::save($fieldNames);
77
	}
78
79
	/** {@inheritdoc} */
80
	protected function postHydrate(array $data)
81
	{
82
		$this->currency = Currency::fromName($data['currency_name']);
83
	}
84
}
85