1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace prgTW\BaseCRM; |
4
|
|
|
|
5
|
|
|
use prgTW\BaseCRM\Client\ClientInterface; |
6
|
|
|
use prgTW\BaseCRM\Resource\Resource; |
7
|
|
|
use prgTW\BaseCRM\Service\Account; |
8
|
|
|
use prgTW\BaseCRM\Service\Contacts; |
9
|
|
|
use prgTW\BaseCRM\Service\Deals; |
10
|
|
|
use prgTW\BaseCRM\Service\Leads; |
11
|
|
|
use prgTW\BaseCRM\Service\Sources; |
12
|
|
|
use prgTW\BaseCRM\Service\Tags; |
13
|
|
|
use prgTW\BaseCRM\Transport\Transport; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* @method Account getAccount() |
17
|
|
|
* @method Contacts getContacts() |
18
|
|
|
* @method Sources getSources() |
19
|
|
|
* @method Deals getDeals() |
20
|
|
|
* @method Leads getLeads() |
21
|
|
|
* @method Tags getTaggings() |
22
|
|
|
*/ |
23
|
|
|
class BaseCrm extends Resource |
24
|
|
|
{ |
25
|
|
|
/** @var Transport */ |
26
|
|
|
protected $transport; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @param string $token |
30
|
|
|
* @param ClientInterface $client |
|
|
|
|
31
|
|
|
*/ |
32
|
|
|
public function __construct($token = '', ClientInterface $client = null) |
33
|
|
|
{ |
34
|
|
|
$transport = new Transport($token, $client); |
35
|
|
|
parent::__construct($transport, ''); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** {@inheritdoc} */ |
39
|
|
|
protected function init() |
40
|
|
|
{ |
41
|
|
|
$this->setSubResources([ |
42
|
|
|
Account::class, |
43
|
|
|
Deals::class, |
44
|
|
|
Contacts::class, |
45
|
|
|
Sources::class, |
46
|
|
|
Leads::class, |
47
|
|
|
Tags::class, |
48
|
|
|
]); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** {@inheritdoc} */ |
52
|
|
|
protected function getEndpoint() |
53
|
|
|
{ |
54
|
|
|
//@codeCoverageIgnoreStart |
55
|
|
|
throw new \LogicException('Cannot call BaseCrm directly'); |
56
|
|
|
//@codeCoverageIgnoreEnd |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @return string |
61
|
|
|
*/ |
62
|
|
|
public function getToken() |
63
|
|
|
{ |
64
|
|
|
return $this->transport->getToken(); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @param string $token |
69
|
|
|
* |
70
|
|
|
* @return $this |
71
|
|
|
*/ |
72
|
|
|
public function setToken($token) |
73
|
|
|
{ |
74
|
|
|
$this->transport->setToken($token); |
75
|
|
|
|
76
|
|
|
return $this; |
77
|
|
|
} |
78
|
|
|
} |
79
|
|
|
|
This check looks for
@param
annotations where the type inferred by our type inference engine differs from the declared type.It makes a suggestion as to what type it considers more descriptive.
Most often this is a case of a parameter that can be null in addition to its declared types.