repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
sendpulse/sendpulse-rest-api-php
src/ApiClient.php
ApiClient.getEmailInfo
public function getEmailInfo($bookID, $email) { if (empty($bookID) || empty($email)) { return $this->handleError('Empty book id or email'); } $requestResult = $this->sendRequest('addressbooks/' . $bookID . '/emails/' . $email); return $this->handleResult($requestResult); }
php
public function getEmailInfo($bookID, $email) { if (empty($bookID) || empty($email)) { return $this->handleError('Empty book id or email'); } $requestResult = $this->sendRequest('addressbooks/' . $bookID . '/emails/' . $email); return $this->handleResult($requestResult); }
[ "public", "function", "getEmailInfo", "(", "$", "bookID", ",", "$", "email", ")", "{", "if", "(", "empty", "(", "$", "bookID", ")", "||", "empty", "(", "$", "email", ")", ")", "{", "return", "$", "this", "->", "handleError", "(", "'Empty book id or ema...
Get information about email address from book @param $bookID @param $email @return stdClass
[ "Get", "information", "about", "email", "address", "from", "book" ]
train
https://github.com/sendpulse/sendpulse-rest-api-php/blob/01932257cb99f06cb05b5baaf13d2b5f7ec174cf/src/ApiClient.php#L412-L421
sendpulse/sendpulse-rest-api-php
src/ApiClient.php
ApiClient.campaignCost
public function campaignCost($bookID) { if (empty($bookID)) { return $this->handleError('Empty book id'); } $requestResult = $this->sendRequest('addressbooks/' . $bookID . '/cost'); return $this->handleResult($requestResult); }
php
public function campaignCost($bookID) { if (empty($bookID)) { return $this->handleError('Empty book id'); } $requestResult = $this->sendRequest('addressbooks/' . $bookID . '/cost'); return $this->handleResult($requestResult); }
[ "public", "function", "campaignCost", "(", "$", "bookID", ")", "{", "if", "(", "empty", "(", "$", "bookID", ")", ")", "{", "return", "$", "this", "->", "handleError", "(", "'Empty book id'", ")", ";", "}", "$", "requestResult", "=", "$", "this", "->", ...
Get cost of campaign based on address book @param $bookID @return stdClass
[ "Get", "cost", "of", "campaign", "based", "on", "address", "book" ]
train
https://github.com/sendpulse/sendpulse-rest-api-php/blob/01932257cb99f06cb05b5baaf13d2b5f7ec174cf/src/ApiClient.php#L430-L439
sendpulse/sendpulse-rest-api-php
src/ApiClient.php
ApiClient.listCampaigns
public function listCampaigns($limit = null, $offset = null) { $data = array(); if (!empty($limit)) { $data['limit'] = $limit; } if (!empty($offset)) { $data['offset'] = $offset; } $requestResult = $this->sendRequest('campaigns', 'GET', $data); return $this->handleResult($requestResult); }
php
public function listCampaigns($limit = null, $offset = null) { $data = array(); if (!empty($limit)) { $data['limit'] = $limit; } if (!empty($offset)) { $data['offset'] = $offset; } $requestResult = $this->sendRequest('campaigns', 'GET', $data); return $this->handleResult($requestResult); }
[ "public", "function", "listCampaigns", "(", "$", "limit", "=", "null", ",", "$", "offset", "=", "null", ")", "{", "$", "data", "=", "array", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "limit", ")", ")", "{", "$", "data", "[", "'limit'", ...
Get list of campaigns @param null $limit @param null $offset @return mixed
[ "Get", "list", "of", "campaigns" ]
train
https://github.com/sendpulse/sendpulse-rest-api-php/blob/01932257cb99f06cb05b5baaf13d2b5f7ec174cf/src/ApiClient.php#L449-L461
sendpulse/sendpulse-rest-api-php
src/ApiClient.php
ApiClient.getCampaignInfo
public function getCampaignInfo($id) { if (empty($id)) { return $this->handleError('Empty campaign id'); } $requestResult = $this->sendRequest('campaigns/' . $id); return $this->handleResult($requestResult); }
php
public function getCampaignInfo($id) { if (empty($id)) { return $this->handleError('Empty campaign id'); } $requestResult = $this->sendRequest('campaigns/' . $id); return $this->handleResult($requestResult); }
[ "public", "function", "getCampaignInfo", "(", "$", "id", ")", "{", "if", "(", "empty", "(", "$", "id", ")", ")", "{", "return", "$", "this", "->", "handleError", "(", "'Empty campaign id'", ")", ";", "}", "$", "requestResult", "=", "$", "this", "->", ...
Get information about campaign @param $id @return stdClass
[ "Get", "information", "about", "campaign" ]
train
https://github.com/sendpulse/sendpulse-rest-api-php/blob/01932257cb99f06cb05b5baaf13d2b5f7ec174cf/src/ApiClient.php#L470-L479
sendpulse/sendpulse-rest-api-php
src/ApiClient.php
ApiClient.campaignStatByCountries
public function campaignStatByCountries($id) { if (empty($id)) { return $this->handleError('Empty campaign id'); } $requestResult = $this->sendRequest('campaigns/' . $id . '/countries'); return $this->handleResult($requestResult); }
php
public function campaignStatByCountries($id) { if (empty($id)) { return $this->handleError('Empty campaign id'); } $requestResult = $this->sendRequest('campaigns/' . $id . '/countries'); return $this->handleResult($requestResult); }
[ "public", "function", "campaignStatByCountries", "(", "$", "id", ")", "{", "if", "(", "empty", "(", "$", "id", ")", ")", "{", "return", "$", "this", "->", "handleError", "(", "'Empty campaign id'", ")", ";", "}", "$", "requestResult", "=", "$", "this", ...
Get campaign statistic by countries @param $id @return stdClass
[ "Get", "campaign", "statistic", "by", "countries" ]
train
https://github.com/sendpulse/sendpulse-rest-api-php/blob/01932257cb99f06cb05b5baaf13d2b5f7ec174cf/src/ApiClient.php#L488-L497
sendpulse/sendpulse-rest-api-php
src/ApiClient.php
ApiClient.campaignStatByReferrals
public function campaignStatByReferrals($id) { if (empty($id)) { return $this->handleError('Empty campaign id'); } $requestResult = $this->sendRequest('campaigns/' . $id . '/referrals'); return $this->handleResult($requestResult); }
php
public function campaignStatByReferrals($id) { if (empty($id)) { return $this->handleError('Empty campaign id'); } $requestResult = $this->sendRequest('campaigns/' . $id . '/referrals'); return $this->handleResult($requestResult); }
[ "public", "function", "campaignStatByReferrals", "(", "$", "id", ")", "{", "if", "(", "empty", "(", "$", "id", ")", ")", "{", "return", "$", "this", "->", "handleError", "(", "'Empty campaign id'", ")", ";", "}", "$", "requestResult", "=", "$", "this", ...
Get campaign statistic by referrals @param $id @return stdClass
[ "Get", "campaign", "statistic", "by", "referrals" ]
train
https://github.com/sendpulse/sendpulse-rest-api-php/blob/01932257cb99f06cb05b5baaf13d2b5f7ec174cf/src/ApiClient.php#L506-L515
sendpulse/sendpulse-rest-api-php
src/ApiClient.php
ApiClient.createCampaign
public function createCampaign( $senderName, $senderEmail, $subject, $bodyOrTemplateId, $bookId, $name = '', $attachments = '', $type = '', $useTemplateId = false ) { if (empty($senderName) || empty($senderEmail) || empty($subject) || empty($bodyOrTemplateId) || empty($bookId)) { return $this->handleError('Not all data.'); } if (!empty($attachments)) { $attachments = serialize($attachments); } if($useTemplateId) { $paramName = 'template_id'; $paramValue = $bodyOrTemplateId; } else { $paramName = 'body'; $paramValue = base64_encode($bodyOrTemplateId); } $data = array( 'sender_name' => $senderName, 'sender_email' => $senderEmail, 'subject' => $subject, $paramName => $paramValue, 'list_id' => $bookId, 'name' => $name, 'attachments' => $attachments, 'type' => $type, ); $requestResult = $this->sendRequest('campaigns', 'POST', $data); return $this->handleResult($requestResult); }
php
public function createCampaign( $senderName, $senderEmail, $subject, $bodyOrTemplateId, $bookId, $name = '', $attachments = '', $type = '', $useTemplateId = false ) { if (empty($senderName) || empty($senderEmail) || empty($subject) || empty($bodyOrTemplateId) || empty($bookId)) { return $this->handleError('Not all data.'); } if (!empty($attachments)) { $attachments = serialize($attachments); } if($useTemplateId) { $paramName = 'template_id'; $paramValue = $bodyOrTemplateId; } else { $paramName = 'body'; $paramValue = base64_encode($bodyOrTemplateId); } $data = array( 'sender_name' => $senderName, 'sender_email' => $senderEmail, 'subject' => $subject, $paramName => $paramValue, 'list_id' => $bookId, 'name' => $name, 'attachments' => $attachments, 'type' => $type, ); $requestResult = $this->sendRequest('campaigns', 'POST', $data); return $this->handleResult($requestResult); }
[ "public", "function", "createCampaign", "(", "$", "senderName", ",", "$", "senderEmail", ",", "$", "subject", ",", "$", "bodyOrTemplateId", ",", "$", "bookId", ",", "$", "name", "=", "''", ",", "$", "attachments", "=", "''", ",", "$", "type", "=", "''"...
Create new campaign @param $senderName @param $senderEmail @param $subject @param $bodyOrTemplateId @param $bookId @param string $name @param string $attachments @param string $type @param bool $useTemplateId @return mixed
[ "Create", "new", "campaign" ]
train
https://github.com/sendpulse/sendpulse-rest-api-php/blob/01932257cb99f06cb05b5baaf13d2b5f7ec174cf/src/ApiClient.php#L532-L573
sendpulse/sendpulse-rest-api-php
src/ApiClient.php
ApiClient.cancelCampaign
public function cancelCampaign($id) { if (empty($id)) { return $this->handleError('Empty campaign id'); } $requestResult = $this->sendRequest('campaigns/' . $id, 'DELETE'); return $this->handleResult($requestResult); }
php
public function cancelCampaign($id) { if (empty($id)) { return $this->handleError('Empty campaign id'); } $requestResult = $this->sendRequest('campaigns/' . $id, 'DELETE'); return $this->handleResult($requestResult); }
[ "public", "function", "cancelCampaign", "(", "$", "id", ")", "{", "if", "(", "empty", "(", "$", "id", ")", ")", "{", "return", "$", "this", "->", "handleError", "(", "'Empty campaign id'", ")", ";", "}", "$", "requestResult", "=", "$", "this", "->", ...
Cancel campaign @param $id @return stdClass
[ "Cancel", "campaign" ]
train
https://github.com/sendpulse/sendpulse-rest-api-php/blob/01932257cb99f06cb05b5baaf13d2b5f7ec174cf/src/ApiClient.php#L582-L591
sendpulse/sendpulse-rest-api-php
src/ApiClient.php
ApiClient.getSenderActivationMail
public function getSenderActivationMail($email) { if (empty($email)) { return $this->handleError('Empty email'); } $requestResult = $this->sendRequest('senders/' . $email . '/code'); return $this->handleResult($requestResult); }
php
public function getSenderActivationMail($email) { if (empty($email)) { return $this->handleError('Empty email'); } $requestResult = $this->sendRequest('senders/' . $email . '/code'); return $this->handleResult($requestResult); }
[ "public", "function", "getSenderActivationMail", "(", "$", "email", ")", "{", "if", "(", "empty", "(", "$", "email", ")", ")", "{", "return", "$", "this", "->", "handleError", "(", "'Empty email'", ")", ";", "}", "$", "requestResult", "=", "$", "this", ...
Request mail with activation code @param $email @return stdClass
[ "Request", "mail", "with", "activation", "code" ]
train
https://github.com/sendpulse/sendpulse-rest-api-php/blob/01932257cb99f06cb05b5baaf13d2b5f7ec174cf/src/ApiClient.php#L693-L702
sendpulse/sendpulse-rest-api-php
src/ApiClient.php
ApiClient.getEmailGlobalInfo
public function getEmailGlobalInfo($email) { if (empty($email)) { return $this->handleError('Empty email'); } $requestResult = $this->sendRequest('emails/' . $email); return $this->handleResult($requestResult); }
php
public function getEmailGlobalInfo($email) { if (empty($email)) { return $this->handleError('Empty email'); } $requestResult = $this->sendRequest('emails/' . $email); return $this->handleResult($requestResult); }
[ "public", "function", "getEmailGlobalInfo", "(", "$", "email", ")", "{", "if", "(", "empty", "(", "$", "email", ")", ")", "{", "return", "$", "this", "->", "handleError", "(", "'Empty email'", ")", ";", "}", "$", "requestResult", "=", "$", "this", "->"...
Get global information about email @param $email @return stdClass
[ "Get", "global", "information", "about", "email" ]
train
https://github.com/sendpulse/sendpulse-rest-api-php/blob/01932257cb99f06cb05b5baaf13d2b5f7ec174cf/src/ApiClient.php#L711-L720
sendpulse/sendpulse-rest-api-php
src/ApiClient.php
ApiClient.getEmailsGlobalInfo
public function getEmailsGlobalInfo($emails) { if (empty($emails)) { return $this->handleError('Empty emails list'); } $requestResult = $this->sendRequest('emails', 'POST', $emails); return $this->handleResult($requestResult); }
php
public function getEmailsGlobalInfo($emails) { if (empty($emails)) { return $this->handleError('Empty emails list'); } $requestResult = $this->sendRequest('emails', 'POST', $emails); return $this->handleResult($requestResult); }
[ "public", "function", "getEmailsGlobalInfo", "(", "$", "emails", ")", "{", "if", "(", "empty", "(", "$", "emails", ")", ")", "{", "return", "$", "this", "->", "handleError", "(", "'Empty emails list'", ")", ";", "}", "$", "requestResult", "=", "$", "this...
Get global information about list of emails @param array $emails Emails list @return stdClass
[ "Get", "global", "information", "about", "list", "of", "emails" ]
train
https://github.com/sendpulse/sendpulse-rest-api-php/blob/01932257cb99f06cb05b5baaf13d2b5f7ec174cf/src/ApiClient.php#L728-L736
sendpulse/sendpulse-rest-api-php
src/ApiClient.php
ApiClient.removeEmailFromAllBooks
public function removeEmailFromAllBooks($email) { if (empty($email)) { return $this->handleError('Empty email'); } $requestResult = $this->sendRequest('emails/' . $email, 'DELETE'); return $this->handleResult($requestResult); }
php
public function removeEmailFromAllBooks($email) { if (empty($email)) { return $this->handleError('Empty email'); } $requestResult = $this->sendRequest('emails/' . $email, 'DELETE'); return $this->handleResult($requestResult); }
[ "public", "function", "removeEmailFromAllBooks", "(", "$", "email", ")", "{", "if", "(", "empty", "(", "$", "email", ")", ")", "{", "return", "$", "this", "->", "handleError", "(", "'Empty email'", ")", ";", "}", "$", "requestResult", "=", "$", "this", ...
Remove email from all books @param $email @return stdClass
[ "Remove", "email", "from", "all", "books" ]
train
https://github.com/sendpulse/sendpulse-rest-api-php/blob/01932257cb99f06cb05b5baaf13d2b5f7ec174cf/src/ApiClient.php#L745-L754
sendpulse/sendpulse-rest-api-php
src/ApiClient.php
ApiClient.emailStatByCampaigns
public function emailStatByCampaigns($email) { if (empty($email)) { return $this->handleError('Empty email'); } $requestResult = $this->sendRequest('emails/' . $email . '/campaigns'); return $this->handleResult($requestResult); }
php
public function emailStatByCampaigns($email) { if (empty($email)) { return $this->handleError('Empty email'); } $requestResult = $this->sendRequest('emails/' . $email . '/campaigns'); return $this->handleResult($requestResult); }
[ "public", "function", "emailStatByCampaigns", "(", "$", "email", ")", "{", "if", "(", "empty", "(", "$", "email", ")", ")", "{", "return", "$", "this", "->", "handleError", "(", "'Empty email'", ")", ";", "}", "$", "requestResult", "=", "$", "this", "-...
Get email statistic by all campaigns @param $email @return stdClass
[ "Get", "email", "statistic", "by", "all", "campaigns" ]
train
https://github.com/sendpulse/sendpulse-rest-api-php/blob/01932257cb99f06cb05b5baaf13d2b5f7ec174cf/src/ApiClient.php#L763-L772
sendpulse/sendpulse-rest-api-php
src/ApiClient.php
ApiClient.addToBlackList
public function addToBlackList($emails, $comment = '') { if (empty($emails)) { return $this->handleError('Empty email'); } $data = array( 'emails' => base64_encode($emails), 'comment' => $comment, ); $requestResult = $this->sendRequest('blacklist', 'POST', $data); return $this->handleResult($requestResult); }
php
public function addToBlackList($emails, $comment = '') { if (empty($emails)) { return $this->handleError('Empty email'); } $data = array( 'emails' => base64_encode($emails), 'comment' => $comment, ); $requestResult = $this->sendRequest('blacklist', 'POST', $data); return $this->handleResult($requestResult); }
[ "public", "function", "addToBlackList", "(", "$", "emails", ",", "$", "comment", "=", "''", ")", "{", "if", "(", "empty", "(", "$", "emails", ")", ")", "{", "return", "$", "this", "->", "handleError", "(", "'Empty email'", ")", ";", "}", "$", "data",...
Add email to blacklist @param $emails - string with emails, separator - , @param string $comment @return stdClass
[ "Add", "email", "to", "blacklist" ]
train
https://github.com/sendpulse/sendpulse-rest-api-php/blob/01932257cb99f06cb05b5baaf13d2b5f7ec174cf/src/ApiClient.php#L794-L808
sendpulse/sendpulse-rest-api-php
src/ApiClient.php
ApiClient.removeFromBlackList
public function removeFromBlackList($emails) { if (empty($emails)) { return $this->handleError('Empty email'); } $data = array( 'emails' => base64_encode($emails), ); $requestResult = $this->sendRequest('blacklist', 'DELETE', $data); return $this->handleResult($requestResult); }
php
public function removeFromBlackList($emails) { if (empty($emails)) { return $this->handleError('Empty email'); } $data = array( 'emails' => base64_encode($emails), ); $requestResult = $this->sendRequest('blacklist', 'DELETE', $data); return $this->handleResult($requestResult); }
[ "public", "function", "removeFromBlackList", "(", "$", "emails", ")", "{", "if", "(", "empty", "(", "$", "emails", ")", ")", "{", "return", "$", "this", "->", "handleError", "(", "'Empty email'", ")", ";", "}", "$", "data", "=", "array", "(", "'emails'...
Remove emails from blacklist @param $emails - string with emails, separator - , @return stdClass
[ "Remove", "emails", "from", "blacklist" ]
train
https://github.com/sendpulse/sendpulse-rest-api-php/blob/01932257cb99f06cb05b5baaf13d2b5f7ec174cf/src/ApiClient.php#L817-L830
sendpulse/sendpulse-rest-api-php
src/ApiClient.php
ApiClient.getBalance
public function getBalance($currency = '') { $currency = strtoupper($currency); $url = 'balance'; if (!empty($currency)) { $url .= '/' . strtoupper($currency); } $requestResult = $this->sendRequest($url); return $this->handleResult($requestResult); }
php
public function getBalance($currency = '') { $currency = strtoupper($currency); $url = 'balance'; if (!empty($currency)) { $url .= '/' . strtoupper($currency); } $requestResult = $this->sendRequest($url); return $this->handleResult($requestResult); }
[ "public", "function", "getBalance", "(", "$", "currency", "=", "''", ")", "{", "$", "currency", "=", "strtoupper", "(", "$", "currency", ")", ";", "$", "url", "=", "'balance'", ";", "if", "(", "!", "empty", "(", "$", "currency", ")", ")", "{", "$",...
Get balance @param string $currency @return mixed
[ "Get", "balance" ]
train
https://github.com/sendpulse/sendpulse-rest-api-php/blob/01932257cb99f06cb05b5baaf13d2b5f7ec174cf/src/ApiClient.php#L839-L850
sendpulse/sendpulse-rest-api-php
src/ApiClient.php
ApiClient.smtpGetEmailInfoById
public function smtpGetEmailInfoById($id) { if (empty($id)) { return $this->handleError('Empty id'); } $requestResult = $this->sendRequest('/smtp/emails/' . $id); return $this->handleResult($requestResult); }
php
public function smtpGetEmailInfoById($id) { if (empty($id)) { return $this->handleError('Empty id'); } $requestResult = $this->sendRequest('/smtp/emails/' . $id); return $this->handleResult($requestResult); }
[ "public", "function", "smtpGetEmailInfoById", "(", "$", "id", ")", "{", "if", "(", "empty", "(", "$", "id", ")", ")", "{", "return", "$", "this", "->", "handleError", "(", "'Empty id'", ")", ";", "}", "$", "requestResult", "=", "$", "this", "->", "se...
Get information about email by id @param $id @return stdClass
[ "Get", "information", "about", "email", "by", "id" ]
train
https://github.com/sendpulse/sendpulse-rest-api-php/blob/01932257cb99f06cb05b5baaf13d2b5f7ec174cf/src/ApiClient.php#L889-L898
sendpulse/sendpulse-rest-api-php
src/ApiClient.php
ApiClient.smtpUnsubscribeEmails
public function smtpUnsubscribeEmails($emails) { if (empty($emails)) { return $this->handleError('Empty emails'); } $data = array( 'emails' => serialize($emails), ); $requestResult = $this->sendRequest('/smtp/unsubscribe', 'POST', $data); return $this->handleResult($requestResult); }
php
public function smtpUnsubscribeEmails($emails) { if (empty($emails)) { return $this->handleError('Empty emails'); } $data = array( 'emails' => serialize($emails), ); $requestResult = $this->sendRequest('/smtp/unsubscribe', 'POST', $data); return $this->handleResult($requestResult); }
[ "public", "function", "smtpUnsubscribeEmails", "(", "$", "emails", ")", "{", "if", "(", "empty", "(", "$", "emails", ")", ")", "{", "return", "$", "this", "->", "handleError", "(", "'Empty emails'", ")", ";", "}", "$", "data", "=", "array", "(", "'emai...
SMTP: add emails to unsubscribe list @param $emails @return stdClass
[ "SMTP", ":", "add", "emails", "to", "unsubscribe", "list" ]
train
https://github.com/sendpulse/sendpulse-rest-api-php/blob/01932257cb99f06cb05b5baaf13d2b5f7ec174cf/src/ApiClient.php#L907-L920
sendpulse/sendpulse-rest-api-php
src/ApiClient.php
ApiClient.smtpVerifyDomain
public function smtpVerifyDomain($email) { if (empty($email)) { return $this->handleError('Empty email'); } $requestResult = $this->sendRequest('smtp/domains/' . $email); return $this->handleResult($requestResult); }
php
public function smtpVerifyDomain($email) { if (empty($email)) { return $this->handleError('Empty email'); } $requestResult = $this->sendRequest('smtp/domains/' . $email); return $this->handleResult($requestResult); }
[ "public", "function", "smtpVerifyDomain", "(", "$", "email", ")", "{", "if", "(", "empty", "(", "$", "email", ")", ")", "{", "return", "$", "this", "->", "handleError", "(", "'Empty email'", ")", ";", "}", "$", "requestResult", "=", "$", "this", "->", ...
SMTP: verify domain @param $email @return stdClass
[ "SMTP", ":", "verify", "domain" ]
train
https://github.com/sendpulse/sendpulse-rest-api-php/blob/01932257cb99f06cb05b5baaf13d2b5f7ec174cf/src/ApiClient.php#L997-L1006
sendpulse/sendpulse-rest-api-php
src/ApiClient.php
ApiClient.pushListWebsites
public function pushListWebsites($limit = null, $offset = null) { $data = array(); if (null !== $limit) { $data['limit'] = $limit; } if (null !== $offset) { $data['offset'] = $offset; } $requestResult = $this->sendRequest('push/websites', 'GET', $data); return $this->handleResult($requestResult); }
php
public function pushListWebsites($limit = null, $offset = null) { $data = array(); if (null !== $limit) { $data['limit'] = $limit; } if (null !== $offset) { $data['offset'] = $offset; } $requestResult = $this->sendRequest('push/websites', 'GET', $data); return $this->handleResult($requestResult); }
[ "public", "function", "pushListWebsites", "(", "$", "limit", "=", "null", ",", "$", "offset", "=", "null", ")", "{", "$", "data", "=", "array", "(", ")", ";", "if", "(", "null", "!==", "$", "limit", ")", "{", "$", "data", "[", "'limit'", "]", "="...
Get list of websites @param null $limit @param null $offset @return mixed
[ "Get", "list", "of", "websites" ]
train
https://github.com/sendpulse/sendpulse-rest-api-php/blob/01932257cb99f06cb05b5baaf13d2b5f7ec174cf/src/ApiClient.php#L1062-L1075
sendpulse/sendpulse-rest-api-php
src/ApiClient.php
ApiClient.pushListWebsiteSubscriptions
public function pushListWebsiteSubscriptions($websiteID, $limit = null, $offset = null) { $data = array(); if (null !== $limit) { $data['limit'] = $limit; } if (null !== $offset) { $data['offset'] = $offset; } $requestResult = $this->sendRequest('push/websites/' . $websiteID . '/subscriptions', 'GET', $data); return $this->handleResult($requestResult); }
php
public function pushListWebsiteSubscriptions($websiteID, $limit = null, $offset = null) { $data = array(); if (null !== $limit) { $data['limit'] = $limit; } if (null !== $offset) { $data['offset'] = $offset; } $requestResult = $this->sendRequest('push/websites/' . $websiteID . '/subscriptions', 'GET', $data); return $this->handleResult($requestResult); }
[ "public", "function", "pushListWebsiteSubscriptions", "(", "$", "websiteID", ",", "$", "limit", "=", "null", ",", "$", "offset", "=", "null", ")", "{", "$", "data", "=", "array", "(", ")", ";", "if", "(", "null", "!==", "$", "limit", ")", "{", "$", ...
Get list of subscriptions for the website @param $websiteID @param null $limit @param null $offset @return mixed
[ "Get", "list", "of", "subscriptions", "for", "the", "website" ]
train
https://github.com/sendpulse/sendpulse-rest-api-php/blob/01932257cb99f06cb05b5baaf13d2b5f7ec174cf/src/ApiClient.php#L1113-L1126
sendpulse/sendpulse-rest-api-php
src/ApiClient.php
ApiClient.pushSetSubscriptionState
public function pushSetSubscriptionState($subscriptionID, $stateValue) { $data = array( 'id' => $subscriptionID, 'state' => $stateValue, ); $requestResult = $this->sendRequest('push/subscriptions/state', 'POST', $data); return $this->handleResult($requestResult); }
php
public function pushSetSubscriptionState($subscriptionID, $stateValue) { $data = array( 'id' => $subscriptionID, 'state' => $stateValue, ); $requestResult = $this->sendRequest('push/subscriptions/state', 'POST', $data); return $this->handleResult($requestResult); }
[ "public", "function", "pushSetSubscriptionState", "(", "$", "subscriptionID", ",", "$", "stateValue", ")", "{", "$", "data", "=", "array", "(", "'id'", "=>", "$", "subscriptionID", ",", "'state'", "=>", "$", "stateValue", ",", ")", ";", "$", "requestResult",...
Set state for subscription @param $subscriptionID @param $stateValue @return mixed
[ "Set", "state", "for", "subscription" ]
train
https://github.com/sendpulse/sendpulse-rest-api-php/blob/01932257cb99f06cb05b5baaf13d2b5f7ec174cf/src/ApiClient.php#L1150-L1160
sendpulse/sendpulse-rest-api-php
src/ApiClient.php
ApiClient.getPushIntegrationCode
public function getPushIntegrationCode($websiteID) { if (empty($websiteID)) { return $this->handleError('Empty website id'); } $requestResult = $this->sendRequest('/push/websites/' . $websiteID . '/code'); return $this->handleResult($requestResult); }
php
public function getPushIntegrationCode($websiteID) { if (empty($websiteID)) { return $this->handleError('Empty website id'); } $requestResult = $this->sendRequest('/push/websites/' . $websiteID . '/code'); return $this->handleResult($requestResult); }
[ "public", "function", "getPushIntegrationCode", "(", "$", "websiteID", ")", "{", "if", "(", "empty", "(", "$", "websiteID", ")", ")", "{", "return", "$", "this", "->", "handleError", "(", "'Empty website id'", ")", ";", "}", "$", "requestResult", "=", "$",...
Get integration code for Push Notifications. @param $websiteID @return stdClass
[ "Get", "integration", "code", "for", "Push", "Notifications", "." ]
train
https://github.com/sendpulse/sendpulse-rest-api-php/blob/01932257cb99f06cb05b5baaf13d2b5f7ec174cf/src/ApiClient.php#L1212-L1221
sendpulse/sendpulse-rest-api-php
src/ApiClient.php
ApiClient.addPhones
public function addPhones($bookID, array $phones) { if (empty($bookID)) { return $this->handleError('Empty book id'); } $data = [ 'addressBookId' => $bookID, 'phones' => json_encode($phones) ]; $requestResult = $this->sendRequest('/sms/numbers', 'POST', $data); return $this->handleResult($requestResult); }
php
public function addPhones($bookID, array $phones) { if (empty($bookID)) { return $this->handleError('Empty book id'); } $data = [ 'addressBookId' => $bookID, 'phones' => json_encode($phones) ]; $requestResult = $this->sendRequest('/sms/numbers', 'POST', $data); return $this->handleResult($requestResult); }
[ "public", "function", "addPhones", "(", "$", "bookID", ",", "array", "$", "phones", ")", "{", "if", "(", "empty", "(", "$", "bookID", ")", ")", "{", "return", "$", "this", "->", "handleError", "(", "'Empty book id'", ")", ";", "}", "$", "data", "=", ...
Add phones to addressbook @param $bookID @param array $phones @return stdClass
[ "Add", "phones", "to", "addressbook" ]
train
https://github.com/sendpulse/sendpulse-rest-api-php/blob/01932257cb99f06cb05b5baaf13d2b5f7ec174cf/src/ApiClient.php#L1264-L1278
sendpulse/sendpulse-rest-api-php
src/ApiClient.php
ApiClient.addPhonesWithVariables
public function addPhonesWithVariables($bookID, array $phonesWithVariables) { if (empty($bookID)) { return $this->handleError('Empty book id'); } $data = [ 'addressBookId' => $bookID, 'phones' => json_encode($phonesWithVariables) ]; $requestResult = $this->sendRequest('/sms/numbers/variables', 'POST', $data); return $this->handleResult($requestResult); }
php
public function addPhonesWithVariables($bookID, array $phonesWithVariables) { if (empty($bookID)) { return $this->handleError('Empty book id'); } $data = [ 'addressBookId' => $bookID, 'phones' => json_encode($phonesWithVariables) ]; $requestResult = $this->sendRequest('/sms/numbers/variables', 'POST', $data); return $this->handleResult($requestResult); }
[ "public", "function", "addPhonesWithVariables", "(", "$", "bookID", ",", "array", "$", "phonesWithVariables", ")", "{", "if", "(", "empty", "(", "$", "bookID", ")", ")", "{", "return", "$", "this", "->", "handleError", "(", "'Empty book id'", ")", ";", "}"...
Add phones with variables to addressbook @param $bookID @param array $phones @return stdClass
[ "Add", "phones", "with", "variables", "to", "addressbook" ]
train
https://github.com/sendpulse/sendpulse-rest-api-php/blob/01932257cb99f06cb05b5baaf13d2b5f7ec174cf/src/ApiClient.php#L1287-L1301
sendpulse/sendpulse-rest-api-php
src/ApiClient.php
ApiClient.updatePhoneVaribales
public function updatePhoneVaribales($bookID, array $phones, array $variables) { if (empty($bookID)) { return $this->handleError('Empty book id'); } $data = [ 'addressBookId' => $bookID, 'phones' => json_encode($phones), 'variables' => json_encode($variables) ]; $requestResult = $this->sendRequest('/sms/numbers', 'PUT', $data); return $this->handleResult($requestResult); }
php
public function updatePhoneVaribales($bookID, array $phones, array $variables) { if (empty($bookID)) { return $this->handleError('Empty book id'); } $data = [ 'addressBookId' => $bookID, 'phones' => json_encode($phones), 'variables' => json_encode($variables) ]; $requestResult = $this->sendRequest('/sms/numbers', 'PUT', $data); return $this->handleResult($requestResult); }
[ "public", "function", "updatePhoneVaribales", "(", "$", "bookID", ",", "array", "$", "phones", ",", "array", "$", "variables", ")", "{", "if", "(", "empty", "(", "$", "bookID", ")", ")", "{", "return", "$", "this", "->", "handleError", "(", "'Empty book ...
Update variables for phones @param $bookID @param array $phones @param array $variables @return stdClass
[ "Update", "variables", "for", "phones" ]
train
https://github.com/sendpulse/sendpulse-rest-api-php/blob/01932257cb99f06cb05b5baaf13d2b5f7ec174cf/src/ApiClient.php#L1311-L1326
sendpulse/sendpulse-rest-api-php
src/ApiClient.php
ApiClient.getPhoneInfo
public function getPhoneInfo($bookID, $phoneNumber) { if (empty($bookID)) { return $this->handleError('Empty book id'); } $requestResult = $this->sendRequest('/sms/numbers/info/'.$bookID.'/'.$phoneNumber); return $this->handleResult($requestResult); }
php
public function getPhoneInfo($bookID, $phoneNumber) { if (empty($bookID)) { return $this->handleError('Empty book id'); } $requestResult = $this->sendRequest('/sms/numbers/info/'.$bookID.'/'.$phoneNumber); return $this->handleResult($requestResult); }
[ "public", "function", "getPhoneInfo", "(", "$", "bookID", ",", "$", "phoneNumber", ")", "{", "if", "(", "empty", "(", "$", "bookID", ")", ")", "{", "return", "$", "this", "->", "handleError", "(", "'Empty book id'", ")", ";", "}", "$", "requestResult", ...
get information about phone number @param $bookID @param $phoneNumber @return stdClass
[ "get", "information", "about", "phone", "number" ]
train
https://github.com/sendpulse/sendpulse-rest-api-php/blob/01932257cb99f06cb05b5baaf13d2b5f7ec174cf/src/ApiClient.php#L1358-L1367
sendpulse/sendpulse-rest-api-php
src/ApiClient.php
ApiClient.addPhonesToBlacklist
public function addPhonesToBlacklist(array $phones) { $data = [ 'phones' => json_encode($phones) ]; $requestResult = $this->sendRequest('/sms/black_list', 'POST', $data); return $this->handleResult($requestResult); }
php
public function addPhonesToBlacklist(array $phones) { $data = [ 'phones' => json_encode($phones) ]; $requestResult = $this->sendRequest('/sms/black_list', 'POST', $data); return $this->handleResult($requestResult); }
[ "public", "function", "addPhonesToBlacklist", "(", "array", "$", "phones", ")", "{", "$", "data", "=", "[", "'phones'", "=>", "json_encode", "(", "$", "phones", ")", "]", ";", "$", "requestResult", "=", "$", "this", "->", "sendRequest", "(", "'/sms/black_l...
Add phones to blacklist @param $bookID @param array $phones @return stdClass
[ "Add", "phones", "to", "blacklist" ]
train
https://github.com/sendpulse/sendpulse-rest-api-php/blob/01932257cb99f06cb05b5baaf13d2b5f7ec174cf/src/ApiClient.php#L1376-L1385
sendpulse/sendpulse-rest-api-php
src/ApiClient.php
ApiClient.removePhonesFromBlacklist
public function removePhonesFromBlacklist(array $phones) { $data = [ 'phones' => json_encode($phones) ]; $requestResult = $this->sendRequest('/sms/black_list', 'DELETE', $data); return $this->handleResult($requestResult); }
php
public function removePhonesFromBlacklist(array $phones) { $data = [ 'phones' => json_encode($phones) ]; $requestResult = $this->sendRequest('/sms/black_list', 'DELETE', $data); return $this->handleResult($requestResult); }
[ "public", "function", "removePhonesFromBlacklist", "(", "array", "$", "phones", ")", "{", "$", "data", "=", "[", "'phones'", "=>", "json_encode", "(", "$", "phones", ")", "]", ";", "$", "requestResult", "=", "$", "this", "->", "sendRequest", "(", "'/sms/bl...
Delete phones from blacklist @param array $phones @return stdClass
[ "Delete", "phones", "from", "blacklist" ]
train
https://github.com/sendpulse/sendpulse-rest-api-php/blob/01932257cb99f06cb05b5baaf13d2b5f7ec174cf/src/ApiClient.php#L1393-L1402
sendpulse/sendpulse-rest-api-php
src/ApiClient.php
ApiClient.sendSmsByBook
public function sendSmsByBook($bookID, array $params, array $additionalParams = []) { if (empty($bookID)) { return $this->handleError('Empty book id'); } $data = [ 'addressBookId' => $bookID ]; $data = array_merge($data, $params); if ($additionalParams) { $data = array_merge($data, $additionalParams); } $requestResult = $this->sendRequest('/sms/campaigns', 'POST', $data); return $this->handleResult($requestResult); }
php
public function sendSmsByBook($bookID, array $params, array $additionalParams = []) { if (empty($bookID)) { return $this->handleError('Empty book id'); } $data = [ 'addressBookId' => $bookID ]; $data = array_merge($data, $params); if ($additionalParams) { $data = array_merge($data, $additionalParams); } $requestResult = $this->sendRequest('/sms/campaigns', 'POST', $data); return $this->handleResult($requestResult); }
[ "public", "function", "sendSmsByBook", "(", "$", "bookID", ",", "array", "$", "params", ",", "array", "$", "additionalParams", "=", "[", "]", ")", "{", "if", "(", "empty", "(", "$", "bookID", ")", ")", "{", "return", "$", "this", "->", "handleError", ...
Create sms campaign based on phones in book @param $bookID @param array $params @param array $additionalParams @return stdClass
[ "Create", "sms", "campaign", "based", "on", "phones", "in", "book" ]
train
https://github.com/sendpulse/sendpulse-rest-api-php/blob/01932257cb99f06cb05b5baaf13d2b5f7ec174cf/src/ApiClient.php#L1424-L1443
sendpulse/sendpulse-rest-api-php
src/ApiClient.php
ApiClient.sendSmsByList
public function sendSmsByList(array $phones, array $params, array $additionalParams) { $data = [ 'phones' => json_encode($phones) ]; $data = array_merge($data, $params); if ($additionalParams) { $data = array_merge($data, $additionalParams); } $requestResult = $this->sendRequest('/sms/send', 'POST', $data); return $this->handleResult($requestResult); }
php
public function sendSmsByList(array $phones, array $params, array $additionalParams) { $data = [ 'phones' => json_encode($phones) ]; $data = array_merge($data, $params); if ($additionalParams) { $data = array_merge($data, $additionalParams); } $requestResult = $this->sendRequest('/sms/send', 'POST', $data); return $this->handleResult($requestResult); }
[ "public", "function", "sendSmsByList", "(", "array", "$", "phones", ",", "array", "$", "params", ",", "array", "$", "additionalParams", ")", "{", "$", "data", "=", "[", "'phones'", "=>", "json_encode", "(", "$", "phones", ")", "]", ";", "$", "data", "=...
Create sms campaign based on list @param $phones @param array $params @param array $additionalParams @return stdClass
[ "Create", "sms", "campaign", "based", "on", "list" ]
train
https://github.com/sendpulse/sendpulse-rest-api-php/blob/01932257cb99f06cb05b5baaf13d2b5f7ec174cf/src/ApiClient.php#L1453-L1468
sendpulse/sendpulse-rest-api-php
src/ApiClient.php
ApiClient.listSmsCampaigns
public function listSmsCampaigns(array $params = null) { $requestResult = $this->sendRequest('/sms/campaigns/list', 'GET', $params); return $this->handleResult($requestResult); }
php
public function listSmsCampaigns(array $params = null) { $requestResult = $this->sendRequest('/sms/campaigns/list', 'GET', $params); return $this->handleResult($requestResult); }
[ "public", "function", "listSmsCampaigns", "(", "array", "$", "params", "=", "null", ")", "{", "$", "requestResult", "=", "$", "this", "->", "sendRequest", "(", "'/sms/campaigns/list'", ",", "'GET'", ",", "$", "params", ")", ";", "return", "$", "this", "->"...
List sms campaigns @param $params @return stdClass
[ "List", "sms", "campaigns" ]
train
https://github.com/sendpulse/sendpulse-rest-api-php/blob/01932257cb99f06cb05b5baaf13d2b5f7ec174cf/src/ApiClient.php#L1476-L1481
sendpulse/sendpulse-rest-api-php
src/ApiClient.php
ApiClient.getSmsCampaignCost
public function getSmsCampaignCost(array $params, array $additionalParams = null) { if (!isset($params['addressBookId']) && !isset($params['phones'])) { return $this->handleError('You mast pass phones list or addressbook ID'); } if ($additionalParams) { $params = array_merge($params, $additionalParams); } $requestResult = $this->sendRequest('/sms/campaigns/cost', 'GET', $params); return $this->handleResult($requestResult); }
php
public function getSmsCampaignCost(array $params, array $additionalParams = null) { if (!isset($params['addressBookId']) && !isset($params['phones'])) { return $this->handleError('You mast pass phones list or addressbook ID'); } if ($additionalParams) { $params = array_merge($params, $additionalParams); } $requestResult = $this->sendRequest('/sms/campaigns/cost', 'GET', $params); return $this->handleResult($requestResult); }
[ "public", "function", "getSmsCampaignCost", "(", "array", "$", "params", ",", "array", "$", "additionalParams", "=", "null", ")", "{", "if", "(", "!", "isset", "(", "$", "params", "[", "'addressBookId'", "]", ")", "&&", "!", "isset", "(", "$", "params", ...
Get SMS campaign cost based on book or simple list @param array $params @param array|null $additionalParams @return stdClass
[ "Get", "SMS", "campaign", "cost", "based", "on", "book", "or", "simple", "list" ]
train
https://github.com/sendpulse/sendpulse-rest-api-php/blob/01932257cb99f06cb05b5baaf13d2b5f7ec174cf/src/ApiClient.php#L1516-L1529
sendpulse/sendpulse-rest-api-php
src/Storage/FileStorage.php
FileStorage.set
public function set($key, $token) { $tokenFile = fopen($this->storageFolder . $key, 'wb'); fwrite($tokenFile, $token); fclose($tokenFile); }
php
public function set($key, $token) { $tokenFile = fopen($this->storageFolder . $key, 'wb'); fwrite($tokenFile, $token); fclose($tokenFile); }
[ "public", "function", "set", "(", "$", "key", ",", "$", "token", ")", "{", "$", "tokenFile", "=", "fopen", "(", "$", "this", "->", "storageFolder", ".", "$", "key", ",", "'wb'", ")", ";", "fwrite", "(", "$", "tokenFile", ",", "$", "token", ")", "...
@param $key string @param $token @return void
[ "@param", "$key", "string", "@param", "$token" ]
train
https://github.com/sendpulse/sendpulse-rest-api-php/blob/01932257cb99f06cb05b5baaf13d2b5f7ec174cf/src/Storage/FileStorage.php#L34-L39
sendpulse/sendpulse-rest-api-php
src/Storage/FileStorage.php
FileStorage.get
public function get($key) { $filePath = $this->storageFolder . $key; if (file_exists($filePath)) { return file_get_contents($filePath); } return null; }
php
public function get($key) { $filePath = $this->storageFolder . $key; if (file_exists($filePath)) { return file_get_contents($filePath); } return null; }
[ "public", "function", "get", "(", "$", "key", ")", "{", "$", "filePath", "=", "$", "this", "->", "storageFolder", ".", "$", "key", ";", "if", "(", "file_exists", "(", "$", "filePath", ")", ")", "{", "return", "file_get_contents", "(", "$", "filePath", ...
@param $key string @return mixed
[ "@param", "$key", "string" ]
train
https://github.com/sendpulse/sendpulse-rest-api-php/blob/01932257cb99f06cb05b5baaf13d2b5f7ec174cf/src/Storage/FileStorage.php#L46-L54
thephpleague/tactician
src/CommandBus.php
CommandBus.handle
public function handle($command) { if (!is_object($command)) { throw InvalidCommandException::forUnknownValue($command); } $middlewareChain = $this->middlewareChain; return $middlewareChain($command); }
php
public function handle($command) { if (!is_object($command)) { throw InvalidCommandException::forUnknownValue($command); } $middlewareChain = $this->middlewareChain; return $middlewareChain($command); }
[ "public", "function", "handle", "(", "$", "command", ")", "{", "if", "(", "!", "is_object", "(", "$", "command", ")", ")", "{", "throw", "InvalidCommandException", "::", "forUnknownValue", "(", "$", "command", ")", ";", "}", "$", "middlewareChain", "=", ...
Executes the given command and optionally returns a value @param object $command @return mixed
[ "Executes", "the", "given", "command", "and", "optionally", "returns", "a", "value" ]
train
https://github.com/thephpleague/tactician/blob/d41462893c6a9aa6754cc8c398329fea30c547a6/src/CommandBus.php#L35-L43
thephpleague/tactician
src/CommandBus.php
CommandBus.createExecutionChain
private function createExecutionChain($middlewareList) { $lastCallable = function () { // the final callable is a no-op }; while ($middleware = array_pop($middlewareList)) { if (! $middleware instanceof Middleware) { throw InvalidMiddlewareException::forMiddleware($middleware); } $lastCallable = function ($command) use ($middleware, $lastCallable) { return $middleware->execute($command, $lastCallable); }; } return $lastCallable; }
php
private function createExecutionChain($middlewareList) { $lastCallable = function () { // the final callable is a no-op }; while ($middleware = array_pop($middlewareList)) { if (! $middleware instanceof Middleware) { throw InvalidMiddlewareException::forMiddleware($middleware); } $lastCallable = function ($command) use ($middleware, $lastCallable) { return $middleware->execute($command, $lastCallable); }; } return $lastCallable; }
[ "private", "function", "createExecutionChain", "(", "$", "middlewareList", ")", "{", "$", "lastCallable", "=", "function", "(", ")", "{", "// the final callable is a no-op", "}", ";", "while", "(", "$", "middleware", "=", "array_pop", "(", "$", "middlewareList", ...
@param Middleware[] $middlewareList @return callable
[ "@param", "Middleware", "[]", "$middlewareList" ]
train
https://github.com/thephpleague/tactician/blob/d41462893c6a9aa6754cc8c398329fea30c547a6/src/CommandBus.php#L50-L67
thephpleague/tactician
src/Setup/QuickStart.php
QuickStart.create
public static function create($commandToHandlerMap) { $handlerMiddleware = new CommandHandlerMiddleware( new ClassNameExtractor(), new InMemoryLocator($commandToHandlerMap), new HandleInflector() ); $lockingMiddleware = new LockingMiddleware(); return new CommandBus([$lockingMiddleware, $handlerMiddleware]); }
php
public static function create($commandToHandlerMap) { $handlerMiddleware = new CommandHandlerMiddleware( new ClassNameExtractor(), new InMemoryLocator($commandToHandlerMap), new HandleInflector() ); $lockingMiddleware = new LockingMiddleware(); return new CommandBus([$lockingMiddleware, $handlerMiddleware]); }
[ "public", "static", "function", "create", "(", "$", "commandToHandlerMap", ")", "{", "$", "handlerMiddleware", "=", "new", "CommandHandlerMiddleware", "(", "new", "ClassNameExtractor", "(", ")", ",", "new", "InMemoryLocator", "(", "$", "commandToHandlerMap", ")", ...
Creates a default CommandBus that you can get started with. @param array $commandToHandlerMap @return CommandBus
[ "Creates", "a", "default", "CommandBus", "that", "you", "can", "get", "started", "with", "." ]
train
https://github.com/thephpleague/tactician/blob/d41462893c6a9aa6754cc8c398329fea30c547a6/src/Setup/QuickStart.php#L33-L44
thephpleague/tactician
src/Handler/MethodNameInflector/ClassNameInflector.php
ClassNameInflector.inflect
public function inflect($command, $commandHandler) { $commandName = get_class($command); // If class name has a namespace separator, only take last portion if (strpos($commandName, '\\') !== false) { $commandName = substr($commandName, strrpos($commandName, '\\') + 1); } return strtolower($commandName[0]) . substr($commandName, 1); }
php
public function inflect($command, $commandHandler) { $commandName = get_class($command); // If class name has a namespace separator, only take last portion if (strpos($commandName, '\\') !== false) { $commandName = substr($commandName, strrpos($commandName, '\\') + 1); } return strtolower($commandName[0]) . substr($commandName, 1); }
[ "public", "function", "inflect", "(", "$", "command", ",", "$", "commandHandler", ")", "{", "$", "commandName", "=", "get_class", "(", "$", "command", ")", ";", "// If class name has a namespace separator, only take last portion", "if", "(", "strpos", "(", "$", "c...
{@inheritdoc}
[ "{" ]
train
https://github.com/thephpleague/tactician/blob/d41462893c6a9aa6754cc8c398329fea30c547a6/src/Handler/MethodNameInflector/ClassNameInflector.php#L17-L27
thephpleague/tactician
src/Plugins/LockingMiddleware.php
LockingMiddleware.execute
public function execute($command, callable $next) { $this->queue[] = function () use ($command, $next) { return $next($command); }; if ($this->isExecuting) { return; } $this->isExecuting = true; try { $returnValue = $this->executeQueuedJobs(); } catch (\Exception $e) { $this->isExecuting = false; $this->queue = []; throw $e; } $this->isExecuting = false; return $returnValue; }
php
public function execute($command, callable $next) { $this->queue[] = function () use ($command, $next) { return $next($command); }; if ($this->isExecuting) { return; } $this->isExecuting = true; try { $returnValue = $this->executeQueuedJobs(); } catch (\Exception $e) { $this->isExecuting = false; $this->queue = []; throw $e; } $this->isExecuting = false; return $returnValue; }
[ "public", "function", "execute", "(", "$", "command", ",", "callable", "$", "next", ")", "{", "$", "this", "->", "queue", "[", "]", "=", "function", "(", ")", "use", "(", "$", "command", ",", "$", "next", ")", "{", "return", "$", "next", "(", "$"...
Execute the given command... after other running commands are complete. @param object $command @param callable $next @throws \Exception @return mixed|void
[ "Execute", "the", "given", "command", "...", "after", "other", "running", "commands", "are", "complete", "." ]
train
https://github.com/thephpleague/tactician/blob/d41462893c6a9aa6754cc8c398329fea30c547a6/src/Plugins/LockingMiddleware.php#L33-L54
thephpleague/tactician
src/Plugins/LockingMiddleware.php
LockingMiddleware.executeQueuedJobs
protected function executeQueuedJobs() { $returnValues = []; while ($resumeCommand = array_shift($this->queue)) { $returnValues[] = $resumeCommand(); } return array_shift($returnValues); }
php
protected function executeQueuedJobs() { $returnValues = []; while ($resumeCommand = array_shift($this->queue)) { $returnValues[] = $resumeCommand(); } return array_shift($returnValues); }
[ "protected", "function", "executeQueuedJobs", "(", ")", "{", "$", "returnValues", "=", "[", "]", ";", "while", "(", "$", "resumeCommand", "=", "array_shift", "(", "$", "this", "->", "queue", ")", ")", "{", "$", "returnValues", "[", "]", "=", "$", "resu...
Process any pending commands in the queue. If multiple, jobs are in the queue, only the first return value is given back. @return mixed
[ "Process", "any", "pending", "commands", "in", "the", "queue", ".", "If", "multiple", "jobs", "are", "in", "the", "queue", "only", "the", "first", "return", "value", "is", "given", "back", "." ]
train
https://github.com/thephpleague/tactician/blob/d41462893c6a9aa6754cc8c398329fea30c547a6/src/Plugins/LockingMiddleware.php#L62-L70
thephpleague/tactician
src/Handler/CommandHandlerMiddleware.php
CommandHandlerMiddleware.execute
public function execute($command, callable $next) { $commandName = $this->commandNameExtractor->extract($command); $handler = $this->handlerLocator->getHandlerForCommand($commandName); $methodName = $this->methodNameInflector->inflect($command, $handler); // is_callable is used here instead of method_exists, as method_exists // will fail when given a handler that relies on __call. if (!is_callable([$handler, $methodName])) { throw CanNotInvokeHandlerException::forCommand( $command, "Method '{$methodName}' does not exist on handler" ); } return $handler->{$methodName}($command); }
php
public function execute($command, callable $next) { $commandName = $this->commandNameExtractor->extract($command); $handler = $this->handlerLocator->getHandlerForCommand($commandName); $methodName = $this->methodNameInflector->inflect($command, $handler); // is_callable is used here instead of method_exists, as method_exists // will fail when given a handler that relies on __call. if (!is_callable([$handler, $methodName])) { throw CanNotInvokeHandlerException::forCommand( $command, "Method '{$methodName}' does not exist on handler" ); } return $handler->{$methodName}($command); }
[ "public", "function", "execute", "(", "$", "command", ",", "callable", "$", "next", ")", "{", "$", "commandName", "=", "$", "this", "->", "commandNameExtractor", "->", "extract", "(", "$", "command", ")", ";", "$", "handler", "=", "$", "this", "->", "h...
Executes a command and optionally returns a value @param object $command @param callable $next @return mixed @throws CanNotInvokeHandlerException
[ "Executes", "a", "command", "and", "optionally", "returns", "a", "value" ]
train
https://github.com/thephpleague/tactician/blob/d41462893c6a9aa6754cc8c398329fea30c547a6/src/Handler/CommandHandlerMiddleware.php#L56-L72
thephpleague/tactician
src/Handler/Locator/InMemoryLocator.php
InMemoryLocator.getHandlerForCommand
public function getHandlerForCommand($commandName) { if (!isset($this->handlers[$commandName])) { throw MissingHandlerException::forCommand($commandName); } return $this->handlers[$commandName]; }
php
public function getHandlerForCommand($commandName) { if (!isset($this->handlers[$commandName])) { throw MissingHandlerException::forCommand($commandName); } return $this->handlers[$commandName]; }
[ "public", "function", "getHandlerForCommand", "(", "$", "commandName", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "handlers", "[", "$", "commandName", "]", ")", ")", "{", "throw", "MissingHandlerException", "::", "forCommand", "(", "$", "co...
Returns the handler bound to the command's class name. @param string $commandName @return object
[ "Returns", "the", "handler", "bound", "to", "the", "command", "s", "class", "name", "." ]
train
https://github.com/thephpleague/tactician/blob/d41462893c6a9aa6754cc8c398329fea30c547a6/src/Handler/Locator/InMemoryLocator.php#L71-L78
thephpleague/tactician
src/Handler/Locator/CallableLocator.php
CallableLocator.getHandlerForCommand
public function getHandlerForCommand($commandName) { $callable = $this->callable; $handler = $callable($commandName); // Odds are the callable threw an exception but it always pays to check if ($handler === null) { throw MissingHandlerException::forCommand($commandName); } return $handler; }
php
public function getHandlerForCommand($commandName) { $callable = $this->callable; $handler = $callable($commandName); // Odds are the callable threw an exception but it always pays to check if ($handler === null) { throw MissingHandlerException::forCommand($commandName); } return $handler; }
[ "public", "function", "getHandlerForCommand", "(", "$", "commandName", ")", "{", "$", "callable", "=", "$", "this", "->", "callable", ";", "$", "handler", "=", "$", "callable", "(", "$", "commandName", ")", ";", "// Odds are the callable threw an exception but it ...
{@inheritdoc}
[ "{" ]
train
https://github.com/thephpleague/tactician/blob/d41462893c6a9aa6754cc8c398329fea30c547a6/src/Handler/Locator/CallableLocator.php#L42-L53
thephpleague/tactician
src/Exception/CanNotDetermineCommandNameException.php
CanNotDetermineCommandNameException.forCommand
public static function forCommand($command) { $type = is_object($command) ? get_class($command) : gettype($command); $exception = new static('Could not determine command name of ' . $type); $exception->command = $command; return $exception; }
php
public static function forCommand($command) { $type = is_object($command) ? get_class($command) : gettype($command); $exception = new static('Could not determine command name of ' . $type); $exception->command = $command; return $exception; }
[ "public", "static", "function", "forCommand", "(", "$", "command", ")", "{", "$", "type", "=", "is_object", "(", "$", "command", ")", "?", "get_class", "(", "$", "command", ")", ":", "gettype", "(", "$", "command", ")", ";", "$", "exception", "=", "n...
@param mixed $command @return static
[ "@param", "mixed", "$command" ]
train
https://github.com/thephpleague/tactician/blob/d41462893c6a9aa6754cc8c398329fea30c547a6/src/Exception/CanNotDetermineCommandNameException.php#L20-L28
thephpleague/tactician
src/Handler/MethodNameInflector/HandleClassNameInflector.php
HandleClassNameInflector.inflect
public function inflect($command, $commandHandler) { $commandName = parent::inflect($command, $commandHandler); return 'handle' . ucfirst($commandName); }
php
public function inflect($command, $commandHandler) { $commandName = parent::inflect($command, $commandHandler); return 'handle' . ucfirst($commandName); }
[ "public", "function", "inflect", "(", "$", "command", ",", "$", "commandHandler", ")", "{", "$", "commandName", "=", "parent", "::", "inflect", "(", "$", "command", ",", "$", "commandHandler", ")", ";", "return", "'handle'", ".", "ucfirst", "(", "$", "co...
{@inheritdoc}
[ "{" ]
train
https://github.com/thephpleague/tactician/blob/d41462893c6a9aa6754cc8c398329fea30c547a6/src/Handler/MethodNameInflector/HandleClassNameInflector.php#L17-L22
shadowhand/latitude
src/QueryFactory.php
QueryFactory.select
public function select(...$columns): Query\SelectQuery { $query = $this->engine->makeSelect(); if (empty($columns) === false) { $query = $query->columns(...$columns); } return $query; }
php
public function select(...$columns): Query\SelectQuery { $query = $this->engine->makeSelect(); if (empty($columns) === false) { $query = $query->columns(...$columns); } return $query; }
[ "public", "function", "select", "(", "...", "$", "columns", ")", ":", "Query", "\\", "SelectQuery", "{", "$", "query", "=", "$", "this", "->", "engine", "->", "makeSelect", "(", ")", ";", "if", "(", "empty", "(", "$", "columns", ")", "===", "false", ...
Create a new SELECT query @param string|StatementInterface ...$columns
[ "Create", "a", "new", "SELECT", "query" ]
train
https://github.com/shadowhand/latitude/blob/1fd72cccffb35df16c683bde4cd635c3f69b5de2/src/QueryFactory.php#L28-L35
shadowhand/latitude
src/QueryFactory.php
QueryFactory.insert
public function insert($table, array $map = []): Query\InsertQuery { $query = $this->engine->makeInsert()->into($table); if (empty($map) === false) { $query = $query->map($map); } return $query; }
php
public function insert($table, array $map = []): Query\InsertQuery { $query = $this->engine->makeInsert()->into($table); if (empty($map) === false) { $query = $query->map($map); } return $query; }
[ "public", "function", "insert", "(", "$", "table", ",", "array", "$", "map", "=", "[", "]", ")", ":", "Query", "\\", "InsertQuery", "{", "$", "query", "=", "$", "this", "->", "engine", "->", "makeInsert", "(", ")", "->", "into", "(", "$", "table", ...
Create a new INSERT query @param string|StatementInterface $table
[ "Create", "a", "new", "INSERT", "query" ]
train
https://github.com/shadowhand/latitude/blob/1fd72cccffb35df16c683bde4cd635c3f69b5de2/src/QueryFactory.php#L52-L59
shadowhand/latitude
src/QueryFactory.php
QueryFactory.update
public function update($table, array $map = []): Query\UpdateQuery { $query = $this->engine->makeUpdate()->table($table); if (empty($map) === false) { $query = $query->set($map); } return $query; }
php
public function update($table, array $map = []): Query\UpdateQuery { $query = $this->engine->makeUpdate()->table($table); if (empty($map) === false) { $query = $query->set($map); } return $query; }
[ "public", "function", "update", "(", "$", "table", ",", "array", "$", "map", "=", "[", "]", ")", ":", "Query", "\\", "UpdateQuery", "{", "$", "query", "=", "$", "this", "->", "engine", "->", "makeUpdate", "(", ")", "->", "table", "(", "$", "table",...
Create a new UPDATE query @param string|StatementInterface $table
[ "Create", "a", "new", "UPDATE", "query" ]
train
https://github.com/shadowhand/latitude/blob/1fd72cccffb35df16c683bde4cd635c3f69b5de2/src/QueryFactory.php#L77-L84
shadowhand/latitude
src/QueryFactory.php
QueryFactory.criteria
public function criteria(string $expression): CriteriaInterface { return $this->visitor()->visit(\Hoa\Ruler\Ruler::interpret($expression)); }
php
public function criteria(string $expression): CriteriaInterface { return $this->visitor()->visit(\Hoa\Ruler\Ruler::interpret($expression)); }
[ "public", "function", "criteria", "(", "string", "$", "expression", ")", ":", "CriteriaInterface", "{", "return", "$", "this", "->", "visitor", "(", ")", "->", "visit", "(", "\\", "Hoa", "\\", "Ruler", "\\", "Ruler", "::", "interpret", "(", "$", "express...
Create a new criteria from an expression @link https://hoa-project.net/En/Literature/Hack/Ruler.html
[ "Create", "a", "new", "criteria", "from", "an", "expression" ]
train
https://github.com/shadowhand/latitude/blob/1fd72cccffb35df16c683bde4cd635c3f69b5de2/src/QueryFactory.php#L91-L94
EasyPost/easypost-php
lib/EasyPost/Tracker.php
Tracker.all
public static function all($params = null, $apiKey = null) { return self::_all(get_class(), $params, $apiKey); }
php
public static function all($params = null, $apiKey = null) { return self::_all(get_class(), $params, $apiKey); }
[ "public", "static", "function", "all", "(", "$", "params", "=", "null", ",", "$", "apiKey", "=", "null", ")", "{", "return", "self", "::", "_all", "(", "get_class", "(", ")", ",", "$", "params", ",", "$", "apiKey", ")", ";", "}" ]
retrieve all trackers @param mixed $params @param string $apiKey @return mixed
[ "retrieve", "all", "trackers" ]
train
https://github.com/EasyPost/easypost-php/blob/517b6205c9316d67da2241345fa9d52b87ddedf4/lib/EasyPost/Tracker.php#L26-L29
EasyPost/easypost-php
lib/EasyPost/Tracker.php
Tracker.create_list
public static function create_list($params = null, $apiKey = null) { $class = get_class(); if (!isset($params['trackers']) || !is_array($params['trackers'])) { $clone = $params; unset($params); $params['trackers'] = $clone; } $requestor = new Requestor($apiKey); $url = self::classUrl($class); list($response, $apiKey) = $requestor->request('post', $url.'/create_list', $params); }
php
public static function create_list($params = null, $apiKey = null) { $class = get_class(); if (!isset($params['trackers']) || !is_array($params['trackers'])) { $clone = $params; unset($params); $params['trackers'] = $clone; } $requestor = new Requestor($apiKey); $url = self::classUrl($class); list($response, $apiKey) = $requestor->request('post', $url.'/create_list', $params); }
[ "public", "static", "function", "create_list", "(", "$", "params", "=", "null", ",", "$", "apiKey", "=", "null", ")", "{", "$", "class", "=", "get_class", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "params", "[", "'trackers'", "]", ")", "||"...
create a list of trackers @param mixed $params @param string $apiKey @return mixed
[ "create", "a", "list", "of", "trackers" ]
train
https://github.com/EasyPost/easypost-php/blob/517b6205c9316d67da2241345fa9d52b87ddedf4/lib/EasyPost/Tracker.php#L70-L82
EasyPost/easypost-php
lib/EasyPost/Webhook.php
Webhook.delete
public function delete($params = null, $apiKey = null) { return self::_delete(get_class(), $params, true); }
php
public function delete($params = null, $apiKey = null) { return self::_delete(get_class(), $params, true); }
[ "public", "function", "delete", "(", "$", "params", "=", "null", ",", "$", "apiKey", "=", "null", ")", "{", "return", "self", "::", "_delete", "(", "get_class", "(", ")", ",", "$", "params", ",", "true", ")", ";", "}" ]
delete a webhook @param string $apiKey @return $this
[ "delete", "a", "webhook" ]
train
https://github.com/EasyPost/easypost-php/blob/517b6205c9316d67da2241345fa9d52b87ddedf4/lib/EasyPost/Webhook.php#L37-L40
EasyPost/easypost-php
lib/EasyPost/Webhook.php
Webhook.update
public function update($params = null, $apiKey = null) { if (!isset($params['webhook']) || !is_array($params['webhook'])) { $clone = $params; unset($params); $params['webhook'] = $clone; } return self::_update(get_class(), $params); }
php
public function update($params = null, $apiKey = null) { if (!isset($params['webhook']) || !is_array($params['webhook'])) { $clone = $params; unset($params); $params['webhook'] = $clone; } return self::_update(get_class(), $params); }
[ "public", "function", "update", "(", "$", "params", "=", "null", ",", "$", "apiKey", "=", "null", ")", "{", "if", "(", "!", "isset", "(", "$", "params", "[", "'webhook'", "]", ")", "||", "!", "is_array", "(", "$", "params", "[", "'webhook'", "]", ...
update a webhook @param mixed $params @param string $apiKey @return $this
[ "update", "a", "webhook" ]
train
https://github.com/EasyPost/easypost-php/blob/517b6205c9316d67da2241345fa9d52b87ddedf4/lib/EasyPost/Webhook.php#L49-L58
EasyPost/easypost-php
lib/EasyPost/Webhook.php
Webhook.create
public static function create($params = null, $apiKey = null) { if (!isset($params['webhook']) || !is_array($params['webhook'])) { $clone = $params; unset($params); $params['webhook'] = $clone; } return self::_create(get_class(), $params, $apiKey); }
php
public static function create($params = null, $apiKey = null) { if (!isset($params['webhook']) || !is_array($params['webhook'])) { $clone = $params; unset($params); $params['webhook'] = $clone; } return self::_create(get_class(), $params, $apiKey); }
[ "public", "static", "function", "create", "(", "$", "params", "=", "null", ",", "$", "apiKey", "=", "null", ")", "{", "if", "(", "!", "isset", "(", "$", "params", "[", "'webhook'", "]", ")", "||", "!", "is_array", "(", "$", "params", "[", "'webhook...
create a webhook @param mixed $params @param string $apiKey @return mixed
[ "create", "a", "webhook" ]
train
https://github.com/EasyPost/easypost-php/blob/517b6205c9316d67da2241345fa9d52b87ddedf4/lib/EasyPost/Webhook.php#L67-L76
EasyPost/easypost-php
lib/EasyPost/ScanForm.php
ScanForm.create
public static function create($params = null, $apiKey = null) { return self::_create(get_class(), $params, $apiKey); }
php
public static function create($params = null, $apiKey = null) { return self::_create(get_class(), $params, $apiKey); }
[ "public", "static", "function", "create", "(", "$", "params", "=", "null", ",", "$", "apiKey", "=", "null", ")", "{", "return", "self", "::", "_create", "(", "get_class", "(", ")", ",", "$", "params", ",", "$", "apiKey", ")", ";", "}" ]
create a scan form @param mixed $params @param string $apiKey @return mixed
[ "create", "a", "scan", "form" ]
train
https://github.com/EasyPost/easypost-php/blob/517b6205c9316d67da2241345fa9d52b87ddedf4/lib/EasyPost/ScanForm.php#L48-L51
EasyPost/easypost-php
lib/EasyPost/Batch.php
Batch.create_and_buy
public static function create_and_buy($params = null, $apiKey = null) { $class = get_class(); if (!isset($params['batch']) || !is_array($params['batch'])) { $clone = $params; unset($params); $params['batch'] = $clone; } $requestor = new Requestor($apiKey); $url = self::classUrl($class); list($response, $apiKey) = $requestor->request('post', $url.'/create_and_buy', $params); return Util::convertToEasyPostObject($response, $apiKey); }
php
public static function create_and_buy($params = null, $apiKey = null) { $class = get_class(); if (!isset($params['batch']) || !is_array($params['batch'])) { $clone = $params; unset($params); $params['batch'] = $clone; } $requestor = new Requestor($apiKey); $url = self::classUrl($class); list($response, $apiKey) = $requestor->request('post', $url.'/create_and_buy', $params); return Util::convertToEasyPostObject($response, $apiKey); }
[ "public", "static", "function", "create_and_buy", "(", "$", "params", "=", "null", ",", "$", "apiKey", "=", "null", ")", "{", "$", "class", "=", "get_class", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "params", "[", "'batch'", "]", ")", "||"...
create and buy a batch @param mixed $params @param string $apiKey @return mixed
[ "create", "and", "buy", "a", "batch" ]
train
https://github.com/EasyPost/easypost-php/blob/517b6205c9316d67da2241345fa9d52b87ddedf4/lib/EasyPost/Batch.php#L56-L70
EasyPost/easypost-php
lib/EasyPost/Batch.php
Batch.buy
public function buy($params = null) { $requestor = new Requestor($this->_apiKey); $url = $this->instanceUrl() . '/buy'; list($response, $apiKey) = $requestor->request('post', $url, $params); $this->refreshFrom($response, $apiKey, true); return $this; }
php
public function buy($params = null) { $requestor = new Requestor($this->_apiKey); $url = $this->instanceUrl() . '/buy'; list($response, $apiKey) = $requestor->request('post', $url, $params); $this->refreshFrom($response, $apiKey, true); return $this; }
[ "public", "function", "buy", "(", "$", "params", "=", "null", ")", "{", "$", "requestor", "=", "new", "Requestor", "(", "$", "this", "->", "_apiKey", ")", ";", "$", "url", "=", "$", "this", "->", "instanceUrl", "(", ")", ".", "'/buy'", ";", "list",...
buy a batch @param mixed $params @return $this @throws \EasyPost\Error
[ "buy", "a", "batch" ]
train
https://github.com/EasyPost/easypost-php/blob/517b6205c9316d67da2241345fa9d52b87ddedf4/lib/EasyPost/Batch.php#L79-L88
EasyPost/easypost-php
lib/EasyPost/Batch.php
Batch.create_scan_form
public function create_scan_form($params = null) { $requestor = new Requestor($this->_apiKey); $url = $this->instanceUrl() . '/scan_form'; list($response, $apiKey) = $requestor->request('post', $url, $params); return Util::convertToEasyPostObject($response, $apiKey); }
php
public function create_scan_form($params = null) { $requestor = new Requestor($this->_apiKey); $url = $this->instanceUrl() . '/scan_form'; list($response, $apiKey) = $requestor->request('post', $url, $params); return Util::convertToEasyPostObject($response, $apiKey); }
[ "public", "function", "create_scan_form", "(", "$", "params", "=", "null", ")", "{", "$", "requestor", "=", "new", "Requestor", "(", "$", "this", "->", "_apiKey", ")", ";", "$", "url", "=", "$", "this", "->", "instanceUrl", "(", ")", ".", "'/scan_form'...
create a batch scan form @param mixed $params @return mixed @throws \EasyPost\Error
[ "create", "a", "batch", "scan", "form" ]
train
https://github.com/EasyPost/easypost-php/blob/517b6205c9316d67da2241345fa9d52b87ddedf4/lib/EasyPost/Batch.php#L149-L157
EasyPost/easypost-php
lib/EasyPost/User.php
User.all_api_keys
public static function all_api_keys($apiKey = null) { $requestor = new Requestor($apiKey); list($response, $apiKey) = $requestor->request('get', '/api_keys'); return Util::convertToEasyPostObject($response, $apiKey); }
php
public static function all_api_keys($apiKey = null) { $requestor = new Requestor($apiKey); list($response, $apiKey) = $requestor->request('get', '/api_keys'); return Util::convertToEasyPostObject($response, $apiKey); }
[ "public", "static", "function", "all_api_keys", "(", "$", "apiKey", "=", "null", ")", "{", "$", "requestor", "=", "new", "Requestor", "(", "$", "apiKey", ")", ";", "list", "(", "$", "response", ",", "$", "apiKey", ")", "=", "$", "requestor", "->", "r...
get all API keys @param null $apiKey @return mixed
[ "get", "all", "API", "keys" ]
train
https://github.com/EasyPost/easypost-php/blob/517b6205c9316d67da2241345fa9d52b87ddedf4/lib/EasyPost/User.php#L63-L68
EasyPost/easypost-php
lib/EasyPost/User.php
User.api_keys
public function api_keys($apiKey = null) { $api_keys = self::all_api_keys(); $my_api_keys = null; if ($api_keys->id == $this->id) { $my_api_keys = $api_keys->keys; } if (is_null($my_api_keys)) { foreach($api_keys->children as $children_keys) { if ($children_keys->id == $this->id) { $my_api_keys = $children_keys->keys; } } } if (is_null($my_api_keys)) { return null; } else { $response = array(); foreach($my_api_keys as $key) { $response[$key->mode] = $key->key; } return $response; } }
php
public function api_keys($apiKey = null) { $api_keys = self::all_api_keys(); $my_api_keys = null; if ($api_keys->id == $this->id) { $my_api_keys = $api_keys->keys; } if (is_null($my_api_keys)) { foreach($api_keys->children as $children_keys) { if ($children_keys->id == $this->id) { $my_api_keys = $children_keys->keys; } } } if (is_null($my_api_keys)) { return null; } else { $response = array(); foreach($my_api_keys as $key) { $response[$key->mode] = $key->key; } return $response; } }
[ "public", "function", "api_keys", "(", "$", "apiKey", "=", "null", ")", "{", "$", "api_keys", "=", "self", "::", "all_api_keys", "(", ")", ";", "$", "my_api_keys", "=", "null", ";", "if", "(", "$", "api_keys", "->", "id", "==", "$", "this", "->", "...
api keys @param string $apiKey @return array|null
[ "api", "keys" ]
train
https://github.com/EasyPost/easypost-php/blob/517b6205c9316d67da2241345fa9d52b87ddedf4/lib/EasyPost/User.php#L76-L101
EasyPost/easypost-php
lib/EasyPost/Report.php
Report.create
public static function create($params = null, $apiKey = null) { if (!isset($params['report']) || !is_array($params['report'])) { $clone = $params; unset($params); $params['report'] = $clone; } if (!isset($params['report']['type'])) { throw new Error('Undetermined Report Type'); } else { $type = $params['report']['type']; self::_validate('create', $params, $apiKey); $requestor = new Requestor($apiKey); $url = self::reportUrl($type); list($response, $apiKey) = $requestor->request('post', $url, $params, true); return Util::convertToEasyPostObject($response, $apiKey); } }
php
public static function create($params = null, $apiKey = null) { if (!isset($params['report']) || !is_array($params['report'])) { $clone = $params; unset($params); $params['report'] = $clone; } if (!isset($params['report']['type'])) { throw new Error('Undetermined Report Type'); } else { $type = $params['report']['type']; self::_validate('create', $params, $apiKey); $requestor = new Requestor($apiKey); $url = self::reportUrl($type); list($response, $apiKey) = $requestor->request('post', $url, $params, true); return Util::convertToEasyPostObject($response, $apiKey); } }
[ "public", "static", "function", "create", "(", "$", "params", "=", "null", ",", "$", "apiKey", "=", "null", ")", "{", "if", "(", "!", "isset", "(", "$", "params", "[", "'report'", "]", ")", "||", "!", "is_array", "(", "$", "params", "[", "'report'"...
create a report @param mixed $params @param string $apiKey @return mixed
[ "create", "a", "report" ]
train
https://github.com/EasyPost/easypost-php/blob/517b6205c9316d67da2241345fa9d52b87ddedf4/lib/EasyPost/Report.php#L54-L75
EasyPost/easypost-php
lib/EasyPost/Report.php
Report.reportUrl
protected static function reportUrl($type) { // Strip namespace if present if ($postfix = strrchr($type, '\\')) { $type = substr($postfix, 1); } if (substr($type, 0, strlen('EasyPost')) == 'EasyPost') { $type = substr($type, strlen('EasyPost')); } $type = substr($type, 0, 1) . preg_replace('/([A-Z])/', '_$1', substr($type, 1)); // Camel -> snake $type = strtolower($type); $type = str_replace('_report', '', $type); $name = urlencode($type); return "/reports/{$name}/"; }
php
protected static function reportUrl($type) { // Strip namespace if present if ($postfix = strrchr($type, '\\')) { $type = substr($postfix, 1); } if (substr($type, 0, strlen('EasyPost')) == 'EasyPost') { $type = substr($type, strlen('EasyPost')); } $type = substr($type, 0, 1) . preg_replace('/([A-Z])/', '_$1', substr($type, 1)); // Camel -> snake $type = strtolower($type); $type = str_replace('_report', '', $type); $name = urlencode($type); return "/reports/{$name}/"; }
[ "protected", "static", "function", "reportUrl", "(", "$", "type", ")", "{", "// Strip namespace if present", "if", "(", "$", "postfix", "=", "strrchr", "(", "$", "type", ",", "'\\\\'", ")", ")", "{", "$", "type", "=", "substr", "(", "$", "postfix", ",", ...
generate report url format @param string $type @return mixed @throws \EasyPost\Error
[ "generate", "report", "url", "format" ]
train
https://github.com/EasyPost/easypost-php/blob/517b6205c9316d67da2241345fa9d52b87ddedf4/lib/EasyPost/Report.php#L84-L101
EasyPost/easypost-php
lib/EasyPost/Order.php
Order.buy
public function buy($params = null) { $requestor = new Requestor($this->_apiKey); $url = $this->instanceUrl() . '/buy'; if ($params instanceof Rate) { $clone = $params; unset($params); $params['carrier'] = $clone->carrier; $params['service'] = $clone->service; } list($response, $apiKey) = $requestor->request('post', $url, $params); $this->refreshFrom($response, $apiKey, false); return $this; }
php
public function buy($params = null) { $requestor = new Requestor($this->_apiKey); $url = $this->instanceUrl() . '/buy'; if ($params instanceof Rate) { $clone = $params; unset($params); $params['carrier'] = $clone->carrier; $params['service'] = $clone->service; } list($response, $apiKey) = $requestor->request('post', $url, $params); $this->refreshFrom($response, $apiKey, false); return $this; }
[ "public", "function", "buy", "(", "$", "params", "=", "null", ")", "{", "$", "requestor", "=", "new", "Requestor", "(", "$", "this", "->", "_apiKey", ")", ";", "$", "url", "=", "$", "this", "->", "instanceUrl", "(", ")", ".", "'/buy'", ";", "if", ...
buy an order @param mixed $params @return $this @throws \EasyPost\Error
[ "buy", "an", "order" ]
train
https://github.com/EasyPost/easypost-php/blob/517b6205c9316d67da2241345fa9d52b87ddedf4/lib/EasyPost/Order.php#L83-L99
EasyPost/easypost-php
lib/EasyPost/Util.php
Util.convertEasyPostObjectToArray
public static function convertEasyPostObjectToArray($values) { $results = array(); foreach ($values as $k => $v) { if ($v instanceof EasyPostObject) { $results[$k] = $v->__toArray(true); } else if (is_array($v)) { $results[$k] = self::convertEasyPostObjectToArray($v); } else { $results[$k] = $v; } } return $results; }
php
public static function convertEasyPostObjectToArray($values) { $results = array(); foreach ($values as $k => $v) { if ($v instanceof EasyPostObject) { $results[$k] = $v->__toArray(true); } else if (is_array($v)) { $results[$k] = self::convertEasyPostObjectToArray($v); } else { $results[$k] = $v; } } return $results; }
[ "public", "static", "function", "convertEasyPostObjectToArray", "(", "$", "values", ")", "{", "$", "results", "=", "array", "(", ")", ";", "foreach", "(", "$", "values", "as", "$", "k", "=>", "$", "v", ")", "{", "if", "(", "$", "v", "instanceof", "Ea...
convert EasyPost object to an array @param mixed $values @return array
[ "convert", "EasyPost", "object", "to", "an", "array" ]
train
https://github.com/EasyPost/easypost-php/blob/517b6205c9316d67da2241345fa9d52b87ddedf4/lib/EasyPost/Util.php#L35-L49
EasyPost/easypost-php
lib/EasyPost/Util.php
Util.convertToEasyPostObject
public static function convertToEasyPostObject($response, $apiKey, $parent = null, $name = null) { $types = array( 'Address' => '\EasyPost\Address', 'Batch' => '\EasyPost\Batch', 'CarrierAccount' => '\EasyPost\CarrierAccount', 'Container' => '\EasyPost\Container', 'CustomsInfo' => '\EasyPost\CustomsInfo', 'CustomsItem' => '\EasyPost\CustomsItem', 'Event' => '\EasyPost\Event', 'Fee' => '\EasyPost\Fee', 'Item' => '\EasyPost\Item', 'Order' => '\EasyPost\Order', 'Parcel' => '\EasyPost\Parcel', 'Pickup' => '\EasyPost\Pickup', 'PostageLabel' => '\EasyPost\PostageLabel', 'Rate' => '\EasyPost\Rate', 'Refund' => '\EasyPost\Refund', 'ScanForm' => '\EasyPost\ScanForm', 'Shipment' => '\EasyPost\Shipment', 'Tracker' => '\EasyPost\Tracker', 'User' => '\EasyPost\User', 'Insurance' => '\EasyPost\Insurance', 'Report' => '\EasyPost\Report', 'ShipmentReport' => '\EasyPost\Report', 'PaymentLogReport' => '\EasyPost\Report', 'TrackerReport' => '\EasyPost\Report', 'Webhook' => '\EasyPost\Webhook' ); $prefixes = array( 'adr' => '\EasyPost\Address', 'batch' => '\EasyPost\Batch', 'ca' => '\EasyPost\CarrierAccount', 'container' => '\EasyPost\Container', 'cstinfo' => '\EasyPost\CustomsInfo', 'cstitem' => '\EasyPost\CustomsItem', 'evt' => '\EasyPost\Event', 'fee' => '\EasyPost\Fee', 'item' => '\EasyPost\Item', 'order' => '\EasyPost\Order', 'prcl' => '\EasyPost\Parcel', 'pickup' => '\EasyPost\Pickup', 'pl' => '\EasyPost\PostageLabel', 'rate' => '\EasyPost\Rate', 'rfnd' => '\EasyPost\Refund', 'sf' => '\EasyPost\ScanForm', 'shp' => '\EasyPost\Shipment', 'trk' => '\EasyPost\Tracker', 'user' => '\EasyPost\User', 'ins' => '\EasyPost\Insurance', 'shprep' => '\EasyPost\Report', 'plrep' => '\EasyPost\Report', 'trkrep' => '\EasyPost\Report', 'hook' => '\EasyPost\Webhook' ); if (self::isList($response)) { $mapped = array(); foreach ($response as $object => $v) { if (is_string($object) && isset($types[$object])) { $v['object'] = $object; } array_push($mapped, self::convertToEasyPostObject($v, $apiKey, $parent, $name)); } return $mapped; } else if (is_array($response)) { if (isset($response['object']) && is_string($response['object']) && isset($types[$response['object']])) { $class = $types[$response['object']]; } else if (isset($response['id']) && isset($prefixes[substr($response['id'], 0, strpos($response['id'], "_"))])) { $class = $prefixes[substr($response['id'], 0, strpos($response['id'], "_"))]; } else { $class = '\EasyPost\EasyPostObject'; } return EasyPostObject::constructFrom($response, $class, $apiKey, $parent, $name); } else { return $response; } }
php
public static function convertToEasyPostObject($response, $apiKey, $parent = null, $name = null) { $types = array( 'Address' => '\EasyPost\Address', 'Batch' => '\EasyPost\Batch', 'CarrierAccount' => '\EasyPost\CarrierAccount', 'Container' => '\EasyPost\Container', 'CustomsInfo' => '\EasyPost\CustomsInfo', 'CustomsItem' => '\EasyPost\CustomsItem', 'Event' => '\EasyPost\Event', 'Fee' => '\EasyPost\Fee', 'Item' => '\EasyPost\Item', 'Order' => '\EasyPost\Order', 'Parcel' => '\EasyPost\Parcel', 'Pickup' => '\EasyPost\Pickup', 'PostageLabel' => '\EasyPost\PostageLabel', 'Rate' => '\EasyPost\Rate', 'Refund' => '\EasyPost\Refund', 'ScanForm' => '\EasyPost\ScanForm', 'Shipment' => '\EasyPost\Shipment', 'Tracker' => '\EasyPost\Tracker', 'User' => '\EasyPost\User', 'Insurance' => '\EasyPost\Insurance', 'Report' => '\EasyPost\Report', 'ShipmentReport' => '\EasyPost\Report', 'PaymentLogReport' => '\EasyPost\Report', 'TrackerReport' => '\EasyPost\Report', 'Webhook' => '\EasyPost\Webhook' ); $prefixes = array( 'adr' => '\EasyPost\Address', 'batch' => '\EasyPost\Batch', 'ca' => '\EasyPost\CarrierAccount', 'container' => '\EasyPost\Container', 'cstinfo' => '\EasyPost\CustomsInfo', 'cstitem' => '\EasyPost\CustomsItem', 'evt' => '\EasyPost\Event', 'fee' => '\EasyPost\Fee', 'item' => '\EasyPost\Item', 'order' => '\EasyPost\Order', 'prcl' => '\EasyPost\Parcel', 'pickup' => '\EasyPost\Pickup', 'pl' => '\EasyPost\PostageLabel', 'rate' => '\EasyPost\Rate', 'rfnd' => '\EasyPost\Refund', 'sf' => '\EasyPost\ScanForm', 'shp' => '\EasyPost\Shipment', 'trk' => '\EasyPost\Tracker', 'user' => '\EasyPost\User', 'ins' => '\EasyPost\Insurance', 'shprep' => '\EasyPost\Report', 'plrep' => '\EasyPost\Report', 'trkrep' => '\EasyPost\Report', 'hook' => '\EasyPost\Webhook' ); if (self::isList($response)) { $mapped = array(); foreach ($response as $object => $v) { if (is_string($object) && isset($types[$object])) { $v['object'] = $object; } array_push($mapped, self::convertToEasyPostObject($v, $apiKey, $parent, $name)); } return $mapped; } else if (is_array($response)) { if (isset($response['object']) && is_string($response['object']) && isset($types[$response['object']])) { $class = $types[$response['object']]; } else if (isset($response['id']) && isset($prefixes[substr($response['id'], 0, strpos($response['id'], "_"))])) { $class = $prefixes[substr($response['id'], 0, strpos($response['id'], "_"))]; } else { $class = '\EasyPost\EasyPostObject'; } return EasyPostObject::constructFrom($response, $class, $apiKey, $parent, $name); } else { return $response; } }
[ "public", "static", "function", "convertToEasyPostObject", "(", "$", "response", ",", "$", "apiKey", ",", "$", "parent", "=", "null", ",", "$", "name", "=", "null", ")", "{", "$", "types", "=", "array", "(", "'Address'", "=>", "'\\EasyPost\\Address'", ",",...
convert input to an EasyPost object @param mixed $response @param string $apiKey @param string $parent @param string $name @return array
[ "convert", "input", "to", "an", "EasyPost", "object" ]
train
https://github.com/EasyPost/easypost-php/blob/517b6205c9316d67da2241345fa9d52b87ddedf4/lib/EasyPost/Util.php#L60-L141
EasyPost/easypost-php
lib/EasyPost/CarrierAccount.php
CarrierAccount.types
public static function types($params = null, $apiKey = null) { $requestor = new Requestor($apiKey); list($response, $apiKey) = $requestor->request('get', '/carrier_types', $params); return Util::convertToEasyPostObject($response, $apiKey); }
php
public static function types($params = null, $apiKey = null) { $requestor = new Requestor($apiKey); list($response, $apiKey) = $requestor->request('get', '/carrier_types', $params); return Util::convertToEasyPostObject($response, $apiKey); }
[ "public", "static", "function", "types", "(", "$", "params", "=", "null", ",", "$", "apiKey", "=", "null", ")", "{", "$", "requestor", "=", "new", "Requestor", "(", "$", "apiKey", ")", ";", "list", "(", "$", "response", ",", "$", "apiKey", ")", "="...
get types of carrier account @param mixed $params @param string $apiKey @return mixed
[ "get", "types", "of", "carrier", "account" ]
train
https://github.com/EasyPost/easypost-php/blob/517b6205c9316d67da2241345fa9d52b87ddedf4/lib/EasyPost/CarrierAccount.php#L75-L80
EasyPost/easypost-php
lib/EasyPost/Address.php
Address.create
public static function create($params = null, $apiKey = null) { $urlMod = ""; if ((isset($params['verify']) && is_array($params['verify'])) || (isset($params['verify_strict']) && is_array($params['verify_strict']))) { $verify = ""; if (isset($params['verify'])) { $verify = $params['verify']; unset($params['verify']); } $verify_strict = ""; if (isset($params['verify_strict'])) { $verify_strict = $params['verify_strict']; unset($params['verify_strict']); } $urlMod = "?"; if (is_array($verify)) { foreach ($verify as $verification) { $urlMod .= "verify[]=" . $verification . "&"; } } if (is_array($verify_strict)) { foreach ($verify_strict as $verification_strict) { $urlMod .= "verify_strict[]=" . $verification_strict . "&"; } } } if (!isset($params['address']) || !is_array($params['address'])) { $clone = $params; unset($params); $params['address'] = $clone; } return self::_create(get_class(), $params, $apiKey, $urlMod); }
php
public static function create($params = null, $apiKey = null) { $urlMod = ""; if ((isset($params['verify']) && is_array($params['verify'])) || (isset($params['verify_strict']) && is_array($params['verify_strict']))) { $verify = ""; if (isset($params['verify'])) { $verify = $params['verify']; unset($params['verify']); } $verify_strict = ""; if (isset($params['verify_strict'])) { $verify_strict = $params['verify_strict']; unset($params['verify_strict']); } $urlMod = "?"; if (is_array($verify)) { foreach ($verify as $verification) { $urlMod .= "verify[]=" . $verification . "&"; } } if (is_array($verify_strict)) { foreach ($verify_strict as $verification_strict) { $urlMod .= "verify_strict[]=" . $verification_strict . "&"; } } } if (!isset($params['address']) || !is_array($params['address'])) { $clone = $params; unset($params); $params['address'] = $clone; } return self::_create(get_class(), $params, $apiKey, $urlMod); }
[ "public", "static", "function", "create", "(", "$", "params", "=", "null", ",", "$", "apiKey", "=", "null", ")", "{", "$", "urlMod", "=", "\"\"", ";", "if", "(", "(", "isset", "(", "$", "params", "[", "'verify'", "]", ")", "&&", "is_array", "(", ...
create an address @param mixed $params @param string $apiKey @return mixed
[ "create", "an", "address" ]
train
https://github.com/EasyPost/easypost-php/blob/517b6205c9316d67da2241345fa9d52b87ddedf4/lib/EasyPost/Address.php#L48-L87
EasyPost/easypost-php
lib/EasyPost/Address.php
Address.create_and_verify
public static function create_and_verify($params = null, $apiKey = null) { $class = get_class(); if (!isset($params['address']) || !is_array($params['address'])) { $clone = $params; unset($params); $params['address'] = $clone; } $requestor = new Requestor($apiKey); $url = self::classUrl($class); list($response, $apiKey) = $requestor->request('post', $url.'/create_and_verify', $params); if (isset($response['address'])) { $verified_address = Util::convertToEasyPostObject($response['address'], $apiKey); if (!empty($response['message'])) { $verified_address->message = $response['message']; $verified_address->_immutableValues[] = 'message'; } return $verified_address; } else { return Util::convertToEasyPostObject($response, $apiKey); } }
php
public static function create_and_verify($params = null, $apiKey = null) { $class = get_class(); if (!isset($params['address']) || !is_array($params['address'])) { $clone = $params; unset($params); $params['address'] = $clone; } $requestor = new Requestor($apiKey); $url = self::classUrl($class); list($response, $apiKey) = $requestor->request('post', $url.'/create_and_verify', $params); if (isset($response['address'])) { $verified_address = Util::convertToEasyPostObject($response['address'], $apiKey); if (!empty($response['message'])) { $verified_address->message = $response['message']; $verified_address->_immutableValues[] = 'message'; } return $verified_address; } else { return Util::convertToEasyPostObject($response, $apiKey); } }
[ "public", "static", "function", "create_and_verify", "(", "$", "params", "=", "null", ",", "$", "apiKey", "=", "null", ")", "{", "$", "class", "=", "get_class", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "params", "[", "'address'", "]", ")", ...
create and verify an address @param mixed $params @param string $apiKey @return mixed
[ "create", "and", "verify", "an", "address" ]
train
https://github.com/EasyPost/easypost-php/blob/517b6205c9316d67da2241345fa9d52b87ddedf4/lib/EasyPost/Address.php#L96-L121
EasyPost/easypost-php
lib/EasyPost/Address.php
Address.verify
public function verify($params = null) { $requestor = new Requestor($this->_apiKey); $url = $this->instanceUrl() . '/verify'; list($response, $apiKey) = $requestor->request('get', $url, $params); if (isset($response['address'])) { $verified_address = Util::convertToEasyPostObject($response['address'], $apiKey); if (!empty($response['message'])) { $verified_address->message = $response['message']; $verified_address->_immutableValues[] = 'message'; } return $verified_address; } else { return Util::convertToEasyPostObject($response, $apiKey); } }
php
public function verify($params = null) { $requestor = new Requestor($this->_apiKey); $url = $this->instanceUrl() . '/verify'; list($response, $apiKey) = $requestor->request('get', $url, $params); if (isset($response['address'])) { $verified_address = Util::convertToEasyPostObject($response['address'], $apiKey); if (!empty($response['message'])) { $verified_address->message = $response['message']; $verified_address->_immutableValues[] = 'message'; } return $verified_address; } else { return Util::convertToEasyPostObject($response, $apiKey); } }
[ "public", "function", "verify", "(", "$", "params", "=", "null", ")", "{", "$", "requestor", "=", "new", "Requestor", "(", "$", "this", "->", "_apiKey", ")", ";", "$", "url", "=", "$", "this", "->", "instanceUrl", "(", ")", ".", "'/verify'", ";", "...
verify an address @param mixed $params @return mixed @throws \EasyPost\Error
[ "verify", "an", "address" ]
train
https://github.com/EasyPost/easypost-php/blob/517b6205c9316d67da2241345fa9d52b87ddedf4/lib/EasyPost/Address.php#L130-L147
EasyPost/easypost-php
lib/EasyPost/Error.php
Error.prettyPrint
public function prettyPrint() { print($this->ecode . " (" . $this->getHttpStatus() . "): " . $this->getMessage() . "\n"); if (!empty($this->errors)) { print("Field errors:\n"); foreach($this->errors as $field_error) { foreach($field_error as $k => $v) { print(" " . $k . ": " . $v . "\n"); } print("\n"); } } }
php
public function prettyPrint() { print($this->ecode . " (" . $this->getHttpStatus() . "): " . $this->getMessage() . "\n"); if (!empty($this->errors)) { print("Field errors:\n"); foreach($this->errors as $field_error) { foreach($field_error as $k => $v) { print(" " . $k . ": " . $v . "\n"); } print("\n"); } } }
[ "public", "function", "prettyPrint", "(", ")", "{", "print", "(", "$", "this", "->", "ecode", ".", "\" (\"", ".", "$", "this", "->", "getHttpStatus", "(", ")", ".", "\"): \"", ".", "$", "this", "->", "getMessage", "(", ")", ".", "\"\\n\"", ")", ";", ...
print out the error @return void
[ "print", "out", "the", "error" ]
train
https://github.com/EasyPost/easypost-php/blob/517b6205c9316d67da2241345fa9d52b87ddedf4/lib/EasyPost/Error.php#L69-L82
EasyPost/easypost-php
lib/EasyPost/EasyPostObject.php
EasyPostObject.constructFrom
public static function constructFrom($values, $class = null, $apiKey = null, $parent = null, $name = null) { if ($class === null) { $class = get_class(); } $obj = new $class(isset($values['id']) ? $values['id'] : null, $apiKey, $parent, $name); $obj->refreshFrom($values, $apiKey); return $obj; }
php
public static function constructFrom($values, $class = null, $apiKey = null, $parent = null, $name = null) { if ($class === null) { $class = get_class(); } $obj = new $class(isset($values['id']) ? $values['id'] : null, $apiKey, $parent, $name); $obj->refreshFrom($values, $apiKey); return $obj; }
[ "public", "static", "function", "constructFrom", "(", "$", "values", ",", "$", "class", "=", "null", ",", "$", "apiKey", "=", "null", ",", "$", "parent", "=", "null", ",", "$", "name", "=", "null", ")", "{", "if", "(", "$", "class", "===", "null", ...
construct from @param array $values @param string $class @param string $apiKey @param string $parent @param string $name @return mixed
[ "construct", "from" ]
train
https://github.com/EasyPost/easypost-php/blob/517b6205c9316d67da2241345fa9d52b87ddedf4/lib/EasyPost/EasyPostObject.php#L167-L177
EasyPost/easypost-php
lib/EasyPost/EasyPostObject.php
EasyPostObject.refreshFrom
public function refreshFrom($values, $apiKey, $partial = false) { $this->_apiKey = $apiKey; if ($partial) { $removed = array(); } else { $removed = array_diff(array_keys($this->_values), array_keys($values)); } foreach ($removed as $k) { if (in_array($k, $this->_immutableValues) || in_array($k, $values)) { continue; } unset($this->$k); } foreach ($values as $k => $v) { if ($k == 'id' && $this->id != $v) { $this->id = $v; } if (in_array($k, $this->_immutableValues)) { continue; } $this->_values[$k] = Util::convertToEasyPostObject($v, $apiKey, $this, $k); } $this->_unsavedValues = array(); }
php
public function refreshFrom($values, $apiKey, $partial = false) { $this->_apiKey = $apiKey; if ($partial) { $removed = array(); } else { $removed = array_diff(array_keys($this->_values), array_keys($values)); } foreach ($removed as $k) { if (in_array($k, $this->_immutableValues) || in_array($k, $values)) { continue; } unset($this->$k); } foreach ($values as $k => $v) { if ($k == 'id' && $this->id != $v) { $this->id = $v; } if (in_array($k, $this->_immutableValues)) { continue; } $this->_values[$k] = Util::convertToEasyPostObject($v, $apiKey, $this, $k); } $this->_unsavedValues = array(); }
[ "public", "function", "refreshFrom", "(", "$", "values", ",", "$", "apiKey", ",", "$", "partial", "=", "false", ")", "{", "$", "this", "->", "_apiKey", "=", "$", "apiKey", ";", "if", "(", "$", "partial", ")", "{", "$", "removed", "=", "array", "(",...
refresh from @param array $values @param string $apiKey @param bool $partial
[ "refresh", "from" ]
train
https://github.com/EasyPost/easypost-php/blob/517b6205c9316d67da2241345fa9d52b87ddedf4/lib/EasyPost/EasyPostObject.php#L186-L216
EasyPost/easypost-php
lib/EasyPost/EasyPostObject.php
EasyPostObject.__toArray
public function __toArray($recursive = false) { if ($recursive) { return Util::convertEasyPostObjectToArray($this->_values); } return $this->_values; }
php
public function __toArray($recursive = false) { if ($recursive) { return Util::convertEasyPostObjectToArray($this->_values); } return $this->_values; }
[ "public", "function", "__toArray", "(", "$", "recursive", "=", "false", ")", "{", "if", "(", "$", "recursive", ")", "{", "return", "Util", "::", "convertEasyPostObjectToArray", "(", "$", "this", "->", "_values", ")", ";", "}", "return", "$", "this", "->"...
convert object to an array @param bool $recursive @return array
[ "convert", "object", "to", "an", "array" ]
train
https://github.com/EasyPost/easypost-php/blob/517b6205c9316d67da2241345fa9d52b87ddedf4/lib/EasyPost/EasyPostObject.php#L343-L350
EasyPost/easypost-php
lib/EasyPost/Shipment.php
Shipment.barcode
public function barcode($params = null) { $requestor = new Requestor($this->_apiKey); $url = $this->instanceUrl() . '/barcode'; list($response, $apiKey) = $requestor->request('get', $url, $params); return $response['barcode_url']; }
php
public function barcode($params = null) { $requestor = new Requestor($this->_apiKey); $url = $this->instanceUrl() . '/barcode'; list($response, $apiKey) = $requestor->request('get', $url, $params); return $response['barcode_url']; }
[ "public", "function", "barcode", "(", "$", "params", "=", "null", ")", "{", "$", "requestor", "=", "new", "Requestor", "(", "$", "this", "->", "_apiKey", ")", ";", "$", "url", "=", "$", "this", "->", "instanceUrl", "(", ")", ".", "'/barcode'", ";", ...
get the shipment barcode @param mixed $params @return mixed @throws \EasyPost\Error
[ "get", "the", "shipment", "barcode" ]
train
https://github.com/EasyPost/easypost-php/blob/517b6205c9316d67da2241345fa9d52b87ddedf4/lib/EasyPost/Shipment.php#L147-L155
EasyPost/easypost-php
lib/EasyPost/Shipment.php
Shipment.lowest_rate
public function lowest_rate($carriers=array(), $services=array()) { $lowest_rate = false; $carriers_include = array(); $carriers_exclude = array(); $services_include = array(); $services_exclude = array(); if(!is_array($carriers)) { $carriers = explode(',', $carriers); } for ($a = 0, $b = count($carriers); $a < $b; $a++) { $carriers[$a] = trim(strtolower($carriers[$a])); if (substr($carriers[$a], 0, 1) == '!') { $carriers_exclude[] = substr($carriers[$a], 1); } else { $carriers_include[] = $carriers[$a]; } } if(!is_array($services)) { $services = explode(',', $services); } for ($c = 0, $d = count($services); $c < $d; $c++) { $services[$c] = trim(strtolower($services[$c])); if (substr($services[$c], 0, 1) == '!') { $services_exclude[] = substr($services[$c], 1); } else { $services_include[] = $services[$c]; } } for ($i = 0, $k = count($this->rates); $i < $k; $i++) { $rate_carrier = strtolower($this->rates[$i]->carrier); if (!empty($carriers_include[0]) && !in_array($rate_carrier, $carriers_include)) { continue; } if (!empty($carriers_exclude[0]) && in_array($rate_carrier, $carriers_exclude)) { continue; } $rate_service = strtolower($this->rates[$i]->service); if (!empty($services_include[0]) && !in_array($rate_service, $services_include)) { continue; } if (!empty($services_exclude[0]) && in_array($rate_service, $services_exclude)) { continue; } if (!$lowest_rate || floatval($this->rates[$i]->rate) < floatval($lowest_rate->rate)) { $lowest_rate = clone($this->rates[$i]); } } if ($lowest_rate == false) { throw new Error('No rates found.'); } return $lowest_rate; }
php
public function lowest_rate($carriers=array(), $services=array()) { $lowest_rate = false; $carriers_include = array(); $carriers_exclude = array(); $services_include = array(); $services_exclude = array(); if(!is_array($carriers)) { $carriers = explode(',', $carriers); } for ($a = 0, $b = count($carriers); $a < $b; $a++) { $carriers[$a] = trim(strtolower($carriers[$a])); if (substr($carriers[$a], 0, 1) == '!') { $carriers_exclude[] = substr($carriers[$a], 1); } else { $carriers_include[] = $carriers[$a]; } } if(!is_array($services)) { $services = explode(',', $services); } for ($c = 0, $d = count($services); $c < $d; $c++) { $services[$c] = trim(strtolower($services[$c])); if (substr($services[$c], 0, 1) == '!') { $services_exclude[] = substr($services[$c], 1); } else { $services_include[] = $services[$c]; } } for ($i = 0, $k = count($this->rates); $i < $k; $i++) { $rate_carrier = strtolower($this->rates[$i]->carrier); if (!empty($carriers_include[0]) && !in_array($rate_carrier, $carriers_include)) { continue; } if (!empty($carriers_exclude[0]) && in_array($rate_carrier, $carriers_exclude)) { continue; } $rate_service = strtolower($this->rates[$i]->service); if (!empty($services_include[0]) && !in_array($rate_service, $services_include)) { continue; } if (!empty($services_exclude[0]) && in_array($rate_service, $services_exclude)) { continue; } if (!$lowest_rate || floatval($this->rates[$i]->rate) < floatval($lowest_rate->rate)) { $lowest_rate = clone($this->rates[$i]); } } if ($lowest_rate == false) { throw new Error('No rates found.'); } return $lowest_rate; }
[ "public", "function", "lowest_rate", "(", "$", "carriers", "=", "array", "(", ")", ",", "$", "services", "=", "array", "(", ")", ")", "{", "$", "lowest_rate", "=", "false", ";", "$", "carriers_include", "=", "array", "(", ")", ";", "$", "carriers_exclu...
get the lowest rate for the shipment @param array $carriers @param array $services @return bool @throws \EasyPost\Error
[ "get", "the", "lowest", "rate", "for", "the", "shipment" ]
train
https://github.com/EasyPost/easypost-php/blob/517b6205c9316d67da2241345fa9d52b87ddedf4/lib/EasyPost/Shipment.php#L230-L289
EasyPost/easypost-php
lib/EasyPost/Event.php
Event.receive
public static function receive($rawInput=null){ if($rawInput == null) throw new Error('The raw input must be set'); $values = json_decode( $rawInput, TRUE ); if ($values != null) { return self::constructFrom($values, get_class(), null); } else { throw new Error('There was a problem decoding the webhook'); } }
php
public static function receive($rawInput=null){ if($rawInput == null) throw new Error('The raw input must be set'); $values = json_decode( $rawInput, TRUE ); if ($values != null) { return self::constructFrom($values, get_class(), null); } else { throw new Error('There was a problem decoding the webhook'); } }
[ "public", "static", "function", "receive", "(", "$", "rawInput", "=", "null", ")", "{", "if", "(", "$", "rawInput", "==", "null", ")", "throw", "new", "Error", "(", "'The raw input must be set'", ")", ";", "$", "values", "=", "json_decode", "(", "$", "ra...
receive an event @param string $rawInput @return mixed @throws \EasyPost\Error
[ "receive", "an", "event" ]
train
https://github.com/EasyPost/easypost-php/blob/517b6205c9316d67da2241345fa9d52b87ddedf4/lib/EasyPost/Event.php#L14-L23
ekino/EkinoWordpressBundle
Twig/Extension/CommentExtension.php
CommentExtension.getCommentAuthorLink
public function getCommentAuthorLink(Comment $comment) { if (!$user = $comment->getUser()) { if ((!$authorUrl = $comment->getAuthorUrl()) || !preg_match('/^http(s)?:\/\/.+$/', $authorUrl)) { return $comment->getAuthor(); } return sprintf('<a href="%s" rel="nofollow" target="_new">%s</a>', $authorUrl, $comment->getAuthor()); } if ((!$userUrl = $user->getUrl()) || !preg_match('/^http(s)?:\/\/.+$/', $userUrl)) { return $user->getDisplayName(); } return sprintf('<a href="%s" rel="nofollow" target="_new">%s</a>', $userUrl, $user->getDisplayName()); }
php
public function getCommentAuthorLink(Comment $comment) { if (!$user = $comment->getUser()) { if ((!$authorUrl = $comment->getAuthorUrl()) || !preg_match('/^http(s)?:\/\/.+$/', $authorUrl)) { return $comment->getAuthor(); } return sprintf('<a href="%s" rel="nofollow" target="_new">%s</a>', $authorUrl, $comment->getAuthor()); } if ((!$userUrl = $user->getUrl()) || !preg_match('/^http(s)?:\/\/.+$/', $userUrl)) { return $user->getDisplayName(); } return sprintf('<a href="%s" rel="nofollow" target="_new">%s</a>', $userUrl, $user->getDisplayName()); }
[ "public", "function", "getCommentAuthorLink", "(", "Comment", "$", "comment", ")", "{", "if", "(", "!", "$", "user", "=", "$", "comment", "->", "getUser", "(", ")", ")", "{", "if", "(", "(", "!", "$", "authorUrl", "=", "$", "comment", "->", "getAutho...
@param Comment $comment @return string
[ "@param", "Comment", "$comment" ]
train
https://github.com/ekino/EkinoWordpressBundle/blob/bf3f4cac10d62d7b57ebf1fb6a5cef1780752bb8/Twig/Extension/CommentExtension.php#L63-L78
ekino/EkinoWordpressBundle
Repository/PostMetaRepository.php
PostMetaRepository.getPostMetaQuery
public function getPostMetaQuery($postId, $metaName) { return $this->createQueryBuilder('m') ->innerJoin('m.post', 'p') ->where('m.key = :metaName') ->andWhere('p.id = :postId') ->setParameter('postId', $postId) ->setParameter('metaName', $metaName) ->getQuery(); }
php
public function getPostMetaQuery($postId, $metaName) { return $this->createQueryBuilder('m') ->innerJoin('m.post', 'p') ->where('m.key = :metaName') ->andWhere('p.id = :postId') ->setParameter('postId', $postId) ->setParameter('metaName', $metaName) ->getQuery(); }
[ "public", "function", "getPostMetaQuery", "(", "$", "postId", ",", "$", "metaName", ")", "{", "return", "$", "this", "->", "createQueryBuilder", "(", "'m'", ")", "->", "innerJoin", "(", "'m.post'", ",", "'p'", ")", "->", "where", "(", "'m.key = :metaName'", ...
@param int $postId @param string $metaName @return \Doctrine\ORM\Query
[ "@param", "int", "$postId", "@param", "string", "$metaName" ]
train
https://github.com/ekino/EkinoWordpressBundle/blob/bf3f4cac10d62d7b57ebf1fb6a5cef1780752bb8/Repository/PostMetaRepository.php#L30-L39
ekino/EkinoWordpressBundle
Subscriber/TablePrefixSubscriber.php
TablePrefixSubscriber.loadClassMetadata
public function loadClassMetadata(LoadClassMetadataEventArgs $args) { $classMetadata = $args->getClassMetadata(); if ($classMetadata->isInheritanceTypeSingleTable() && !$classMetadata->isRootEntity()) { return; } if ($classMetadata->getReflectionClass() && $classMetadata->getReflectionClass()->implementsInterface('Ekino\\WordpressBundle\\Model\\WordpressEntityInterface')) { $classMetadata->setPrimaryTable(['name' => $this->prefix.$classMetadata->getTableName()]); foreach ($classMetadata->getAssociationMappings() as $fieldName => $mapping) { if ($mapping['type'] == ClassMetadataInfo::MANY_TO_MANY) { $mappedTableName = $classMetadata->associationMappings[$fieldName]['joinTable']['name']; $classMetadata->associationMappings[$fieldName]['joinTable']['name'] = $this->prefix.$mappedTableName; } } } }
php
public function loadClassMetadata(LoadClassMetadataEventArgs $args) { $classMetadata = $args->getClassMetadata(); if ($classMetadata->isInheritanceTypeSingleTable() && !$classMetadata->isRootEntity()) { return; } if ($classMetadata->getReflectionClass() && $classMetadata->getReflectionClass()->implementsInterface('Ekino\\WordpressBundle\\Model\\WordpressEntityInterface')) { $classMetadata->setPrimaryTable(['name' => $this->prefix.$classMetadata->getTableName()]); foreach ($classMetadata->getAssociationMappings() as $fieldName => $mapping) { if ($mapping['type'] == ClassMetadataInfo::MANY_TO_MANY) { $mappedTableName = $classMetadata->associationMappings[$fieldName]['joinTable']['name']; $classMetadata->associationMappings[$fieldName]['joinTable']['name'] = $this->prefix.$mappedTableName; } } } }
[ "public", "function", "loadClassMetadata", "(", "LoadClassMetadataEventArgs", "$", "args", ")", "{", "$", "classMetadata", "=", "$", "args", "->", "getClassMetadata", "(", ")", ";", "if", "(", "$", "classMetadata", "->", "isInheritanceTypeSingleTable", "(", ")", ...
Loads class metadata and updates table prefix name. @param LoadClassMetadataEventArgs $args
[ "Loads", "class", "metadata", "and", "updates", "table", "prefix", "name", "." ]
train
https://github.com/ekino/EkinoWordpressBundle/blob/bf3f4cac10d62d7b57ebf1fb6a5cef1780752bb8/Subscriber/TablePrefixSubscriber.php#L58-L76
ekino/EkinoWordpressBundle
Repository/PostRepository.php
PostRepository.findByDate
public function findByDate(\DateTime $date = null) { $qb = $this->createQueryBuilder('p') ->where('p.date LIKE :date') ->addOrderBy('p.date', 'DESC') ->addOrderBy('p.id', 'DESC') ->setParameter('date', $date->format('Y-m-d').'%'); return $qb->getQuery()->getResult(); }
php
public function findByDate(\DateTime $date = null) { $qb = $this->createQueryBuilder('p') ->where('p.date LIKE :date') ->addOrderBy('p.date', 'DESC') ->addOrderBy('p.id', 'DESC') ->setParameter('date', $date->format('Y-m-d').'%'); return $qb->getQuery()->getResult(); }
[ "public", "function", "findByDate", "(", "\\", "DateTime", "$", "date", "=", "null", ")", "{", "$", "qb", "=", "$", "this", "->", "createQueryBuilder", "(", "'p'", ")", "->", "where", "(", "'p.date LIKE :date'", ")", "->", "addOrderBy", "(", "'p.date'", ...
@param \DateTime|null $date @return array @author Elvis Morales <elvismdev@gmail.com> & Leroy Ley <lele140686@gmail.com>
[ "@param", "\\", "DateTime|null", "$date" ]
train
https://github.com/ekino/EkinoWordpressBundle/blob/bf3f4cac10d62d7b57ebf1fb6a5cef1780752bb8/Repository/PostRepository.php#L31-L40
ekino/EkinoWordpressBundle
Repository/PostRepository.php
PostRepository.findByCategory
public function findByCategory($category) { return $this->createQueryBuilder('p') ->leftJoin('Ekino\WordpressBundle\Entity\TermRelationships', 'tr', 'WITH', 'p.id = tr.post') ->leftJoin('Ekino\WordpressBundle\Entity\Term', 't', 'WITH', 't.id = tr.taxonomy') ->where('t.name = :category') ->setParameter('category', $category) ->getQuery()->getResult(); }
php
public function findByCategory($category) { return $this->createQueryBuilder('p') ->leftJoin('Ekino\WordpressBundle\Entity\TermRelationships', 'tr', 'WITH', 'p.id = tr.post') ->leftJoin('Ekino\WordpressBundle\Entity\Term', 't', 'WITH', 't.id = tr.taxonomy') ->where('t.name = :category') ->setParameter('category', $category) ->getQuery()->getResult(); }
[ "public", "function", "findByCategory", "(", "$", "category", ")", "{", "return", "$", "this", "->", "createQueryBuilder", "(", "'p'", ")", "->", "leftJoin", "(", "'Ekino\\WordpressBundle\\Entity\\TermRelationships'", ",", "'tr'", ",", "'WITH'", ",", "'p.id = tr.pos...
@param string $category @return array @author Guillaume Leclercq <g.leclercq12@gmail.com>
[ "@param", "string", "$category" ]
train
https://github.com/ekino/EkinoWordpressBundle/blob/bf3f4cac10d62d7b57ebf1fb6a5cef1780752bb8/Repository/PostRepository.php#L49-L57
ekino/EkinoWordpressBundle
Model/Term.php
Term.addTaxonomy
public function addTaxonomy(TermTaxonomy $taxonomy) { if (!$this->taxonomies->contains($taxonomy)) { $this->taxonomies[] = $taxonomy; } return $this; }
php
public function addTaxonomy(TermTaxonomy $taxonomy) { if (!$this->taxonomies->contains($taxonomy)) { $this->taxonomies[] = $taxonomy; } return $this; }
[ "public", "function", "addTaxonomy", "(", "TermTaxonomy", "$", "taxonomy", ")", "{", "if", "(", "!", "$", "this", "->", "taxonomies", "->", "contains", "(", "$", "taxonomy", ")", ")", "{", "$", "this", "->", "taxonomies", "[", "]", "=", "$", "taxonomy"...
@param TermTaxonomy $taxonomy @return Term
[ "@param", "TermTaxonomy", "$taxonomy" ]
train
https://github.com/ekino/EkinoWordpressBundle/blob/bf3f4cac10d62d7b57ebf1fb6a5cef1780752bb8/Model/Term.php#L150-L157
ekino/EkinoWordpressBundle
Model/Term.php
Term.removeTaxonomy
public function removeTaxonomy(TermTaxonomy $taxonomy) { if ($this->taxonomies->contains($taxonomy)) { $this->taxonomies->remove($taxonomy); } return $this; }
php
public function removeTaxonomy(TermTaxonomy $taxonomy) { if ($this->taxonomies->contains($taxonomy)) { $this->taxonomies->remove($taxonomy); } return $this; }
[ "public", "function", "removeTaxonomy", "(", "TermTaxonomy", "$", "taxonomy", ")", "{", "if", "(", "$", "this", "->", "taxonomies", "->", "contains", "(", "$", "taxonomy", ")", ")", "{", "$", "this", "->", "taxonomies", "->", "remove", "(", "$", "taxonom...
@param TermTaxonomy $taxonomy @return Term
[ "@param", "TermTaxonomy", "$taxonomy" ]
train
https://github.com/ekino/EkinoWordpressBundle/blob/bf3f4cac10d62d7b57ebf1fb6a5cef1780752bb8/Model/Term.php#L164-L171
ekino/EkinoWordpressBundle
Twig/Extension/OptionExtension.php
OptionExtension.getOption
public function getOption($optionName, $defaultValue = null) { $option = $this->optionManager->findOneByOptionName($optionName); return $option ?: $defaultValue; }
php
public function getOption($optionName, $defaultValue = null) { $option = $this->optionManager->findOneByOptionName($optionName); return $option ?: $defaultValue; }
[ "public", "function", "getOption", "(", "$", "optionName", ",", "$", "defaultValue", "=", "null", ")", "{", "$", "option", "=", "$", "this", "->", "optionManager", "->", "findOneByOptionName", "(", "$", "optionName", ")", ";", "return", "$", "option", "?",...
@param string $optionName @param mixed $defaultValue @return mixed
[ "@param", "string", "$optionName", "@param", "mixed", "$defaultValue" ]
train
https://github.com/ekino/EkinoWordpressBundle/blob/bf3f4cac10d62d7b57ebf1fb6a5cef1780752bb8/Twig/Extension/OptionExtension.php#L60-L65
ekino/EkinoWordpressBundle
Model/Post.php
Post.removeMeta
public function removeMeta(PostMeta $meta) { if ($this->metas->contains($meta)) { $this->metas->remove($meta); } return $this; }
php
public function removeMeta(PostMeta $meta) { if ($this->metas->contains($meta)) { $this->metas->remove($meta); } return $this; }
[ "public", "function", "removeMeta", "(", "PostMeta", "$", "meta", ")", "{", "if", "(", "$", "this", "->", "metas", "->", "contains", "(", "$", "meta", ")", ")", "{", "$", "this", "->", "metas", "->", "remove", "(", "$", "meta", ")", ";", "}", "re...
@param PostMeta $meta @return Post
[ "@param", "PostMeta", "$meta" ]
train
https://github.com/ekino/EkinoWordpressBundle/blob/bf3f4cac10d62d7b57ebf1fb6a5cef1780752bb8/Model/Post.php#L670-L677
ekino/EkinoWordpressBundle
Model/Post.php
Post.getMetaByKey
public function getMetaByKey($name) { $criteria = Criteria::create(); $criteria->where(Criteria::expr()->eq('key', $name)); return $this->metas->matching($criteria); }
php
public function getMetaByKey($name) { $criteria = Criteria::create(); $criteria->where(Criteria::expr()->eq('key', $name)); return $this->metas->matching($criteria); }
[ "public", "function", "getMetaByKey", "(", "$", "name", ")", "{", "$", "criteria", "=", "Criteria", "::", "create", "(", ")", ";", "$", "criteria", "->", "where", "(", "Criteria", "::", "expr", "(", ")", "->", "eq", "(", "'key'", ",", "$", "name", ...
@param string $name @return \Doctrine\Common\Collections\Collection
[ "@param", "string", "$name" ]
train
https://github.com/ekino/EkinoWordpressBundle/blob/bf3f4cac10d62d7b57ebf1fb6a5cef1780752bb8/Model/Post.php#L684-L690
ekino/EkinoWordpressBundle
Model/Post.php
Post.getMetaValue
public function getMetaValue($name) { /** @var PostMeta $meta */ foreach ($this->getMetas() as $meta) { if ($name == $meta->getKey()) { return $meta->getValue(); } } return; }
php
public function getMetaValue($name) { /** @var PostMeta $meta */ foreach ($this->getMetas() as $meta) { if ($name == $meta->getKey()) { return $meta->getValue(); } } return; }
[ "public", "function", "getMetaValue", "(", "$", "name", ")", "{", "/** @var PostMeta $meta */", "foreach", "(", "$", "this", "->", "getMetas", "(", ")", "as", "$", "meta", ")", "{", "if", "(", "$", "name", "==", "$", "meta", "->", "getKey", "(", ")", ...
Returns user meta value from a meta key name. @param string $name @return string|null
[ "Returns", "user", "meta", "value", "from", "a", "meta", "key", "name", "." ]
train
https://github.com/ekino/EkinoWordpressBundle/blob/bf3f4cac10d62d7b57ebf1fb6a5cef1780752bb8/Model/Post.php#L699-L709
ekino/EkinoWordpressBundle
Model/Post.php
Post.getTaxonomiesByType
public function getTaxonomiesByType($type) { $taxonomies = new ArrayCollection(); /** @var TermRelationships $relationship */ foreach ($this->getTermRelationships() as $relationship) { if ($type === $relationship->getTaxonomy()->getTaxonomy()) { $taxonomies[] = $relationship->getTaxonomy(); } } return ($taxonomies->count() == 0) ? null : $taxonomies; }
php
public function getTaxonomiesByType($type) { $taxonomies = new ArrayCollection(); /** @var TermRelationships $relationship */ foreach ($this->getTermRelationships() as $relationship) { if ($type === $relationship->getTaxonomy()->getTaxonomy()) { $taxonomies[] = $relationship->getTaxonomy(); } } return ($taxonomies->count() == 0) ? null : $taxonomies; }
[ "public", "function", "getTaxonomiesByType", "(", "$", "type", ")", "{", "$", "taxonomies", "=", "new", "ArrayCollection", "(", ")", ";", "/** @var TermRelationships $relationship */", "foreach", "(", "$", "this", "->", "getTermRelationships", "(", ")", "as", "$",...
@param string $type @return ArrayCollection|null
[ "@param", "string", "$type" ]
train
https://github.com/ekino/EkinoWordpressBundle/blob/bf3f4cac10d62d7b57ebf1fb6a5cef1780752bb8/Model/Post.php#L782-L794
ekino/EkinoWordpressBundle
Model/Post.php
Post.getTermsByType
public function getTermsByType($type) { $terms = new ArrayCollection(); $taxonomies = $this->getTaxonomiesByType($type); /* @var TermTaxonomy $taxonomy */ if ($taxonomies !== null) { foreach ($taxonomies as $taxonomy) { $terms[] = $taxonomy->getTerm(); } } return ($terms->count() == 0) ? null : $terms; }
php
public function getTermsByType($type) { $terms = new ArrayCollection(); $taxonomies = $this->getTaxonomiesByType($type); /* @var TermTaxonomy $taxonomy */ if ($taxonomies !== null) { foreach ($taxonomies as $taxonomy) { $terms[] = $taxonomy->getTerm(); } } return ($terms->count() == 0) ? null : $terms; }
[ "public", "function", "getTermsByType", "(", "$", "type", ")", "{", "$", "terms", "=", "new", "ArrayCollection", "(", ")", ";", "$", "taxonomies", "=", "$", "this", "->", "getTaxonomiesByType", "(", "$", "type", ")", ";", "/* @var TermTaxonomy $taxonomy */", ...
@param $type @return ArrayCollection|null
[ "@param", "$type" ]
train
https://github.com/ekino/EkinoWordpressBundle/blob/bf3f4cac10d62d7b57ebf1fb6a5cef1780752bb8/Model/Post.php#L801-L814
ekino/EkinoWordpressBundle
Event/WordpressEvent.php
WordpressEvent.getParameter
public function getParameter($index) { if (!$this->hasParameter($index)) { throw new \InvalidArgumentException(sprintf('Cannot retrieve parameter "%s"', $index)); } return $this->parameters[$index]; }
php
public function getParameter($index) { if (!$this->hasParameter($index)) { throw new \InvalidArgumentException(sprintf('Cannot retrieve parameter "%s"', $index)); } return $this->parameters[$index]; }
[ "public", "function", "getParameter", "(", "$", "index", ")", "{", "if", "(", "!", "$", "this", "->", "hasParameter", "(", "$", "index", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'Cannot retrieve parameter \"%s\"'",...
Returns a parameter of given index position. @param mixed $index @throws \InvalidArgumentException @return mixed
[ "Returns", "a", "parameter", "of", "given", "index", "position", "." ]
train
https://github.com/ekino/EkinoWordpressBundle/blob/bf3f4cac10d62d7b57ebf1fb6a5cef1780752bb8/Event/WordpressEvent.php#L60-L67
ekino/EkinoWordpressBundle
Twig/Extension/PostMetaExtension.php
PostMetaExtension.getPostMeta
public function getPostMeta($postId, $metaName, $fetchOneResult = false) { return $this->postMetaManager->getPostMeta($postId, $metaName, $fetchOneResult); }
php
public function getPostMeta($postId, $metaName, $fetchOneResult = false) { return $this->postMetaManager->getPostMeta($postId, $metaName, $fetchOneResult); }
[ "public", "function", "getPostMeta", "(", "$", "postId", ",", "$", "metaName", ",", "$", "fetchOneResult", "=", "false", ")", "{", "return", "$", "this", "->", "postMetaManager", "->", "getPostMeta", "(", "$", "postId", ",", "$", "metaName", ",", "$", "f...
@param int $postId A post identifier @param string $metaName A meta name @param bool $fetchOneResult Use fetchOneOrNullResult() method instead of getResult()? @return array|\Ekino\WordpressBundle\Entity\PostMeta
[ "@param", "int", "$postId", "A", "post", "identifier", "@param", "string", "$metaName", "A", "meta", "name", "@param", "bool", "$fetchOneResult", "Use", "fetchOneOrNullResult", "()", "method", "instead", "of", "getResult", "()", "?" ]
train
https://github.com/ekino/EkinoWordpressBundle/blob/bf3f4cac10d62d7b57ebf1fb6a5cef1780752bb8/Twig/Extension/PostMetaExtension.php#L63-L66
ekino/EkinoWordpressBundle
DependencyInjection/Compiler/RegisterMappingsPass.php
RegisterMappingsPass.process
public function process(ContainerBuilder $container) { if (!$container->hasParameter($this->enabledParameter)) { return; } $chainDriverDefService = $this->getChainDriverServiceName($container); $chainDriverDef = $container->getDefinition($chainDriverDefService); foreach ($this->namespaces as $namespace) { $chainDriverDef->addMethodCall('addDriver', [$this->driver, $namespace]); } }
php
public function process(ContainerBuilder $container) { if (!$container->hasParameter($this->enabledParameter)) { return; } $chainDriverDefService = $this->getChainDriverServiceName($container); $chainDriverDef = $container->getDefinition($chainDriverDefService); foreach ($this->namespaces as $namespace) { $chainDriverDef->addMethodCall('addDriver', [$this->driver, $namespace]); } }
[ "public", "function", "process", "(", "ContainerBuilder", "$", "container", ")", "{", "if", "(", "!", "$", "container", "->", "hasParameter", "(", "$", "this", "->", "enabledParameter", ")", ")", "{", "return", ";", "}", "$", "chainDriverDefService", "=", ...
Register mappings with the metadata drivers. @param ContainerBuilder $container
[ "Register", "mappings", "with", "the", "metadata", "drivers", "." ]
train
https://github.com/ekino/EkinoWordpressBundle/blob/bf3f4cac10d62d7b57ebf1fb6a5cef1780752bb8/DependencyInjection/Compiler/RegisterMappingsPass.php#L75-L87
ekino/EkinoWordpressBundle
DependencyInjection/Compiler/RegisterMappingsPass.php
RegisterMappingsPass.getChainDriverServiceName
protected function getChainDriverServiceName(ContainerBuilder $container) { foreach (['ekino_wordpress.model_manager_name', $this->fallbackManagerParameter] as $param) { if ($container->hasParameter($param)) { $name = $container->getParameter($param); if ($name) { return sprintf($this->driverPattern, $name); } } } throw new ParameterNotFoundException('None of the managerParameters resulted in a valid name'); }
php
protected function getChainDriverServiceName(ContainerBuilder $container) { foreach (['ekino_wordpress.model_manager_name', $this->fallbackManagerParameter] as $param) { if ($container->hasParameter($param)) { $name = $container->getParameter($param); if ($name) { return sprintf($this->driverPattern, $name); } } } throw new ParameterNotFoundException('None of the managerParameters resulted in a valid name'); }
[ "protected", "function", "getChainDriverServiceName", "(", "ContainerBuilder", "$", "container", ")", "{", "foreach", "(", "[", "'ekino_wordpress.model_manager_name'", ",", "$", "this", "->", "fallbackManagerParameter", "]", "as", "$", "param", ")", "{", "if", "(", ...
@param ContainerBuilder $container @throws \Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException @return string
[ "@param", "ContainerBuilder", "$container" ]
train
https://github.com/ekino/EkinoWordpressBundle/blob/bf3f4cac10d62d7b57ebf1fb6a5cef1780752bb8/DependencyInjection/Compiler/RegisterMappingsPass.php#L96-L108
ekino/EkinoWordpressBundle
DependencyInjection/Compiler/RegisterMappingsPass.php
RegisterMappingsPass.createOrmMappingDriver
public static function createOrmMappingDriver(array $mappings) { $arguments = [$mappings, '.orm.xml']; $locator = new Definition('Doctrine\Common\Persistence\Mapping\Driver\SymfonyFileLocator', $arguments); $driver = new Definition('Doctrine\ORM\Mapping\Driver\XmlDriver', [$locator]); return new self($driver, 'doctrine.orm.%s_metadata_driver', $mappings, 'ekino_wordpress.backend_type_orm', 'doctrine.default_entity_manager'); }
php
public static function createOrmMappingDriver(array $mappings) { $arguments = [$mappings, '.orm.xml']; $locator = new Definition('Doctrine\Common\Persistence\Mapping\Driver\SymfonyFileLocator', $arguments); $driver = new Definition('Doctrine\ORM\Mapping\Driver\XmlDriver', [$locator]); return new self($driver, 'doctrine.orm.%s_metadata_driver', $mappings, 'ekino_wordpress.backend_type_orm', 'doctrine.default_entity_manager'); }
[ "public", "static", "function", "createOrmMappingDriver", "(", "array", "$", "mappings", ")", "{", "$", "arguments", "=", "[", "$", "mappings", ",", "'.orm.xml'", "]", ";", "$", "locator", "=", "new", "Definition", "(", "'Doctrine\\Common\\Persistence\\Mapping\\Dr...
@param array $mappings @return RegisterMappingsPass
[ "@param", "array", "$mappings" ]
train
https://github.com/ekino/EkinoWordpressBundle/blob/bf3f4cac10d62d7b57ebf1fb6a5cef1780752bb8/DependencyInjection/Compiler/RegisterMappingsPass.php#L115-L122
ekino/EkinoWordpressBundle
Event/Hook/UserHookListener.php
UserHookListener.onLogin
public function onLogin(WordpressEvent $event) { $wpUser = $event->getParameter('user'); $user = $this->userManager->find($wpUser->data->ID); $user->setWordpressRoles($wpUser->roles); $token = new UsernamePasswordToken($user, $user->getPass(), $this->firewall, $user->getRoles()); $this->tokenStorage->setToken($token); $this->session->set('_security_'.$this->firewall, serialize($token)); }
php
public function onLogin(WordpressEvent $event) { $wpUser = $event->getParameter('user'); $user = $this->userManager->find($wpUser->data->ID); $user->setWordpressRoles($wpUser->roles); $token = new UsernamePasswordToken($user, $user->getPass(), $this->firewall, $user->getRoles()); $this->tokenStorage->setToken($token); $this->session->set('_security_'.$this->firewall, serialize($token)); }
[ "public", "function", "onLogin", "(", "WordpressEvent", "$", "event", ")", "{", "$", "wpUser", "=", "$", "event", "->", "getParameter", "(", "'user'", ")", ";", "$", "user", "=", "$", "this", "->", "userManager", "->", "find", "(", "$", "wpUser", "->",...
Wordpress user login hook method. @param WordpressEvent $event @see http://codex.wordpress.org/Plugin_API/Action_Reference/wp_login
[ "Wordpress", "user", "login", "hook", "method", "." ]
train
https://github.com/ekino/EkinoWordpressBundle/blob/bf3f4cac10d62d7b57ebf1fb6a5cef1780752bb8/Event/Hook/UserHookListener.php#L79-L90
ekino/EkinoWordpressBundle
Event/Hook/UserHookListener.php
UserHookListener.onLogout
public function onLogout(WordpressEvent $event) { $this->session->clear(); $this->tokenStorage->setToken(null); }
php
public function onLogout(WordpressEvent $event) { $this->session->clear(); $this->tokenStorage->setToken(null); }
[ "public", "function", "onLogout", "(", "WordpressEvent", "$", "event", ")", "{", "$", "this", "->", "session", "->", "clear", "(", ")", ";", "$", "this", "->", "tokenStorage", "->", "setToken", "(", "null", ")", ";", "}" ]
Wordpress user log out hook method. @param WordpressEvent $event @see http://codex.wordpress.org/Plugin_API/Action_Reference/wp_logout
[ "Wordpress", "user", "log", "out", "hook", "method", "." ]
train
https://github.com/ekino/EkinoWordpressBundle/blob/bf3f4cac10d62d7b57ebf1fb6a5cef1780752bb8/Event/Hook/UserHookListener.php#L99-L103
ekino/EkinoWordpressBundle
Security/WordpressEntryPoint.php
WordpressEntryPoint.createRedirectResponse
private function createRedirectResponse(Request $request) { $url = $this->loginUrl.'?'.http_build_query([ 'redirect_to' => $request->getUri(), 'reauth' => 0, ]); return RedirectResponse::create($url, 302); }
php
private function createRedirectResponse(Request $request) { $url = $this->loginUrl.'?'.http_build_query([ 'redirect_to' => $request->getUri(), 'reauth' => 0, ]); return RedirectResponse::create($url, 302); }
[ "private", "function", "createRedirectResponse", "(", "Request", "$", "request", ")", "{", "$", "url", "=", "$", "this", "->", "loginUrl", ".", "'?'", ".", "http_build_query", "(", "[", "'redirect_to'", "=>", "$", "request", "->", "getUri", "(", ")", ",", ...
Creates a redirect response from the given request. @param Request $request @return \Symfony\Component\HttpFoundation\Response|static
[ "Creates", "a", "redirect", "response", "from", "the", "given", "request", "." ]
train
https://github.com/ekino/EkinoWordpressBundle/blob/bf3f4cac10d62d7b57ebf1fb6a5cef1780752bb8/Security/WordpressEntryPoint.php#L71-L79
ekino/EkinoWordpressBundle
Twig/Extension/PostExtension.php
PostExtension.getPermalink
public function getPermalink($postId, $isAbsolute = false) { $post = $postId instanceof Post ? $postId : $this->postManager->find($postId); if (!$post) { throw new \UnexpectedValueException(sprintf('No post with ID "%d"', $postId)); } $permalinkStructure = $this->optionExtension->getOption('permalink_structure', '')->getValue(); $relativeUrl = $this->replacePostArguments($permalinkStructure, $post); if ($isAbsolute) { $home = $this->optionExtension->getOption('home'); return rtrim($home->getValue(), '/').'/'.ltrim($relativeUrl, '/'); } return $relativeUrl; }
php
public function getPermalink($postId, $isAbsolute = false) { $post = $postId instanceof Post ? $postId : $this->postManager->find($postId); if (!$post) { throw new \UnexpectedValueException(sprintf('No post with ID "%d"', $postId)); } $permalinkStructure = $this->optionExtension->getOption('permalink_structure', '')->getValue(); $relativeUrl = $this->replacePostArguments($permalinkStructure, $post); if ($isAbsolute) { $home = $this->optionExtension->getOption('home'); return rtrim($home->getValue(), '/').'/'.ltrim($relativeUrl, '/'); } return $relativeUrl; }
[ "public", "function", "getPermalink", "(", "$", "postId", ",", "$", "isAbsolute", "=", "false", ")", "{", "$", "post", "=", "$", "postId", "instanceof", "Post", "?", "$", "postId", ":", "$", "this", "->", "postManager", "->", "find", "(", "$", "postId"...
@param int|Post $postId A Wordpress post identifier @param bool $isAbsolute Determines if you want to retrieve an absolute URL @throws \UnexpectedValueException @return string
[ "@param", "int|Post", "$postId", "A", "Wordpress", "post", "identifier", "@param", "bool", "$isAbsolute", "Determines", "if", "you", "want", "to", "retrieve", "an", "absolute", "URL" ]
train
https://github.com/ekino/EkinoWordpressBundle/blob/bf3f4cac10d62d7b57ebf1fb6a5cef1780752bb8/Twig/Extension/PostExtension.php#L80-L99
ekino/EkinoWordpressBundle
Twig/Extension/PostExtension.php
PostExtension.replacePostArguments
public function replacePostArguments($permalinkStructure, Post $post) { $postDate = $post->getDate(); $permalinkStructure = str_replace('%year%', $postDate->format('Y'), $permalinkStructure); $permalinkStructure = str_replace('%monthnum%', $postDate->format('m'), $permalinkStructure); $permalinkStructure = str_replace('%day%', $postDate->format('d'), $permalinkStructure); $permalinkStructure = str_replace('%post_id%', $post->getId(), $permalinkStructure); $permalinkStructure = str_replace('%postname%', $post->getName(), $permalinkStructure); return $permalinkStructure; }
php
public function replacePostArguments($permalinkStructure, Post $post) { $postDate = $post->getDate(); $permalinkStructure = str_replace('%year%', $postDate->format('Y'), $permalinkStructure); $permalinkStructure = str_replace('%monthnum%', $postDate->format('m'), $permalinkStructure); $permalinkStructure = str_replace('%day%', $postDate->format('d'), $permalinkStructure); $permalinkStructure = str_replace('%post_id%', $post->getId(), $permalinkStructure); $permalinkStructure = str_replace('%postname%', $post->getName(), $permalinkStructure); return $permalinkStructure; }
[ "public", "function", "replacePostArguments", "(", "$", "permalinkStructure", ",", "Post", "$", "post", ")", "{", "$", "postDate", "=", "$", "post", "->", "getDate", "(", ")", ";", "$", "permalinkStructure", "=", "str_replace", "(", "'%year%'", ",", "$", "...
@param string $permalinkStructure @param Post $post @return string
[ "@param", "string", "$permalinkStructure", "@param", "Post", "$post" ]
train
https://github.com/ekino/EkinoWordpressBundle/blob/bf3f4cac10d62d7b57ebf1fb6a5cef1780752bb8/Twig/Extension/PostExtension.php#L107-L118