repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
eveseat/services
src/Repositories/Corporation/Divisions.php
Divisions.getCorporationDivisions
public function getCorporationDivisions(int $corporation_id): Collection { return CorporationDivision::where('corporation_id', $corporation_id) ->where('type', 'hangar') ->orderBy('division') ->get(); }
php
public function getCorporationDivisions(int $corporation_id): Collection { return CorporationDivision::where('corporation_id', $corporation_id) ->where('type', 'hangar') ->orderBy('division') ->get(); }
[ "public", "function", "getCorporationDivisions", "(", "int", "$", "corporation_id", ")", ":", "Collection", "{", "return", "CorporationDivision", "::", "where", "(", "'corporation_id'", ",", "$", "corporation_id", ")", "->", "where", "(", "'type'", ",", "'hangar'"...
Return the Divisions for a Corporation. @param int $corporation_id @return \Illuminate\Support\Collection
[ "Return", "the", "Divisions", "for", "a", "Corporation", "." ]
89562547b16d1a59f49bb0fe12426ce8d6133ee6
https://github.com/eveseat/services/blob/89562547b16d1a59f49bb0fe12426ce8d6133ee6/src/Repositories/Corporation/Divisions.php#L41-L48
train
eveseat/services
src/Repositories/Corporation/Wallet.php
Wallet.getCorporationWalletDivisions
public function getCorporationWalletDivisions(int $corporation_id): Collection { return CorporationDivision::where('corporation_id', $corporation_id) ->where('type', 'wallet') ->orderBy('division') ->get(); }
php
public function getCorporationWalletDivisions(int $corporation_id): Collection { return CorporationDivision::where('corporation_id', $corporation_id) ->where('type', 'wallet') ->orderBy('division') ->get(); }
[ "public", "function", "getCorporationWalletDivisions", "(", "int", "$", "corporation_id", ")", ":", "Collection", "{", "return", "CorporationDivision", "::", "where", "(", "'corporation_id'", ",", "$", "corporation_id", ")", "->", "where", "(", "'type'", ",", "'wa...
Return the Corporation Wallet Divisions for a Corporation. @param $corporation_id @return mixed
[ "Return", "the", "Corporation", "Wallet", "Divisions", "for", "a", "Corporation", "." ]
89562547b16d1a59f49bb0fe12426ce8d6133ee6
https://github.com/eveseat/services/blob/89562547b16d1a59f49bb0fe12426ce8d6133ee6/src/Repositories/Corporation/Wallet.php#L44-L51
train
eveseat/services
src/Repositories/Corporation/Wallet.php
Wallet.getCorporationWalletJournal
public function getCorporationWalletJournal(int $corporation_id, int $division_id) : Builder { return CorporationWalletJournal::with('first_party', 'second_party') ->where('corporation_id', $corporation_id) ->where('division', $division_id); }
php
public function getCorporationWalletJournal(int $corporation_id, int $division_id) : Builder { return CorporationWalletJournal::with('first_party', 'second_party') ->where('corporation_id', $corporation_id) ->where('division', $division_id); }
[ "public", "function", "getCorporationWalletJournal", "(", "int", "$", "corporation_id", ",", "int", "$", "division_id", ")", ":", "Builder", "{", "return", "CorporationWalletJournal", "::", "with", "(", "'first_party'", ",", "'second_party'", ")", "->", "where", "...
Return a Wallet Journal for a Corporation. @param int $corporation_id @return \Illuminate\Database\Eloquent\Builder
[ "Return", "a", "Wallet", "Journal", "for", "a", "Corporation", "." ]
89562547b16d1a59f49bb0fe12426ce8d6133ee6
https://github.com/eveseat/services/blob/89562547b16d1a59f49bb0fe12426ce8d6133ee6/src/Repositories/Corporation/Wallet.php#L76-L83
train
eveseat/services
src/Repositories/Corporation/Wallet.php
Wallet.getCorporationWalletTransactions
public function getCorporationWalletTransactions( int $corporation_id, bool $get = true, int $chunk = 50) { $transactions = CorporationWalletTransaction::where('corporation_id', $corporation_id); if ($get) return $transactions->orderBy('date', 'desc') ->paginate($chunk); return $transactions; }
php
public function getCorporationWalletTransactions( int $corporation_id, bool $get = true, int $chunk = 50) { $transactions = CorporationWalletTransaction::where('corporation_id', $corporation_id); if ($get) return $transactions->orderBy('date', 'desc') ->paginate($chunk); return $transactions; }
[ "public", "function", "getCorporationWalletTransactions", "(", "int", "$", "corporation_id", ",", "bool", "$", "get", "=", "true", ",", "int", "$", "chunk", "=", "50", ")", "{", "$", "transactions", "=", "CorporationWalletTransaction", "::", "where", "(", "'co...
Return Wallet Transactions for a Corporation. @param int $corporation_id @param bool $get @param int $chunk @return mixed
[ "Return", "Wallet", "Transactions", "for", "a", "Corporation", "." ]
89562547b16d1a59f49bb0fe12426ce8d6133ee6
https://github.com/eveseat/services/blob/89562547b16d1a59f49bb0fe12426ce8d6133ee6/src/Repositories/Corporation/Wallet.php#L94-L105
train
php-http/guzzle5-adapter
src/Client.php
Client.createRequest
private function createRequest(RequestInterface $request) { $options = [ 'exceptions' => false, 'allow_redirects' => false, ]; $options['version'] = $request->getProtocolVersion(); $options['headers'] = $request->getHeaders(); $body = (string) $request->getBody(); $options['body'] = '' === $body ? null : $body; return $this->client->createRequest( $request->getMethod(), (string) $request->getUri(), $options ); }
php
private function createRequest(RequestInterface $request) { $options = [ 'exceptions' => false, 'allow_redirects' => false, ]; $options['version'] = $request->getProtocolVersion(); $options['headers'] = $request->getHeaders(); $body = (string) $request->getBody(); $options['body'] = '' === $body ? null : $body; return $this->client->createRequest( $request->getMethod(), (string) $request->getUri(), $options ); }
[ "private", "function", "createRequest", "(", "RequestInterface", "$", "request", ")", "{", "$", "options", "=", "[", "'exceptions'", "=>", "false", ",", "'allow_redirects'", "=>", "false", ",", "]", ";", "$", "options", "[", "'version'", "]", "=", "$", "re...
Converts a PSR request into a Guzzle request. @param RequestInterface $request @return GuzzleRequest
[ "Converts", "a", "PSR", "request", "into", "a", "Guzzle", "request", "." ]
cce48360b1f8a3467bd94e853e6107aa4532008e
https://github.com/php-http/guzzle5-adapter/blob/cce48360b1f8a3467bd94e853e6107aa4532008e/src/Client.php#L66-L83
train
php-http/guzzle5-adapter
src/Client.php
Client.createResponse
private function createResponse(GuzzleResponse $response) { $body = $response->getBody(); return $this->responseFactory->createResponse( $response->getStatusCode(), null, $response->getHeaders(), isset($body) ? $body->detach() : null, $response->getProtocolVersion() ); }
php
private function createResponse(GuzzleResponse $response) { $body = $response->getBody(); return $this->responseFactory->createResponse( $response->getStatusCode(), null, $response->getHeaders(), isset($body) ? $body->detach() : null, $response->getProtocolVersion() ); }
[ "private", "function", "createResponse", "(", "GuzzleResponse", "$", "response", ")", "{", "$", "body", "=", "$", "response", "->", "getBody", "(", ")", ";", "return", "$", "this", "->", "responseFactory", "->", "createResponse", "(", "$", "response", "->", ...
Converts a Guzzle response into a PSR response. @param GuzzleResponse $response @return ResponseInterface
[ "Converts", "a", "Guzzle", "response", "into", "a", "PSR", "response", "." ]
cce48360b1f8a3467bd94e853e6107aa4532008e
https://github.com/php-http/guzzle5-adapter/blob/cce48360b1f8a3467bd94e853e6107aa4532008e/src/Client.php#L92-L103
train
Nosto/nosto-php-sdk
src/Result/Graphql/ResultSetBuilder.php
ResultSetBuilder.fromHttpResponse
public static function fromHttpResponse(HttpResponse $httpResponse) { $result = json_decode($httpResponse->getResult()); $primaryData = self::parsePrimaryData($result); $resultSet = new ResultSet(); foreach ($primaryData as $primaryDataItem) { if ($primaryDataItem instanceof \stdClass) { $primaryDataItem = ArrayHelper::stdClassToArray($primaryDataItem); } $item = new ResultItem($primaryDataItem); $resultSet->append($item); } return $resultSet; }
php
public static function fromHttpResponse(HttpResponse $httpResponse) { $result = json_decode($httpResponse->getResult()); $primaryData = self::parsePrimaryData($result); $resultSet = new ResultSet(); foreach ($primaryData as $primaryDataItem) { if ($primaryDataItem instanceof \stdClass) { $primaryDataItem = ArrayHelper::stdClassToArray($primaryDataItem); } $item = new ResultItem($primaryDataItem); $resultSet->append($item); } return $resultSet; }
[ "public", "static", "function", "fromHttpResponse", "(", "HttpResponse", "$", "httpResponse", ")", "{", "$", "result", "=", "json_decode", "(", "$", "httpResponse", "->", "getResult", "(", ")", ")", ";", "$", "primaryData", "=", "self", "::", "parsePrimaryData...
Builds a result set from HttpResponse @param HttpResponse $httpResponse @return ResultSet @throws NostoException
[ "Builds", "a", "result", "set", "from", "HttpResponse" ]
cbee56de27e613c9c594814476e53886e6fd7f38
https://github.com/Nosto/nosto-php-sdk/blob/cbee56de27e613c9c594814476e53886e6fd7f38/src/Result/Graphql/ResultSetBuilder.php#L56-L69
train
Nosto/nosto-php-sdk
src/Result/Graphql/ResultSetBuilder.php
ResultSetBuilder.parsePrimaryData
public static function parsePrimaryData(\stdClass $class) { $members = get_object_vars($class); foreach ($members as $varName => $member) { if ($varName == AbstractOperation::GRAPHQL_DATA_KEY) { return $member; } if ($member instanceof \stdClass) { return self::parsePrimaryData($member); } } throw new NostoException( sprintf( 'Could not find primary data field (%s) from response', AbstractOperation::GRAPHQL_DATA_KEY ) ); }
php
public static function parsePrimaryData(\stdClass $class) { $members = get_object_vars($class); foreach ($members as $varName => $member) { if ($varName == AbstractOperation::GRAPHQL_DATA_KEY) { return $member; } if ($member instanceof \stdClass) { return self::parsePrimaryData($member); } } throw new NostoException( sprintf( 'Could not find primary data field (%s) from response', AbstractOperation::GRAPHQL_DATA_KEY ) ); }
[ "public", "static", "function", "parsePrimaryData", "(", "\\", "stdClass", "$", "class", ")", "{", "$", "members", "=", "get_object_vars", "(", "$", "class", ")", ";", "foreach", "(", "$", "members", "as", "$", "varName", "=>", "$", "member", ")", "{", ...
Finds the primary data field from stdClass @param \stdClass $class @return array @throws NostoException
[ "Finds", "the", "primary", "data", "field", "from", "stdClass" ]
cbee56de27e613c9c594814476e53886e6fd7f38
https://github.com/Nosto/nosto-php-sdk/blob/cbee56de27e613c9c594814476e53886e6fd7f38/src/Result/Graphql/ResultSetBuilder.php#L78-L96
train
Nosto/nosto-php-sdk
src/Object/Signup/Account.php
Account.validate
protected function validate() { $validator = new ValidationHelper($this); if (!$validator->validate()) { foreach ($validator->getErrors() as $errors) { throw new NostoException(sprintf('Invalid Nosto account. %s', $errors[0])); } } }
php
protected function validate() { $validator = new ValidationHelper($this); if (!$validator->validate()) { foreach ($validator->getErrors() as $errors) { throw new NostoException(sprintf('Invalid Nosto account. %s', $errors[0])); } } }
[ "protected", "function", "validate", "(", ")", "{", "$", "validator", "=", "new", "ValidationHelper", "(", "$", "this", ")", ";", "if", "(", "!", "$", "validator", "->", "validate", "(", ")", ")", "{", "foreach", "(", "$", "validator", "->", "getErrors...
Validates the account attributes. @throws NostoException if any attribute is invalid.
[ "Validates", "the", "account", "attributes", "." ]
cbee56de27e613c9c594814476e53886e6fd7f38
https://github.com/Nosto/nosto-php-sdk/blob/cbee56de27e613c9c594814476e53886e6fd7f38/src/Object/Signup/Account.php#L78-L86
train
Nosto/nosto-php-sdk
src/Operation/OrderConfirm.php
OrderConfirm.send
public function send(OrderInterface $order, $customerId = null) { $request = new ApiRequest(); if (!empty($customerId)) { $request->setPath(ApiRequest::PATH_ORDER_TAGGING); $replaceParams = array('{m}' => $this->account->getName(), '{cid}' => $customerId); } else { $request->setPath(ApiRequest::PATH_UNMATCHED_ORDER_TAGGING); $replaceParams = array('{m}' => $this->account->getName()); } if (is_string($this->activeDomain)) { $request->setActiveDomainHeader($this->activeDomain); } if (is_string($this->account->getName())) { $request->setNostoAccountHeader($this->account->getName()); } $request->setReplaceParams($replaceParams); $response = $request->post($order); return self::checkResponse($request, $response); }
php
public function send(OrderInterface $order, $customerId = null) { $request = new ApiRequest(); if (!empty($customerId)) { $request->setPath(ApiRequest::PATH_ORDER_TAGGING); $replaceParams = array('{m}' => $this->account->getName(), '{cid}' => $customerId); } else { $request->setPath(ApiRequest::PATH_UNMATCHED_ORDER_TAGGING); $replaceParams = array('{m}' => $this->account->getName()); } if (is_string($this->activeDomain)) { $request->setActiveDomainHeader($this->activeDomain); } if (is_string($this->account->getName())) { $request->setNostoAccountHeader($this->account->getName()); } $request->setReplaceParams($replaceParams); $response = $request->post($order); return self::checkResponse($request, $response); }
[ "public", "function", "send", "(", "OrderInterface", "$", "order", ",", "$", "customerId", "=", "null", ")", "{", "$", "request", "=", "new", "ApiRequest", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "customerId", ")", ")", "{", "$", "request",...
Sends the OrderConfirm confirmation to Nosto. @param OrderInterface $order the placed OrderConfirm model. @param string|null $customerId the Nosto customer ID of the user who placed the OrderConfirm. @return true on success. @throws AbstractHttpException
[ "Sends", "the", "OrderConfirm", "confirmation", "to", "Nosto", "." ]
cbee56de27e613c9c594814476e53886e6fd7f38
https://github.com/Nosto/nosto-php-sdk/blob/cbee56de27e613c9c594814476e53886e6fd7f38/src/Operation/OrderConfirm.php#L73-L92
train
Nosto/nosto-php-sdk
src/Operation/CartOperation.php
CartOperation.updateCart
public function updateCart(Update $update, $nostoCustomerId, $accountId) { $request = new ApiRequest(); $request->setContentType(self::CONTENT_TYPE_APPLICATION_JSON); $request->setPath(ApiRequest::PATH_CART_UPDATE); $channelName = 'cartUpdated/' . $accountId . '/' . $nostoCustomerId; $data = array(); $item = array(); $item['channel'] = $channelName; $item['formats'] = array('json-object' => json_decode(SerializationHelper::serialize($update))); $data['items'] = array($item); $updateJson = json_encode($data); $response = $request->postRaw($updateJson); return $this->checkResponse($request, $response); }
php
public function updateCart(Update $update, $nostoCustomerId, $accountId) { $request = new ApiRequest(); $request->setContentType(self::CONTENT_TYPE_APPLICATION_JSON); $request->setPath(ApiRequest::PATH_CART_UPDATE); $channelName = 'cartUpdated/' . $accountId . '/' . $nostoCustomerId; $data = array(); $item = array(); $item['channel'] = $channelName; $item['formats'] = array('json-object' => json_decode(SerializationHelper::serialize($update))); $data['items'] = array($item); $updateJson = json_encode($data); $response = $request->postRaw($updateJson); return $this->checkResponse($request, $response); }
[ "public", "function", "updateCart", "(", "Update", "$", "update", ",", "$", "nostoCustomerId", ",", "$", "accountId", ")", "{", "$", "request", "=", "new", "ApiRequest", "(", ")", ";", "$", "request", "->", "setContentType", "(", "self", "::", "CONTENT_TYP...
Sends a POST request to update the cart @param Update $update the cart changes @param string $nostoCustomerId @param string $accountId merchange id @return bool if the request was successful. @throws AbstractHttpException
[ "Sends", "a", "POST", "request", "to", "update", "the", "cart" ]
cbee56de27e613c9c594814476e53886e6fd7f38
https://github.com/Nosto/nosto-php-sdk/blob/cbee56de27e613c9c594814476e53886e6fd7f38/src/Operation/CartOperation.php#L55-L70
train
Nosto/nosto-php-sdk
src/Object/Product/Product.php
Product.setDatePublished
public function setDatePublished($datePublished) { try { $this->datePublished = DateHelper::format($datePublished); } catch (\Exception $e) { throw new NostoException($e->getMessage()); } }
php
public function setDatePublished($datePublished) { try { $this->datePublished = DateHelper::format($datePublished); } catch (\Exception $e) { throw new NostoException($e->getMessage()); } }
[ "public", "function", "setDatePublished", "(", "$", "datePublished", ")", "{", "try", "{", "$", "this", "->", "datePublished", "=", "DateHelper", "::", "format", "(", "$", "datePublished", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{...
Sets the product publication date in the shop in the Y-m-d format. @param $datePublished @throws NostoException
[ "Sets", "the", "product", "publication", "date", "in", "the", "shop", "in", "the", "Y", "-", "m", "-", "d", "format", "." ]
cbee56de27e613c9c594814476e53886e6fd7f38
https://github.com/Nosto/nosto-php-sdk/blob/cbee56de27e613c9c594814476e53886e6fd7f38/src/Object/Product/Product.php#L641-L648
train
Nosto/nosto-php-sdk
src/Object/Product/Product.php
Product.addCustomField
public function addCustomField($attribute, $value) { if ($this->customFields === null) { $this->customFields = array(); } $this->customFields[$attribute] = $value; }
php
public function addCustomField($attribute, $value) { if ($this->customFields === null) { $this->customFields = array(); } $this->customFields[$attribute] = $value; }
[ "public", "function", "addCustomField", "(", "$", "attribute", ",", "$", "value", ")", "{", "if", "(", "$", "this", "->", "customFields", "===", "null", ")", "{", "$", "this", "->", "customFields", "=", "array", "(", ")", ";", "}", "$", "this", "->",...
Add a custom attribute @param $attribute @param $value
[ "Add", "a", "custom", "attribute" ]
cbee56de27e613c9c594814476e53886e6fd7f38
https://github.com/Nosto/nosto-php-sdk/blob/cbee56de27e613c9c594814476e53886e6fd7f38/src/Object/Product/Product.php#L990-L996
train
Nosto/nosto-php-sdk
src/Object/Product/Product.php
Product.altImagesToUnique
private function altImagesToUnique() { if ($this->alternateImageUrls->count() === 0) { return; } $images = $this->getAlternateImageUrls(); $resetImages = false; $duplicates = array_count_values($images); foreach ($duplicates as $val => $count) { if ($count > 1) { $resetImages = true; $images = array_unique($images); break; } } $key = array_search($this->getImageUrl(), $images, true); if ($key !== false) { $resetImages = true; unset($images[$key]); } if ($resetImages) { $this->setAlternateImageUrls(array_values($images)); } }
php
private function altImagesToUnique() { if ($this->alternateImageUrls->count() === 0) { return; } $images = $this->getAlternateImageUrls(); $resetImages = false; $duplicates = array_count_values($images); foreach ($duplicates as $val => $count) { if ($count > 1) { $resetImages = true; $images = array_unique($images); break; } } $key = array_search($this->getImageUrl(), $images, true); if ($key !== false) { $resetImages = true; unset($images[$key]); } if ($resetImages) { $this->setAlternateImageUrls(array_values($images)); } }
[ "private", "function", "altImagesToUnique", "(", ")", "{", "if", "(", "$", "this", "->", "alternateImageUrls", "->", "count", "(", ")", "===", "0", ")", "{", "return", ";", "}", "$", "images", "=", "$", "this", "->", "getAlternateImageUrls", "(", ")", ...
Makes the alternative images collection unique and removes the main product image from alt images if present
[ "Makes", "the", "alternative", "images", "collection", "unique", "and", "removes", "the", "main", "product", "image", "from", "alt", "images", "if", "present" ]
cbee56de27e613c9c594814476e53886e6fd7f38
https://github.com/Nosto/nosto-php-sdk/blob/cbee56de27e613c9c594814476e53886e6fd7f38/src/Object/Product/Product.php#L1029-L1052
train
Nosto/nosto-php-sdk
src/Helper/CurrencyHelper.php
CurrencyHelper.assertCurrency
private static function assertCurrency($code) { if (!isset(self::$data[$code])) { throw new NostoException(sprintf( 'Currency (%s) must be one of the following ISO 4217 codes: "%s".', $code, implode('", "', array_keys(self::$data)) )); } }
php
private static function assertCurrency($code) { if (!isset(self::$data[$code])) { throw new NostoException(sprintf( 'Currency (%s) must be one of the following ISO 4217 codes: "%s".', $code, implode('", "', array_keys(self::$data)) )); } }
[ "private", "static", "function", "assertCurrency", "(", "$", "code", ")", "{", "if", "(", "!", "isset", "(", "self", "::", "$", "data", "[", "$", "code", "]", ")", ")", "{", "throw", "new", "NostoException", "(", "sprintf", "(", "'Currency (%s) must be o...
Asserts that the currency code is supported. @param string $code the currency code to test. @throws NostoException
[ "Asserts", "that", "the", "currency", "code", "is", "supported", "." ]
cbee56de27e613c9c594814476e53886e6fd7f38
https://github.com/Nosto/nosto-php-sdk/blob/cbee56de27e613c9c594814476e53886e6fd7f38/src/Helper/CurrencyHelper.php#L1155-L1164
train
Nosto/nosto-php-sdk
src/Operation/AbstractOperation.php
AbstractOperation.checkResponse
protected static function checkResponse(HttpRequest $request, HttpResponse $response) { if ($response->getCode() !== 200) { throw ExceptionBuilder::fromHttpRequestAndResponse($request, $response); } return true; }
php
protected static function checkResponse(HttpRequest $request, HttpResponse $response) { if ($response->getCode() !== 200) { throw ExceptionBuilder::fromHttpRequestAndResponse($request, $response); } return true; }
[ "protected", "static", "function", "checkResponse", "(", "HttpRequest", "$", "request", ",", "HttpResponse", "$", "response", ")", "{", "if", "(", "$", "response", "->", "getCode", "(", ")", "!==", "200", ")", "{", "throw", "ExceptionBuilder", "::", "fromHtt...
Helper method to throw an exception when an API or HTTP endpoint responds with a non-200 status code. @param $request HttpRequest the HTTP request @param $response HttpResponse the HTTP response to check @return bool returns true when everything was okay @throws AbstractHttpException
[ "Helper", "method", "to", "throw", "an", "exception", "when", "an", "API", "or", "HTTP", "endpoint", "responds", "with", "a", "non", "-", "200", "status", "code", "." ]
cbee56de27e613c9c594814476e53886e6fd7f38
https://github.com/Nosto/nosto-php-sdk/blob/cbee56de27e613c9c594814476e53886e6fd7f38/src/Operation/AbstractOperation.php#L75-L81
train
Nosto/nosto-php-sdk
src/Helper/ValidationHelper.php
ValidationHelper.validate
public function validate() { $valid = true; foreach ($this->object->validationRules() as $rule) { if (isset($rule[0], $rule[1])) { $properties = $rule[0]; $validator = 'validate' . $rule[1]; if (!method_exists($this, $validator)) { throw new NostoException(sprintf( 'Nosto validator "%s" does not exist.', $validator )); } $params = array_merge(array($properties), array_slice($rule, 2)); $isValid = call_user_func_array(array($this, $validator), $params); if (!$isValid) { $valid = false; } } } return $valid; }
php
public function validate() { $valid = true; foreach ($this->object->validationRules() as $rule) { if (isset($rule[0], $rule[1])) { $properties = $rule[0]; $validator = 'validate' . $rule[1]; if (!method_exists($this, $validator)) { throw new NostoException(sprintf( 'Nosto validator "%s" does not exist.', $validator )); } $params = array_merge(array($properties), array_slice($rule, 2)); $isValid = call_user_func_array(array($this, $validator), $params); if (!$isValid) { $valid = false; } } } return $valid; }
[ "public", "function", "validate", "(", ")", "{", "$", "valid", "=", "true", ";", "foreach", "(", "$", "this", "->", "object", "->", "validationRules", "(", ")", "as", "$", "rule", ")", "{", "if", "(", "isset", "(", "$", "rule", "[", "0", "]", ","...
Validates the `validatable` object based on it's validation rules. @return bool true if the object is valid, false otherwise. @throws NostoException if the rule validator is not found.
[ "Validates", "the", "validatable", "object", "based", "on", "it", "s", "validation", "rules", "." ]
cbee56de27e613c9c594814476e53886e6fd7f38
https://github.com/Nosto/nosto-php-sdk/blob/cbee56de27e613c9c594814476e53886e6fd7f38/src/Helper/ValidationHelper.php#L74-L96
train
Nosto/nosto-php-sdk
src/Helper/ValidationHelper.php
ValidationHelper.validateRequired
protected function validateRequired(array $properties) { $valid = true; foreach ($properties as $property) { $value = $this->getPropertyValue($property); if (empty($value)) { $this->addError($property, sprintf('Property "%s" must not be empty.', $property)); $valid = false; } } return $valid; }
php
protected function validateRequired(array $properties) { $valid = true; foreach ($properties as $property) { $value = $this->getPropertyValue($property); if (empty($value)) { $this->addError($property, sprintf('Property "%s" must not be empty.', $property)); $valid = false; } } return $valid; }
[ "protected", "function", "validateRequired", "(", "array", "$", "properties", ")", "{", "$", "valid", "=", "true", ";", "foreach", "(", "$", "properties", "as", "$", "property", ")", "{", "$", "value", "=", "$", "this", "->", "getPropertyValue", "(", "$"...
Validates that all the given properties are NOT empty in this instance. @param array $properties the list of property names to validate. @return bool true if all are valid, false otherwise. @throws NostoException
[ "Validates", "that", "all", "the", "given", "properties", "are", "NOT", "empty", "in", "this", "instance", "." ]
cbee56de27e613c9c594814476e53886e6fd7f38
https://github.com/Nosto/nosto-php-sdk/blob/cbee56de27e613c9c594814476e53886e6fd7f38/src/Helper/ValidationHelper.php#L125-L136
train
Nosto/nosto-php-sdk
src/Helper/ValidationHelper.php
ValidationHelper.addError
protected function addError($attribute, $message) { if (!isset($this->errors[$attribute])) { $this->errors[$attribute] = array(); } $this->errors[$attribute][] = $message; }
php
protected function addError($attribute, $message) { if (!isset($this->errors[$attribute])) { $this->errors[$attribute] = array(); } $this->errors[$attribute][] = $message; }
[ "protected", "function", "addError", "(", "$", "attribute", ",", "$", "message", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "errors", "[", "$", "attribute", "]", ")", ")", "{", "$", "this", "->", "errors", "[", "$", "attribute", "]"...
Adds a new validation error message for the attribute. @param string $attribute the attribute name. @param string $message the error message.
[ "Adds", "a", "new", "validation", "error", "message", "for", "the", "attribute", "." ]
cbee56de27e613c9c594814476e53886e6fd7f38
https://github.com/Nosto/nosto-php-sdk/blob/cbee56de27e613c9c594814476e53886e6fd7f38/src/Helper/ValidationHelper.php#L144-L150
train
Nosto/nosto-php-sdk
src/Helper/ValidationHelper.php
ValidationHelper.validateIn
protected function validateIn(array $properties, array $values) { $valid = true; $supported = implode('", "', $values); foreach ($properties as $property) { $value = $this->getPropertyValue($property); if (!in_array($value, $values)) { $this->addError( $property, sprintf( 'Property "%s" must be one of the following: "%s".', $property, $supported ) ); $valid = false; } } return $valid; }
php
protected function validateIn(array $properties, array $values) { $valid = true; $supported = implode('", "', $values); foreach ($properties as $property) { $value = $this->getPropertyValue($property); if (!in_array($value, $values)) { $this->addError( $property, sprintf( 'Property "%s" must be one of the following: "%s".', $property, $supported ) ); $valid = false; } } return $valid; }
[ "protected", "function", "validateIn", "(", "array", "$", "properties", ",", "array", "$", "values", ")", "{", "$", "valid", "=", "true", ";", "$", "supported", "=", "implode", "(", "'\", \"'", ",", "$", "values", ")", ";", "foreach", "(", "$", "proper...
Validates that all given properties are IN the list of supplied values. @param array $properties the list of properties to validate. @param array $values the list of valid values the properties must @return bool true if all are valid, false otherwise. @throws NostoException
[ "Validates", "that", "all", "given", "properties", "are", "IN", "the", "list", "of", "supplied", "values", "." ]
cbee56de27e613c9c594814476e53886e6fd7f38
https://github.com/Nosto/nosto-php-sdk/blob/cbee56de27e613c9c594814476e53886e6fd7f38/src/Helper/ValidationHelper.php#L160-L180
train
Nosto/nosto-php-sdk
src/Helper/ValidationHelper.php
ValidationHelper.getPropertyValue
protected function getPropertyValue($property) { $getter = sprintf('get%s', $property); if (!method_exists($this->object, $getter)) { throw new NostoException( sprintf( 'Class %s does not have getter for property %s', get_class($this->object), $property ) ); } return $this->object->$getter(); }
php
protected function getPropertyValue($property) { $getter = sprintf('get%s', $property); if (!method_exists($this->object, $getter)) { throw new NostoException( sprintf( 'Class %s does not have getter for property %s', get_class($this->object), $property ) ); } return $this->object->$getter(); }
[ "protected", "function", "getPropertyValue", "(", "$", "property", ")", "{", "$", "getter", "=", "sprintf", "(", "'get%s'", ",", "$", "property", ")", ";", "if", "(", "!", "method_exists", "(", "$", "this", "->", "object", ",", "$", "getter", ")", ")",...
Gets the value of an attribute Throws an exception if the getter doesn't exist @param $property @return mixed @throws NostoException
[ "Gets", "the", "value", "of", "an", "attribute", "Throws", "an", "exception", "if", "the", "getter", "doesn", "t", "exist" ]
cbee56de27e613c9c594814476e53886e6fd7f38
https://github.com/Nosto/nosto-php-sdk/blob/cbee56de27e613c9c594814476e53886e6fd7f38/src/Helper/ValidationHelper.php#L190-L204
train
Nosto/nosto-php-sdk
src/Operation/InitiateSso.php
InitiateSso.get
public function get(UserInterface $user, $platform) { $request = $this->initHttpRequest( $this->account->getApiToken(Token::API_SSO), $this->account->getName() ); $request->setPath(ApiRequest::PATH_SSO_AUTH); $request->setContentType(self::CONTENT_TYPE_APPLICATION_JSON); $request->setReplaceParams(array('{platform}' => $platform)); $response = $request->post($user); if ($response->getCode() !== 200) { throw ExceptionBuilder::fromHttpRequestAndResponse($request, $response); } return $response->getJsonResult()->login_url; }
php
public function get(UserInterface $user, $platform) { $request = $this->initHttpRequest( $this->account->getApiToken(Token::API_SSO), $this->account->getName() ); $request->setPath(ApiRequest::PATH_SSO_AUTH); $request->setContentType(self::CONTENT_TYPE_APPLICATION_JSON); $request->setReplaceParams(array('{platform}' => $platform)); $response = $request->post($user); if ($response->getCode() !== 200) { throw ExceptionBuilder::fromHttpRequestAndResponse($request, $response); } return $response->getJsonResult()->login_url; }
[ "public", "function", "get", "(", "UserInterface", "$", "user", ",", "$", "platform", ")", "{", "$", "request", "=", "$", "this", "->", "initHttpRequest", "(", "$", "this", "->", "account", "->", "getApiToken", "(", "Token", "::", "API_SSO", ")", ",", ...
Sends a POST request to get a single sign-on URL for a store @param UserInterface $user @param $platform @return string the sso URL if the request was successful. @throws NostoException @throws AbstractHttpException
[ "Sends", "a", "POST", "request", "to", "get", "a", "single", "sign", "-", "on", "URL", "for", "a", "store" ]
cbee56de27e613c9c594814476e53886e6fd7f38
https://github.com/Nosto/nosto-php-sdk/blob/cbee56de27e613c9c594814476e53886e6fd7f38/src/Operation/InitiateSso.php#L62-L77
train
Nosto/nosto-php-sdk
src/Helper/OAuthHelper.php
OAuthHelper.getAuthorizationUrl
public static function getAuthorizationUrl(OAuthInterface $params) { $oauthBaseUrl = Nosto::getOAuthBaseUrl(); return HttpRequest::buildUri( $oauthBaseUrl . self::PATH_AUTH, array( '{cid}' => $params->getClientId(), '{uri}' => $params->getRedirectUrl(), '{sco}' => implode(' ', $params->getScopes()), '{iso}' => strtolower($params->getLanguageIsoCode()), ) ); }
php
public static function getAuthorizationUrl(OAuthInterface $params) { $oauthBaseUrl = Nosto::getOAuthBaseUrl(); return HttpRequest::buildUri( $oauthBaseUrl . self::PATH_AUTH, array( '{cid}' => $params->getClientId(), '{uri}' => $params->getRedirectUrl(), '{sco}' => implode(' ', $params->getScopes()), '{iso}' => strtolower($params->getLanguageIsoCode()), ) ); }
[ "public", "static", "function", "getAuthorizationUrl", "(", "OAuthInterface", "$", "params", ")", "{", "$", "oauthBaseUrl", "=", "Nosto", "::", "getOAuthBaseUrl", "(", ")", ";", "return", "HttpRequest", "::", "buildUri", "(", "$", "oauthBaseUrl", ".", "self", ...
Returns the authorize url to the oauth2 server. @param OAuthInterface $params @return string the url.
[ "Returns", "the", "authorize", "url", "to", "the", "oauth2", "server", "." ]
cbee56de27e613c9c594814476e53886e6fd7f38
https://github.com/Nosto/nosto-php-sdk/blob/cbee56de27e613c9c594814476e53886e6fd7f38/src/Helper/OAuthHelper.php#L57-L70
train
Nosto/nosto-php-sdk
src/Helper/HtmlMarkupSerializationHelper.php
HtmlMarkupSerializationHelper.encodableClassVariable
public static function encodableClassVariable($class, $variable) { $getter = 'get' . str_replace('_', '', $variable); $setter = 'set' . str_replace('_', '', $variable); if (!method_exists($class, $getter) || !method_exists($class, $setter)) { return false; } return true; }
php
public static function encodableClassVariable($class, $variable) { $getter = 'get' . str_replace('_', '', $variable); $setter = 'set' . str_replace('_', '', $variable); if (!method_exists($class, $getter) || !method_exists($class, $setter)) { return false; } return true; }
[ "public", "static", "function", "encodableClassVariable", "(", "$", "class", ",", "$", "variable", ")", "{", "$", "getter", "=", "'get'", ".", "str_replace", "(", "'_'", ",", "''", ",", "$", "variable", ")", ";", "$", "setter", "=", "'set'", ".", "str_...
Checks if a class variable can be encoded. In practice checks that a getter and a setter for the property is found from the class. @param $class @param $variable @return bool
[ "Checks", "if", "a", "class", "variable", "can", "be", "encoded", ".", "In", "practice", "checks", "that", "a", "getter", "and", "a", "setter", "for", "the", "property", "is", "found", "from", "the", "class", "." ]
cbee56de27e613c9c594814476e53886e6fd7f38
https://github.com/Nosto/nosto-php-sdk/blob/cbee56de27e613c9c594814476e53886e6fd7f38/src/Helper/HtmlMarkupSerializationHelper.php#L193-L202
train
Nosto/nosto-php-sdk
src/Request/Http/Adapter/Adapter.php
Adapter.init
protected function init(array $options = array()) { foreach ($options as $key => $value) { if (property_exists($this, $key)) { $this->{$key} = $value; } } }
php
protected function init(array $options = array()) { foreach ($options as $key => $value) { if (property_exists($this, $key)) { $this->{$key} = $value; } } }
[ "protected", "function", "init", "(", "array", "$", "options", "=", "array", "(", ")", ")", "{", "foreach", "(", "$", "options", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "property_exists", "(", "$", "this", ",", "$", "key", ")", ...
Initializes the request options. @param array $options the options.
[ "Initializes", "the", "request", "options", "." ]
cbee56de27e613c9c594814476e53886e6fd7f38
https://github.com/Nosto/nosto-php-sdk/blob/cbee56de27e613c9c594814476e53886e6fd7f38/src/Request/Http/Adapter/Adapter.php#L125-L132
train
Nosto/nosto-php-sdk
src/Request/Http/HttpResponse.php
HttpResponse.getCode
public function getCode() { if (is_null($this->code)) { $code = 0; if (!empty($this->headers)) { foreach ($this->headers as $header) { $matches = array(); preg_match('|HTTP/\d(\.\d)?\s+(\d+)(\s+.*)?|', $header, $matches); if (isset($matches[2])) { $code = (int)$matches[2]; } } } $this->code = $code; } return $this->code; }
php
public function getCode() { if (is_null($this->code)) { $code = 0; if (!empty($this->headers)) { foreach ($this->headers as $header) { $matches = array(); preg_match('|HTTP/\d(\.\d)?\s+(\d+)(\s+.*)?|', $header, $matches); if (isset($matches[2])) { $code = (int)$matches[2]; } } } $this->code = $code; } return $this->code; }
[ "public", "function", "getCode", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "code", ")", ")", "{", "$", "code", "=", "0", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "headers", ")", ")", "{", "foreach", "(", "$", "...
Returns the `last` http response code. @return int the http code or 0 if not set.
[ "Returns", "the", "last", "http", "response", "code", "." ]
cbee56de27e613c9c594814476e53886e6fd7f38
https://github.com/Nosto/nosto-php-sdk/blob/cbee56de27e613c9c594814476e53886e6fd7f38/src/Request/Http/HttpResponse.php#L132-L148
train
Nosto/nosto-php-sdk
src/Request/Http/HttpResponse.php
HttpResponse.getXRequestId
public function getXRequestId() { if (is_null($this->xRequestId)) { if (!empty($this->headers)) { foreach ($this->headers as $header) { $position = strpos(strtolower($header), self::HEADER_PREFIX_X_REQUEST_ID); if ($position === 0) { $this->xRequestId = substr($header, strlen(self::HEADER_PREFIX_X_REQUEST_ID)); break; } } } } return $this->xRequestId; }
php
public function getXRequestId() { if (is_null($this->xRequestId)) { if (!empty($this->headers)) { foreach ($this->headers as $header) { $position = strpos(strtolower($header), self::HEADER_PREFIX_X_REQUEST_ID); if ($position === 0) { $this->xRequestId = substr($header, strlen(self::HEADER_PREFIX_X_REQUEST_ID)); break; } } } } return $this->xRequestId; }
[ "public", "function", "getXRequestId", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "xRequestId", ")", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "headers", ")", ")", "{", "foreach", "(", "$", "this", "->", "headers"...
Get the nosto request id reply from nosto backend @return string|null
[ "Get", "the", "nosto", "request", "id", "reply", "from", "nosto", "backend" ]
cbee56de27e613c9c594814476e53886e6fd7f38
https://github.com/Nosto/nosto-php-sdk/blob/cbee56de27e613c9c594814476e53886e6fd7f38/src/Request/Http/HttpResponse.php#L155-L170
train
Nosto/nosto-php-sdk
src/Helper/SerializationHelper.php
SerializationHelper.toArray
private static function toArray($object) { $json = array(); $props = self::getProperties($object); foreach ($props as $key => $value) { $check_references = explode("_", $key); $getter = ""; if (count($check_references) > 0) { foreach ($check_references as $reference) { $getter .= ucfirst($reference); } } else { $getter = ucfirst($key); } $getter = "get" . $getter; if (!method_exists($object, $getter)) { continue; } $key = self::toSnakeCase($key); $value = $object->$getter(); if (self::isNull($value)) { continue; } if ($value instanceof \Iterator) { $value = iterator_to_array($value); } if (is_object($value)) { $json[$key] = self::toArray($value); } else { if (is_array($value)) { $json[$key] = array(); if (ArrayHelper::isAssoc($value)) { foreach ($value as $k => $anObject) { if (is_object($anObject)) { $json[$key][$k] = self::toArray($anObject); } else { $json[$key][$k] = $anObject; } } } else { foreach ($value as $anObject) { if (is_object($anObject)) { $json[$key][] = self::toArray($anObject); } else { $json[$key][] = $anObject; } } } } else { $json[$key] = $value; } } } return $json; }
php
private static function toArray($object) { $json = array(); $props = self::getProperties($object); foreach ($props as $key => $value) { $check_references = explode("_", $key); $getter = ""; if (count($check_references) > 0) { foreach ($check_references as $reference) { $getter .= ucfirst($reference); } } else { $getter = ucfirst($key); } $getter = "get" . $getter; if (!method_exists($object, $getter)) { continue; } $key = self::toSnakeCase($key); $value = $object->$getter(); if (self::isNull($value)) { continue; } if ($value instanceof \Iterator) { $value = iterator_to_array($value); } if (is_object($value)) { $json[$key] = self::toArray($value); } else { if (is_array($value)) { $json[$key] = array(); if (ArrayHelper::isAssoc($value)) { foreach ($value as $k => $anObject) { if (is_object($anObject)) { $json[$key][$k] = self::toArray($anObject); } else { $json[$key][$k] = $anObject; } } } else { foreach ($value as $anObject) { if (is_object($anObject)) { $json[$key][] = self::toArray($anObject); } else { $json[$key][] = $anObject; } } } } else { $json[$key] = $value; } } } return $json; }
[ "private", "static", "function", "toArray", "(", "$", "object", ")", "{", "$", "json", "=", "array", "(", ")", ";", "$", "props", "=", "self", "::", "getProperties", "(", "$", "object", ")", ";", "foreach", "(", "$", "props", "as", "$", "key", "=>"...
Serializes the given object to JSON using a snake-case naming convention. Arrays and objects can both be passed normally. @param $object @return array
[ "Serializes", "the", "given", "object", "to", "JSON", "using", "a", "snake", "-", "case", "naming", "convention", ".", "Arrays", "and", "objects", "can", "both", "be", "passed", "normally", "." ]
cbee56de27e613c9c594814476e53886e6fd7f38
https://github.com/Nosto/nosto-php-sdk/blob/cbee56de27e613c9c594814476e53886e6fd7f38/src/Helper/SerializationHelper.php#L77-L133
train
Nosto/nosto-php-sdk
src/Helper/SerializationHelper.php
SerializationHelper.getProperties
public static function getProperties($obj) { $properties = array(); try { $rc = new ReflectionClass($obj); do { $rp = array(); // Note that we will not include any properties in traits $traits = $rc->getTraits(); $skipProperties = array(); if (!empty($traits)) { foreach ($traits as $trait) { foreach ($trait->getProperties() as $traitProperty) { $skipProperties[] = $traitProperty->getName(); } } } /* @var $p \ReflectionProperty */ foreach ($rc->getProperties() as $p) { if (in_array($p->getName(), $skipProperties, true)) { continue; } $p->setAccessible(true); $rp[$p->getName()] = $p->getValue($obj); } $properties = array_merge($rp, $properties); } while ($rc = $rc->getParentClass()); } catch (ReflectionException $e) { // } return $properties; }
php
public static function getProperties($obj) { $properties = array(); try { $rc = new ReflectionClass($obj); do { $rp = array(); // Note that we will not include any properties in traits $traits = $rc->getTraits(); $skipProperties = array(); if (!empty($traits)) { foreach ($traits as $trait) { foreach ($trait->getProperties() as $traitProperty) { $skipProperties[] = $traitProperty->getName(); } } } /* @var $p \ReflectionProperty */ foreach ($rc->getProperties() as $p) { if (in_array($p->getName(), $skipProperties, true)) { continue; } $p->setAccessible(true); $rp[$p->getName()] = $p->getValue($obj); } $properties = array_merge($rp, $properties); } while ($rc = $rc->getParentClass()); } catch (ReflectionException $e) { // } return $properties; }
[ "public", "static", "function", "getProperties", "(", "$", "obj", ")", "{", "$", "properties", "=", "array", "(", ")", ";", "try", "{", "$", "rc", "=", "new", "ReflectionClass", "(", "$", "obj", ")", ";", "do", "{", "$", "rp", "=", "array", "(", ...
Recursively lists all the properties of the given class by traversing up the class hierarchy @param $obj object the object whose properties to list @return array the array of the keys and properties of the object
[ "Recursively", "lists", "all", "the", "properties", "of", "the", "given", "class", "by", "traversing", "up", "the", "class", "hierarchy" ]
cbee56de27e613c9c594814476e53886e6fd7f38
https://github.com/Nosto/nosto-php-sdk/blob/cbee56de27e613c9c594814476e53886e6fd7f38/src/Helper/SerializationHelper.php#L141-L173
train
Nosto/nosto-php-sdk
src/Operation/OAuth/AuthorizationCode.php
AuthorizationCode.authenticate
public function authenticate($code) { if (empty($code)) { throw new NostoException('Invalid authentication token'); } $request = new HttpRequest(); $request->setUrl(Nosto::getOAuthBaseUrl() . self::PATH_TOKEN); $request->setReplaceParams( array( '{cid}' => $this->clientId, '{sec}' => $this->clientSecret, '{uri}' => $this->redirectUrl, '{cod}' => $code ) ); $response = $request->get(); $result = $response->getJsonResult(true); if ($response->getCode() !== 200) { throw ExceptionBuilder::fromHttpRequestAndResponse($request, $response); } if (empty($result['access_token'])) { throw new NostoException('No "access_token" returned after authenticating with code'); } if (empty($result['merchant_name'])) { throw new NostoException('No "merchant_name" returned after authenticating with code'); } return NostoOAuthToken::create($result); }
php
public function authenticate($code) { if (empty($code)) { throw new NostoException('Invalid authentication token'); } $request = new HttpRequest(); $request->setUrl(Nosto::getOAuthBaseUrl() . self::PATH_TOKEN); $request->setReplaceParams( array( '{cid}' => $this->clientId, '{sec}' => $this->clientSecret, '{uri}' => $this->redirectUrl, '{cod}' => $code ) ); $response = $request->get(); $result = $response->getJsonResult(true); if ($response->getCode() !== 200) { throw ExceptionBuilder::fromHttpRequestAndResponse($request, $response); } if (empty($result['access_token'])) { throw new NostoException('No "access_token" returned after authenticating with code'); } if (empty($result['merchant_name'])) { throw new NostoException('No "merchant_name" returned after authenticating with code'); } return NostoOAuthToken::create($result); }
[ "public", "function", "authenticate", "(", "$", "code", ")", "{", "if", "(", "empty", "(", "$", "code", ")", ")", "{", "throw", "new", "NostoException", "(", "'Invalid authentication token'", ")", ";", "}", "$", "request", "=", "new", "HttpRequest", "(", ...
Authenticates the application with the given code to receive an access token. @param string $code code sent by the authorization server to exchange for an access token. @return NostoOAuthToken @throws NostoException
[ "Authenticates", "the", "application", "with", "the", "given", "code", "to", "receive", "an", "access", "token", "." ]
cbee56de27e613c9c594814476e53886e6fd7f38
https://github.com/Nosto/nosto-php-sdk/blob/cbee56de27e613c9c594814476e53886e6fd7f38/src/Operation/OAuth/AuthorizationCode.php#L98-L128
train
Nosto/nosto-php-sdk
src/Object/NostoOAuthToken.php
NostoOAuthToken.create
public static function create(array $data) { $token = new self(); foreach ($data as $key => $value) { $key = self::underscore2CamelCase($key); if (property_exists($token, $key)) { $token->{$key} = $value; } } return $token; }
php
public static function create(array $data) { $token = new self(); foreach ($data as $key => $value) { $key = self::underscore2CamelCase($key); if (property_exists($token, $key)) { $token->{$key} = $value; } } return $token; }
[ "public", "static", "function", "create", "(", "array", "$", "data", ")", "{", "$", "token", "=", "new", "self", "(", ")", ";", "foreach", "(", "$", "data", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "key", "=", "self", "::", "underscor...
Creates a new token instance and populates it with the given data. @param array $data the data to put in the token. @return NostoOAuthToken
[ "Creates", "a", "new", "token", "instance", "and", "populates", "it", "with", "the", "given", "data", "." ]
cbee56de27e613c9c594814476e53886e6fd7f38
https://github.com/Nosto/nosto-php-sdk/blob/cbee56de27e613c9c594814476e53886e6fd7f38/src/Object/NostoOAuthToken.php#L67-L77
train
Nosto/nosto-php-sdk
src/Object/Order/Order.php
Order.setCreatedAt
public function setCreatedAt($createdAt) { if ($createdAt instanceof \DateTime || (is_object($createdAt) && method_exists($createdAt, 'format'))) { $this->createdAt = $createdAt->format('Y-m-d H:i:s'); } else { $this->createdAt = $createdAt; } }
php
public function setCreatedAt($createdAt) { if ($createdAt instanceof \DateTime || (is_object($createdAt) && method_exists($createdAt, 'format'))) { $this->createdAt = $createdAt->format('Y-m-d H:i:s'); } else { $this->createdAt = $createdAt; } }
[ "public", "function", "setCreatedAt", "(", "$", "createdAt", ")", "{", "if", "(", "$", "createdAt", "instanceof", "\\", "DateTime", "||", "(", "is_object", "(", "$", "createdAt", ")", "&&", "method_exists", "(", "$", "createdAt", ",", "'format'", ")", ")",...
Sets the date when the OrderConfirm was placed in the format Y-m-d @param \DateTimeInterface|\DateTime|string $createdAt the created date.
[ "Sets", "the", "date", "when", "the", "OrderConfirm", "was", "placed", "in", "the", "format", "Y", "-", "m", "-", "d" ]
cbee56de27e613c9c594814476e53886e6fd7f38
https://github.com/Nosto/nosto-php-sdk/blob/cbee56de27e613c9c594814476e53886e6fd7f38/src/Object/Order/Order.php#L195-L203
train
Nosto/nosto-php-sdk
src/Object/Order/Order.php
Order.setOrderStatus
public function setOrderStatus(StatusInterface $orderStatus) { $this->orderStatusCode = $orderStatus->getCode(); $this->orderStatusLabel = $orderStatus->getLabel(); }
php
public function setOrderStatus(StatusInterface $orderStatus) { $this->orderStatusCode = $orderStatus->getCode(); $this->orderStatusLabel = $orderStatus->getLabel(); }
[ "public", "function", "setOrderStatus", "(", "StatusInterface", "$", "orderStatus", ")", "{", "$", "this", "->", "orderStatusCode", "=", "$", "orderStatus", "->", "getCode", "(", ")", ";", "$", "this", "->", "orderStatusLabel", "=", "$", "orderStatus", "->", ...
Sets the latest OrderConfirm status for the OrderConfirm @param StatusInterface $orderStatus the OrderConfirm status
[ "Sets", "the", "latest", "OrderConfirm", "status", "for", "the", "OrderConfirm" ]
cbee56de27e613c9c594814476e53886e6fd7f38
https://github.com/Nosto/nosto-php-sdk/blob/cbee56de27e613c9c594814476e53886e6fd7f38/src/Object/Order/Order.php#L264-L268
train
Nosto/nosto-php-sdk
src/Exception/Builder.php
Builder.fromHttpRequestAndResponse
public static function fromHttpRequestAndResponse( HttpRequest $request, HttpResponse $response ) { $message = ''; $jsonResponse = $response->getJsonResult(); $errors = self::parseErrorsFromResponse($response); if (isset($jsonResponse->type, $jsonResponse->message)) { $message .= $jsonResponse->message; if (!empty($errors)) { $message .= ' | ' . $errors; } return new ApiResponseException( $message, $response->getCode(), null, $request, $response ); } if ($response->getMessage()) { $message .= $response->getMessage(); } if (!empty($errors)) { $message .= ' | ' . $errors; } return new HttpResponseException( $message, $response->getCode(), null, $request, $response ); }
php
public static function fromHttpRequestAndResponse( HttpRequest $request, HttpResponse $response ) { $message = ''; $jsonResponse = $response->getJsonResult(); $errors = self::parseErrorsFromResponse($response); if (isset($jsonResponse->type, $jsonResponse->message)) { $message .= $jsonResponse->message; if (!empty($errors)) { $message .= ' | ' . $errors; } return new ApiResponseException( $message, $response->getCode(), null, $request, $response ); } if ($response->getMessage()) { $message .= $response->getMessage(); } if (!empty($errors)) { $message .= ' | ' . $errors; } return new HttpResponseException( $message, $response->getCode(), null, $request, $response ); }
[ "public", "static", "function", "fromHttpRequestAndResponse", "(", "HttpRequest", "$", "request", ",", "HttpResponse", "$", "response", ")", "{", "$", "message", "=", "''", ";", "$", "jsonResponse", "=", "$", "response", "->", "getJsonResult", "(", ")", ";", ...
Return HttpException exception with info about both the request and response. @param HttpRequest $request @param HttpResponse $response @return AbstractHttpException|HttpResponseException
[ "Return", "HttpException", "exception", "with", "info", "about", "both", "the", "request", "and", "response", "." ]
cbee56de27e613c9c594814476e53886e6fd7f38
https://github.com/Nosto/nosto-php-sdk/blob/cbee56de27e613c9c594814476e53886e6fd7f38/src/Exception/Builder.php#L56-L91
train
Nosto/nosto-php-sdk
src/Exception/Builder.php
Builder.parseErrorsFromResponse
public static function parseErrorsFromResponse(HttpResponse $response) { $json = $response->getJsonResult(); $errorStr = ''; if (isset($json->errors) && is_array($json->errors) && !empty($json->errors) ) { foreach ($json->errors as $stdClassError) { if (isset($stdClassError->errors)) { $errorStr .= $stdClassError->errors; } if (isset($stdClassError->product_id)) { $errorStr .= sprintf('(product #%s)', $stdClassError->product_id); } } } return $errorStr; }
php
public static function parseErrorsFromResponse(HttpResponse $response) { $json = $response->getJsonResult(); $errorStr = ''; if (isset($json->errors) && is_array($json->errors) && !empty($json->errors) ) { foreach ($json->errors as $stdClassError) { if (isset($stdClassError->errors)) { $errorStr .= $stdClassError->errors; } if (isset($stdClassError->product_id)) { $errorStr .= sprintf('(product #%s)', $stdClassError->product_id); } } } return $errorStr; }
[ "public", "static", "function", "parseErrorsFromResponse", "(", "HttpResponse", "$", "response", ")", "{", "$", "json", "=", "$", "response", "->", "getJsonResult", "(", ")", ";", "$", "errorStr", "=", "''", ";", "if", "(", "isset", "(", "$", "json", "->...
Parses errors from HttpResponse @param HttpResponse $response @return string
[ "Parses", "errors", "from", "HttpResponse" ]
cbee56de27e613c9c594814476e53886e6fd7f38
https://github.com/Nosto/nosto-php-sdk/blob/cbee56de27e613c9c594814476e53886e6fd7f38/src/Exception/Builder.php#L98-L117
train
Nosto/nosto-php-sdk
src/Operation/SyncRates.php
SyncRates.update
public function update(ExchangeRateCollection $collection) { $request = $this->initApiRequest( $this->account->getApiToken(Token::API_EXCHANGE_RATES), $this->account->getName(), $this->activeDomain ); $request->setPath(ApiRequest::PATH_CURRENCY_EXCHANGE_RATE); $response = $request->post($collection); return self::checkResponse($request, $response); }
php
public function update(ExchangeRateCollection $collection) { $request = $this->initApiRequest( $this->account->getApiToken(Token::API_EXCHANGE_RATES), $this->account->getName(), $this->activeDomain ); $request->setPath(ApiRequest::PATH_CURRENCY_EXCHANGE_RATE); $response = $request->post($collection); return self::checkResponse($request, $response); }
[ "public", "function", "update", "(", "ExchangeRateCollection", "$", "collection", ")", "{", "$", "request", "=", "$", "this", "->", "initApiRequest", "(", "$", "this", "->", "account", "->", "getApiToken", "(", "Token", "::", "API_EXCHANGE_RATES", ")", ",", ...
Updates exchange rates to Nosto @param ExchangeRateCollection $collection the collection of exchange rates to update @return bool returns true when the operation was a success @throws NostoException @throws AbstractHttpException
[ "Updates", "exchange", "rates", "to", "Nosto" ]
cbee56de27e613c9c594814476e53886e6fd7f38
https://github.com/Nosto/nosto-php-sdk/blob/cbee56de27e613c9c594814476e53886e6fd7f38/src/Operation/SyncRates.php#L69-L79
train
Nosto/nosto-php-sdk
src/Request/Api/Token.php
Token.parseTokens
public static function parseTokens(array $tokens, $prefix = '', $postfix = '') { $parsedTokens = array(); foreach (self::$tokenNames as $name) { $key = $prefix . $name . $postfix; if (isset($tokens[$key])) { $parsedTokens[$name] = new self($name, $tokens[$key]); } } return $parsedTokens; }
php
public static function parseTokens(array $tokens, $prefix = '', $postfix = '') { $parsedTokens = array(); foreach (self::$tokenNames as $name) { $key = $prefix . $name . $postfix; if (isset($tokens[$key])) { $parsedTokens[$name] = new self($name, $tokens[$key]); } } return $parsedTokens; }
[ "public", "static", "function", "parseTokens", "(", "array", "$", "tokens", ",", "$", "prefix", "=", "''", ",", "$", "postfix", "=", "''", ")", "{", "$", "parsedTokens", "=", "array", "(", ")", ";", "foreach", "(", "self", "::", "$", "tokenNames", "a...
Parses a list of token name=>value pairs and creates token instances of them. @param array $tokens the list of token name=>value pairs. @param string $prefix optional prefix for the token name in the list. @param string $postfix optional postfix for the token name in the list. @return Token[] a list of token instances.
[ "Parses", "a", "list", "of", "token", "name", "=", ">", "value", "pairs", "and", "creates", "token", "instances", "of", "them", "." ]
cbee56de27e613c9c594814476e53886e6fd7f38
https://github.com/Nosto/nosto-php-sdk/blob/cbee56de27e613c9c594814476e53886e6fd7f38/src/Request/Api/Token.php#L115-L125
train
Nosto/nosto-php-sdk
src/Util/Memory.php
Memory.getRealConsumption
public static function getRealConsumption($mb = true) { $mem = memory_get_usage(true); if ($mb === true) { $mem = round($mem/self::MB_DIVIDER, 2); } return $mem; }
php
public static function getRealConsumption($mb = true) { $mem = memory_get_usage(true); if ($mb === true) { $mem = round($mem/self::MB_DIVIDER, 2); } return $mem; }
[ "public", "static", "function", "getRealConsumption", "(", "$", "mb", "=", "true", ")", "{", "$", "mem", "=", "memory_get_usage", "(", "true", ")", ";", "if", "(", "$", "mb", "===", "true", ")", "{", "$", "mem", "=", "round", "(", "$", "mem", "/", ...
Returns the runtime memory consumption for the whole PHP @param bool $mb (if true the memory consumption is returned in megabytes) @return float|int
[ "Returns", "the", "runtime", "memory", "consumption", "for", "the", "whole", "PHP" ]
cbee56de27e613c9c594814476e53886e6fd7f38
https://github.com/Nosto/nosto-php-sdk/blob/cbee56de27e613c9c594814476e53886e6fd7f38/src/Util/Memory.php#L59-L67
train
Nosto/nosto-php-sdk
src/Util/Memory.php
Memory.getConsumption
public static function getConsumption($mb = true) { $mem = memory_get_usage(false); if ($mb === true) { $mem = round($mem/self::MB_DIVIDER, 2); } return $mem; }
php
public static function getConsumption($mb = true) { $mem = memory_get_usage(false); if ($mb === true) { $mem = round($mem/self::MB_DIVIDER, 2); } return $mem; }
[ "public", "static", "function", "getConsumption", "(", "$", "mb", "=", "true", ")", "{", "$", "mem", "=", "memory_get_usage", "(", "false", ")", ";", "if", "(", "$", "mb", "===", "true", ")", "{", "$", "mem", "=", "round", "(", "$", "mem", "/", "...
Returns the runtime memory consumption for the current PHP script @param bool $mb (if true the memory consumption is returned in megabytes) @return float|int
[ "Returns", "the", "runtime", "memory", "consumption", "for", "the", "current", "PHP", "script" ]
cbee56de27e613c9c594814476e53886e6fd7f38
https://github.com/Nosto/nosto-php-sdk/blob/cbee56de27e613c9c594814476e53886e6fd7f38/src/Util/Memory.php#L75-L83
train
Nosto/nosto-php-sdk
src/Operation/MarketingPermission.php
MarketingPermission.update
public function update($email, $hasPermission) { $request = $this->initApiRequest( $this->account->getApiToken(Token::API_EMAIL), $this->account->getName(), $this->activeDomain ); $request->setPath(ApiRequest::PATH_MARKETING_PERMISSION); $replaceParams = array('{email}' => $email, '{state}' => $hasPermission ? 'true' : 'false'); $request->setReplaceParams($replaceParams); $response = $request->postRaw(''); return self::checkResponse($request, $response); }
php
public function update($email, $hasPermission) { $request = $this->initApiRequest( $this->account->getApiToken(Token::API_EMAIL), $this->account->getName(), $this->activeDomain ); $request->setPath(ApiRequest::PATH_MARKETING_PERMISSION); $replaceParams = array('{email}' => $email, '{state}' => $hasPermission ? 'true' : 'false'); $request->setReplaceParams($replaceParams); $response = $request->postRaw(''); return self::checkResponse($request, $response); }
[ "public", "function", "update", "(", "$", "email", ",", "$", "hasPermission", ")", "{", "$", "request", "=", "$", "this", "->", "initApiRequest", "(", "$", "this", "->", "account", "->", "getApiToken", "(", "Token", "::", "API_EMAIL", ")", ",", "$", "t...
Update customer marketing permission @param string $email @param bool $hasPermission @return bool
[ "Update", "customer", "marketing", "permission" ]
cbee56de27e613c9c594814476e53886e6fd7f38
https://github.com/Nosto/nosto-php-sdk/blob/cbee56de27e613c9c594814476e53886e6fd7f38/src/Operation/MarketingPermission.php#L64-L78
train
Nosto/nosto-php-sdk
src/Operation/Recommendation/AbstractOperation.php
AbstractOperation.execute
public function execute() { $request = $this->initGraphqlRequest(); $response = $request->postRaw( $this->buildPayload() ); if ($response->getCode() !== 200) { throw ExceptionBuilder::fromHttpRequestAndResponse($request, $response); } return ResultSetBuilder::fromHttpResponse($response); }
php
public function execute() { $request = $this->initGraphqlRequest(); $response = $request->postRaw( $this->buildPayload() ); if ($response->getCode() !== 200) { throw ExceptionBuilder::fromHttpRequestAndResponse($request, $response); } return ResultSetBuilder::fromHttpResponse($response); }
[ "public", "function", "execute", "(", ")", "{", "$", "request", "=", "$", "this", "->", "initGraphqlRequest", "(", ")", ";", "$", "response", "=", "$", "request", "->", "postRaw", "(", "$", "this", "->", "buildPayload", "(", ")", ")", ";", "if", "(",...
Returns the result @return ResultSet @throws AbstractHttpException @throws NostoException @throws HttpResponseException
[ "Returns", "the", "result" ]
cbee56de27e613c9c594814476e53886e6fd7f38
https://github.com/Nosto/nosto-php-sdk/blob/cbee56de27e613c9c594814476e53886e6fd7f38/src/Operation/Recommendation/AbstractOperation.php#L112-L123
train
Nosto/nosto-php-sdk
src/Mixins/HtmlEncoderTrait.php
HtmlEncoderTrait.varsToEncode
public function varsToEncode() { if ($this->isAutoEncodeAll() === true) { $allClassVariables = array(); $vars = SerializationHelper::getProperties($this); foreach ($vars as $classVar => $val) { if (HtmlMarkupSerializationHelper::encodableClassVariable($this, $classVar)) { $allClassVariables[] = $classVar; } } return $allClassVariables; } else { return $this->varsToEncode; } }
php
public function varsToEncode() { if ($this->isAutoEncodeAll() === true) { $allClassVariables = array(); $vars = SerializationHelper::getProperties($this); foreach ($vars as $classVar => $val) { if (HtmlMarkupSerializationHelper::encodableClassVariable($this, $classVar)) { $allClassVariables[] = $classVar; } } return $allClassVariables; } else { return $this->varsToEncode; } }
[ "public", "function", "varsToEncode", "(", ")", "{", "if", "(", "$", "this", "->", "isAutoEncodeAll", "(", ")", "===", "true", ")", "{", "$", "allClassVariables", "=", "array", "(", ")", ";", "$", "vars", "=", "SerializationHelper", "::", "getProperties", ...
Returns the class variables to encode @return array
[ "Returns", "the", "class", "variables", "to", "encode" ]
cbee56de27e613c9c594814476e53886e6fd7f38
https://github.com/Nosto/nosto-php-sdk/blob/cbee56de27e613c9c594814476e53886e6fd7f38/src/Mixins/HtmlEncoderTrait.php#L62-L76
train
Nosto/nosto-php-sdk
src/Request/Http/HttpRequest.php
HttpRequest.replaceQueryParamInUrl
public static function replaceQueryParamInUrl($param, $value, $url) { $parsedUrl = self::parseUrl($url); $queryString = isset($parsedUrl['query']) ? $parsedUrl['query'] : ''; $queryString = self::replaceQueryParam($param, $value, $queryString); $parsedUrl['query'] = $queryString; return self::buildUrl($parsedUrl); }
php
public static function replaceQueryParamInUrl($param, $value, $url) { $parsedUrl = self::parseUrl($url); $queryString = isset($parsedUrl['query']) ? $parsedUrl['query'] : ''; $queryString = self::replaceQueryParam($param, $value, $queryString); $parsedUrl['query'] = $queryString; return self::buildUrl($parsedUrl); }
[ "public", "static", "function", "replaceQueryParamInUrl", "(", "$", "param", ",", "$", "value", ",", "$", "url", ")", "{", "$", "parsedUrl", "=", "self", "::", "parseUrl", "(", "$", "url", ")", ";", "$", "queryString", "=", "isset", "(", "$", "parsedUr...
Replaces or adds a query parameter to a url. @param string $param the query param name to replace. @param mixed $value the query param value to replace. @param string $url the url. @return string the updated url.
[ "Replaces", "or", "adds", "a", "query", "parameter", "to", "a", "url", "." ]
cbee56de27e613c9c594814476e53886e6fd7f38
https://github.com/Nosto/nosto-php-sdk/blob/cbee56de27e613c9c594814476e53886e6fd7f38/src/Request/Http/HttpRequest.php#L144-L151
train
Nosto/nosto-php-sdk
src/Request/Http/HttpRequest.php
HttpRequest.replaceQueryParam
public static function replaceQueryParam($param, $value, $queryString) { $parsedQuery = self::parseQueryString($queryString); $parsedQuery[$param] = $value; return http_build_query($parsedQuery); }
php
public static function replaceQueryParam($param, $value, $queryString) { $parsedQuery = self::parseQueryString($queryString); $parsedQuery[$param] = $value; return http_build_query($parsedQuery); }
[ "public", "static", "function", "replaceQueryParam", "(", "$", "param", ",", "$", "value", ",", "$", "queryString", ")", "{", "$", "parsedQuery", "=", "self", "::", "parseQueryString", "(", "$", "queryString", ")", ";", "$", "parsedQuery", "[", "$", "param...
Replaces a parameter in a query string with given value. @param string $param the query param name to replace. @param mixed $value the query param value to replace. @param string $queryString the query string. @return string the updated query string.
[ "Replaces", "a", "parameter", "in", "a", "query", "string", "with", "given", "value", "." ]
cbee56de27e613c9c594814476e53886e6fd7f38
https://github.com/Nosto/nosto-php-sdk/blob/cbee56de27e613c9c594814476e53886e6fd7f38/src/Request/Http/HttpRequest.php#L173-L178
train
Nosto/nosto-php-sdk
src/Request/Http/HttpRequest.php
HttpRequest.buildUrl
public static function buildUrl(array $parts) { $scheme = isset($parts['scheme']) ? $parts['scheme'] . '://' : ''; $host = isset($parts['host']) ? $parts['host'] : ''; $port = isset($parts['port']) ? ':' . $parts['port'] : ''; $user = isset($parts['user']) ? $parts['user'] : ''; $pass = isset($parts['pass']) ? ':' . $parts['pass'] : ''; $pass = ($user || $pass) ? "$pass@" : ''; $path = isset($parts['path']) ? $parts['path'] : ''; $query = isset($parts['query']) ? '?' . $parts['query'] : ''; $fragment = isset($parts['fragment']) ? '#' . $parts['fragment'] : ''; return $scheme . $user . $pass . $host . $port . $path . $query . $fragment; }
php
public static function buildUrl(array $parts) { $scheme = isset($parts['scheme']) ? $parts['scheme'] . '://' : ''; $host = isset($parts['host']) ? $parts['host'] : ''; $port = isset($parts['port']) ? ':' . $parts['port'] : ''; $user = isset($parts['user']) ? $parts['user'] : ''; $pass = isset($parts['pass']) ? ':' . $parts['pass'] : ''; $pass = ($user || $pass) ? "$pass@" : ''; $path = isset($parts['path']) ? $parts['path'] : ''; $query = isset($parts['query']) ? '?' . $parts['query'] : ''; $fragment = isset($parts['fragment']) ? '#' . $parts['fragment'] : ''; return $scheme . $user . $pass . $host . $port . $path . $query . $fragment; }
[ "public", "static", "function", "buildUrl", "(", "array", "$", "parts", ")", "{", "$", "scheme", "=", "isset", "(", "$", "parts", "[", "'scheme'", "]", ")", "?", "$", "parts", "[", "'scheme'", "]", ".", "'://'", ":", "''", ";", "$", "host", "=", ...
Builds a url based on given parts. @see http://php.net/manual/en/function.parse-url.php @param array $parts part(s) of an URL in form of a string or associative array like parseUrl() returns. @return string
[ "Builds", "a", "url", "based", "on", "given", "parts", "." ]
cbee56de27e613c9c594814476e53886e6fd7f38
https://github.com/Nosto/nosto-php-sdk/blob/cbee56de27e613c9c594814476e53886e6fd7f38/src/Request/Http/HttpRequest.php#L203-L215
train
Nosto/nosto-php-sdk
src/Request/Http/HttpRequest.php
HttpRequest.replaceQueryParamsInUrl
public static function replaceQueryParamsInUrl(array $queryParams, $url) { if (empty($queryParams)) { return $url; } $parsedUrl = self::parseUrl($url); $queryString = isset($parsedUrl['query']) ? $parsedUrl['query'] : ''; foreach ($queryParams as $param => $value) { $queryString = self::replaceQueryParam($param, $value, $queryString); } $parsedUrl['query'] = $queryString; return self::buildUrl($parsedUrl); }
php
public static function replaceQueryParamsInUrl(array $queryParams, $url) { if (empty($queryParams)) { return $url; } $parsedUrl = self::parseUrl($url); $queryString = isset($parsedUrl['query']) ? $parsedUrl['query'] : ''; foreach ($queryParams as $param => $value) { $queryString = self::replaceQueryParam($param, $value, $queryString); } $parsedUrl['query'] = $queryString; return self::buildUrl($parsedUrl); }
[ "public", "static", "function", "replaceQueryParamsInUrl", "(", "array", "$", "queryParams", ",", "$", "url", ")", "{", "if", "(", "empty", "(", "$", "queryParams", ")", ")", "{", "return", "$", "url", ";", "}", "$", "parsedUrl", "=", "self", "::", "pa...
Replaces or adds a query parameters to a url. @param array $queryParams the query params to replace. @param string $url the url. @return string the updated url.
[ "Replaces", "or", "adds", "a", "query", "parameters", "to", "a", "url", "." ]
cbee56de27e613c9c594814476e53886e6fd7f38
https://github.com/Nosto/nosto-php-sdk/blob/cbee56de27e613c9c594814476e53886e6fd7f38/src/Request/Http/HttpRequest.php#L224-L236
train
Nosto/nosto-php-sdk
src/Request/Http/HttpRequest.php
HttpRequest.buildUserAgent
public static function buildUserAgent($platformName, $platformVersion, $pluginVersion) { self::$userAgent = sprintf( 'Nosto %s / %s %s', $pluginVersion, $platformName, $platformVersion ); }
php
public static function buildUserAgent($platformName, $platformVersion, $pluginVersion) { self::$userAgent = sprintf( 'Nosto %s / %s %s', $pluginVersion, $platformName, $platformVersion ); }
[ "public", "static", "function", "buildUserAgent", "(", "$", "platformName", ",", "$", "platformVersion", ",", "$", "pluginVersion", ")", "{", "self", "::", "$", "userAgent", "=", "sprintf", "(", "'Nosto %s / %s %s'", ",", "$", "pluginVersion", ",", "$", "platf...
Builds the custom-user agent by using the platform's name and version with the plugin version @param string $platformName the name of the platform using the SDK @param string $platformVersion the version of the platform using the SDK @param string $pluginVersion the version of the plugin using the SDK
[ "Builds", "the", "custom", "-", "user", "agent", "by", "using", "the", "platform", "s", "name", "and", "version", "with", "the", "plugin", "version" ]
cbee56de27e613c9c594814476e53886e6fd7f38
https://github.com/Nosto/nosto-php-sdk/blob/cbee56de27e613c9c594814476e53886e6fd7f38/src/Request/Http/HttpRequest.php#L246-L254
train
Nosto/nosto-php-sdk
src/Request/Http/HttpRequest.php
HttpRequest.setAuth
public function setAuth($type, $value) { switch ($type) { case self::AUTH_BASIC: // The use of base64 encoding for authorization headers follow the RFC 2617 standard for http // authentication (https://www.ietf.org/rfc/rfc2617.txt). $this->addHeader( self::HEADER_AUTHORIZATION, 'Basic ' . base64_encode(implode(':', $value)) ); break; case self::AUTH_BEARER: $this->addHeader(self::HEADER_AUTHORIZATION, 'Bearer ' . $value); break; default: throw new NostoException('Unsupported auth type.'); } }
php
public function setAuth($type, $value) { switch ($type) { case self::AUTH_BASIC: // The use of base64 encoding for authorization headers follow the RFC 2617 standard for http // authentication (https://www.ietf.org/rfc/rfc2617.txt). $this->addHeader( self::HEADER_AUTHORIZATION, 'Basic ' . base64_encode(implode(':', $value)) ); break; case self::AUTH_BEARER: $this->addHeader(self::HEADER_AUTHORIZATION, 'Bearer ' . $value); break; default: throw new NostoException('Unsupported auth type.'); } }
[ "public", "function", "setAuth", "(", "$", "type", ",", "$", "value", ")", "{", "switch", "(", "$", "type", ")", "{", "case", "self", "::", "AUTH_BASIC", ":", "// The use of base64 encoding for authorization headers follow the RFC 2617 standard for http", "// authentica...
Setter for the request authentication header. @param string $type the auth type (use AUTH_ constants). @param mixed $value the auth header value, format depending on the auth type. @throws NostoException if an incorrect auth type is given.
[ "Setter", "for", "the", "request", "authentication", "header", "." ]
cbee56de27e613c9c594814476e53886e6fd7f38
https://github.com/Nosto/nosto-php-sdk/blob/cbee56de27e613c9c594814476e53886e6fd7f38/src/Request/Http/HttpRequest.php#L352-L371
train
Nosto/nosto-php-sdk
src/Request/Http/HttpRequest.php
HttpRequest.postRaw
public function postRaw($data) { $this->content = $data; $url = $this->url; if (!empty($this->replaceParams)) { $url = self::buildUri($url, $this->replaceParams); } $this->adapter->setResponseTimeout($this->getResponseTimeout()); $this->adapter->setConnectTimeout($this->getConnectTimeout()); return $this->adapter->post( $url, array( self::HEADERS => $this->headers, self::CONTENT => $this->content, ) ); }
php
public function postRaw($data) { $this->content = $data; $url = $this->url; if (!empty($this->replaceParams)) { $url = self::buildUri($url, $this->replaceParams); } $this->adapter->setResponseTimeout($this->getResponseTimeout()); $this->adapter->setConnectTimeout($this->getConnectTimeout()); return $this->adapter->post( $url, array( self::HEADERS => $this->headers, self::CONTENT => $this->content, ) ); }
[ "public", "function", "postRaw", "(", "$", "data", ")", "{", "$", "this", "->", "content", "=", "$", "data", ";", "$", "url", "=", "$", "this", "->", "url", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "replaceParams", ")", ")", "{", "...
Makes a POST request with the raw data @param string $data @return HttpResponse the response as returned by the endpoint
[ "Makes", "a", "POST", "request", "with", "the", "raw", "data" ]
cbee56de27e613c9c594814476e53886e6fd7f38
https://github.com/Nosto/nosto-php-sdk/blob/cbee56de27e613c9c594814476e53886e6fd7f38/src/Request/Http/HttpRequest.php#L411-L428
train
Nosto/nosto-php-sdk
src/Request/Http/HttpRequest.php
HttpRequest.put
public function put($content) { $this->content = SerializationHelper::serialize($content); $url = $this->url; if (!empty($this->replaceParams)) { $url = self::buildUri($url, $this->replaceParams); } $this->adapter->setResponseTimeout($this->getResponseTimeout()); $this->adapter->setConnectTimeout($this->getConnectTimeout()); return $this->adapter->put( $url, array( self::HEADERS => $this->headers, self::CONTENT => $this->content, ) ); }
php
public function put($content) { $this->content = SerializationHelper::serialize($content); $url = $this->url; if (!empty($this->replaceParams)) { $url = self::buildUri($url, $this->replaceParams); } $this->adapter->setResponseTimeout($this->getResponseTimeout()); $this->adapter->setConnectTimeout($this->getConnectTimeout()); return $this->adapter->put( $url, array( self::HEADERS => $this->headers, self::CONTENT => $this->content, ) ); }
[ "public", "function", "put", "(", "$", "content", ")", "{", "$", "this", "->", "content", "=", "SerializationHelper", "::", "serialize", "(", "$", "content", ")", ";", "$", "url", "=", "$", "this", "->", "url", ";", "if", "(", "!", "empty", "(", "$...
Makes a PUT request with the specified content to the configured endpoint @param mixed $content the object to be serialized to JSON and sent @return HttpResponse the response as returned by the endpoint
[ "Makes", "a", "PUT", "request", "with", "the", "specified", "content", "to", "the", "configured", "endpoint" ]
cbee56de27e613c9c594814476e53886e6fd7f38
https://github.com/Nosto/nosto-php-sdk/blob/cbee56de27e613c9c594814476e53886e6fd7f38/src/Request/Http/HttpRequest.php#L463-L480
train
Nosto/nosto-php-sdk
src/Request/Http/HttpRequest.php
HttpRequest.get
public function get() { $url = $this->url; if (!empty($this->replaceParams)) { $url = self::buildUri($url, $this->replaceParams); } if (!empty($this->queryParams)) { $url .= '?' . http_build_query($this->queryParams); } $this->adapter->setResponseTimeout($this->getResponseTimeout()); $this->adapter->setConnectTimeout($this->getConnectTimeout()); return $this->adapter->get( $url, array( self::HEADERS => $this->headers, ) ); }
php
public function get() { $url = $this->url; if (!empty($this->replaceParams)) { $url = self::buildUri($url, $this->replaceParams); } if (!empty($this->queryParams)) { $url .= '?' . http_build_query($this->queryParams); } $this->adapter->setResponseTimeout($this->getResponseTimeout()); $this->adapter->setConnectTimeout($this->getConnectTimeout()); return $this->adapter->get( $url, array( self::HEADERS => $this->headers, ) ); }
[ "public", "function", "get", "(", ")", "{", "$", "url", "=", "$", "this", "->", "url", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "replaceParams", ")", ")", "{", "$", "url", "=", "self", "::", "buildUri", "(", "$", "url", ",", "$", ...
Makes a GET request with the specified content to the configured endpoint @return HttpResponse the response as returned by the endpoint
[ "Makes", "a", "GET", "request", "with", "the", "specified", "content", "to", "the", "configured", "endpoint" ]
cbee56de27e613c9c594814476e53886e6fd7f38
https://github.com/Nosto/nosto-php-sdk/blob/cbee56de27e613c9c594814476e53886e6fd7f38/src/Request/Http/HttpRequest.php#L487-L505
train
Nosto/nosto-php-sdk
src/Request/Http/HttpRequest.php
HttpRequest.delete
public function delete() { $url = $this->url; if (!empty($this->replaceParams)) { $url = self::buildUri($url, $this->replaceParams); } $this->adapter->setResponseTimeout($this->getResponseTimeout()); $this->adapter->setConnectTimeout($this->getConnectTimeout()); return $this->adapter->delete( $url, array( self::HEADERS => $this->headers, ) ); }
php
public function delete() { $url = $this->url; if (!empty($this->replaceParams)) { $url = self::buildUri($url, $this->replaceParams); } $this->adapter->setResponseTimeout($this->getResponseTimeout()); $this->adapter->setConnectTimeout($this->getConnectTimeout()); return $this->adapter->delete( $url, array( self::HEADERS => $this->headers, ) ); }
[ "public", "function", "delete", "(", ")", "{", "$", "url", "=", "$", "this", "->", "url", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "replaceParams", ")", ")", "{", "$", "url", "=", "self", "::", "buildUri", "(", "$", "url", ",", "$"...
Makes a DELETE request with the specified content to the configured endpoint @return HttpResponse the response as returned by the endpoint
[ "Makes", "a", "DELETE", "request", "with", "the", "specified", "content", "to", "the", "configured", "endpoint" ]
cbee56de27e613c9c594814476e53886e6fd7f38
https://github.com/Nosto/nosto-php-sdk/blob/cbee56de27e613c9c594814476e53886e6fd7f38/src/Request/Http/HttpRequest.php#L512-L527
train
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/Formatting/AlphabeticClassContentSniff.php
AlphabeticClassContentSniff.checkAndRegisterSortingProblems
private function checkAndRegisterSortingProblems(array $foundContentsOrg, array $foundContentsSorted): void { $checkIndex = 0; foreach ($foundContentsOrg as $foundContentPos => $foundContent) { if ($foundContentsSorted[$checkIndex++] !== $foundContent) { $this->file->getBaseFile()->addWarning( self::MESSAGE_SORT_ALPHABETICALLY, $foundContentPos, static::CODE_SORT_ALPHABETICALLY ); } } }
php
private function checkAndRegisterSortingProblems(array $foundContentsOrg, array $foundContentsSorted): void { $checkIndex = 0; foreach ($foundContentsOrg as $foundContentPos => $foundContent) { if ($foundContentsSorted[$checkIndex++] !== $foundContent) { $this->file->getBaseFile()->addWarning( self::MESSAGE_SORT_ALPHABETICALLY, $foundContentPos, static::CODE_SORT_ALPHABETICALLY ); } } }
[ "private", "function", "checkAndRegisterSortingProblems", "(", "array", "$", "foundContentsOrg", ",", "array", "$", "foundContentsSorted", ")", ":", "void", "{", "$", "checkIndex", "=", "0", ";", "foreach", "(", "$", "foundContentsOrg", "as", "$", "foundContentPos...
Checks the sorting of both arrays and registered warnings, if a token is not on the correct position. @param array $foundContentsOrg The original contents with their position. @param array $foundContentsSorted The sorted contents without their position as array key. @return void
[ "Checks", "the", "sorting", "of", "both", "arrays", "and", "registered", "warnings", "if", "a", "token", "is", "not", "on", "the", "correct", "position", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/Formatting/AlphabeticClassContentSniff.php#L46-L59
train
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/Formatting/AlphabeticClassContentSniff.php
AlphabeticClassContentSniff.checkAndRegisterSortingProblemsOfTypes
private function checkAndRegisterSortingProblemsOfTypes(int $token): void { $foundContentsOrg = $this->getContentsOfTokenType($token); $foundContentsSorted = $this->sortTokensWithoutPos($foundContentsOrg); $this->checkAndRegisterSortingProblems($foundContentsOrg, $foundContentsSorted); }
php
private function checkAndRegisterSortingProblemsOfTypes(int $token): void { $foundContentsOrg = $this->getContentsOfTokenType($token); $foundContentsSorted = $this->sortTokensWithoutPos($foundContentsOrg); $this->checkAndRegisterSortingProblems($foundContentsOrg, $foundContentsSorted); }
[ "private", "function", "checkAndRegisterSortingProblemsOfTypes", "(", "int", "$", "token", ")", ":", "void", "{", "$", "foundContentsOrg", "=", "$", "this", "->", "getContentsOfTokenType", "(", "$", "token", ")", ";", "$", "foundContentsSorted", "=", "$", "this"...
Loads every content for the token type and checks their sorting. @param int $token @return void
[ "Loads", "every", "content", "for", "the", "token", "type", "and", "checks", "their", "sorting", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/Formatting/AlphabeticClassContentSniff.php#L68-L75
train
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/Formatting/AlphabeticClassContentSniff.php
AlphabeticClassContentSniff.getContentsOfTokenType
private function getContentsOfTokenType(int $token): array { $helper = new PropertyHelper($this->file); $tokenPoss = TokenHelper::findNextAll( $this->file->getBaseFile(), [$token], $this->stackPos + 1, $this->token['scope_closer'] ); $foundContentsOrg = []; foreach ($tokenPoss as $tokenPos) { $tokenContentPos = $tokenPos; if (($token === T_VARIABLE) && (!$helper->isProperty($tokenPos))) { continue; } if ($token !== T_VARIABLE) { $tokenContentPos = $this->file->findNext([T_STRING], $tokenPos); } $foundContentsOrg[$tokenContentPos] = $this->tokens[$tokenContentPos]['content']; } return $foundContentsOrg; }
php
private function getContentsOfTokenType(int $token): array { $helper = new PropertyHelper($this->file); $tokenPoss = TokenHelper::findNextAll( $this->file->getBaseFile(), [$token], $this->stackPos + 1, $this->token['scope_closer'] ); $foundContentsOrg = []; foreach ($tokenPoss as $tokenPos) { $tokenContentPos = $tokenPos; if (($token === T_VARIABLE) && (!$helper->isProperty($tokenPos))) { continue; } if ($token !== T_VARIABLE) { $tokenContentPos = $this->file->findNext([T_STRING], $tokenPos); } $foundContentsOrg[$tokenContentPos] = $this->tokens[$tokenContentPos]['content']; } return $foundContentsOrg; }
[ "private", "function", "getContentsOfTokenType", "(", "int", "$", "token", ")", ":", "array", "{", "$", "helper", "=", "new", "PropertyHelper", "(", "$", "this", "->", "file", ")", ";", "$", "tokenPoss", "=", "TokenHelper", "::", "findNextAll", "(", "$", ...
Returns the contents of the token type. @param int $token The contents with their position as array key. @return array
[ "Returns", "the", "contents", "of", "the", "token", "type", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/Formatting/AlphabeticClassContentSniff.php#L84-L111
train
joomla-framework/ldap
src/LdapClient.php
LdapClient.anonymous_bind
public function anonymous_bind() { if (!$this->isConnected()) { if (!$this->connect()) { return false; } } $this->isBound = ldap_bind($this->resource); return $this->isBound; }
php
public function anonymous_bind() { if (!$this->isConnected()) { if (!$this->connect()) { return false; } } $this->isBound = ldap_bind($this->resource); return $this->isBound; }
[ "public", "function", "anonymous_bind", "(", ")", "{", "if", "(", "!", "$", "this", "->", "isConnected", "(", ")", ")", "{", "if", "(", "!", "$", "this", "->", "connect", "(", ")", ")", "{", "return", "false", ";", "}", "}", "$", "this", "->", ...
Anonymously binds to LDAP directory @return boolean @since 1.0
[ "Anonymously", "binds", "to", "LDAP", "directory" ]
2b81fb2bb0a95b66d8aa1e3a4b6875990f5adf46
https://github.com/joomla-framework/ldap/blob/2b81fb2bb0a95b66d8aa1e3a4b6875990f5adf46/src/LdapClient.php#L296-L309
train
joomla-framework/ldap
src/LdapClient.php
LdapClient.unbind
public function unbind() { if ($this->isBound && $this->resource && \is_resource($this->resource)) { return ldap_unbind($this->resource); } return true; }
php
public function unbind() { if ($this->isBound && $this->resource && \is_resource($this->resource)) { return ldap_unbind($this->resource); } return true; }
[ "public", "function", "unbind", "(", ")", "{", "if", "(", "$", "this", "->", "isBound", "&&", "$", "this", "->", "resource", "&&", "\\", "is_resource", "(", "$", "this", "->", "resource", ")", ")", "{", "return", "ldap_unbind", "(", "$", "this", "->"...
Unbinds from the LDAP directory @return boolean @since 1.3.0
[ "Unbinds", "from", "the", "LDAP", "directory" ]
2b81fb2bb0a95b66d8aa1e3a4b6875990f5adf46
https://github.com/joomla-framework/ldap/blob/2b81fb2bb0a95b66d8aa1e3a4b6875990f5adf46/src/LdapClient.php#L356-L364
train
joomla-framework/ldap
src/LdapClient.php
LdapClient.simple_search
public function simple_search($search) { $results = explode(';', $search); foreach ($results as $key => $result) { $results[$key] = '(' . $result . ')'; } return $this->search($results); }
php
public function simple_search($search) { $results = explode(';', $search); foreach ($results as $key => $result) { $results[$key] = '(' . $result . ')'; } return $this->search($results); }
[ "public", "function", "simple_search", "(", "$", "search", ")", "{", "$", "results", "=", "explode", "(", "';'", ",", "$", "search", ")", ";", "foreach", "(", "$", "results", "as", "$", "key", "=>", "$", "result", ")", "{", "$", "results", "[", "$"...
Perform an LDAP search using comma separated search strings @param string $search search string of search values @return array Search results @since 1.0
[ "Perform", "an", "LDAP", "search", "using", "comma", "separated", "search", "strings" ]
2b81fb2bb0a95b66d8aa1e3a4b6875990f5adf46
https://github.com/joomla-framework/ldap/blob/2b81fb2bb0a95b66d8aa1e3a4b6875990f5adf46/src/LdapClient.php#L375-L385
train
joomla-framework/ldap
src/LdapClient.php
LdapClient.replace
public function replace($dn, $attribute) { if (!$this->isBound || !$this->isConnected()) { return false; } return ldap_mod_replace($this->resource, $dn, $attribute); }
php
public function replace($dn, $attribute) { if (!$this->isBound || !$this->isConnected()) { return false; } return ldap_mod_replace($this->resource, $dn, $attribute); }
[ "public", "function", "replace", "(", "$", "dn", ",", "$", "attribute", ")", "{", "if", "(", "!", "$", "this", "->", "isBound", "||", "!", "$", "this", "->", "isConnected", "(", ")", ")", "{", "return", "false", ";", "}", "return", "ldap_mod_replace"...
Replace attribute values with new ones @param string $dn The DN which contains the attribute you want to replace @param string $attribute The attribute values you want to replace @return boolean @since 1.0
[ "Replace", "attribute", "values", "with", "new", "ones" ]
2b81fb2bb0a95b66d8aa1e3a4b6875990f5adf46
https://github.com/joomla-framework/ldap/blob/2b81fb2bb0a95b66d8aa1e3a4b6875990f5adf46/src/LdapClient.php#L471-L479
train
joomla-framework/ldap
src/LdapClient.php
LdapClient.modify
public function modify($dn, $attribute) { if (!$this->isBound || !$this->isConnected()) { return false; } return ldap_modify($this->resource, $dn, $attribute); }
php
public function modify($dn, $attribute) { if (!$this->isBound || !$this->isConnected()) { return false; } return ldap_modify($this->resource, $dn, $attribute); }
[ "public", "function", "modify", "(", "$", "dn", ",", "$", "attribute", ")", "{", "if", "(", "!", "$", "this", "->", "isBound", "||", "!", "$", "this", "->", "isConnected", "(", ")", ")", "{", "return", "false", ";", "}", "return", "ldap_modify", "(...
Modify an LDAP entry @param string $dn The DN which contains the attribute you want to modify @param string $attribute The attribute values you want to modify @return boolean @since 1.0
[ "Modify", "an", "LDAP", "entry" ]
2b81fb2bb0a95b66d8aa1e3a4b6875990f5adf46
https://github.com/joomla-framework/ldap/blob/2b81fb2bb0a95b66d8aa1e3a4b6875990f5adf46/src/LdapClient.php#L491-L499
train
joomla-framework/ldap
src/LdapClient.php
LdapClient.remove
public function remove($dn, $attribute) { if (!$this->isBound || !$this->isConnected()) { return false; } return ldap_mod_del($this->resource, $dn, $attribute); }
php
public function remove($dn, $attribute) { if (!$this->isBound || !$this->isConnected()) { return false; } return ldap_mod_del($this->resource, $dn, $attribute); }
[ "public", "function", "remove", "(", "$", "dn", ",", "$", "attribute", ")", "{", "if", "(", "!", "$", "this", "->", "isBound", "||", "!", "$", "this", "->", "isConnected", "(", ")", ")", "{", "return", "false", ";", "}", "return", "ldap_mod_del", "...
Delete attribute values from current attributes @param string $dn The DN which contains the attribute you want to remove @param string $attribute The attribute values you want to remove @return boolean @since 1.0
[ "Delete", "attribute", "values", "from", "current", "attributes" ]
2b81fb2bb0a95b66d8aa1e3a4b6875990f5adf46
https://github.com/joomla-framework/ldap/blob/2b81fb2bb0a95b66d8aa1e3a4b6875990f5adf46/src/LdapClient.php#L511-L519
train
joomla-framework/ldap
src/LdapClient.php
LdapClient.compare
public function compare($dn, $attribute, $value) { if (!$this->isBound || !$this->isConnected()) { return false; } return ldap_compare($this->resource, $dn, $attribute, $value); }
php
public function compare($dn, $attribute, $value) { if (!$this->isBound || !$this->isConnected()) { return false; } return ldap_compare($this->resource, $dn, $attribute, $value); }
[ "public", "function", "compare", "(", "$", "dn", ",", "$", "attribute", ",", "$", "value", ")", "{", "if", "(", "!", "$", "this", "->", "isBound", "||", "!", "$", "this", "->", "isConnected", "(", ")", ")", "{", "return", "false", ";", "}", "retu...
Compare value of attribute found in entry specified with DN @param string $dn The DN which contains the attribute you want to compare @param string $attribute The attribute whose value you want to compare @param string $value The value you want to check against the LDAP attribute @return boolean|integer Boolean result of the comparison or -1 on error @since 1.0
[ "Compare", "value", "of", "attribute", "found", "in", "entry", "specified", "with", "DN" ]
2b81fb2bb0a95b66d8aa1e3a4b6875990f5adf46
https://github.com/joomla-framework/ldap/blob/2b81fb2bb0a95b66d8aa1e3a4b6875990f5adf46/src/LdapClient.php#L532-L540
train
joomla-framework/ldap
src/LdapClient.php
LdapClient.read
public function read($dn) { if (!$this->isBound || !$this->isConnected()) { return false; } $base = substr($dn, strpos($dn, ',') + 1); $cn = substr($dn, 0, strpos($dn, ',')); $result = ldap_read($this->resource, $base, $cn); if ($result === false) { return false; } return ldap_get_entries($this->resource, $result); }
php
public function read($dn) { if (!$this->isBound || !$this->isConnected()) { return false; } $base = substr($dn, strpos($dn, ',') + 1); $cn = substr($dn, 0, strpos($dn, ',')); $result = ldap_read($this->resource, $base, $cn); if ($result === false) { return false; } return ldap_get_entries($this->resource, $result); }
[ "public", "function", "read", "(", "$", "dn", ")", "{", "if", "(", "!", "$", "this", "->", "isBound", "||", "!", "$", "this", "->", "isConnected", "(", ")", ")", "{", "return", "false", ";", "}", "$", "base", "=", "substr", "(", "$", "dn", ",",...
Read attributes of a given DN @param string $dn The DN of the object you want to read @return array|boolean Array of attributes for the given DN or boolean false on failure @since 1.0
[ "Read", "attributes", "of", "a", "given", "DN" ]
2b81fb2bb0a95b66d8aa1e3a4b6875990f5adf46
https://github.com/joomla-framework/ldap/blob/2b81fb2bb0a95b66d8aa1e3a4b6875990f5adf46/src/LdapClient.php#L551-L568
train
joomla-framework/ldap
src/LdapClient.php
LdapClient.delete
public function delete($dn) { if (!$this->isBound || !$this->isConnected()) { return false; } return ldap_delete($this->resource, $dn); }
php
public function delete($dn) { if (!$this->isBound || !$this->isConnected()) { return false; } return ldap_delete($this->resource, $dn); }
[ "public", "function", "delete", "(", "$", "dn", ")", "{", "if", "(", "!", "$", "this", "->", "isBound", "||", "!", "$", "this", "->", "isConnected", "(", ")", ")", "{", "return", "false", ";", "}", "return", "ldap_delete", "(", "$", "this", "->", ...
Delete an entry from a directory @param string $dn The DN of the object you want to delete @return boolean @since 1.0
[ "Delete", "an", "entry", "from", "a", "directory" ]
2b81fb2bb0a95b66d8aa1e3a4b6875990f5adf46
https://github.com/joomla-framework/ldap/blob/2b81fb2bb0a95b66d8aa1e3a4b6875990f5adf46/src/LdapClient.php#L579-L587
train
joomla-framework/ldap
src/LdapClient.php
LdapClient.create
public function create($dn, array $entries) { if (!$this->isBound || !$this->isConnected()) { return false; } return ldap_add($this->resource, $dn, $entries); }
php
public function create($dn, array $entries) { if (!$this->isBound || !$this->isConnected()) { return false; } return ldap_add($this->resource, $dn, $entries); }
[ "public", "function", "create", "(", "$", "dn", ",", "array", "$", "entries", ")", "{", "if", "(", "!", "$", "this", "->", "isBound", "||", "!", "$", "this", "->", "isConnected", "(", ")", ")", "{", "return", "false", ";", "}", "return", "ldap_add"...
Add entries to LDAP directory @param string $dn The DN where you want to put the object @param array $entries An array of arrays describing the object to add @return boolean @since 1.0
[ "Add", "entries", "to", "LDAP", "directory" ]
2b81fb2bb0a95b66d8aa1e3a4b6875990f5adf46
https://github.com/joomla-framework/ldap/blob/2b81fb2bb0a95b66d8aa1e3a4b6875990f5adf46/src/LdapClient.php#L599-L607
train
joomla-framework/ldap
src/LdapClient.php
LdapClient.add
public function add($dn, array $entry) { if (!$this->isBound || !$this->isConnected()) { return false; } return ldap_mod_add($this->resource, $dn, $entry); }
php
public function add($dn, array $entry) { if (!$this->isBound || !$this->isConnected()) { return false; } return ldap_mod_add($this->resource, $dn, $entry); }
[ "public", "function", "add", "(", "$", "dn", ",", "array", "$", "entry", ")", "{", "if", "(", "!", "$", "this", "->", "isBound", "||", "!", "$", "this", "->", "isConnected", "(", ")", ")", "{", "return", "false", ";", "}", "return", "ldap_mod_add",...
Add attribute values to current attributes @param string $dn The DN of the entry to add the attribute @param array $entry An array of arrays with attributes to add @return boolean @since 1.0
[ "Add", "attribute", "values", "to", "current", "attributes" ]
2b81fb2bb0a95b66d8aa1e3a4b6875990f5adf46
https://github.com/joomla-framework/ldap/blob/2b81fb2bb0a95b66d8aa1e3a4b6875990f5adf46/src/LdapClient.php#L619-L627
train
joomla-framework/ldap
src/LdapClient.php
LdapClient.rename
public function rename($dn, $newdn, $newparent, $deleteolddn) { if (!$this->isBound || !$this->isConnected()) { return false; } return ldap_rename($this->resource, $dn, $newdn, $newparent, $deleteolddn); }
php
public function rename($dn, $newdn, $newparent, $deleteolddn) { if (!$this->isBound || !$this->isConnected()) { return false; } return ldap_rename($this->resource, $dn, $newdn, $newparent, $deleteolddn); }
[ "public", "function", "rename", "(", "$", "dn", ",", "$", "newdn", ",", "$", "newparent", ",", "$", "deleteolddn", ")", "{", "if", "(", "!", "$", "this", "->", "isBound", "||", "!", "$", "this", "->", "isConnected", "(", ")", ")", "{", "return", ...
Modify the name of an entry @param string $dn The DN of the entry at the moment @param string $newdn The DN of the entry should be (only cn=newvalue) @param string $newparent The full DN of the parent (null by default) @param boolean $deleteolddn Delete the old values (default) @return boolean @since 1.0
[ "Modify", "the", "name", "of", "an", "entry" ]
2b81fb2bb0a95b66d8aa1e3a4b6875990f5adf46
https://github.com/joomla-framework/ldap/blob/2b81fb2bb0a95b66d8aa1e3a4b6875990f5adf46/src/LdapClient.php#L641-L649
train
bestit/PHP_CodeSniffer
src/Standards/BestIt/CodeSniffer/Helper/ExceptionHelper.php
ExceptionHelper.handleException
public function handleException(CodeWarning $exception): bool { $isError = $exception instanceof CodeError; $isFixable = $exception->isFixable(); $method = 'add'; if ($isFixable) { $method .= 'Fixable'; } $method .= $isError ? 'Error' : 'Warning'; return $this->file->$method( $exception->getMessage(), $exception->getStackPosition(), $exception->getCode(), $exception->getPayload() ); }
php
public function handleException(CodeWarning $exception): bool { $isError = $exception instanceof CodeError; $isFixable = $exception->isFixable(); $method = 'add'; if ($isFixable) { $method .= 'Fixable'; } $method .= $isError ? 'Error' : 'Warning'; return $this->file->$method( $exception->getMessage(), $exception->getStackPosition(), $exception->getCode(), $exception->getPayload() ); }
[ "public", "function", "handleException", "(", "CodeWarning", "$", "exception", ")", ":", "bool", "{", "$", "isError", "=", "$", "exception", "instanceof", "CodeError", ";", "$", "isFixable", "=", "$", "exception", "->", "isFixable", "(", ")", ";", "$", "me...
Registers the exception as an error or warning on the file. @param CodeWarning $exception The error which should be handled. @return bool Should this error be fixed?
[ "Registers", "the", "exception", "as", "an", "error", "or", "warning", "on", "the", "file", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/CodeSniffer/Helper/ExceptionHelper.php#L43-L61
train
mimmi20/BrowserDetector
src/Parser/BrowserParser.php
BrowserParser.parse
public function parse(string $useragent): array { $mode = $this->fileParser->parseFile( new \SplFileInfo(self::GENERIC_FILE), $useragent, 'unknown' ); $key = $this->fileParser->parseFile( new \SplFileInfo(sprintf(self::SPECIFIC_FILE, $mode)), $useragent, 'unknown' ); return $this->load($key, $useragent); }
php
public function parse(string $useragent): array { $mode = $this->fileParser->parseFile( new \SplFileInfo(self::GENERIC_FILE), $useragent, 'unknown' ); $key = $this->fileParser->parseFile( new \SplFileInfo(sprintf(self::SPECIFIC_FILE, $mode)), $useragent, 'unknown' ); return $this->load($key, $useragent); }
[ "public", "function", "parse", "(", "string", "$", "useragent", ")", ":", "array", "{", "$", "mode", "=", "$", "this", "->", "fileParser", "->", "parseFile", "(", "new", "\\", "SplFileInfo", "(", "self", "::", "GENERIC_FILE", ")", ",", "$", "useragent", ...
Gets the information about the browser by User Agent @param string $useragent @throws \ExceptionalJSON\DecodeErrorException @return array
[ "Gets", "the", "information", "about", "the", "browser", "by", "User", "Agent" ]
1b90d994fcee01344a36bbe39afb14622bc8df9c
https://github.com/mimmi20/BrowserDetector/blob/1b90d994fcee01344a36bbe39afb14622bc8df9c/src/Parser/BrowserParser.php#L55-L70
train
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/Formatting/AlphabeticallySortedUsesSniff.php
AlphabeticallySortedUsesSniff.areRequirementsMet
protected function areRequirementsMet(): bool { return (bool) $this->useStatements = UseStatementHelper::getUseStatements( $this->getFile()->getBaseFile(), $this->getStackPos() ); }
php
protected function areRequirementsMet(): bool { return (bool) $this->useStatements = UseStatementHelper::getUseStatements( $this->getFile()->getBaseFile(), $this->getStackPos() ); }
[ "protected", "function", "areRequirementsMet", "(", ")", ":", "bool", "{", "return", "(", "bool", ")", "$", "this", "->", "useStatements", "=", "UseStatementHelper", "::", "getUseStatements", "(", "$", "this", "->", "getFile", "(", ")", "->", "getBaseFile", ...
Returns true if we have use statements. @return bool
[ "Returns", "true", "if", "we", "have", "use", "statements", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/Formatting/AlphabeticallySortedUsesSniff.php#L46-L52
train
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/Formatting/AlphabeticallySortedUsesSniff.php
AlphabeticallySortedUsesSniff.compareUseStatements
private function compareUseStatements(UseStatement $prevStatement, UseStatement $nextStatement): int { $callbacks = [ 'compareUseStatementsByType', 'compareUseStatementsByContent', // This will return something in any case! 'compareUseStatementsByNamespaceCount' ]; foreach ($callbacks as $callback) { $compared = $this->$callback($prevStatement, $nextStatement); if ($compared !== null) { return $compared; } } }
php
private function compareUseStatements(UseStatement $prevStatement, UseStatement $nextStatement): int { $callbacks = [ 'compareUseStatementsByType', 'compareUseStatementsByContent', // This will return something in any case! 'compareUseStatementsByNamespaceCount' ]; foreach ($callbacks as $callback) { $compared = $this->$callback($prevStatement, $nextStatement); if ($compared !== null) { return $compared; } } }
[ "private", "function", "compareUseStatements", "(", "UseStatement", "$", "prevStatement", ",", "UseStatement", "$", "nextStatement", ")", ":", "int", "{", "$", "callbacks", "=", "[", "'compareUseStatementsByType'", ",", "'compareUseStatementsByContent'", ",", "// This w...
Will removing a compare marker for the given use statements. @param UseStatement $prevStatement @param UseStatement $nextStatement @return int 1 <=> -1 To move statements in a direction.
[ "Will", "removing", "a", "compare", "marker", "for", "the", "given", "use", "statements", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/Formatting/AlphabeticallySortedUsesSniff.php#L62-L78
train
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/Formatting/AlphabeticallySortedUsesSniff.php
AlphabeticallySortedUsesSniff.compareUseStatementsByContent
private function compareUseStatementsByContent(UseStatement $prevStatement, UseStatement $nextStatement): ?int { $compareByContent = null; $prevParts = explode(NamespaceHelper::NAMESPACE_SEPARATOR, $prevStatement->getFullyQualifiedTypeName()); $nextParts = explode(NamespaceHelper::NAMESPACE_SEPARATOR, $nextStatement->getFullyQualifiedTypeName()); $minPartsCount = min(count($prevParts), count($nextParts)); for ($i = 0; $i < $minPartsCount; ++$i) { $comparison = strcasecmp($prevParts[$i], $nextParts[$i]); if ($comparison) { $compareByContent = $comparison; break; } } return $compareByContent; }
php
private function compareUseStatementsByContent(UseStatement $prevStatement, UseStatement $nextStatement): ?int { $compareByContent = null; $prevParts = explode(NamespaceHelper::NAMESPACE_SEPARATOR, $prevStatement->getFullyQualifiedTypeName()); $nextParts = explode(NamespaceHelper::NAMESPACE_SEPARATOR, $nextStatement->getFullyQualifiedTypeName()); $minPartsCount = min(count($prevParts), count($nextParts)); for ($i = 0; $i < $minPartsCount; ++$i) { $comparison = strcasecmp($prevParts[$i], $nextParts[$i]); if ($comparison) { $compareByContent = $comparison; break; } } return $compareByContent; }
[ "private", "function", "compareUseStatementsByContent", "(", "UseStatement", "$", "prevStatement", ",", "UseStatement", "$", "nextStatement", ")", ":", "?", "int", "{", "$", "compareByContent", "=", "null", ";", "$", "prevParts", "=", "explode", "(", "NamespaceHel...
Compares the given use statements by their string content. @SuppressWarnings(PHPMD.UnusedPrivateMethod) @param UseStatement $prevStatement @param UseStatement $nextStatement @return int|null 1 <=> -1 To move statements in a direction.
[ "Compares", "the", "given", "use", "statements", "by", "their", "string", "content", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/Formatting/AlphabeticallySortedUsesSniff.php#L90-L109
train
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/Formatting/AlphabeticallySortedUsesSniff.php
AlphabeticallySortedUsesSniff.compareUseStatementsByNamespaceCount
private function compareUseStatementsByNamespaceCount( UseStatement $prevStatement, UseStatement $nextStatement ): int { $aNameParts = explode(NamespaceHelper::NAMESPACE_SEPARATOR, $prevStatement->getFullyQualifiedTypeName()); $bNameParts = explode(NamespaceHelper::NAMESPACE_SEPARATOR, $nextStatement->getFullyQualifiedTypeName()); return count($aNameParts) <=> count($bNameParts); }
php
private function compareUseStatementsByNamespaceCount( UseStatement $prevStatement, UseStatement $nextStatement ): int { $aNameParts = explode(NamespaceHelper::NAMESPACE_SEPARATOR, $prevStatement->getFullyQualifiedTypeName()); $bNameParts = explode(NamespaceHelper::NAMESPACE_SEPARATOR, $nextStatement->getFullyQualifiedTypeName()); return count($aNameParts) <=> count($bNameParts); }
[ "private", "function", "compareUseStatementsByNamespaceCount", "(", "UseStatement", "$", "prevStatement", ",", "UseStatement", "$", "nextStatement", ")", ":", "int", "{", "$", "aNameParts", "=", "explode", "(", "NamespaceHelper", "::", "NAMESPACE_SEPARATOR", ",", "$",...
The shorted usage comes at top. @SuppressWarnings(PHPMD.UnusedPrivateMethod) @param UseStatement $prevStatement @param UseStatement $nextStatement @return int 1 <=> -1 To move statements in a direction.
[ "The", "shorted", "usage", "comes", "at", "top", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/Formatting/AlphabeticallySortedUsesSniff.php#L121-L129
train
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/Formatting/AlphabeticallySortedUsesSniff.php
AlphabeticallySortedUsesSniff.compareUseStatementsByType
private function compareUseStatementsByType(UseStatement $prevStatement, UseStatement $nextStatement): ?int { $comparedByType = null; if (!$prevStatement->hasSameType($nextStatement)) { $order = [ UseStatement::TYPE_DEFAULT => 1, UseStatement::TYPE_FUNCTION => 2, UseStatement::TYPE_CONSTANT => 3, ]; $file = $this->getFile(); $comparedByType = $order[UseStatementHelper::getType($file, $prevStatement)] <=> $order[UseStatementHelper::getType($file, $nextStatement)]; } return $comparedByType; }
php
private function compareUseStatementsByType(UseStatement $prevStatement, UseStatement $nextStatement): ?int { $comparedByType = null; if (!$prevStatement->hasSameType($nextStatement)) { $order = [ UseStatement::TYPE_DEFAULT => 1, UseStatement::TYPE_FUNCTION => 2, UseStatement::TYPE_CONSTANT => 3, ]; $file = $this->getFile(); $comparedByType = $order[UseStatementHelper::getType($file, $prevStatement)] <=> $order[UseStatementHelper::getType($file, $nextStatement)]; } return $comparedByType; }
[ "private", "function", "compareUseStatementsByType", "(", "UseStatement", "$", "prevStatement", ",", "UseStatement", "$", "nextStatement", ")", ":", "?", "int", "{", "$", "comparedByType", "=", "null", ";", "if", "(", "!", "$", "prevStatement", "->", "hasSameTyp...
Classes to the top, functions next, constants last. @SuppressWarnings(PHPMD.UnusedPrivateMethod) @param UseStatement $prevStatement @param UseStatement $nextStatement @return int|null 1 <=> -1 To move statements in a direction.
[ "Classes", "to", "the", "top", "functions", "next", "constants", "last", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/Formatting/AlphabeticallySortedUsesSniff.php#L141-L158
train
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/Formatting/AlphabeticallySortedUsesSniff.php
AlphabeticallySortedUsesSniff.fixDefaultProblem
protected function fixDefaultProblem(CodeWarning $error): void { // Satisfy phpmd unset($error); $firstUseStatement = reset($this->useStatements); $file = $this->getFile()->getBaseFile(); $file->fixer->beginChangeset(); $this->removeOldUseStatements($firstUseStatement); $file->fixer->addContent( $firstUseStatement->getPointer(), $this->getNewUseStatements() ); $file->fixer->endChangeset(); }
php
protected function fixDefaultProblem(CodeWarning $error): void { // Satisfy phpmd unset($error); $firstUseStatement = reset($this->useStatements); $file = $this->getFile()->getBaseFile(); $file->fixer->beginChangeset(); $this->removeOldUseStatements($firstUseStatement); $file->fixer->addContent( $firstUseStatement->getPointer(), $this->getNewUseStatements() ); $file->fixer->endChangeset(); }
[ "protected", "function", "fixDefaultProblem", "(", "CodeWarning", "$", "error", ")", ":", "void", "{", "// Satisfy phpmd", "unset", "(", "$", "error", ")", ";", "$", "firstUseStatement", "=", "reset", "(", "$", "this", "->", "useStatements", ")", ";", "$", ...
Sorts the uses correctly and saves them in the file. @param CodeWarning $error @return void
[ "Sorts", "the", "uses", "correctly", "and", "saves", "them", "in", "the", "file", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/Formatting/AlphabeticallySortedUsesSniff.php#L167-L186
train
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/Formatting/AlphabeticallySortedUsesSniff.php
AlphabeticallySortedUsesSniff.getNewUseStatements
private function getNewUseStatements(): string { $this->sortUseStatements(); $file = $this->getFile()->getBaseFile(); return implode( $file->eolChar, array_map( function (UseStatement $useStatement) use ($file): string { $unqualifiedName = NamespaceHelper::getUnqualifiedNameFromFullyQualifiedName( $useStatement->getFullyQualifiedTypeName() ); $useTypeName = UseStatementHelper::getTypeName($file, $useStatement); $useTypeFormatted = $useTypeName ? sprintf('%s ', $useTypeName) : ''; return ($unqualifiedName === $useStatement->getNameAsReferencedInFile()) ? sprintf( 'use %s%s;', $useTypeFormatted, $useStatement->getFullyQualifiedTypeName() ) : sprintf( 'use %s%s as %s;', $useTypeFormatted, $useStatement->getFullyQualifiedTypeName(), $useStatement->getNameAsReferencedInFile() ); }, $this->useStatements ) ); }
php
private function getNewUseStatements(): string { $this->sortUseStatements(); $file = $this->getFile()->getBaseFile(); return implode( $file->eolChar, array_map( function (UseStatement $useStatement) use ($file): string { $unqualifiedName = NamespaceHelper::getUnqualifiedNameFromFullyQualifiedName( $useStatement->getFullyQualifiedTypeName() ); $useTypeName = UseStatementHelper::getTypeName($file, $useStatement); $useTypeFormatted = $useTypeName ? sprintf('%s ', $useTypeName) : ''; return ($unqualifiedName === $useStatement->getNameAsReferencedInFile()) ? sprintf( 'use %s%s;', $useTypeFormatted, $useStatement->getFullyQualifiedTypeName() ) : sprintf( 'use %s%s as %s;', $useTypeFormatted, $useStatement->getFullyQualifiedTypeName(), $useStatement->getNameAsReferencedInFile() ); }, $this->useStatements ) ); }
[ "private", "function", "getNewUseStatements", "(", ")", ":", "string", "{", "$", "this", "->", "sortUseStatements", "(", ")", ";", "$", "file", "=", "$", "this", "->", "getFile", "(", ")", "->", "getBaseFile", "(", ")", ";", "return", "implode", "(", "...
Returns the new statements as a string for fixing. @return string
[ "Returns", "the", "new", "statements", "as", "a", "string", "for", "fixing", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/Formatting/AlphabeticallySortedUsesSniff.php#L193-L226
train
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/Formatting/AlphabeticallySortedUsesSniff.php
AlphabeticallySortedUsesSniff.processToken
protected function processToken(): void { $prevStatement = null; foreach ($this->useStatements as $useStatement) { if ($prevStatement && ($this->compareUseStatements($prevStatement, $useStatement) > 0)) { $exception = new CodeError( static::CODE_INCORRECT_ORDER, 'Use statements should be sorted alphabetically. The first wrong one is %s.', $useStatement->getPointer() ); $exception ->setPayload([$useStatement->getFullyQualifiedTypeName()]) ->isFixable(true); throw $exception; } $prevStatement = $useStatement; } }
php
protected function processToken(): void { $prevStatement = null; foreach ($this->useStatements as $useStatement) { if ($prevStatement && ($this->compareUseStatements($prevStatement, $useStatement) > 0)) { $exception = new CodeError( static::CODE_INCORRECT_ORDER, 'Use statements should be sorted alphabetically. The first wrong one is %s.', $useStatement->getPointer() ); $exception ->setPayload([$useStatement->getFullyQualifiedTypeName()]) ->isFixable(true); throw $exception; } $prevStatement = $useStatement; } }
[ "protected", "function", "processToken", "(", ")", ":", "void", "{", "$", "prevStatement", "=", "null", ";", "foreach", "(", "$", "this", "->", "useStatements", "as", "$", "useStatement", ")", "{", "if", "(", "$", "prevStatement", "&&", "(", "$", "this",...
Checks if the uses are in the correct order. @throws CodeError @return void
[ "Checks", "if", "the", "uses", "are", "in", "the", "correct", "order", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/Formatting/AlphabeticallySortedUsesSniff.php#L235-L256
train
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/Formatting/AlphabeticallySortedUsesSniff.php
AlphabeticallySortedUsesSniff.removeOldUseStatements
private function removeOldUseStatements(UseStatement $firstUseStatement): void { $file = $this->getFile()->getBaseFile(); $lastUseStatement = end($this->useStatements); $lastSemicolonPointer = TokenHelper::findNext($file, T_SEMICOLON, $lastUseStatement->getPointer()); for ($i = $firstUseStatement->getPointer(); $i <= $lastSemicolonPointer; $i++) { $file->fixer->replaceToken($i, ''); } }
php
private function removeOldUseStatements(UseStatement $firstUseStatement): void { $file = $this->getFile()->getBaseFile(); $lastUseStatement = end($this->useStatements); $lastSemicolonPointer = TokenHelper::findNext($file, T_SEMICOLON, $lastUseStatement->getPointer()); for ($i = $firstUseStatement->getPointer(); $i <= $lastSemicolonPointer; $i++) { $file->fixer->replaceToken($i, ''); } }
[ "private", "function", "removeOldUseStatements", "(", "UseStatement", "$", "firstUseStatement", ")", ":", "void", "{", "$", "file", "=", "$", "this", "->", "getFile", "(", ")", "->", "getBaseFile", "(", ")", ";", "$", "lastUseStatement", "=", "end", "(", "...
Removes the lines of the old statements. @param UseStatement $firstUseStatement @return void
[ "Removes", "the", "lines", "of", "the", "old", "statements", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/Formatting/AlphabeticallySortedUsesSniff.php#L286-L295
train
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/Formatting/AlphabeticallySortedUsesSniff.php
AlphabeticallySortedUsesSniff.sortUseStatements
private function sortUseStatements(): void { uasort($this->useStatements, function (UseStatement $prevStatement, UseStatement $nextStatement) { return $this->compareUseStatements($prevStatement, $nextStatement); }); }
php
private function sortUseStatements(): void { uasort($this->useStatements, function (UseStatement $prevStatement, UseStatement $nextStatement) { return $this->compareUseStatements($prevStatement, $nextStatement); }); }
[ "private", "function", "sortUseStatements", "(", ")", ":", "void", "{", "uasort", "(", "$", "this", "->", "useStatements", ",", "function", "(", "UseStatement", "$", "prevStatement", ",", "UseStatement", "$", "nextStatement", ")", "{", "return", "$", "this", ...
Saves the use-property by the compare function. @return void
[ "Saves", "the", "use", "-", "property", "by", "the", "compare", "function", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/Formatting/AlphabeticallySortedUsesSniff.php#L302-L307
train
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/Formatting/OpenTagSniff.php
OpenTagSniff.handleOpenTagNotFirstStatement
private function handleOpenTagNotFirstStatement(File $phpcsFile, int $stackPtr): void { $fixNotFirstStatement = $phpcsFile->addFixableError( self::ERROR_NOT_FIRST_STATEMENT, $stackPtr, static::CODE_NOT_FIRST_STATEMENT ); if ($fixNotFirstStatement) { $phpcsFile->fixer->beginChangeset(); for ($i = 0; $i < $stackPtr; $i++) { $phpcsFile->fixer->replaceToken($i, ''); } $phpcsFile->fixer->endChangeset(); } }
php
private function handleOpenTagNotFirstStatement(File $phpcsFile, int $stackPtr): void { $fixNotFirstStatement = $phpcsFile->addFixableError( self::ERROR_NOT_FIRST_STATEMENT, $stackPtr, static::CODE_NOT_FIRST_STATEMENT ); if ($fixNotFirstStatement) { $phpcsFile->fixer->beginChangeset(); for ($i = 0; $i < $stackPtr; $i++) { $phpcsFile->fixer->replaceToken($i, ''); } $phpcsFile->fixer->endChangeset(); } }
[ "private", "function", "handleOpenTagNotFirstStatement", "(", "File", "$", "phpcsFile", ",", "int", "$", "stackPtr", ")", ":", "void", "{", "$", "fixNotFirstStatement", "=", "$", "phpcsFile", "->", "addFixableError", "(", "self", "::", "ERROR_NOT_FIRST_STATEMENT", ...
Handles open tag not first statement error. @param File $phpcsFile The php cs file @param int $stackPtr Pointer to the open tag token @return void
[ "Handles", "open", "tag", "not", "first", "statement", "error", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/Formatting/OpenTagSniff.php#L103-L118
train
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/Formatting/OpenTagSniff.php
OpenTagSniff.handleNoSpaceAfterOpenTag
private function handleNoSpaceAfterOpenTag(File $phpcsFile, int $stackPtr, int $whitespacePtr): void { $fixNoSpaceAfterTag = $phpcsFile->addFixableError( self::ERROR_NO_SPACE_AFTER_OPEN_TAG, $whitespacePtr, static::CODE_NO_SPACE_AFTER_OPEN_TAG ); if ($fixNoSpaceAfterTag) { $phpcsFile->fixer->beginChangeset(); $phpcsFile->fixer->addNewline($stackPtr); $phpcsFile->fixer->endChangeset(); } }
php
private function handleNoSpaceAfterOpenTag(File $phpcsFile, int $stackPtr, int $whitespacePtr): void { $fixNoSpaceAfterTag = $phpcsFile->addFixableError( self::ERROR_NO_SPACE_AFTER_OPEN_TAG, $whitespacePtr, static::CODE_NO_SPACE_AFTER_OPEN_TAG ); if ($fixNoSpaceAfterTag) { $phpcsFile->fixer->beginChangeset(); $phpcsFile->fixer->addNewline($stackPtr); $phpcsFile->fixer->endChangeset(); } }
[ "private", "function", "handleNoSpaceAfterOpenTag", "(", "File", "$", "phpcsFile", ",", "int", "$", "stackPtr", ",", "int", "$", "whitespacePtr", ")", ":", "void", "{", "$", "fixNoSpaceAfterTag", "=", "$", "phpcsFile", "->", "addFixableError", "(", "self", "::...
Handles no space after open tag error. @param File $phpcsFile The php cs file @param int $stackPtr Pointer to the open tag token @param int $whitespacePtr Pointer to the line after the open tag @return void
[ "Handles", "no", "space", "after", "open", "tag", "error", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/Formatting/OpenTagSniff.php#L129-L142
train
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/Formatting/OpenTagSniff.php
OpenTagSniff.handleLineNotEmpty
private function handleLineNotEmpty(File $phpcsFile, int $whitespacePtr): void { $fixSpaceNotScndLine = $phpcsFile->addFixableError( self::ERROR_LINE_NOT_EMPTY, $whitespacePtr, static::CODE_LINE_NOT_EMPTY ); if ($fixSpaceNotScndLine) { $phpcsFile->fixer->beginChangeset(); $phpcsFile->fixer->replaceToken( $whitespacePtr, '' ); $phpcsFile->fixer->endChangeset(); } }
php
private function handleLineNotEmpty(File $phpcsFile, int $whitespacePtr): void { $fixSpaceNotScndLine = $phpcsFile->addFixableError( self::ERROR_LINE_NOT_EMPTY, $whitespacePtr, static::CODE_LINE_NOT_EMPTY ); if ($fixSpaceNotScndLine) { $phpcsFile->fixer->beginChangeset(); $phpcsFile->fixer->replaceToken( $whitespacePtr, '' ); $phpcsFile->fixer->endChangeset(); } }
[ "private", "function", "handleLineNotEmpty", "(", "File", "$", "phpcsFile", ",", "int", "$", "whitespacePtr", ")", ":", "void", "{", "$", "fixSpaceNotScndLine", "=", "$", "phpcsFile", "->", "addFixableError", "(", "self", "::", "ERROR_LINE_NOT_EMPTY", ",", "$", ...
Handles line after open tag not empty. @param File $phpcsFile The php cs file @param int $whitespacePtr Pointer to the line after the open tag @return void
[ "Handles", "line", "after", "open", "tag", "not", "empty", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/Formatting/OpenTagSniff.php#L152-L168
train
mimmi20/BrowserDetector
src/Parser/EngineParser.php
EngineParser.parse
public function parse(string $useragent): EngineInterface { $key = $this->fileParser->parseFile( new \SplFileInfo(self::GENERIC_FILE), $useragent, 'unknown' ); return $this->load($key, $useragent); }
php
public function parse(string $useragent): EngineInterface { $key = $this->fileParser->parseFile( new \SplFileInfo(self::GENERIC_FILE), $useragent, 'unknown' ); return $this->load($key, $useragent); }
[ "public", "function", "parse", "(", "string", "$", "useragent", ")", ":", "EngineInterface", "{", "$", "key", "=", "$", "this", "->", "fileParser", "->", "parseFile", "(", "new", "\\", "SplFileInfo", "(", "self", "::", "GENERIC_FILE", ")", ",", "$", "use...
Gets the information about the engine by User Agent @param string $useragent @throws \ExceptionalJSON\DecodeErrorException @return \UaResult\Engine\EngineInterface
[ "Gets", "the", "information", "about", "the", "engine", "by", "User", "Agent" ]
1b90d994fcee01344a36bbe39afb14622bc8df9c
https://github.com/mimmi20/BrowserDetector/blob/1b90d994fcee01344a36bbe39afb14622bc8df9c/src/Parser/EngineParser.php#L55-L64
train
mimmi20/BrowserDetector
src/Version/Helper/MicrosoftOffice.php
MicrosoftOffice.mapOfficeVersion
public function mapOfficeVersion(string $version): string { $intVersion = (int) $version; if (in_array($intVersion, [2007, 2010, 2013, 2016])) { return (string) $intVersion; } if (16 === $intVersion) { return '2016'; } if (15 === $intVersion) { return '2013'; } if (14 === $intVersion) { return '2010'; } if (12 === $intVersion) { return '2007'; } return '0'; }
php
public function mapOfficeVersion(string $version): string { $intVersion = (int) $version; if (in_array($intVersion, [2007, 2010, 2013, 2016])) { return (string) $intVersion; } if (16 === $intVersion) { return '2016'; } if (15 === $intVersion) { return '2013'; } if (14 === $intVersion) { return '2010'; } if (12 === $intVersion) { return '2007'; } return '0'; }
[ "public", "function", "mapOfficeVersion", "(", "string", "$", "version", ")", ":", "string", "{", "$", "intVersion", "=", "(", "int", ")", "$", "version", ";", "if", "(", "in_array", "(", "$", "intVersion", ",", "[", "2007", ",", "2010", ",", "2013", ...
maps the version @param string $version @return string
[ "maps", "the", "version" ]
1b90d994fcee01344a36bbe39afb14622bc8df9c
https://github.com/mimmi20/BrowserDetector/blob/1b90d994fcee01344a36bbe39afb14622bc8df9c/src/Version/Helper/MicrosoftOffice.php#L23-L48
train
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/Commenting/AbstractDocSniff.php
AbstractDocSniff.fixDocCommentUcFirst
private function fixDocCommentUcFirst(int $position, array $token): void { $this->file->fixer->beginChangeset(); $this->file->fixer->replaceToken($position, ucfirst($token['content'])); $this->file->fixer->endChangeset(); }
php
private function fixDocCommentUcFirst(int $position, array $token): void { $this->file->fixer->beginChangeset(); $this->file->fixer->replaceToken($position, ucfirst($token['content'])); $this->file->fixer->endChangeset(); }
[ "private", "function", "fixDocCommentUcFirst", "(", "int", "$", "position", ",", "array", "$", "token", ")", ":", "void", "{", "$", "this", "->", "file", "->", "fixer", "->", "beginChangeset", "(", ")", ";", "$", "this", "->", "file", "->", "fixer", "-...
Fixes the first letter of the doc comment, which must be uppercase. @param int $position @param array $token @return void
[ "Fixes", "the", "first", "letter", "of", "the", "doc", "comment", "which", "must", "be", "uppercase", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/Commenting/AbstractDocSniff.php#L93-L98
train
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/Commenting/AbstractDocSniff.php
AbstractDocSniff.fixNoLineAfterDocComment
private function fixNoLineAfterDocComment(int $position, array $token): void { $this->file->fixer->beginChangeset(); $this->file->fixer->addContent( $position, $this->file->getEolChar() . str_repeat(' ', $token['level']) . ' *' ); $this->file->fixer->endChangeset(); }
php
private function fixNoLineAfterDocComment(int $position, array $token): void { $this->file->fixer->beginChangeset(); $this->file->fixer->addContent( $position, $this->file->getEolChar() . str_repeat(' ', $token['level']) . ' *' ); $this->file->fixer->endChangeset(); }
[ "private", "function", "fixNoLineAfterDocComment", "(", "int", "$", "position", ",", "array", "$", "token", ")", ":", "void", "{", "$", "this", "->", "file", "->", "fixer", "->", "beginChangeset", "(", ")", ";", "$", "this", "->", "file", "->", "fixer", ...
Fixes no line after doc comment. @param int $position @param array $token @return void
[ "Fixes", "no", "line", "after", "doc", "comment", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/Commenting/AbstractDocSniff.php#L108-L118
train
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/Commenting/AbstractDocSniff.php
AbstractDocSniff.getSummaryPosition
private function getSummaryPosition(): ?int { if ($this->summaryPosition === -1) { $this->summaryPosition = $this->loadSummaryPosition(); } return $this->summaryPosition; }
php
private function getSummaryPosition(): ?int { if ($this->summaryPosition === -1) { $this->summaryPosition = $this->loadSummaryPosition(); } return $this->summaryPosition; }
[ "private", "function", "getSummaryPosition", "(", ")", ":", "?", "int", "{", "if", "(", "$", "this", "->", "summaryPosition", "===", "-", "1", ")", "{", "$", "this", "->", "summaryPosition", "=", "$", "this", "->", "loadSummaryPosition", "(", ")", ";", ...
Returns the position of the summary or null. @return int|null
[ "Returns", "the", "position", "of", "the", "summary", "or", "null", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/Commenting/AbstractDocSniff.php#L125-L132
train
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/Commenting/AbstractDocSniff.php
AbstractDocSniff.isNextLineEmpty
private function isNextLineEmpty(int $startPosition): bool { $istNextLineEmpty = true; $nextRelevantPos = $this->loadNextDocBlockContent($startPosition); if ($nextRelevantPos !== -1) { $istNextLineEmpty = $this->tokens[$startPosition]['line'] + 1 < $this->tokens[$nextRelevantPos]['line']; } return $istNextLineEmpty; }
php
private function isNextLineEmpty(int $startPosition): bool { $istNextLineEmpty = true; $nextRelevantPos = $this->loadNextDocBlockContent($startPosition); if ($nextRelevantPos !== -1) { $istNextLineEmpty = $this->tokens[$startPosition]['line'] + 1 < $this->tokens[$nextRelevantPos]['line']; } return $istNextLineEmpty; }
[ "private", "function", "isNextLineEmpty", "(", "int", "$", "startPosition", ")", ":", "bool", "{", "$", "istNextLineEmpty", "=", "true", ";", "$", "nextRelevantPos", "=", "$", "this", "->", "loadNextDocBlockContent", "(", "$", "startPosition", ")", ";", "if", ...
Returns true if the next line of the comment is empty. @param int $startPosition The position where to start the search. @return bool
[ "Returns", "true", "if", "the", "next", "line", "of", "the", "comment", "is", "empty", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/Commenting/AbstractDocSniff.php#L141-L151
train
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/Commenting/AbstractDocSniff.php
AbstractDocSniff.isPrevLineEmpty
private function isPrevLineEmpty(int $startPosition): bool { $isPrevLineEmpty = true; $posPrevContentPos = $this->loadPrevDocBlockContent($startPosition); if ($posPrevContentPos !== -1) { $isPrevLineEmpty = $this->tokens[$startPosition]['line'] - 1 > $this->tokens[$posPrevContentPos]['line']; } return $isPrevLineEmpty; }
php
private function isPrevLineEmpty(int $startPosition): bool { $isPrevLineEmpty = true; $posPrevContentPos = $this->loadPrevDocBlockContent($startPosition); if ($posPrevContentPos !== -1) { $isPrevLineEmpty = $this->tokens[$startPosition]['line'] - 1 > $this->tokens[$posPrevContentPos]['line']; } return $isPrevLineEmpty; }
[ "private", "function", "isPrevLineEmpty", "(", "int", "$", "startPosition", ")", ":", "bool", "{", "$", "isPrevLineEmpty", "=", "true", ";", "$", "posPrevContentPos", "=", "$", "this", "->", "loadPrevDocBlockContent", "(", "$", "startPosition", ")", ";", "if",...
Returns true if the prev line of the comment is empty. @param int $startPosition The position where to start the search. @return bool
[ "Returns", "true", "if", "the", "prev", "line", "of", "the", "comment", "is", "empty", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/Commenting/AbstractDocSniff.php#L160-L170
train
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/Commenting/AbstractDocSniff.php
AbstractDocSniff.loadNextDocBlockContent
private function loadNextDocBlockContent(int $startPosition): int { return $this->file->findNext( [ T_DOC_COMMENT_WHITESPACE, T_DOC_COMMENT_STAR ], $startPosition + 1, $this->getDocHelper()->getBlockEndPosition(), true ); }
php
private function loadNextDocBlockContent(int $startPosition): int { return $this->file->findNext( [ T_DOC_COMMENT_WHITESPACE, T_DOC_COMMENT_STAR ], $startPosition + 1, $this->getDocHelper()->getBlockEndPosition(), true ); }
[ "private", "function", "loadNextDocBlockContent", "(", "int", "$", "startPosition", ")", ":", "int", "{", "return", "$", "this", "->", "file", "->", "findNext", "(", "[", "T_DOC_COMMENT_WHITESPACE", ",", "T_DOC_COMMENT_STAR", "]", ",", "$", "startPosition", "+",...
Returns the position of the next whitespace or star of the comment for checking the line after that. @param int $startPosition @return int
[ "Returns", "the", "position", "of", "the", "next", "whitespace", "or", "star", "of", "the", "comment", "for", "checking", "the", "line", "after", "that", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/Commenting/AbstractDocSniff.php#L191-L202
train
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/Commenting/AbstractDocSniff.php
AbstractDocSniff.loadPrevDocBlockContent
private function loadPrevDocBlockContent(int $startPosition): int { return $this->file->findPrevious( [ T_DOC_COMMENT_OPEN_TAG, T_DOC_COMMENT_STAR, T_DOC_COMMENT_WHITESPACE, ], $startPosition - 1, $this->getDocCommentPos(), true ); }
php
private function loadPrevDocBlockContent(int $startPosition): int { return $this->file->findPrevious( [ T_DOC_COMMENT_OPEN_TAG, T_DOC_COMMENT_STAR, T_DOC_COMMENT_WHITESPACE, ], $startPosition - 1, $this->getDocCommentPos(), true ); }
[ "private", "function", "loadPrevDocBlockContent", "(", "int", "$", "startPosition", ")", ":", "int", "{", "return", "$", "this", "->", "file", "->", "findPrevious", "(", "[", "T_DOC_COMMENT_OPEN_TAG", ",", "T_DOC_COMMENT_STAR", ",", "T_DOC_COMMENT_WHITESPACE", ",", ...
Returns the position of the previous whitespace or star of the comment for checking the line after that. @param int $startPosition @return int
[ "Returns", "the", "position", "of", "the", "previous", "whitespace", "or", "star", "of", "the", "comment", "for", "checking", "the", "line", "after", "that", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/Commenting/AbstractDocSniff.php#L211-L223
train
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/Commenting/AbstractDocSniff.php
AbstractDocSniff.loadSummaryPosition
private function loadSummaryPosition(): ?int { $return = null; $possSummaryPos = $this->loadNextDocBlockContent($this->getDocCommentPos()); if ((int) $possSummaryPos > 0) { $possSummaryToken = $this->tokens[$possSummaryPos]; $return = $this->isSimpleText($possSummaryToken) ? $possSummaryPos : null; } return $return; }
php
private function loadSummaryPosition(): ?int { $return = null; $possSummaryPos = $this->loadNextDocBlockContent($this->getDocCommentPos()); if ((int) $possSummaryPos > 0) { $possSummaryToken = $this->tokens[$possSummaryPos]; $return = $this->isSimpleText($possSummaryToken) ? $possSummaryPos : null; } return $return; }
[ "private", "function", "loadSummaryPosition", "(", ")", ":", "?", "int", "{", "$", "return", "=", "null", ";", "$", "possSummaryPos", "=", "$", "this", "->", "loadNextDocBlockContent", "(", "$", "this", "->", "getDocCommentPos", "(", ")", ")", ";", "if", ...
Loads the position of the summary token if possible. @return int|null
[ "Loads", "the", "position", "of", "the", "summary", "token", "if", "possible", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/Commenting/AbstractDocSniff.php#L230-L242
train
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/Commenting/AbstractDocSniff.php
AbstractDocSniff.validateDescriptions
private function validateDescriptions(): self { $commentPoss = TokenHelper::findNextAll( $this->file->getBaseFile(), [T_DOC_COMMENT_STRING, T_DOC_COMMENT_TAG], $this->getDocCommentPos(), $this->getDocHelper()->getBlockEndPosition() ); foreach ($commentPoss as $index => $commentPos) { $commentToken = $this->tokens[$commentPos]; $skipNewLineCheck = false; // We only search till the tags. if ($commentToken['code'] === T_DOC_COMMENT_TAG) { break; } if ($isFirstDocString = $index === 0) { $skipNewLineCheck = !$this->validateOneLineSummary(); } $this->validateUCFirstDocComment($commentPos, $commentToken); if (!$skipNewLineCheck) { $this->validateNewLineAfterDocComment($commentPos, $commentToken, $isFirstDocString); } } return $this; ; }
php
private function validateDescriptions(): self { $commentPoss = TokenHelper::findNextAll( $this->file->getBaseFile(), [T_DOC_COMMENT_STRING, T_DOC_COMMENT_TAG], $this->getDocCommentPos(), $this->getDocHelper()->getBlockEndPosition() ); foreach ($commentPoss as $index => $commentPos) { $commentToken = $this->tokens[$commentPos]; $skipNewLineCheck = false; // We only search till the tags. if ($commentToken['code'] === T_DOC_COMMENT_TAG) { break; } if ($isFirstDocString = $index === 0) { $skipNewLineCheck = !$this->validateOneLineSummary(); } $this->validateUCFirstDocComment($commentPos, $commentToken); if (!$skipNewLineCheck) { $this->validateNewLineAfterDocComment($commentPos, $commentToken, $isFirstDocString); } } return $this; ; }
[ "private", "function", "validateDescriptions", "(", ")", ":", "self", "{", "$", "commentPoss", "=", "TokenHelper", "::", "findNextAll", "(", "$", "this", "->", "file", "->", "getBaseFile", "(", ")", ",", "[", "T_DOC_COMMENT_STRING", ",", "T_DOC_COMMENT_TAG", "...
Validates the descriptions in the file. @return AbstractDocSniff
[ "Validates", "the", "descriptions", "in", "the", "file", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/Commenting/AbstractDocSniff.php#L274-L306
train
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/Commenting/AbstractDocSniff.php
AbstractDocSniff.validateNewLineAfterDocComment
private function validateNewLineAfterDocComment(int $position, array $token, bool $asSingleLine = true): void { if (!$this->isNextLineEmpty($position)) { $nextRelevantPos = $this->loadNextDocBlockContent($position); $nextToken = $this->tokens[$nextRelevantPos]; // Register an error if we force a single line or this is no long description with more then one line. if ($asSingleLine || ($nextToken['code'] !== T_DOC_COMMENT_STRING)) { $isFixing = $this->file->addFixableWarning( self::MESSAGE_NO_LINE_AFTER_DOC_COMMENT, $position, static::CODE_NO_LINE_AFTER_DOC_COMMENT ); if ($isFixing) { $this->fixNoLineAfterDocComment($position, $token); } } } }
php
private function validateNewLineAfterDocComment(int $position, array $token, bool $asSingleLine = true): void { if (!$this->isNextLineEmpty($position)) { $nextRelevantPos = $this->loadNextDocBlockContent($position); $nextToken = $this->tokens[$nextRelevantPos]; // Register an error if we force a single line or this is no long description with more then one line. if ($asSingleLine || ($nextToken['code'] !== T_DOC_COMMENT_STRING)) { $isFixing = $this->file->addFixableWarning( self::MESSAGE_NO_LINE_AFTER_DOC_COMMENT, $position, static::CODE_NO_LINE_AFTER_DOC_COMMENT ); if ($isFixing) { $this->fixNoLineAfterDocComment($position, $token); } } } }
[ "private", "function", "validateNewLineAfterDocComment", "(", "int", "$", "position", ",", "array", "$", "token", ",", "bool", "$", "asSingleLine", "=", "true", ")", ":", "void", "{", "if", "(", "!", "$", "this", "->", "isNextLineEmpty", "(", "$", "positio...
Checks if there is a line break after the comment block.. @param int $position @param array $token @param bool $asSingleLine @return void
[ "Checks", "if", "there", "is", "a", "line", "break", "after", "the", "comment", "block", ".." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/Commenting/AbstractDocSniff.php#L317-L336
train
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/Commenting/AbstractDocSniff.php
AbstractDocSniff.validateOneLineSummary
private function validateOneLineSummary(): bool { $isValid = true; $summaryPos = $this->getSummaryPosition(); $nextPossiblePos = $this->loadNextDocBlockContent($summaryPos); if ($nextPossiblePos > -1) { $nextToken = $this->tokens[$nextPossiblePos]; if (($nextToken['code'] === T_DOC_COMMENT_STRING) && !$this->isNextLineEmpty($summaryPos)) { $isValid = false; $this->file->addWarning( self::MESSAGE_SUMMARY_TOO_LONG, $nextPossiblePos, static::CODE_SUMMARY_TOO_LONG ); } } return $isValid; }
php
private function validateOneLineSummary(): bool { $isValid = true; $summaryPos = $this->getSummaryPosition(); $nextPossiblePos = $this->loadNextDocBlockContent($summaryPos); if ($nextPossiblePos > -1) { $nextToken = $this->tokens[$nextPossiblePos]; if (($nextToken['code'] === T_DOC_COMMENT_STRING) && !$this->isNextLineEmpty($summaryPos)) { $isValid = false; $this->file->addWarning( self::MESSAGE_SUMMARY_TOO_LONG, $nextPossiblePos, static::CODE_SUMMARY_TOO_LONG ); } } return $isValid; }
[ "private", "function", "validateOneLineSummary", "(", ")", ":", "bool", "{", "$", "isValid", "=", "true", ";", "$", "summaryPos", "=", "$", "this", "->", "getSummaryPosition", "(", ")", ";", "$", "nextPossiblePos", "=", "$", "this", "->", "loadNextDocBlockCo...
Checks if the summary is on line or registers a warning. @return bool We can skip the new line error, so return true if the one line summary is true.
[ "Checks", "if", "the", "summary", "is", "on", "line", "or", "registers", "a", "warning", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/Commenting/AbstractDocSniff.php#L343-L364
train
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/Commenting/AbstractDocSniff.php
AbstractDocSniff.validateSummaryExistence
private function validateSummaryExistence(): self { $summaryPos = $this->getSummaryPosition(); if (!$summaryPos) { throw new CodeWarning( static::CODE_NO_SUMMARY, self::MESSAGE_NO_SUMMARY, $this->getDocCommentPos() ); } return $this; }
php
private function validateSummaryExistence(): self { $summaryPos = $this->getSummaryPosition(); if (!$summaryPos) { throw new CodeWarning( static::CODE_NO_SUMMARY, self::MESSAGE_NO_SUMMARY, $this->getDocCommentPos() ); } return $this; }
[ "private", "function", "validateSummaryExistence", "(", ")", ":", "self", "{", "$", "summaryPos", "=", "$", "this", "->", "getSummaryPosition", "(", ")", ";", "if", "(", "!", "$", "summaryPos", ")", "{", "throw", "new", "CodeWarning", "(", "static", "::", ...
Returns position to the comment summary or null. @throws CodeWarning If there is no summary. @return $this
[ "Returns", "position", "to", "the", "comment", "summary", "or", "null", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/Commenting/AbstractDocSniff.php#L373-L386
train
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/Commenting/AbstractDocSniff.php
AbstractDocSniff.validateUCFirstDocComment
private function validateUCFirstDocComment(int $position, array $token): void { $commentText = $token['content']; if (ucfirst($commentText) !== $commentText && $this->isPrevLineEmpty($position)) { $isFixing = $this->file->addFixableWarning( self::MESSAGE_DOC_COMMENT_UC_FIRST, $position, static::CODE_DOC_COMMENT_UC_FIRST ); if ($isFixing) { $this->fixDocCommentUcFirst($position, $token); } } }
php
private function validateUCFirstDocComment(int $position, array $token): void { $commentText = $token['content']; if (ucfirst($commentText) !== $commentText && $this->isPrevLineEmpty($position)) { $isFixing = $this->file->addFixableWarning( self::MESSAGE_DOC_COMMENT_UC_FIRST, $position, static::CODE_DOC_COMMENT_UC_FIRST ); if ($isFixing) { $this->fixDocCommentUcFirst($position, $token); } } }
[ "private", "function", "validateUCFirstDocComment", "(", "int", "$", "position", ",", "array", "$", "token", ")", ":", "void", "{", "$", "commentText", "=", "$", "token", "[", "'content'", "]", ";", "if", "(", "ucfirst", "(", "$", "commentText", ")", "!=...
Checks if the first char of the doc comment is ucfirst. @param int $position @param array $token @return void
[ "Checks", "if", "the", "first", "char", "of", "the", "doc", "comment", "is", "ucfirst", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/Commenting/AbstractDocSniff.php#L396-L411
train
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/DocTags/AbstractDisallowedTagsSniff.php
AbstractDisallowedTagsSniff.checkAndRegisterDisallowedTagsError
private function checkAndRegisterDisallowedTagsError(): void { $disallowedTags = $this->getDisallowedTags(); $tags = $this->getAllTags(); foreach ($tags as $tagPos => $tag) { $tagContent = $tag['content']; if (in_array(substr($tagContent, 1), $disallowedTags)) { $this->file->addError( self::MESSAGE_TAG_NOT_ALLOWED, $tagPos, static::CODE_TAG_NOT_ALLOWED, [$tagContent] ); } } }
php
private function checkAndRegisterDisallowedTagsError(): void { $disallowedTags = $this->getDisallowedTags(); $tags = $this->getAllTags(); foreach ($tags as $tagPos => $tag) { $tagContent = $tag['content']; if (in_array(substr($tagContent, 1), $disallowedTags)) { $this->file->addError( self::MESSAGE_TAG_NOT_ALLOWED, $tagPos, static::CODE_TAG_NOT_ALLOWED, [$tagContent] ); } } }
[ "private", "function", "checkAndRegisterDisallowedTagsError", "(", ")", ":", "void", "{", "$", "disallowedTags", "=", "$", "this", "->", "getDisallowedTags", "(", ")", ";", "$", "tags", "=", "$", "this", "->", "getAllTags", "(", ")", ";", "foreach", "(", "...
Checks and registers errors for the disallowed tags. @return void
[ "Checks", "and", "registers", "errors", "for", "the", "disallowed", "tags", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/DocTags/AbstractDisallowedTagsSniff.php#L62-L79
train
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/DocTags/AbstractDisallowedTagsSniff.php
AbstractDisallowedTagsSniff.getAllTags
private function getAllTags(): array { if ($this->tags === null) { $this->tags = $this->loadAllTags(); } return $this->tags; }
php
private function getAllTags(): array { if ($this->tags === null) { $this->tags = $this->loadAllTags(); } return $this->tags; }
[ "private", "function", "getAllTags", "(", ")", ":", "array", "{", "if", "(", "$", "this", "->", "tags", "===", "null", ")", "{", "$", "this", "->", "tags", "=", "$", "this", "->", "loadAllTags", "(", ")", ";", "}", "return", "$", "this", "->", "t...
Returns all tag tokens for this doc block. @return array
[ "Returns", "all", "tag", "tokens", "for", "this", "doc", "block", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/DocTags/AbstractDisallowedTagsSniff.php#L86-L93
train
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/Formatting/TraitUseSpacingSniff.php
TraitUseSpacingSniff.areRequirementsMet
protected function areRequirementsMet(): bool { return (bool) $this->uses = ClassHelper::getTraitUsePointers($this->getFile(), $this->getStackPos()); }
php
protected function areRequirementsMet(): bool { return (bool) $this->uses = ClassHelper::getTraitUsePointers($this->getFile(), $this->getStackPos()); }
[ "protected", "function", "areRequirementsMet", "(", ")", ":", "bool", "{", "return", "(", "bool", ")", "$", "this", "->", "uses", "=", "ClassHelper", "::", "getTraitUsePointers", "(", "$", "this", "->", "getFile", "(", ")", ",", "$", "this", "->", "getSt...
Returns false if there are no uses. @return bool
[ "Returns", "false", "if", "there", "are", "no", "uses", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/Formatting/TraitUseSpacingSniff.php#L94-L97
train