/** * TODO: currently, only happy case :) * * @param $curlHandler * @param AbstractRequest $request * @return bool|AbstractObject */ protected function execute($curlHandler, AbstractRequest $request) { $result = curl_exec($curlHandler); $curlInfo = curl_getinfo($curlHandler); // $lastHttpCode = $curlInfo['http_code']; curl_close($curlHandler); // // TODO: remove this debug output // echo PHP_EOL.'<hr /><pre>'; \Doctrine\Common\Util\Debug::dump($request); echo '</pre><hr />'.PHP_EOL.__CLASS__.PHP_EOL.__FILE__ . ':'.__LINE__.PHP_EOL.PHP_EOL; // echo PHP_EOL.'<hr /><pre>'; \Doctrine\Common\Util\Debug::dump($curlInfo); echo '</pre><hr />'.PHP_EOL.__CLASS__.PHP_EOL.__FILE__ . ':'.__LINE__.PHP_EOL.PHP_EOL; if ($result) { $responseData = json_decode($result, true); $object = ObjectPopulator::populate($request->getObject(), $responseData); return $object; } return false; }
/** * @param array $content */ protected function setRepository(array $content) { if (array_key_exists(self::PARAM_REPOSITORY, $content)) { $this->repository = ObjectPopulator::populate(new Repository(), $content[self::PARAM_REPOSITORY]); } }
/** * @param Checklist $checklist * @param RepositoryInformation $repositoryInformationNew * @return ChecklistItem|null */ public function getChecklistItemByRepositoryInformation(Checklist $checklist = null, RepositoryInformation $repositoryInformationNew) { if (!$checklist || $checklist->getCheckItems() === null) { return null; } foreach ($checklist->getCheckItems() as $itemData) { $repoInfo = IssueReference::getRepositoryInformationFromUrl($itemData['name']); if (!$repoInfo) { continue; } if ($repoInfo->isSame($repositoryInformationNew)) { $checkItem = new ChecklistItem(); $checkItem = ObjectPopulator::populate($checkItem, $itemData); $checkItem->setIdChecklist($checklist->getId()); return $checkItem; } } return null; }
/** * @param array $content */ protected function setSender(array $content) { if (array_key_exists(self::PARAM_SENDER, $content)) { $this->sender = ObjectPopulator::populate(new Sender(), $content[self::PARAM_SENDER]); } }
/** * @param $comment * @param Checklist $checklist * @return mixed|string */ private function prepareBadgeCommentForMentionedRepositories($comment, Checklist $checklist) { $replaceWords = []; /* @var RepositoryInformation $mentionedIssue */ foreach ($this->mentionedRepositories as $mentionedRepository) { //--___________________________________________________--> //-- if checklist items are mentioned add badge foreach ($checklist->getCheckItems() as $checkItem) { if (!$checkItem instanceof ChecklistItem) { //--___________________________________________________--> //-- prepare /* @var CheckListItem $checkListItem */ $checkListItem = ObjectPopulator::populate(new ChecklistItem(), $checkItem); $checkListItemName = $checkListItem->getName(); $repositoryInformationFromChecklistItemName = IssueReference::getRepositoryInformationFromUrl($checkListItemName); //--___________________________________________________--> //-- check if repository exists try { $this->githubClient->issues()->show($this->getGithubUserName(), $repositoryInformationFromChecklistItemName->getRepositoryName(), $repositoryInformationFromChecklistItemName->getIssueId()); } catch (\Github\Exception\RuntimeException $runtimeException) { continue; } //--___________________________________________________--> //-- add issue badge if repository was mentioned if ($repositoryInformationFromChecklistItemName->getRepositoryName() == $mentionedRepository) { $comment .= $this->getIssueBadge($repositoryInformationFromChecklistItemName); } } } $replaceWords[] = '[' . $mentionedRepository . ']'; } $comment = str_replace($replaceWords, '', $comment); return $comment; }