/** * @param Client $client * @param array $data * @return Project */ public static function populate(Client $client, $data) { if (!is_array($data) || !isset($data['id'])) { return null; } $project = new self(); $project->_client = $client; $project->id = (int) $data['id']; $project->key = $data['key']; $project->name = $data['name']; $project->issueTypes = IssueType::populateAll($project, $data['issueTypes']); $project->components = ArrayHelper::index($data['components'], 'name'); $project->projectTypeKey = $data['projectTypeKey']; return $project; }
public function serialize() { $fields = ['project' => ['id' => $this->project->id], 'issuetype' => $this->issueType, 'components' => is_array($this->components) ? array_values($this->components) : []]; if ($this->description) { $fields['description'] = $this->description; } if ($this->summary) { $fields['summary'] = $this->summary; } foreach ($this->issueType->getCustomFieldsMap() as $name => $id) { if (isset($this->customFields[$name])) { $fields['customfield_' . $id] = $this->customFields[$name]; } } return ['fields' => $fields]; }