|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Helix\Asana\Task; |
|
4
|
|
|
|
|
5
|
|
|
use Helix\Asana\Base\Data; |
|
6
|
|
|
use Helix\Asana\Task; |
|
7
|
|
|
|
|
8
|
|
|
/** |
|
9
|
|
|
* Custom task data. |
|
10
|
|
|
* |
|
11
|
|
|
* @see https://developers.asana.com/docs/custom-external-data |
|
12
|
|
|
* |
|
13
|
|
|
* @method null|string getGid () |
|
14
|
|
|
* @method bool hasGid () |
|
15
|
|
|
* @method $this setGid (null|string $gid) 1024 chars max. |
|
16
|
|
|
* @method null|string getData () |
|
17
|
|
|
* @method bool hasData () |
|
18
|
|
|
* @method $this setData (null|string $data) 32768 chars max. |
|
19
|
|
|
*/ |
|
20
|
|
|
class External extends Data { |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* @var Task |
|
24
|
|
|
*/ |
|
25
|
|
|
protected $task; |
|
26
|
|
|
|
|
27
|
|
|
public function __construct (Task $task, array $data = []) { |
|
28
|
|
|
parent::__construct($task, $data); |
|
29
|
|
|
$this->task = $task; |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* Marks the task's `external` diff. |
|
34
|
|
|
* |
|
35
|
|
|
* @param string $field |
|
36
|
|
|
* @param mixed $value |
|
37
|
|
|
* @return $this |
|
38
|
|
|
*/ |
|
39
|
|
|
protected function _set (string $field, $value) { |
|
40
|
|
|
$this->task->diff['external'] = true; |
|
41
|
|
|
return parent::_set($field, $value); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* The JSON decoded data, or `null`. |
|
46
|
|
|
* |
|
47
|
|
|
* @return null|bool|number|string|array |
|
48
|
|
|
*/ |
|
49
|
|
|
public function getDataJsonDecoded () { |
|
50
|
|
|
if (strlen($data = $this->getData())) { |
|
51
|
|
|
return json_decode($data, true, 512, JSON_BIGINT_AS_STRING | JSON_THROW_ON_ERROR); |
|
52
|
|
|
} |
|
53
|
|
|
return null; |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* JSON encodes and sets. |
|
58
|
|
|
* This field is nullable, so `null` is not encoded. |
|
59
|
|
|
* |
|
60
|
|
|
* @param mixed $data |
|
61
|
|
|
* @return $this |
|
62
|
|
|
*/ |
|
63
|
|
|
public function setDataJsonEncoded ($data) { |
|
64
|
|
|
if (isset($data)) { |
|
65
|
|
|
return $this->setData(json_encode($data, JSON_THROW_ON_ERROR)); |
|
|
|
|
|
|
66
|
|
|
} |
|
67
|
|
|
return $this->setData(null); |
|
68
|
|
|
} |
|
69
|
|
|
} |
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.