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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
nyeholt/silverstripe-solr | code/service/SolrSearchService.php | SolrSearchService.getAllSearchableFieldsFor | public function getAllSearchableFieldsFor($classNames) {
$allfields = array();
foreach ($classNames as $className) {
$fields = $this->getSearchableFieldsFor($className);
$allfields = array_merge($allfields, $fields);
}
return $allfields;
} | php | public function getAllSearchableFieldsFor($classNames) {
$allfields = array();
foreach ($classNames as $className) {
$fields = $this->getSearchableFieldsFor($className);
$allfields = array_merge($allfields, $fields);
}
return $allfields;
} | [
"public",
"function",
"getAllSearchableFieldsFor",
"(",
"$",
"classNames",
")",
"{",
"$",
"allfields",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"classNames",
"as",
"$",
"className",
")",
"{",
"$",
"fields",
"=",
"$",
"this",
"->",
"getSearchableFi... | Get all the searchable fields for a given set of classes
@param type $classNames | [
"Get",
"all",
"the",
"searchable",
"fields",
"for",
"a",
"given",
"set",
"of",
"classes"
] | a573df88167ba9b2bec51e2660a4edfdad446fcf | https://github.com/nyeholt/silverstripe-solr/blob/a573df88167ba9b2bec51e2660a4edfdad446fcf/code/service/SolrSearchService.php#L677-L685 | train |
nyeholt/silverstripe-solr | code/service/SolrSearchService.php | SolrSearchService.buildSearchableFieldCache | protected function buildSearchableFieldCache() {
if (!$this->searchableCache) {
$objects = DataObject::get('SolrTypeConfiguration');
if ($objects) {
foreach ($objects as $obj) {
$this->searchableCache[$obj->Title] = $obj->FieldMappings->getValues();
}
}
}
return $this->searchableCache;
} | php | protected function buildSearchableFieldCache() {
if (!$this->searchableCache) {
$objects = DataObject::get('SolrTypeConfiguration');
if ($objects) {
foreach ($objects as $obj) {
$this->searchableCache[$obj->Title] = $obj->FieldMappings->getValues();
}
}
}
return $this->searchableCache;
} | [
"protected",
"function",
"buildSearchableFieldCache",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"searchableCache",
")",
"{",
"$",
"objects",
"=",
"DataObject",
"::",
"get",
"(",
"'SolrTypeConfiguration'",
")",
";",
"if",
"(",
"$",
"objects",
")",
"... | Builds up the searchable fields configuration baased on the solrtypeconfiguration objects | [
"Builds",
"up",
"the",
"searchable",
"fields",
"configuration",
"baased",
"on",
"the",
"solrtypeconfiguration",
"objects"
] | a573df88167ba9b2bec51e2660a4edfdad446fcf | https://github.com/nyeholt/silverstripe-solr/blob/a573df88167ba9b2bec51e2660a4edfdad446fcf/code/service/SolrSearchService.php#L692-L702 | train |
nyeholt/silverstripe-solr | code/service/SolrSearchService.php | SolrSearchService.getSolrFieldName | public function getSolrFieldName($field, $classNames = null) {
if (!$classNames) {
$classNames = Config::inst()->get('SolrSearch', 'default_searchable_types');
}
if (!is_array($classNames)) {
$classNames = array($classNames);
}
foreach ($classNames as $className) {
if (!class_exists($className)) {
continue;
}
$dummy = singleton($className);
$fields = $this->objectToFields($dummy);
if ($field == 'ID') {
$field = 'SS_ID';
}
if (isset($fields[$field])) {
$configForType = $this->getSearchableFieldsFor($className);
$hint = isset($configForType[$field]) ? $configForType[$field] : false;
return $this->mapper->mapFieldNameFromType($field, $fields[$field]['Type'], $hint);
}
}
} | php | public function getSolrFieldName($field, $classNames = null) {
if (!$classNames) {
$classNames = Config::inst()->get('SolrSearch', 'default_searchable_types');
}
if (!is_array($classNames)) {
$classNames = array($classNames);
}
foreach ($classNames as $className) {
if (!class_exists($className)) {
continue;
}
$dummy = singleton($className);
$fields = $this->objectToFields($dummy);
if ($field == 'ID') {
$field = 'SS_ID';
}
if (isset($fields[$field])) {
$configForType = $this->getSearchableFieldsFor($className);
$hint = isset($configForType[$field]) ? $configForType[$field] : false;
return $this->mapper->mapFieldNameFromType($field, $fields[$field]['Type'], $hint);
}
}
} | [
"public",
"function",
"getSolrFieldName",
"(",
"$",
"field",
",",
"$",
"classNames",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"classNames",
")",
"{",
"$",
"classNames",
"=",
"Config",
"::",
"inst",
"(",
")",
"->",
"get",
"(",
"'SolrSearch'",
",",
... | Return the field name for a given property within a given set of data object types
First matching data object with that field is used
@param String $field
The field name to get the Solr type for.
@param String $classNames
A list of data object class name.
@return String | [
"Return",
"the",
"field",
"name",
"for",
"a",
"given",
"property",
"within",
"a",
"given",
"set",
"of",
"data",
"object",
"types"
] | a573df88167ba9b2bec51e2660a4edfdad446fcf | https://github.com/nyeholt/silverstripe-solr/blob/a573df88167ba9b2bec51e2660a4edfdad446fcf/code/service/SolrSearchService.php#L717-L740 | train |
nyeholt/silverstripe-solr | code/service/SolrSearchService.php | SolrSchemaMapper.mapFieldNameFromType | public function mapFieldNameFromType($field, $type, $hint = '') {
if (isset($this->solrFields[$field])) {
return $this->solrFields[$field];
}
if (strpos($type, '(')) {
$type = substr($type, 0, strpos($type, '('));
}
if ($hint && is_string($hint) && $hint != 'default') {
return str_replace(':field', $field, $hint);
}
if ($pos = strpos($field, ':')) {
$field = substr($field, 0, $pos);
}
// otherwise, lets use a generic field for it
switch ($type) {
case 'MultiValueField': {
return $field . '_ms';
}
case 'Text':
case 'HTMLText': {
return $field . '_t';
}
case 'Date':
case 'SS_Datetime': {
return $field . '_dt';
}
case 'Str':
case 'Enum': {
return $field . '_ms';
}
case 'Attr': {
return 'attr_' . $field;
}
case 'Double':
case 'Decimal':
case 'Currency':
case 'Float':
case 'Money': {
return $field . '_f';
}
case 'Int':
case 'Integer': {
return $field . '_i';
}
case 'SolrGeoPoint': {
return $field . '_p';
}
case 'String': {
return $field . '_s';
}
case 'Varchar':
default: {
return $field . '_as';
}
}
} | php | public function mapFieldNameFromType($field, $type, $hint = '') {
if (isset($this->solrFields[$field])) {
return $this->solrFields[$field];
}
if (strpos($type, '(')) {
$type = substr($type, 0, strpos($type, '('));
}
if ($hint && is_string($hint) && $hint != 'default') {
return str_replace(':field', $field, $hint);
}
if ($pos = strpos($field, ':')) {
$field = substr($field, 0, $pos);
}
// otherwise, lets use a generic field for it
switch ($type) {
case 'MultiValueField': {
return $field . '_ms';
}
case 'Text':
case 'HTMLText': {
return $field . '_t';
}
case 'Date':
case 'SS_Datetime': {
return $field . '_dt';
}
case 'Str':
case 'Enum': {
return $field . '_ms';
}
case 'Attr': {
return 'attr_' . $field;
}
case 'Double':
case 'Decimal':
case 'Currency':
case 'Float':
case 'Money': {
return $field . '_f';
}
case 'Int':
case 'Integer': {
return $field . '_i';
}
case 'SolrGeoPoint': {
return $field . '_p';
}
case 'String': {
return $field . '_s';
}
case 'Varchar':
default: {
return $field . '_as';
}
}
} | [
"public",
"function",
"mapFieldNameFromType",
"(",
"$",
"field",
",",
"$",
"type",
",",
"$",
"hint",
"=",
"''",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"solrFields",
"[",
"$",
"field",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
... | Map a SilverStripe field to a Solr field
@param String $field
The field name
@param String $type
The field type
@param String $value
The value being stored (needed if a multival)
@return String | [
"Map",
"a",
"SilverStripe",
"field",
"to",
"a",
"Solr",
"field"
] | a573df88167ba9b2bec51e2660a4edfdad446fcf | https://github.com/nyeholt/silverstripe-solr/blob/a573df88167ba9b2bec51e2660a4edfdad446fcf/code/service/SolrSearchService.php#L892-L951 | train |
nyeholt/silverstripe-solr | code/service/SolrSearchService.php | SolrSchemaMapper.mapValueToType | public function mapValueToType($name, $value) {
// just store as an untokenised string
$type = 'String';
if (strpos($name, ':')) {
list($name, $type) = explode(':', $name);
return $type;
}
// or an array of strings
if (is_array($value)) {
$type = 'MultiValueField';
}
if (is_double($value)) {
return 'Double';
}
if (is_int($value)) {
return 'Int';
}
return $type;
} | php | public function mapValueToType($name, $value) {
// just store as an untokenised string
$type = 'String';
if (strpos($name, ':')) {
list($name, $type) = explode(':', $name);
return $type;
}
// or an array of strings
if (is_array($value)) {
$type = 'MultiValueField';
}
if (is_double($value)) {
return 'Double';
}
if (is_int($value)) {
return 'Int';
}
return $type;
} | [
"public",
"function",
"mapValueToType",
"(",
"$",
"name",
",",
"$",
"value",
")",
"{",
"// just store as an untokenised string",
"$",
"type",
"=",
"'String'",
";",
"if",
"(",
"strpos",
"(",
"$",
"name",
",",
"':'",
")",
")",
"{",
"list",
"(",
"$",
"name"... | Map a raw PHP value to a type
@param string $name
The name of the field. If there is a ':' character, the type is assumed to be that
which follows the ':'
@param mixed $value
The value being checked | [
"Map",
"a",
"raw",
"PHP",
"value",
"to",
"a",
"type"
] | a573df88167ba9b2bec51e2660a4edfdad446fcf | https://github.com/nyeholt/silverstripe-solr/blob/a573df88167ba9b2bec51e2660a4edfdad446fcf/code/service/SolrSearchService.php#L962-L985 | train |
nyeholt/silverstripe-solr | code/service/SolrSearchService.php | SolrSchemaMapper.convertValue | public function convertValue($value, $type) {
if (is_array($value)) {
$newReturn = array();
foreach ($value as $v) {
$newReturn[] = $this->convertValue($v, $type);
}
return $newReturn;
} else {
switch ($type) {
case 'Date':
case 'SS_Datetime': {
// we don't want a complete iso8601 date, we want it
// in UTC time with a Z at the end. It's okay, php's
// strtotime will correctly re-convert this to the correct
// timestamp, but this is how Solr wants things.
// If we don't have a full DateTime stamp we won't remove any hours
$hoursToRemove = date('Z');
$ts = strtotime($value);
$tsHTR = $ts - $hoursToRemove;
$date = date('Y-m-d\TH:i:s\Z', $tsHTR);
return $date;
}
case 'HTMLText': {
return strip_tags($value);
}
case 'SolrGeoPoint': {
return $value->y . ',' . $value->x;
}
default: {
return $value;
}
}
}
} | php | public function convertValue($value, $type) {
if (is_array($value)) {
$newReturn = array();
foreach ($value as $v) {
$newReturn[] = $this->convertValue($v, $type);
}
return $newReturn;
} else {
switch ($type) {
case 'Date':
case 'SS_Datetime': {
// we don't want a complete iso8601 date, we want it
// in UTC time with a Z at the end. It's okay, php's
// strtotime will correctly re-convert this to the correct
// timestamp, but this is how Solr wants things.
// If we don't have a full DateTime stamp we won't remove any hours
$hoursToRemove = date('Z');
$ts = strtotime($value);
$tsHTR = $ts - $hoursToRemove;
$date = date('Y-m-d\TH:i:s\Z', $tsHTR);
return $date;
}
case 'HTMLText': {
return strip_tags($value);
}
case 'SolrGeoPoint': {
return $value->y . ',' . $value->x;
}
default: {
return $value;
}
}
}
} | [
"public",
"function",
"convertValue",
"(",
"$",
"value",
",",
"$",
"type",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"newReturn",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"value",
"as",
"$",
"v",
")",
"{",
... | Convert a value to a format handled by solr
@param mixed $value
@param string $type
@return mixed | [
"Convert",
"a",
"value",
"to",
"a",
"format",
"handled",
"by",
"solr"
] | a573df88167ba9b2bec51e2660a4edfdad446fcf | https://github.com/nyeholt/silverstripe-solr/blob/a573df88167ba9b2bec51e2660a4edfdad446fcf/code/service/SolrSearchService.php#L994-L1027 | train |
eloquent/composer-config-reader | src/ObjectAccess.php | ObjectAccess.get | public function get($property)
{
if (!$this->exists($property)) {
throw new UndefinedPropertyException($property);
}
return $this->data()->$property;
} | php | public function get($property)
{
if (!$this->exists($property)) {
throw new UndefinedPropertyException($property);
}
return $this->data()->$property;
} | [
"public",
"function",
"get",
"(",
"$",
"property",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"exists",
"(",
"$",
"property",
")",
")",
"{",
"throw",
"new",
"UndefinedPropertyException",
"(",
"$",
"property",
")",
";",
"}",
"return",
"$",
"this",
"... | Get the value of the specified property.
@param string $property The property name.
@return mixed The value of the property.
@throws UndefinedPropertyException If the property does not exist. | [
"Get",
"the",
"value",
"of",
"the",
"specified",
"property",
"."
] | ee83a1cad8f68508f05b30c376003045a7cdfcd8 | https://github.com/eloquent/composer-config-reader/blob/ee83a1cad8f68508f05b30c376003045a7cdfcd8/src/ObjectAccess.php#L62-L69 | train |
figdice/figdice | src/figdice/classes/tags/TagFigInclude.php | TagFigInclude.fig_include | private function fig_include(Context $context) {
$file = $this->includedFile;
$realFilename = dirname($context->getFilename()).'/'.$file;
//Create a sub-view, attached to the current element.
$view = new View();
if ($context->view->getCachePath() && $context->view->getTemplatesRoot()) {
$view->setCachePath($context->view->getCachePath(), $context->view->getTemplatesRoot());
}
$view->loadFile($realFilename);
//Parse the subview (build its own tree).
$context->pushInclude($realFilename, $view->figNamespace);
$view->parse();
// If the included template specifies a doctype, use it globally for our context.
if ($view->getRootNode() instanceof ViewElementTag) {
$doctype = $view->getRootNode()->getAttribute($context->figNamespace . 'doctype');
if ($doctype) {
$context->setDoctype($doctype);
}
}
$result = $view->getRootNode()->render($context);
$context->popInclude();
return $result;
} | php | private function fig_include(Context $context) {
$file = $this->includedFile;
$realFilename = dirname($context->getFilename()).'/'.$file;
//Create a sub-view, attached to the current element.
$view = new View();
if ($context->view->getCachePath() && $context->view->getTemplatesRoot()) {
$view->setCachePath($context->view->getCachePath(), $context->view->getTemplatesRoot());
}
$view->loadFile($realFilename);
//Parse the subview (build its own tree).
$context->pushInclude($realFilename, $view->figNamespace);
$view->parse();
// If the included template specifies a doctype, use it globally for our context.
if ($view->getRootNode() instanceof ViewElementTag) {
$doctype = $view->getRootNode()->getAttribute($context->figNamespace . 'doctype');
if ($doctype) {
$context->setDoctype($doctype);
}
}
$result = $view->getRootNode()->render($context);
$context->popInclude();
return $result;
} | [
"private",
"function",
"fig_include",
"(",
"Context",
"$",
"context",
")",
"{",
"$",
"file",
"=",
"$",
"this",
"->",
"includedFile",
";",
"$",
"realFilename",
"=",
"dirname",
"(",
"$",
"context",
"->",
"getFilename",
"(",
")",
")",
".",
"'/'",
".",
"$"... | Creates a sub-view object, invokes its parsing phase,
and renders it as the child of the current tag.
@param Context $context
@return string or false
@throws RequiredAttributeException
@throws \figdice\exceptions\FileNotFoundException
@throws \figdice\exceptions\RenderingException
@throws \figdice\exceptions\XMLParsingException | [
"Creates",
"a",
"sub",
"-",
"view",
"object",
"invokes",
"its",
"parsing",
"phase",
"and",
"renders",
"it",
"as",
"the",
"child",
"of",
"the",
"current",
"tag",
"."
] | 896bbe3aec365c416e368dcc6b888a6cf1832afc | https://github.com/figdice/figdice/blob/896bbe3aec365c416e368dcc6b888a6cf1832afc/src/figdice/classes/tags/TagFigInclude.php#L66-L98 | train |
rojr/SuperCMS | src/Models/User/SuperCMSUser.php | SuperCMSUser.getUserDefaultLocation | public static function getUserDefaultLocation()
{
try {
$user = self::getLoggedInUser();
if ($user->PrimaryLocation) {
return $user->PrimaryLocation;
}
if ($user->Locations && $user->Locations->count()) {
$user->PrimaryLocationID = $user->Locations[0]->UniqueIdentifier;
$user->save();
return $user->PrimaryLocation;
}
} catch (NotLoggedInException $ex) {
}
$basket = Basket::getCurrentBasket();
if ($basket->Locations && $basket->Locations->count()) {
if (isset($user)) {
$user->PrimaryLocationID = $basket->Locations[0];
$user->save();
return $user->PrimaryLocation;
}
return $basket->Locations[0];
}
return null;
} | php | public static function getUserDefaultLocation()
{
try {
$user = self::getLoggedInUser();
if ($user->PrimaryLocation) {
return $user->PrimaryLocation;
}
if ($user->Locations && $user->Locations->count()) {
$user->PrimaryLocationID = $user->Locations[0]->UniqueIdentifier;
$user->save();
return $user->PrimaryLocation;
}
} catch (NotLoggedInException $ex) {
}
$basket = Basket::getCurrentBasket();
if ($basket->Locations && $basket->Locations->count()) {
if (isset($user)) {
$user->PrimaryLocationID = $basket->Locations[0];
$user->save();
return $user->PrimaryLocation;
}
return $basket->Locations[0];
}
return null;
} | [
"public",
"static",
"function",
"getUserDefaultLocation",
"(",
")",
"{",
"try",
"{",
"$",
"user",
"=",
"self",
"::",
"getLoggedInUser",
"(",
")",
";",
"if",
"(",
"$",
"user",
"->",
"PrimaryLocation",
")",
"{",
"return",
"$",
"user",
"->",
"PrimaryLocation"... | First tries to load a location from the user, setting primary location if one isn't set
And then attempts to load from basket.
@return mixed|null|Location | [
"First",
"tries",
"to",
"load",
"a",
"location",
"from",
"the",
"user",
"setting",
"primary",
"location",
"if",
"one",
"isn",
"t",
"set",
"And",
"then",
"attempts",
"to",
"load",
"from",
"basket",
"."
] | 85c42cbf6d326ab253db3787f31cfc8a8f6cd6fc | https://github.com/rojr/SuperCMS/blob/85c42cbf6d326ab253db3787f31cfc8a8f6cd6fc/src/Models/User/SuperCMSUser.php#L82-L108 | train |
ynloultratech/graphql-bundle | src/Behat/Context/ResponseContext.php | ResponseContext.theResponseIsGraphQLErrorWith | public function theResponseIsGraphQLErrorWith(string $message)
{
$this->assertResponseStatus(Response::HTTP_OK);
//success GraphQL response should not contains errors
if ($this->client->getGraphQL()) {
if ($this->isValidGraphQLResponse() && $errors = $this->getGraphQLResponseError()) {
$errorsStack = '';
foreach ($errors as $error) {
$errorsStack .= $error->message."\n";
}
Assert::assertContains($message, $errorsStack);
} else {
$this->graphQLContext->debugLastQuery();
throw new AssertionFailedError('The response is not the expected error response.');
}
}
} | php | public function theResponseIsGraphQLErrorWith(string $message)
{
$this->assertResponseStatus(Response::HTTP_OK);
//success GraphQL response should not contains errors
if ($this->client->getGraphQL()) {
if ($this->isValidGraphQLResponse() && $errors = $this->getGraphQLResponseError()) {
$errorsStack = '';
foreach ($errors as $error) {
$errorsStack .= $error->message."\n";
}
Assert::assertContains($message, $errorsStack);
} else {
$this->graphQLContext->debugLastQuery();
throw new AssertionFailedError('The response is not the expected error response.');
}
}
} | [
"public",
"function",
"theResponseIsGraphQLErrorWith",
"(",
"string",
"$",
"message",
")",
"{",
"$",
"this",
"->",
"assertResponseStatus",
"(",
"Response",
"::",
"HTTP_OK",
")",
";",
"//success GraphQL response should not contains errors",
"if",
"(",
"$",
"this",
"->"... | Assert that latest response is a GraphQL error with the given message
@Then /^the response is GraphQL error with "([^"]*)"$/ | [
"Assert",
"that",
"latest",
"response",
"is",
"a",
"GraphQL",
"error",
"with",
"the",
"given",
"message"
] | 390aa1ca77cf00ae02688839ea4fca1026954501 | https://github.com/ynloultratech/graphql-bundle/blob/390aa1ca77cf00ae02688839ea4fca1026954501/src/Behat/Context/ResponseContext.php#L60-L78 | train |
cakemanager/cakephp-cakemanager | src/Controller/Admin/UsersController.php | UsersController.newPassword | public function newPassword($id = null)
{
$user = $this->Users->get($id, [
'contain' => []
]);
$user->accessible('send_mail', true); // checkbox to send an e-mail
if ($this->request->is(['patch', 'post', 'put'])) {
$user = $this->Users->patchEntity($user, $this->request->data);
if ($this->Users->save($user)) {
if ($user->send_mail) {
$this->EmailListener->passwordConfirmation($user);
}
$this->Flash->success(__('The user has been saved.'));
return $this->redirect($this->referer());
} else {
$this->Flash->error(__('The password could not be saved. Please, try again.'));
}
}
$this->set(compact('user'));
$this->render(Configure::read('CM.AdminUserViews.newPassword'));
} | php | public function newPassword($id = null)
{
$user = $this->Users->get($id, [
'contain' => []
]);
$user->accessible('send_mail', true); // checkbox to send an e-mail
if ($this->request->is(['patch', 'post', 'put'])) {
$user = $this->Users->patchEntity($user, $this->request->data);
if ($this->Users->save($user)) {
if ($user->send_mail) {
$this->EmailListener->passwordConfirmation($user);
}
$this->Flash->success(__('The user has been saved.'));
return $this->redirect($this->referer());
} else {
$this->Flash->error(__('The password could not be saved. Please, try again.'));
}
}
$this->set(compact('user'));
$this->render(Configure::read('CM.AdminUserViews.newPassword'));
} | [
"public",
"function",
"newPassword",
"(",
"$",
"id",
"=",
"null",
")",
"{",
"$",
"user",
"=",
"$",
"this",
"->",
"Users",
"->",
"get",
"(",
"$",
"id",
",",
"[",
"'contain'",
"=>",
"[",
"]",
"]",
")",
";",
"$",
"user",
"->",
"accessible",
"(",
"... | New Password method
Admin action to change someones password.
@param string|null $id User id.
@return void|\Cake\Network\Respose | [
"New",
"Password",
"method"
] | 428f7bc32b64d4bfd51845aebdaf92922c7568b3 | https://github.com/cakemanager/cakephp-cakemanager/blob/428f7bc32b64d4bfd51845aebdaf92922c7568b3/src/Controller/Admin/UsersController.php#L206-L230 | train |
cakemanager/cakephp-cakemanager | src/Controller/Admin/UsersController.php | UsersController.sendActivationMail | public function sendActivationMail($id = null)
{
$user = $this->Users->get($id, [
'contain' => []
]);
$user->set('active', false);
$user->set('activation_key', $this->Users->generateActivationKey());
if ($this->Users->save($user)) {
$this->EmailListener->activation($user);
$this->Flash->success(__('The e-mail has been sent.'));
return $this->redirect($this->referer());
} else {
$this->Flash->error(__('The e-mail could not be sent. Please, try again.'));
}
} | php | public function sendActivationMail($id = null)
{
$user = $this->Users->get($id, [
'contain' => []
]);
$user->set('active', false);
$user->set('activation_key', $this->Users->generateActivationKey());
if ($this->Users->save($user)) {
$this->EmailListener->activation($user);
$this->Flash->success(__('The e-mail has been sent.'));
return $this->redirect($this->referer());
} else {
$this->Flash->error(__('The e-mail could not be sent. Please, try again.'));
}
} | [
"public",
"function",
"sendActivationMail",
"(",
"$",
"id",
"=",
"null",
")",
"{",
"$",
"user",
"=",
"$",
"this",
"->",
"Users",
"->",
"get",
"(",
"$",
"id",
",",
"[",
"'contain'",
"=>",
"[",
"]",
"]",
")",
";",
"$",
"user",
"->",
"set",
"(",
"... | Send Activation Mail method
Method to unactivate a specific user and send a new activation-mail.
@param int $id User id.
@return void|\Cake\Network\Response | [
"Send",
"Activation",
"Mail",
"method"
] | 428f7bc32b64d4bfd51845aebdaf92922c7568b3 | https://github.com/cakemanager/cakephp-cakemanager/blob/428f7bc32b64d4bfd51845aebdaf92922c7568b3/src/Controller/Admin/UsersController.php#L240-L256 | train |
jsifuentes/php-image-upload | src/Services/ImageShack.php | ImageShack.withCredentials | public function withCredentials($username, $password)
{
$this->cookie = null;
$this->credentials = array('username' => $username, 'password' => $password);
return $this;
} | php | public function withCredentials($username, $password)
{
$this->cookie = null;
$this->credentials = array('username' => $username, 'password' => $password);
return $this;
} | [
"public",
"function",
"withCredentials",
"(",
"$",
"username",
",",
"$",
"password",
")",
"{",
"$",
"this",
"->",
"cookie",
"=",
"null",
";",
"$",
"this",
"->",
"credentials",
"=",
"array",
"(",
"'username'",
"=>",
"$",
"username",
",",
"'password'",
"=>... | Upload media by using credentials.
@param string Username
@param string Password
@return $this | [
"Upload",
"media",
"by",
"using",
"credentials",
"."
] | 4b130655ed2ab380f5f2eb051551aa8b388a90a7 | https://github.com/jsifuentes/php-image-upload/blob/4b130655ed2ab380f5f2eb051551aa8b388a90a7/src/Services/ImageShack.php#L24-L29 | train |
jsifuentes/php-image-upload | src/Services/ImageShack.php | ImageShack.upload | public function upload($file, $format = 'json')
{
// Is this "file" a URL?
$url = filter_var($file, FILTER_VALIDATE_URL) !== false;
$data = array(
'key' => $this->key,
'format' => $format
);
if ($url) {
$data['url'] = $file;
} else {
$data['fileupload'] = $file;
}
if ($this->credentials) {
$data['a_username'] = $this->credentials['username'];
$data['a_password'] = $this->credentials['password'];
} else if($this->cookie) {
$data['cookie'] = $this->cookie;
}
return $this->post('https://post.imageshack.us/upload_api.php', $data);
} | php | public function upload($file, $format = 'json')
{
// Is this "file" a URL?
$url = filter_var($file, FILTER_VALIDATE_URL) !== false;
$data = array(
'key' => $this->key,
'format' => $format
);
if ($url) {
$data['url'] = $file;
} else {
$data['fileupload'] = $file;
}
if ($this->credentials) {
$data['a_username'] = $this->credentials['username'];
$data['a_password'] = $this->credentials['password'];
} else if($this->cookie) {
$data['cookie'] = $this->cookie;
}
return $this->post('https://post.imageshack.us/upload_api.php', $data);
} | [
"public",
"function",
"upload",
"(",
"$",
"file",
",",
"$",
"format",
"=",
"'json'",
")",
"{",
"// Is this \"file\" a URL?",
"$",
"url",
"=",
"filter_var",
"(",
"$",
"file",
",",
"FILTER_VALIDATE_URL",
")",
"!==",
"false",
";",
"$",
"data",
"=",
"array",
... | Upload an image to Imageshack
@param string File you will be uploading (URL, Base64)
@param string Description of image
@return mixed Response | [
"Upload",
"an",
"image",
"to",
"Imageshack"
] | 4b130655ed2ab380f5f2eb051551aa8b388a90a7 | https://github.com/jsifuentes/php-image-upload/blob/4b130655ed2ab380f5f2eb051551aa8b388a90a7/src/Services/ImageShack.php#L51-L75 | train |
ynloultratech/graphql-bundle | src/Definition/Loader/Annotation/ObjectTypeAnnotationParser.php | ObjectTypeAnnotationParser.copyFieldsFromInterface | protected function copyFieldsFromInterface(InterfaceDefinition $intDef, FieldsAwareDefinitionInterface $fieldsAwareDefinition)
{
foreach ($intDef->getFields() as $field) {
if (!$fieldsAwareDefinition->hasField($field->getName())) {
$newField = clone $field;
$newField->addInheritedFrom($intDef->getName());
$fieldsAwareDefinition->addField($newField);
} else {
$fieldsAwareDefinition->getField($field->getName())->addInheritedFrom($intDef->getName());
}
}
} | php | protected function copyFieldsFromInterface(InterfaceDefinition $intDef, FieldsAwareDefinitionInterface $fieldsAwareDefinition)
{
foreach ($intDef->getFields() as $field) {
if (!$fieldsAwareDefinition->hasField($field->getName())) {
$newField = clone $field;
$newField->addInheritedFrom($intDef->getName());
$fieldsAwareDefinition->addField($newField);
} else {
$fieldsAwareDefinition->getField($field->getName())->addInheritedFrom($intDef->getName());
}
}
} | [
"protected",
"function",
"copyFieldsFromInterface",
"(",
"InterfaceDefinition",
"$",
"intDef",
",",
"FieldsAwareDefinitionInterface",
"$",
"fieldsAwareDefinition",
")",
"{",
"foreach",
"(",
"$",
"intDef",
"->",
"getFields",
"(",
")",
"as",
"$",
"field",
")",
"{",
... | Copy all fields from interface to given object implementor
@param InterfaceDefinition $intDef
@param FieldsAwareDefinitionInterface $fieldsAwareDefinition | [
"Copy",
"all",
"fields",
"from",
"interface",
"to",
"given",
"object",
"implementor"
] | 390aa1ca77cf00ae02688839ea4fca1026954501 | https://github.com/ynloultratech/graphql-bundle/blob/390aa1ca77cf00ae02688839ea4fca1026954501/src/Definition/Loader/Annotation/ObjectTypeAnnotationParser.php#L238-L249 | train |
ynloultratech/graphql-bundle | src/Definition/Loader/Annotation/ObjectTypeAnnotationParser.php | ObjectTypeAnnotationParser.isExposed | protected function isExposed(ObjectDefinitionInterface $definition, $prop): bool
{
$exposed = $definition->getExclusionPolicy() === ObjectDefinitionInterface::EXCLUDE_NONE;
if ($prop instanceof \ReflectionMethod) {
$exposed = false;
//implicit inclusion
if ($this->getFieldAnnotation($prop, Annotation\Field::class)) {
$exposed = true;
}
}
if ($exposed && $this->getFieldAnnotation($prop, Annotation\Exclude::class)) {
$exposed = false;
} elseif (!$exposed && $this->getFieldAnnotation($prop, Annotation\Expose::class)) {
$exposed = true;
}
/** @var Annotation\Field $fieldAnnotation */
if ($fieldAnnotation = $this->getFieldAnnotation($prop, Annotation\Field::class)) {
$exposed = true;
if ($fieldAnnotation->in) {
$exposed = \in_array($definition->getName(), $fieldAnnotation->in);
} elseif (($fieldAnnotation->notIn)) {
$exposed = !\in_array($definition->getName(), $fieldAnnotation->notIn);
}
}
return $exposed;
} | php | protected function isExposed(ObjectDefinitionInterface $definition, $prop): bool
{
$exposed = $definition->getExclusionPolicy() === ObjectDefinitionInterface::EXCLUDE_NONE;
if ($prop instanceof \ReflectionMethod) {
$exposed = false;
//implicit inclusion
if ($this->getFieldAnnotation($prop, Annotation\Field::class)) {
$exposed = true;
}
}
if ($exposed && $this->getFieldAnnotation($prop, Annotation\Exclude::class)) {
$exposed = false;
} elseif (!$exposed && $this->getFieldAnnotation($prop, Annotation\Expose::class)) {
$exposed = true;
}
/** @var Annotation\Field $fieldAnnotation */
if ($fieldAnnotation = $this->getFieldAnnotation($prop, Annotation\Field::class)) {
$exposed = true;
if ($fieldAnnotation->in) {
$exposed = \in_array($definition->getName(), $fieldAnnotation->in);
} elseif (($fieldAnnotation->notIn)) {
$exposed = !\in_array($definition->getName(), $fieldAnnotation->notIn);
}
}
return $exposed;
} | [
"protected",
"function",
"isExposed",
"(",
"ObjectDefinitionInterface",
"$",
"definition",
",",
"$",
"prop",
")",
":",
"bool",
"{",
"$",
"exposed",
"=",
"$",
"definition",
"->",
"getExclusionPolicy",
"(",
")",
"===",
"ObjectDefinitionInterface",
"::",
"EXCLUDE_NON... | Verify if a given property for given definition is exposed or not
@param ObjectDefinitionInterface $definition
@param \ReflectionMethod|\ReflectionProperty $prop
@return boolean | [
"Verify",
"if",
"a",
"given",
"property",
"for",
"given",
"definition",
"is",
"exposed",
"or",
"not"
] | 390aa1ca77cf00ae02688839ea4fca1026954501 | https://github.com/ynloultratech/graphql-bundle/blob/390aa1ca77cf00ae02688839ea4fca1026954501/src/Definition/Loader/Annotation/ObjectTypeAnnotationParser.php#L409-L439 | train |
ynloultratech/graphql-bundle | src/Definition/Loader/Annotation/ObjectTypeAnnotationParser.php | ObjectTypeAnnotationParser.getFieldAnnotation | protected function getFieldAnnotation($prop, string $annotationClass)
{
if ($prop instanceof \ReflectionProperty) {
return $this->reader->getPropertyAnnotation($prop, $annotationClass);
}
return $this->reader->getMethodAnnotation($prop, $annotationClass);
} | php | protected function getFieldAnnotation($prop, string $annotationClass)
{
if ($prop instanceof \ReflectionProperty) {
return $this->reader->getPropertyAnnotation($prop, $annotationClass);
}
return $this->reader->getMethodAnnotation($prop, $annotationClass);
} | [
"protected",
"function",
"getFieldAnnotation",
"(",
"$",
"prop",
",",
"string",
"$",
"annotationClass",
")",
"{",
"if",
"(",
"$",
"prop",
"instanceof",
"\\",
"ReflectionProperty",
")",
"{",
"return",
"$",
"this",
"->",
"reader",
"->",
"getPropertyAnnotation",
... | Get field specific annotation matching given implementor
@param \ReflectionMethod|\ReflectionProperty $prop
@param string $annotationClass
@return mixed | [
"Get",
"field",
"specific",
"annotation",
"matching",
"given",
"implementor"
] | 390aa1ca77cf00ae02688839ea4fca1026954501 | https://github.com/ynloultratech/graphql-bundle/blob/390aa1ca77cf00ae02688839ea4fca1026954501/src/Definition/Loader/Annotation/ObjectTypeAnnotationParser.php#L449-L456 | train |
thisdata/thisdata-php | src/Endpoint/VerifyEndpoint.php | VerifyEndpoint.verify | public function verify($ip, array $user, $userAgent = null, array $source = null, array $session = null, array $device = null)
{
$event = [
self::PARAM_IP => $ip
];
if (!is_null($userAgent)) {
$event[self::PARAM_USER_AGENT] = $userAgent;
}
$event[self::PARAM_USER] = array_filter([
self::PARAM_USER__ID => $this->findValue(self::PARAM_USER__ID, $user),
self::PARAM_USER__NAME => $this->findValue(self::PARAM_USER__NAME, $user),
self::PARAM_USER__EMAIL => $this->findValue(self::PARAM_USER__EMAIL, $user),
self::PARAM_USER__MOBILE => $this->findValue(self::PARAM_USER__MOBILE, $user),
self::PARAM_USER__AUTHENTICATED => $this->findValue(self::PARAM_USER__AUTHENTICATED, $user),
]);
if (!is_null($source)) {
$event[self::PARAM_SOURCE] = array_filter([
self::PARAM_SOURCE__NAME => $this->findValue(self::PARAM_SOURCE__NAME, $source),
self::PARAM_SOURCE__LOGO_URL => $this->findValue(self::PARAM_SOURCE__LOGO_URL, $source)
]);
}
// Add information about the session
// First, the session ID if it's passed
$event[self::PARAM_SESSION] = array_filter([
self::PARAM_SESSION__ID => $this->findValue(self::PARAM_SESSION__ID, $session)
]);
// Then pull the TD cookie if its present
if (isset($_COOKIE[ThisData::TD_COOKIE_NAME])) {
$event[self::PARAM_SESSION][self::PARAM_SESSION__TD_COOKIE_ID] = $_COOKIE[ThisData::TD_COOKIE_NAME];
}
// Then whether we expect the JS Cookie at all
if ($this->configuration[Builder::CONF_EXPECT_JS_COOKIE]) {
$event[self::PARAM_SESSION][self::PARAM_SESSION__TD_COOKIE_EXPECTED] = $this->configuration[Builder::CONF_EXPECT_JS_COOKIE];
}
if (!is_null($device)) {
$event[self::PARAM_DEVICE] = array_filter([
self::PARAM_DEVICE__ID => $this->findValue(self::PARAM_DEVICE__ID, $device)
]);
}
$response = $this->synchronousExecute('POST', ThisData::ENDPOINT_VERIFY, array_filter($event));
return json_decode($response->getBody(), TRUE);
} | php | public function verify($ip, array $user, $userAgent = null, array $source = null, array $session = null, array $device = null)
{
$event = [
self::PARAM_IP => $ip
];
if (!is_null($userAgent)) {
$event[self::PARAM_USER_AGENT] = $userAgent;
}
$event[self::PARAM_USER] = array_filter([
self::PARAM_USER__ID => $this->findValue(self::PARAM_USER__ID, $user),
self::PARAM_USER__NAME => $this->findValue(self::PARAM_USER__NAME, $user),
self::PARAM_USER__EMAIL => $this->findValue(self::PARAM_USER__EMAIL, $user),
self::PARAM_USER__MOBILE => $this->findValue(self::PARAM_USER__MOBILE, $user),
self::PARAM_USER__AUTHENTICATED => $this->findValue(self::PARAM_USER__AUTHENTICATED, $user),
]);
if (!is_null($source)) {
$event[self::PARAM_SOURCE] = array_filter([
self::PARAM_SOURCE__NAME => $this->findValue(self::PARAM_SOURCE__NAME, $source),
self::PARAM_SOURCE__LOGO_URL => $this->findValue(self::PARAM_SOURCE__LOGO_URL, $source)
]);
}
// Add information about the session
// First, the session ID if it's passed
$event[self::PARAM_SESSION] = array_filter([
self::PARAM_SESSION__ID => $this->findValue(self::PARAM_SESSION__ID, $session)
]);
// Then pull the TD cookie if its present
if (isset($_COOKIE[ThisData::TD_COOKIE_NAME])) {
$event[self::PARAM_SESSION][self::PARAM_SESSION__TD_COOKIE_ID] = $_COOKIE[ThisData::TD_COOKIE_NAME];
}
// Then whether we expect the JS Cookie at all
if ($this->configuration[Builder::CONF_EXPECT_JS_COOKIE]) {
$event[self::PARAM_SESSION][self::PARAM_SESSION__TD_COOKIE_EXPECTED] = $this->configuration[Builder::CONF_EXPECT_JS_COOKIE];
}
if (!is_null($device)) {
$event[self::PARAM_DEVICE] = array_filter([
self::PARAM_DEVICE__ID => $this->findValue(self::PARAM_DEVICE__ID, $device)
]);
}
$response = $this->synchronousExecute('POST', ThisData::ENDPOINT_VERIFY, array_filter($event));
return json_decode($response->getBody(), TRUE);
} | [
"public",
"function",
"verify",
"(",
"$",
"ip",
",",
"array",
"$",
"user",
",",
"$",
"userAgent",
"=",
"null",
",",
"array",
"$",
"source",
"=",
"null",
",",
"array",
"$",
"session",
"=",
"null",
",",
"array",
"$",
"device",
"=",
"null",
")",
"{",
... | Verify the current user to get the risk that their account is being
hijacked.
@param string $ip The IP address of the client logging in
@param array $user Array containing id, and optionally name, email, mobile.
@param string|null $userAgent The browser user agent of the client logging in
@param array|null $source Source details (e.g. for multi-tenanted applications)
@param array|null $session Extra information that provides useful context about the session, for example the session ID, or some cookie information
@param array|null $device Information about the device being used
@return an Array with details on the current risk (a JSON representation of the API response).
@see http://help.thisdata.com/docs/apiv1verify | [
"Verify",
"the",
"current",
"user",
"to",
"get",
"the",
"risk",
"that",
"their",
"account",
"is",
"being",
"hijacked",
"."
] | 1b3144e6308d6a07a5d1d66b2a20df821edf6f99 | https://github.com/thisdata/thisdata-php/blob/1b3144e6308d6a07a5d1d66b2a20df821edf6f99/src/Endpoint/VerifyEndpoint.php#L38-L85 | train |
maastermedia/phpwhois | src/PhpWhois/Whois.php | Whois.clean | public function clean($domain)
{
$domain = trim($domain);
$domain = preg_replace('#^https?://#', '', $domain);
if (substr(strtolower($domain), 0, 4) == "www.") $domain = substr($domain, 4);
return $domain;
} | php | public function clean($domain)
{
$domain = trim($domain);
$domain = preg_replace('#^https?://#', '', $domain);
if (substr(strtolower($domain), 0, 4) == "www.") $domain = substr($domain, 4);
return $domain;
} | [
"public",
"function",
"clean",
"(",
"$",
"domain",
")",
"{",
"$",
"domain",
"=",
"trim",
"(",
"$",
"domain",
")",
";",
"$",
"domain",
"=",
"preg_replace",
"(",
"'#^https?://#'",
",",
"''",
",",
"$",
"domain",
")",
";",
"if",
"(",
"substr",
"(",
"st... | Cleans domain name of empty spaces, www, http and https.
@param string $domain Domain name
@return string | [
"Cleans",
"domain",
"name",
"of",
"empty",
"spaces",
"www",
"http",
"and",
"https",
"."
] | 2e1e76f5049b7d1786e50ff3fe4308f831d46cd8 | https://github.com/maastermedia/phpwhois/blob/2e1e76f5049b7d1786e50ff3fe4308f831d46cd8/src/PhpWhois/Whois.php#L58-L65 | train |
maastermedia/phpwhois | src/PhpWhois/Whois.php | Whois.lookup | public function lookup()
{
if ($this->ip) {
$result = $this->lookupIp($this->ip);
} else {
$result = $this->lookupDomain($this->domain);
}
return $result;
} | php | public function lookup()
{
if ($this->ip) {
$result = $this->lookupIp($this->ip);
} else {
$result = $this->lookupDomain($this->domain);
}
return $result;
} | [
"public",
"function",
"lookup",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"ip",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"lookupIp",
"(",
"$",
"this",
"->",
"ip",
")",
";",
"}",
"else",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"... | Looks up the current domain or IP.
@return string Content of whois lookup. | [
"Looks",
"up",
"the",
"current",
"domain",
"or",
"IP",
"."
] | 2e1e76f5049b7d1786e50ff3fe4308f831d46cd8 | https://github.com/maastermedia/phpwhois/blob/2e1e76f5049b7d1786e50ff3fe4308f831d46cd8/src/PhpWhois/Whois.php#L72-L80 | train |
maastermedia/phpwhois | src/PhpWhois/Whois.php | Whois.lookupDomain | public function lookupDomain($domain)
{
$serverObj = new Server();
$server = $serverObj->getServerByTld($this->tld);
if (!$server) {
throw new Exception("Error: No appropriate Whois server found for $domain domain!");
}
$result = $this->queryServer($server, $domain);
if (!$result) {
throw new Exception("Error: No results retrieved from $server server for $domain domain!");
} else {
while (strpos($result, "Whois Server:") !== false) {
preg_match("/Whois Server: (.*)/", $result, $matches);
$secondary = $matches[1];
if ($secondary) {
$result = $this->queryServer($secondary, $domain);
$server = $secondary;
}
}
}
return "$domain domain lookup results from $server server:\n\n" . $result;
} | php | public function lookupDomain($domain)
{
$serverObj = new Server();
$server = $serverObj->getServerByTld($this->tld);
if (!$server) {
throw new Exception("Error: No appropriate Whois server found for $domain domain!");
}
$result = $this->queryServer($server, $domain);
if (!$result) {
throw new Exception("Error: No results retrieved from $server server for $domain domain!");
} else {
while (strpos($result, "Whois Server:") !== false) {
preg_match("/Whois Server: (.*)/", $result, $matches);
$secondary = $matches[1];
if ($secondary) {
$result = $this->queryServer($secondary, $domain);
$server = $secondary;
}
}
}
return "$domain domain lookup results from $server server:\n\n" . $result;
} | [
"public",
"function",
"lookupDomain",
"(",
"$",
"domain",
")",
"{",
"$",
"serverObj",
"=",
"new",
"Server",
"(",
")",
";",
"$",
"server",
"=",
"$",
"serverObj",
"->",
"getServerByTld",
"(",
"$",
"this",
"->",
"tld",
")",
";",
"if",
"(",
"!",
"$",
"... | Domain lookup.
@param string @domain Domain name
@return string Domain lookup results. | [
"Domain",
"lookup",
"."
] | 2e1e76f5049b7d1786e50ff3fe4308f831d46cd8 | https://github.com/maastermedia/phpwhois/blob/2e1e76f5049b7d1786e50ff3fe4308f831d46cd8/src/PhpWhois/Whois.php#L89-L110 | train |
maastermedia/phpwhois | src/PhpWhois/Whois.php | Whois.lookupIp | public function lookupIp($ip)
{
$results = array();
$continentServer = new Server();
foreach ($continentServer->getContinentServers() as $server) {
$result = $this->queryServer($server, $ip);
if ($result && !in_array($result, $results)) {
$results[$server]= $result;
}
}
$res = "RESULTS FOUND: " . count($results);
foreach ($results as $server => $result) {
$res .= "Lookup results for " . $ip . " from " . $server . " server: " . $result;
}
return $res;
} | php | public function lookupIp($ip)
{
$results = array();
$continentServer = new Server();
foreach ($continentServer->getContinentServers() as $server) {
$result = $this->queryServer($server, $ip);
if ($result && !in_array($result, $results)) {
$results[$server]= $result;
}
}
$res = "RESULTS FOUND: " . count($results);
foreach ($results as $server => $result) {
$res .= "Lookup results for " . $ip . " from " . $server . " server: " . $result;
}
return $res;
} | [
"public",
"function",
"lookupIp",
"(",
"$",
"ip",
")",
"{",
"$",
"results",
"=",
"array",
"(",
")",
";",
"$",
"continentServer",
"=",
"new",
"Server",
"(",
")",
";",
"foreach",
"(",
"$",
"continentServer",
"->",
"getContinentServers",
"(",
")",
"as",
"... | IP lookup.
@param string $ip
@return string IP lookup results. | [
"IP",
"lookup",
"."
] | 2e1e76f5049b7d1786e50ff3fe4308f831d46cd8 | https://github.com/maastermedia/phpwhois/blob/2e1e76f5049b7d1786e50ff3fe4308f831d46cd8/src/PhpWhois/Whois.php#L119-L135 | train |
maastermedia/phpwhois | src/PhpWhois/Whois.php | Whois.queryServer | public function queryServer($server, $domain)
{
$port = 43;
$timeout = 10;
$fp = @fsockopen($server, $port, $errno, $errstr, $timeout);
if ( !$fp ) {
throw new Exception("Socket Error " . $errno . " - " . $errstr);
}
// if($server == "whois.verisign-grs.com") $domain = "=".$domain; // whois.verisign-grs.com requires the equals sign ("=") or it returns any result containing the searched string.
fputs($fp, $domain . "\r\n");
$out = "";
while (!feof($fp)) {
$out .= fgets($fp);
}
fclose($fp);
$res = "";
if ((strpos(strtolower($out), "error") === false) && (strpos(strtolower($out), "not allocated") === false)) {
$rows = explode("\n", $out);
foreach ($rows as $row) {
$row = trim($row);
if (($row != '') && ($row{0} != '#') && ($row{0} != '%')) {
$res .= $row."\n";
}
}
}
return $res;
} | php | public function queryServer($server, $domain)
{
$port = 43;
$timeout = 10;
$fp = @fsockopen($server, $port, $errno, $errstr, $timeout);
if ( !$fp ) {
throw new Exception("Socket Error " . $errno . " - " . $errstr);
}
// if($server == "whois.verisign-grs.com") $domain = "=".$domain; // whois.verisign-grs.com requires the equals sign ("=") or it returns any result containing the searched string.
fputs($fp, $domain . "\r\n");
$out = "";
while (!feof($fp)) {
$out .= fgets($fp);
}
fclose($fp);
$res = "";
if ((strpos(strtolower($out), "error") === false) && (strpos(strtolower($out), "not allocated") === false)) {
$rows = explode("\n", $out);
foreach ($rows as $row) {
$row = trim($row);
if (($row != '') && ($row{0} != '#') && ($row{0} != '%')) {
$res .= $row."\n";
}
}
}
return $res;
} | [
"public",
"function",
"queryServer",
"(",
"$",
"server",
",",
"$",
"domain",
")",
"{",
"$",
"port",
"=",
"43",
";",
"$",
"timeout",
"=",
"10",
";",
"$",
"fp",
"=",
"@",
"fsockopen",
"(",
"$",
"server",
",",
"$",
"port",
",",
"$",
"errno",
",",
... | Queries the whois server.
@param string $server
@param string $domain
@return string Information returned from whois server. | [
"Queries",
"the",
"whois",
"server",
"."
] | 2e1e76f5049b7d1786e50ff3fe4308f831d46cd8 | https://github.com/maastermedia/phpwhois/blob/2e1e76f5049b7d1786e50ff3fe4308f831d46cd8/src/PhpWhois/Whois.php#L145-L172 | train |
psbhanu/whatsapi | src/Tools/MGP25.php | MGP25.getRegistrationClient | private function getRegistrationClient($number)
{
$file = $this->customPath ? $this->customPath . '/phone-id-' . $number . '.dat' : null;
$registration = new Registration($number, $this->debug, $file);
$this->listener->registerRegistrationEvents($registration);
return $registration;
} | php | private function getRegistrationClient($number)
{
$file = $this->customPath ? $this->customPath . '/phone-id-' . $number . '.dat' : null;
$registration = new Registration($number, $this->debug, $file);
$this->listener->registerRegistrationEvents($registration);
return $registration;
} | [
"private",
"function",
"getRegistrationClient",
"(",
"$",
"number",
")",
"{",
"$",
"file",
"=",
"$",
"this",
"->",
"customPath",
"?",
"$",
"this",
"->",
"customPath",
".",
"'/phone-id-'",
".",
"$",
"number",
".",
"'.dat'",
":",
"null",
";",
"$",
"registr... | Get WhatsProt instance for given number
@param string $number
@return \Registration | [
"Get",
"WhatsProt",
"instance",
"for",
"given",
"number"
] | be34f35bb5e0fd3c6f2196260865bef65c1240c2 | https://github.com/psbhanu/whatsapi/blob/be34f35bb5e0fd3c6f2196260865bef65c1240c2/src/Tools/MGP25.php#L89-L97 | train |
spiral/vault | source/Vault/Models/Section.php | Section.isAvailable | public function isAvailable(): bool
{
foreach ($this->items as $item) {
if ($item->isVisible()) {
return true;
}
}
return false;
} | php | public function isAvailable(): bool
{
foreach ($this->items as $item) {
if ($item->isVisible()) {
return true;
}
}
return false;
} | [
"public",
"function",
"isAvailable",
"(",
")",
":",
"bool",
"{",
"foreach",
"(",
"$",
"this",
"->",
"items",
"as",
"$",
"item",
")",
"{",
"if",
"(",
"$",
"item",
"->",
"isVisible",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"f... | Must return true is section has at least one available item.
@return bool | [
"Must",
"return",
"true",
"is",
"section",
"has",
"at",
"least",
"one",
"available",
"item",
"."
] | fb64c1bcaa3aa4e926ff94902bf08e059ad849bf | https://github.com/spiral/vault/blob/fb64c1bcaa3aa4e926ff94902bf08e059ad849bf/source/Vault/Models/Section.php#L77-L86 | train |
tinymighty/skinny | includes/Skin.php | Skin.ResourceLoaderRegisterModules | public static function ResourceLoaderRegisterModules( \ResourceLoader $rl ){
self::$_modulesRegistered = true;
$rl->register( self::$modules );
return true;
} | php | public static function ResourceLoaderRegisterModules( \ResourceLoader $rl ){
self::$_modulesRegistered = true;
$rl->register( self::$modules );
return true;
} | [
"public",
"static",
"function",
"ResourceLoaderRegisterModules",
"(",
"\\",
"ResourceLoader",
"$",
"rl",
")",
"{",
"self",
"::",
"$",
"_modulesRegistered",
"=",
"true",
";",
"$",
"rl",
"->",
"register",
"(",
"self",
"::",
"$",
"modules",
")",
";",
"return",
... | Register resources with the ResourceLoader.
Handler for Hook: ResourceLoaderRegisterModules hook. | [
"Register",
"resources",
"with",
"the",
"ResourceLoader",
"."
] | c653369c68e61522e6a22a729182a49f070cff21 | https://github.com/tinymighty/skinny/blob/c653369c68e61522e6a22a729182a49f070cff21/includes/Skin.php#L42-L46 | train |
tinymighty/skinny | includes/Skin.php | Skin.initPage | public function initPage( \OutputPage $out ){
parent::initPage( $out );
$out->addModules(self::$autoloadModules);
} | php | public function initPage( \OutputPage $out ){
parent::initPage( $out );
$out->addModules(self::$autoloadModules);
} | [
"public",
"function",
"initPage",
"(",
"\\",
"OutputPage",
"$",
"out",
")",
"{",
"parent",
"::",
"initPage",
"(",
"$",
"out",
")",
";",
"$",
"out",
"->",
"addModules",
"(",
"self",
"::",
"$",
"autoloadModules",
")",
";",
"}"
] | Load required modules with ResourceLoader | [
"Load",
"required",
"modules",
"with",
"ResourceLoader"
] | c653369c68e61522e6a22a729182a49f070cff21 | https://github.com/tinymighty/skinny/blob/c653369c68e61522e6a22a729182a49f070cff21/includes/Skin.php#L59-L63 | train |
tinymighty/skinny | includes/Skin.php | Skin.setupSkinUserCss | function setupSkinUserCss( \OutputPage $out ) {
parent::setupSkinUserCss( $out );
//TODO: load modules from parent of layout, too...
$layoutClass = self::getLayoutClass();
$layoutTree = \Skinny::getClassAncestors($layoutClass);
$styles = array('mediawiki.skinning.interface');
foreach ($layoutTree as $lc) {
$styles = array_merge($styles, $lc::getHeadModules());
}
$out->addModuleStyles( $styles );
} | php | function setupSkinUserCss( \OutputPage $out ) {
parent::setupSkinUserCss( $out );
//TODO: load modules from parent of layout, too...
$layoutClass = self::getLayoutClass();
$layoutTree = \Skinny::getClassAncestors($layoutClass);
$styles = array('mediawiki.skinning.interface');
foreach ($layoutTree as $lc) {
$styles = array_merge($styles, $lc::getHeadModules());
}
$out->addModuleStyles( $styles );
} | [
"function",
"setupSkinUserCss",
"(",
"\\",
"OutputPage",
"$",
"out",
")",
"{",
"parent",
"::",
"setupSkinUserCss",
"(",
"$",
"out",
")",
";",
"//TODO: load modules from parent of layout, too...",
"$",
"layoutClass",
"=",
"self",
"::",
"getLayoutClass",
"(",
")",
"... | Loads skin and user CSS files.
@param OutputPage $out | [
"Loads",
"skin",
"and",
"user",
"CSS",
"files",
"."
] | c653369c68e61522e6a22a729182a49f070cff21 | https://github.com/tinymighty/skinny/blob/c653369c68e61522e6a22a729182a49f070cff21/includes/Skin.php#L69-L81 | train |
tinymighty/skinny | includes/Skin.php | Skin.addToBodyAttributes | public function addToBodyAttributes( $out, &$attrs){
$classes = array();
$layout = $this->getLayout();
$attrs['class'] .= ' sitename-'.strtolower(str_replace(' ','_',$GLOBALS['wgSitename']));
$layoutClass = self::getLayoutClass();
$layoutTree = \Skinny::getClassAncestors($layoutClass);
$layoutNames = array_flip(self::$layouts);
foreach ($layoutTree as $lc) {
if (isset($layoutNames[$lc])) {
$classes[] = 'layout-'.$layoutNames[$lc];
}
}
if( $GLOBALS['wgUser']->isLoggedIn() ){
$classes[] = 'user-loggedin';
}else{
$classes[] = 'user-anonymous';
}
$attrs['class'] .= ' '.implode(' ',$classes);
} | php | public function addToBodyAttributes( $out, &$attrs){
$classes = array();
$layout = $this->getLayout();
$attrs['class'] .= ' sitename-'.strtolower(str_replace(' ','_',$GLOBALS['wgSitename']));
$layoutClass = self::getLayoutClass();
$layoutTree = \Skinny::getClassAncestors($layoutClass);
$layoutNames = array_flip(self::$layouts);
foreach ($layoutTree as $lc) {
if (isset($layoutNames[$lc])) {
$classes[] = 'layout-'.$layoutNames[$lc];
}
}
if( $GLOBALS['wgUser']->isLoggedIn() ){
$classes[] = 'user-loggedin';
}else{
$classes[] = 'user-anonymous';
}
$attrs['class'] .= ' '.implode(' ',$classes);
} | [
"public",
"function",
"addToBodyAttributes",
"(",
"$",
"out",
",",
"&",
"$",
"attrs",
")",
"{",
"$",
"classes",
"=",
"array",
"(",
")",
";",
"$",
"layout",
"=",
"$",
"this",
"->",
"getLayout",
"(",
")",
";",
"$",
"attrs",
"[",
"'class'",
"]",
".=",... | Called by OutputPage to provide opportunity to add to body attrs | [
"Called",
"by",
"OutputPage",
"to",
"provide",
"opportunity",
"to",
"add",
"to",
"body",
"attrs"
] | c653369c68e61522e6a22a729182a49f070cff21 | https://github.com/tinymighty/skinny/blob/c653369c68e61522e6a22a729182a49f070cff21/includes/Skin.php#L108-L130 | train |
tinymighty/skinny | includes/Skin.php | Skin.addLayout | public static function addLayout ($name, $className){
if (!class_exists($className)) {
throw new \Exception('Invalid Layout class: '.$className);
}
static::$layouts[$name] = $className;
self::addModules($className::getResourceModules());
} | php | public static function addLayout ($name, $className){
if (!class_exists($className)) {
throw new \Exception('Invalid Layout class: '.$className);
}
static::$layouts[$name] = $className;
self::addModules($className::getResourceModules());
} | [
"public",
"static",
"function",
"addLayout",
"(",
"$",
"name",
",",
"$",
"className",
")",
"{",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"className",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Invalid Layout class: '",
".",
"$",
"className",... | Add a new skin layout for this skin | [
"Add",
"a",
"new",
"skin",
"layout",
"for",
"this",
"skin"
] | c653369c68e61522e6a22a729182a49f070cff21 | https://github.com/tinymighty/skinny/blob/c653369c68e61522e6a22a729182a49f070cff21/includes/Skin.php#L135-L142 | train |
tinymighty/skinny | includes/Skin.php | Skin.addModules | public static function addModules ($modules=array(), $load=false){
if( static::$_modulesRegistered ){
throw new Exception('Skin is attempting to add modules after modules have already been registered.');
}
if(empty($modules)){
return;
}
static::$modules += (array) $modules;
if($load){
static::$autoloadModules += array_keys($modules);
}
} | php | public static function addModules ($modules=array(), $load=false){
if( static::$_modulesRegistered ){
throw new Exception('Skin is attempting to add modules after modules have already been registered.');
}
if(empty($modules)){
return;
}
static::$modules += (array) $modules;
if($load){
static::$autoloadModules += array_keys($modules);
}
} | [
"public",
"static",
"function",
"addModules",
"(",
"$",
"modules",
"=",
"array",
"(",
")",
",",
"$",
"load",
"=",
"false",
")",
"{",
"if",
"(",
"static",
"::",
"$",
"_modulesRegistered",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Skin is attempting to a... | Build a list of modules to be registered to the ResourceLoader when it initializes. | [
"Build",
"a",
"list",
"of",
"modules",
"to",
"be",
"registered",
"to",
"the",
"ResourceLoader",
"when",
"it",
"initializes",
"."
] | c653369c68e61522e6a22a729182a49f070cff21 | https://github.com/tinymighty/skinny/blob/c653369c68e61522e6a22a729182a49f070cff21/includes/Skin.php#L206-L217 | train |
maastermedia/phpwhois | src/PhpWhois/Validator.php | Validator.validateIp | public function validateIp($ip)
{
$ipnums = explode(".", $ip);
if (count($ipnums) != 4) {
return false;
}
foreach($ipnums as $ipnum) {
if (!is_numeric($ipnum) || ($ipnum > 255)) {
return false;
}
}
return $ip;
} | php | public function validateIp($ip)
{
$ipnums = explode(".", $ip);
if (count($ipnums) != 4) {
return false;
}
foreach($ipnums as $ipnum) {
if (!is_numeric($ipnum) || ($ipnum > 255)) {
return false;
}
}
return $ip;
} | [
"public",
"function",
"validateIp",
"(",
"$",
"ip",
")",
"{",
"$",
"ipnums",
"=",
"explode",
"(",
"\".\"",
",",
"$",
"ip",
")",
";",
"if",
"(",
"count",
"(",
"$",
"ipnums",
")",
"!=",
"4",
")",
"{",
"return",
"false",
";",
"}",
"foreach",
"(",
... | Validates if string is IP.
@param string $ip IP or domain name
@return boolean|string $ip IP or domain name | [
"Validates",
"if",
"string",
"is",
"IP",
"."
] | 2e1e76f5049b7d1786e50ff3fe4308f831d46cd8 | https://github.com/maastermedia/phpwhois/blob/2e1e76f5049b7d1786e50ff3fe4308f831d46cd8/src/PhpWhois/Validator.php#L38-L50 | train |
jacklul/e621-api | src/E621.php | E621.prepareRequestParams | private function prepareRequestParams(array $data)
{
$has_resource = false;
$multipart = [];
foreach ($data as $key => $value) {
if (!is_array($value)) {
$multipart[] = ['name' => $key, 'contents' => $value];
continue;
}
foreach ($value as $multiKey => $multiValue) {
is_resource($multiValue) && $has_resource = true;
$multiName = $key . '[' . $multiKey . ']' . (is_array($multiValue) ? '[' . key($multiValue) . ']' : '') . '';
$multipart[] = ['name' => $multiName, 'contents' => (is_array($multiValue) ? reset($multiValue) : $multiValue)];
}
}
if ($has_resource) {
return ['multipart' => $multipart];
}
return ['form_params' => $data];
} | php | private function prepareRequestParams(array $data)
{
$has_resource = false;
$multipart = [];
foreach ($data as $key => $value) {
if (!is_array($value)) {
$multipart[] = ['name' => $key, 'contents' => $value];
continue;
}
foreach ($value as $multiKey => $multiValue) {
is_resource($multiValue) && $has_resource = true;
$multiName = $key . '[' . $multiKey . ']' . (is_array($multiValue) ? '[' . key($multiValue) . ']' : '') . '';
$multipart[] = ['name' => $multiName, 'contents' => (is_array($multiValue) ? reset($multiValue) : $multiValue)];
}
}
if ($has_resource) {
return ['multipart' => $multipart];
}
return ['form_params' => $data];
} | [
"private",
"function",
"prepareRequestParams",
"(",
"array",
"$",
"data",
")",
"{",
"$",
"has_resource",
"=",
"false",
";",
"$",
"multipart",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
... | Prepare request params for POST request, convert to multipart when needed
@param array $data
@return array | [
"Prepare",
"request",
"params",
"for",
"POST",
"request",
"convert",
"to",
"multipart",
"when",
"needed"
] | 7253a8ca91a246120f2bc6dc139dcba22662a813 | https://github.com/jacklul/e621-api/blob/7253a8ca91a246120f2bc6dc139dcba22662a813/src/E621.php#L357-L380 | train |
jacklul/e621-api | src/E621.php | E621.debugLog | private function debugLog($message)
{
$this->debug_log_handler !== null && is_callable($this->debug_log_handler) && call_user_func($this->debug_log_handler, $message);
} | php | private function debugLog($message)
{
$this->debug_log_handler !== null && is_callable($this->debug_log_handler) && call_user_func($this->debug_log_handler, $message);
} | [
"private",
"function",
"debugLog",
"(",
"$",
"message",
")",
"{",
"$",
"this",
"->",
"debug_log_handler",
"!==",
"null",
"&&",
"is_callable",
"(",
"$",
"this",
"->",
"debug_log_handler",
")",
"&&",
"call_user_func",
"(",
"$",
"this",
"->",
"debug_log_handler",... | Write to debug log
@param $message | [
"Write",
"to",
"debug",
"log"
] | 7253a8ca91a246120f2bc6dc139dcba22662a813 | https://github.com/jacklul/e621-api/blob/7253a8ca91a246120f2bc6dc139dcba22662a813/src/E621.php#L401-L404 | train |
jacklul/e621-api | src/E621.php | E621.endDebugStream | private function endDebugStream()
{
if (is_resource($this->debug_log_stream_handle)) {
rewind($this->debug_log_stream_handle);
$this->debugLog('E621 API Verbose HTTP Request output:' . PHP_EOL . stream_get_contents($this->debug_log_stream_handle) . PHP_EOL);
fclose($this->debug_log_stream_handle);
$this->debug_log_stream_handle = null;
}
} | php | private function endDebugStream()
{
if (is_resource($this->debug_log_stream_handle)) {
rewind($this->debug_log_stream_handle);
$this->debugLog('E621 API Verbose HTTP Request output:' . PHP_EOL . stream_get_contents($this->debug_log_stream_handle) . PHP_EOL);
fclose($this->debug_log_stream_handle);
$this->debug_log_stream_handle = null;
}
} | [
"private",
"function",
"endDebugStream",
"(",
")",
"{",
"if",
"(",
"is_resource",
"(",
"$",
"this",
"->",
"debug_log_stream_handle",
")",
")",
"{",
"rewind",
"(",
"$",
"this",
"->",
"debug_log_stream_handle",
")",
";",
"$",
"this",
"->",
"debugLog",
"(",
"... | Write the temporary debug stream to log and close the stream handle | [
"Write",
"the",
"temporary",
"debug",
"stream",
"to",
"log",
"and",
"close",
"the",
"stream",
"handle"
] | 7253a8ca91a246120f2bc6dc139dcba22662a813 | https://github.com/jacklul/e621-api/blob/7253a8ca91a246120f2bc6dc139dcba22662a813/src/E621.php#L409-L417 | train |
jacklul/e621-api | src/E621.php | E621.setProgressHandler | public function setProgressHandler($progress_handler)
{
if ($progress_handler !== null && is_callable($progress_handler)) {
$this->progress_handler = $progress_handler;
} elseif ($progress_handler === null) {
$this->progress_handler = null;
} else {
throw new \InvalidArgumentException('Argument "progress_handler" must be a callable');
}
} | php | public function setProgressHandler($progress_handler)
{
if ($progress_handler !== null && is_callable($progress_handler)) {
$this->progress_handler = $progress_handler;
} elseif ($progress_handler === null) {
$this->progress_handler = null;
} else {
throw new \InvalidArgumentException('Argument "progress_handler" must be a callable');
}
} | [
"public",
"function",
"setProgressHandler",
"(",
"$",
"progress_handler",
")",
"{",
"if",
"(",
"$",
"progress_handler",
"!==",
"null",
"&&",
"is_callable",
"(",
"$",
"progress_handler",
")",
")",
"{",
"$",
"this",
"->",
"progress_handler",
"=",
"$",
"progress_... | Set progress handler
@param callable|null $progress_handler
@throws \InvalidArgumentException | [
"Set",
"progress",
"handler"
] | 7253a8ca91a246120f2bc6dc139dcba22662a813 | https://github.com/jacklul/e621-api/blob/7253a8ca91a246120f2bc6dc139dcba22662a813/src/E621.php#L426-L435 | train |
jacklul/e621-api | src/E621.php | E621.setDebugLogHandler | public function setDebugLogHandler($debug_log_handler)
{
if ($debug_log_handler !== null && is_callable($debug_log_handler)) {
$this->debug_log_handler = $debug_log_handler;
} elseif ($debug_log_handler === null) {
$this->debug_log_handler = null;
} else {
throw new \InvalidArgumentException('Argument "debug_log_handler" must be a callable');
}
} | php | public function setDebugLogHandler($debug_log_handler)
{
if ($debug_log_handler !== null && is_callable($debug_log_handler)) {
$this->debug_log_handler = $debug_log_handler;
} elseif ($debug_log_handler === null) {
$this->debug_log_handler = null;
} else {
throw new \InvalidArgumentException('Argument "debug_log_handler" must be a callable');
}
} | [
"public",
"function",
"setDebugLogHandler",
"(",
"$",
"debug_log_handler",
")",
"{",
"if",
"(",
"$",
"debug_log_handler",
"!==",
"null",
"&&",
"is_callable",
"(",
"$",
"debug_log_handler",
")",
")",
"{",
"$",
"this",
"->",
"debug_log_handler",
"=",
"$",
"debug... | Set debug log handler
@param callable|null $debug_log_handler
@throws \InvalidArgumentException | [
"Set",
"debug",
"log",
"handler"
] | 7253a8ca91a246120f2bc6dc139dcba22662a813 | https://github.com/jacklul/e621-api/blob/7253a8ca91a246120f2bc6dc139dcba22662a813/src/E621.php#L444-L453 | train |
jacklul/e621-api | src/E621.php | E621.login | public function login($login, $api_key)
{
if (empty($login) || !is_string($login)) {
throw new \InvalidArgumentException('Argument "login" cannot be empty and must be a string');
}
if (empty($login) || !is_string($api_key)) {
throw new \InvalidArgumentException('Argument "api_key" cannot be empty and must be a string');
}
$this->auth = [
'login' => $login,
'password_hash' => $api_key,
];
} | php | public function login($login, $api_key)
{
if (empty($login) || !is_string($login)) {
throw new \InvalidArgumentException('Argument "login" cannot be empty and must be a string');
}
if (empty($login) || !is_string($api_key)) {
throw new \InvalidArgumentException('Argument "api_key" cannot be empty and must be a string');
}
$this->auth = [
'login' => $login,
'password_hash' => $api_key,
];
} | [
"public",
"function",
"login",
"(",
"$",
"login",
",",
"$",
"api_key",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"login",
")",
"||",
"!",
"is_string",
"(",
"$",
"login",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Argument \"l... | Set login data globally
@param $login
@param $api_key
@throws \InvalidArgumentException | [
"Set",
"login",
"data",
"globally"
] | 7253a8ca91a246120f2bc6dc139dcba22662a813 | https://github.com/jacklul/e621-api/blob/7253a8ca91a246120f2bc6dc139dcba22662a813/src/E621.php#L463-L477 | train |
ekyna/Dpd | src/Pudo/Api.php | Api.getClient | private function getClient(): Client
{
if (null !== $this->client) {
return $this->client;
}
return $this->client = new Client(
$this->config['carrier'],
$this->config['key'],
$this->config['cache'],
$this->config['debug']
);
} | php | private function getClient(): Client
{
if (null !== $this->client) {
return $this->client;
}
return $this->client = new Client(
$this->config['carrier'],
$this->config['key'],
$this->config['cache'],
$this->config['debug']
);
} | [
"private",
"function",
"getClient",
"(",
")",
":",
"Client",
"{",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"client",
")",
"{",
"return",
"$",
"this",
"->",
"client",
";",
"}",
"return",
"$",
"this",
"->",
"client",
"=",
"new",
"Client",
"(",
"$... | Returns the client.
@return Client | [
"Returns",
"the",
"client",
"."
] | 67eabcff840b310021d5ca7ebb824fa7d7cb700b | https://github.com/ekyna/Dpd/blob/67eabcff840b310021d5ca7ebb824fa7d7cb700b/src/Pudo/Api.php#L87-L99 | train |
rojr/SuperCMS | src/Models/Shopping/Basket.php | Basket.getCurrentBasket | public static function getCurrentBasket()
{
$settings = SuperCMSSession::singleton();
try {
$user = SCmsLoginProvider::getLoggedInUser();
try {
$basket = Basket::findLast(new AndGroup(
[
new Equals('UserID', $user->UniqueIdentifier),
new Not(new Equals('Status', self::STATUS_COMPLETED))
]
));
} catch (RecordNotFoundException $ex) {
$basket = new Basket();
$basket->UserID = $user->UniqueIdentifier;
$basket->save();
}
if ($settings->basketId != $basket->UniqueIdentifier) {
self::joinAnonymousBasketItemsToUserBasket($basket);
self::updateSession($basket);
}
} catch (NotLoggedInException $ex) {
try {
$basket = new Basket($settings->basketId);
} catch (RecordNotFoundException $ex) {
$basket = new Basket();
$basket->save();
self::updateSession($basket);
}
}
return $basket;
} | php | public static function getCurrentBasket()
{
$settings = SuperCMSSession::singleton();
try {
$user = SCmsLoginProvider::getLoggedInUser();
try {
$basket = Basket::findLast(new AndGroup(
[
new Equals('UserID', $user->UniqueIdentifier),
new Not(new Equals('Status', self::STATUS_COMPLETED))
]
));
} catch (RecordNotFoundException $ex) {
$basket = new Basket();
$basket->UserID = $user->UniqueIdentifier;
$basket->save();
}
if ($settings->basketId != $basket->UniqueIdentifier) {
self::joinAnonymousBasketItemsToUserBasket($basket);
self::updateSession($basket);
}
} catch (NotLoggedInException $ex) {
try {
$basket = new Basket($settings->basketId);
} catch (RecordNotFoundException $ex) {
$basket = new Basket();
$basket->save();
self::updateSession($basket);
}
}
return $basket;
} | [
"public",
"static",
"function",
"getCurrentBasket",
"(",
")",
"{",
"$",
"settings",
"=",
"SuperCMSSession",
"::",
"singleton",
"(",
")",
";",
"try",
"{",
"$",
"user",
"=",
"SCmsLoginProvider",
"::",
"getLoggedInUser",
"(",
")",
";",
"try",
"{",
"$",
"baske... | Creates an instance of the basket, and reloads the object.
@return Basket | [
"Creates",
"an",
"instance",
"of",
"the",
"basket",
"and",
"reloads",
"the",
"object",
"."
] | 85c42cbf6d326ab253db3787f31cfc8a8f6cd6fc | https://github.com/rojr/SuperCMS/blob/85c42cbf6d326ab253db3787f31cfc8a8f6cd6fc/src/Models/Shopping/Basket.php#L96-L130 | train |
rojr/SuperCMS | src/Models/Shopping/Basket.php | Basket.markBasketPaid | public static function markBasketPaid(Basket $basket)
{
$basket->Status = Basket::STATUS_COMPLETED;
$basket->save();
$session = SuperCMSSession::singleton();
$session->basketId = 0;
$session->storeSession();
} | php | public static function markBasketPaid(Basket $basket)
{
$basket->Status = Basket::STATUS_COMPLETED;
$basket->save();
$session = SuperCMSSession::singleton();
$session->basketId = 0;
$session->storeSession();
} | [
"public",
"static",
"function",
"markBasketPaid",
"(",
"Basket",
"$",
"basket",
")",
"{",
"$",
"basket",
"->",
"Status",
"=",
"Basket",
"::",
"STATUS_COMPLETED",
";",
"$",
"basket",
"->",
"save",
"(",
")",
";",
"$",
"session",
"=",
"SuperCMSSession",
"::",... | Marks existing basket as paid and reloads all the settings
for a new basket
@param Basket $basket | [
"Marks",
"existing",
"basket",
"as",
"paid",
"and",
"reloads",
"all",
"the",
"settings",
"for",
"a",
"new",
"basket"
] | 85c42cbf6d326ab253db3787f31cfc8a8f6cd6fc | https://github.com/rojr/SuperCMS/blob/85c42cbf6d326ab253db3787f31cfc8a8f6cd6fc/src/Models/Shopping/Basket.php#L165-L172 | train |
psbhanu/whatsapi | src/Events/Listener.php | Listener.registerEvents | protected function registerEvents(WhatsApiEventsManager $manager)
{
foreach ($this->events as $event)
{
if (is_callable(array($this, $event)))
{
$manager->bind($event, [$this, $event]);
}
}
return $this;
} | php | protected function registerEvents(WhatsApiEventsManager $manager)
{
foreach ($this->events as $event)
{
if (is_callable(array($this, $event)))
{
$manager->bind($event, [$this, $event]);
}
}
return $this;
} | [
"protected",
"function",
"registerEvents",
"(",
"WhatsApiEventsManager",
"$",
"manager",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"events",
"as",
"$",
"event",
")",
"{",
"if",
"(",
"is_callable",
"(",
"array",
"(",
"$",
"this",
",",
"$",
"event",
")"... | Binds events to the WhatsApiEventsManager
@param \WhatsApiEventsManager $manager
@return \psbhanu\Whatsapi\Events\Listener | [
"Binds",
"events",
"to",
"the",
"WhatsApiEventsManager"
] | be34f35bb5e0fd3c6f2196260865bef65c1240c2 | https://github.com/psbhanu/whatsapi/blob/be34f35bb5e0fd3c6f2196260865bef65c1240c2/src/Events/Listener.php#L85-L96 | train |
orchestral/control | src/Http/Controllers/RolesController.php | RolesController.update | public function update(RoleProcessor $processor, $roles)
{
return $processor->update($this, Input::all(), $roles);
} | php | public function update(RoleProcessor $processor, $roles)
{
return $processor->update($this, Input::all(), $roles);
} | [
"public",
"function",
"update",
"(",
"RoleProcessor",
"$",
"processor",
",",
"$",
"roles",
")",
"{",
"return",
"$",
"processor",
"->",
"update",
"(",
"$",
"this",
",",
"Input",
"::",
"all",
"(",
")",
",",
"$",
"roles",
")",
";",
"}"
] | Update the role.
@param \Orchestra\Control\Processors\Role $processor
@param int $roles
@return mixed | [
"Update",
"the",
"role",
"."
] | 7c23db19373adbb0fe44491af12f370ba6547d2a | https://github.com/orchestral/control/blob/7c23db19373adbb0fe44491af12f370ba6547d2a/src/Http/Controllers/RolesController.php#L93-L96 | train |
orchestral/control | src/Commands/Synchronizer.php | Synchronizer.handle | public function handle()
{
$admin = $this->app->make('orchestra.role')->admin();
$this->acl->allow($admin->name, ['Manage Users', 'Manage Orchestra', 'Manage Roles', 'Manage Acl']);
} | php | public function handle()
{
$admin = $this->app->make('orchestra.role')->admin();
$this->acl->allow($admin->name, ['Manage Users', 'Manage Orchestra', 'Manage Roles', 'Manage Acl']);
} | [
"public",
"function",
"handle",
"(",
")",
"{",
"$",
"admin",
"=",
"$",
"this",
"->",
"app",
"->",
"make",
"(",
"'orchestra.role'",
")",
"->",
"admin",
"(",
")",
";",
"$",
"this",
"->",
"acl",
"->",
"allow",
"(",
"$",
"admin",
"->",
"name",
",",
"... | Re-sync administrator access control.
@return void | [
"Re",
"-",
"sync",
"administrator",
"access",
"control",
"."
] | 7c23db19373adbb0fe44491af12f370ba6547d2a | https://github.com/orchestral/control/blob/7c23db19373adbb0fe44491af12f370ba6547d2a/src/Commands/Synchronizer.php#L42-L47 | train |
joomla-framework/console | src/Loader/ContainerLoader.php | ContainerLoader.get | public function get(string $name): AbstractCommand
{
if (!$this->has($name))
{
throw new CommandNotFoundException(sprintf('Command "%s" does not exist.', $name));
}
return $this->container->get($this->commandMap[$name]);
} | php | public function get(string $name): AbstractCommand
{
if (!$this->has($name))
{
throw new CommandNotFoundException(sprintf('Command "%s" does not exist.', $name));
}
return $this->container->get($this->commandMap[$name]);
} | [
"public",
"function",
"get",
"(",
"string",
"$",
"name",
")",
":",
"AbstractCommand",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"has",
"(",
"$",
"name",
")",
")",
"{",
"throw",
"new",
"CommandNotFoundException",
"(",
"sprintf",
"(",
"'Command \"%s\" does not... | Loads a command.
@param string $name The command to load.
@return AbstractCommand
@since __DEPLOY_VERSION__
@throws CommandNotFoundException | [
"Loads",
"a",
"command",
"."
] | b8ab98ec0fab96002b22399dea8c2ff206a87380 | https://github.com/joomla-framework/console/blob/b8ab98ec0fab96002b22399dea8c2ff206a87380/src/Loader/ContainerLoader.php#L62-L70 | train |
joomla-framework/console | src/Loader/ContainerLoader.php | ContainerLoader.has | public function has($name): bool
{
return isset($this->commandMap[$name]) && $this->container->has($this->commandMap[$name]);
} | php | public function has($name): bool
{
return isset($this->commandMap[$name]) && $this->container->has($this->commandMap[$name]);
} | [
"public",
"function",
"has",
"(",
"$",
"name",
")",
":",
"bool",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"commandMap",
"[",
"$",
"name",
"]",
")",
"&&",
"$",
"this",
"->",
"container",
"->",
"has",
"(",
"$",
"this",
"->",
"commandMap",
"[",... | Checks if a command exists.
@param string $name The command to check.
@return boolean
@since __DEPLOY_VERSION__ | [
"Checks",
"if",
"a",
"command",
"exists",
"."
] | b8ab98ec0fab96002b22399dea8c2ff206a87380 | https://github.com/joomla-framework/console/blob/b8ab98ec0fab96002b22399dea8c2ff206a87380/src/Loader/ContainerLoader.php#L93-L96 | train |
PlasmaPHP/core | src/Types/TypeExtensionsManager.php | TypeExtensionsManager.getManager | static function getManager(?string $name = null): \Plasma\Types\TypeExtensionsManager {
if($name === null) {
if(!isset(static::$instances[static::GLOBAL_NAME])) {
static::$instances[static::GLOBAL_NAME] = new static();
}
return static::$instances[static::GLOBAL_NAME];
}
if(isset(static::$instances[$name])) {
return static::$instances[$name];
}
throw new \Plasma\Exception('Unknown name');
} | php | static function getManager(?string $name = null): \Plasma\Types\TypeExtensionsManager {
if($name === null) {
if(!isset(static::$instances[static::GLOBAL_NAME])) {
static::$instances[static::GLOBAL_NAME] = new static();
}
return static::$instances[static::GLOBAL_NAME];
}
if(isset(static::$instances[$name])) {
return static::$instances[$name];
}
throw new \Plasma\Exception('Unknown name');
} | [
"static",
"function",
"getManager",
"(",
"?",
"string",
"$",
"name",
"=",
"null",
")",
":",
"\\",
"Plasma",
"\\",
"Types",
"\\",
"TypeExtensionsManager",
"{",
"if",
"(",
"$",
"name",
"===",
"null",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"static",
":... | Get a specific Type Extensions Manager under a specific name.
@param string|null $name If `null` is passed, the generic global one will be returned.
@return \Plasma\Types\TypeExtensionsManager
@throws \Plasma\Exception Thrown if the name does not exist. | [
"Get",
"a",
"specific",
"Type",
"Extensions",
"Manager",
"under",
"a",
"specific",
"name",
"."
] | ce9b1a206e3777f3cf884eec5eee686a073ddfb2 | https://github.com/PlasmaPHP/core/blob/ce9b1a206e3777f3cf884eec5eee686a073ddfb2/src/Types/TypeExtensionsManager.php#L73-L87 | train |
PlasmaPHP/core | src/Types/TypeExtensionsManager.php | TypeExtensionsManager.registerManager | static function registerManager(string $name, ?\Plasma\Types\TypeExtensionsManager $manager = null): void {
if(isset(static::$instances[$name])) {
throw new \Plasma\Exception('Name is already in use');
}
if($manager === null) {
$manager = new static();
}
static::$instances[$name] = $manager;
} | php | static function registerManager(string $name, ?\Plasma\Types\TypeExtensionsManager $manager = null): void {
if(isset(static::$instances[$name])) {
throw new \Plasma\Exception('Name is already in use');
}
if($manager === null) {
$manager = new static();
}
static::$instances[$name] = $manager;
} | [
"static",
"function",
"registerManager",
"(",
"string",
"$",
"name",
",",
"?",
"\\",
"Plasma",
"\\",
"Types",
"\\",
"TypeExtensionsManager",
"$",
"manager",
"=",
"null",
")",
":",
"void",
"{",
"if",
"(",
"isset",
"(",
"static",
"::",
"$",
"instances",
"[... | Registers a specific Type Extensions Manager under a specific name.
@param string $name
@param \Plasma\Types\TypeExtensionsManager|null $manager If `null` is passed, one will be created.
@return void
@throws \Plasma\Exception Thrown if the name is already in use. | [
"Registers",
"a",
"specific",
"Type",
"Extensions",
"Manager",
"under",
"a",
"specific",
"name",
"."
] | ce9b1a206e3777f3cf884eec5eee686a073ddfb2 | https://github.com/PlasmaPHP/core/blob/ce9b1a206e3777f3cf884eec5eee686a073ddfb2/src/Types/TypeExtensionsManager.php#L96-L106 | train |
PlasmaPHP/core | src/Types/TypeExtensionsManager.php | TypeExtensionsManager.encodeType | function encodeType($value, \Plasma\ColumnDefinitionInterface $column): \Plasma\Types\TypeExtensionResultInterface {
$type = \gettype($value);
if($type === 'double') {
$type = 'float';
}
if($type === 'object') {
$classes = \array_merge(
array(\get_class($value)),
\class_parents($value),
\class_implements($value)
);
/** @var \Plasma\Types\TypeExtensionInterface $encoder */
foreach($this->classTypes as $key => $encoder) {
if(\in_array($key, $classes, true)) {
return $encoder->encode($value, $column);
}
}
}
/** @var \Plasma\Types\TypeExtensionInterface $encoder */
foreach($this->regularTypes as $key => $encoder) {
if($type === $key) {
return $encoder->encode($value, $column);
}
}
if($this->enabledFuzzySearch) {
/** @var \Plasma\Types\TypeExtensionInterface $encoder */
foreach($this->classTypes as $key => $encoder) {
if($encoder->canHandleType($value, $column)) {
return $encoder->encode($value, $column);
}
}
/** @var \Plasma\Types\TypeExtensionInterface $encoder */
foreach($this->regularTypes as $key => $encoder) {
if($encoder->canHandleType($value, $column)) {
return $encoder->encode($value, $column);
}
}
}
throw new \Plasma\Exception('Unable to encode given value');
} | php | function encodeType($value, \Plasma\ColumnDefinitionInterface $column): \Plasma\Types\TypeExtensionResultInterface {
$type = \gettype($value);
if($type === 'double') {
$type = 'float';
}
if($type === 'object') {
$classes = \array_merge(
array(\get_class($value)),
\class_parents($value),
\class_implements($value)
);
/** @var \Plasma\Types\TypeExtensionInterface $encoder */
foreach($this->classTypes as $key => $encoder) {
if(\in_array($key, $classes, true)) {
return $encoder->encode($value, $column);
}
}
}
/** @var \Plasma\Types\TypeExtensionInterface $encoder */
foreach($this->regularTypes as $key => $encoder) {
if($type === $key) {
return $encoder->encode($value, $column);
}
}
if($this->enabledFuzzySearch) {
/** @var \Plasma\Types\TypeExtensionInterface $encoder */
foreach($this->classTypes as $key => $encoder) {
if($encoder->canHandleType($value, $column)) {
return $encoder->encode($value, $column);
}
}
/** @var \Plasma\Types\TypeExtensionInterface $encoder */
foreach($this->regularTypes as $key => $encoder) {
if($encoder->canHandleType($value, $column)) {
return $encoder->encode($value, $column);
}
}
}
throw new \Plasma\Exception('Unable to encode given value');
} | [
"function",
"encodeType",
"(",
"$",
"value",
",",
"\\",
"Plasma",
"\\",
"ColumnDefinitionInterface",
"$",
"column",
")",
":",
"\\",
"Plasma",
"\\",
"Types",
"\\",
"TypeExtensionResultInterface",
"{",
"$",
"type",
"=",
"\\",
"gettype",
"(",
"$",
"value",
")",... | Tries to encode a value.
@param mixed $value
@param \Plasma\ColumnDefinitionInterface $column
@return \Plasma\Types\TypeExtensionResultInterface
@throws \Plasma\Exception Thrown if unable to encode the value. | [
"Tries",
"to",
"encode",
"a",
"value",
"."
] | ce9b1a206e3777f3cf884eec5eee686a073ddfb2 | https://github.com/PlasmaPHP/core/blob/ce9b1a206e3777f3cf884eec5eee686a073ddfb2/src/Types/TypeExtensionsManager.php#L192-L237 | train |
PlasmaPHP/core | src/Types/TypeExtensionsManager.php | TypeExtensionsManager.decodeType | function decodeType($type, $value): \Plasma\Types\TypeExtensionResultInterface {
if($type === null && $this->enabledFuzzySearch) {
/** @var \Plasma\Types\TypeExtensionInterface $decoder */
foreach($this->dbTypes as $dbType => $decoder) {
if($decoder->canHandleType($value, null)) {
return $decoder->decode($value);
}
}
} elseif(isset($this->dbTypes[$type])) {
return $this->dbTypes[$type]->decode($value);
}
throw new \Plasma\Exception('Unable to decode given value');
} | php | function decodeType($type, $value): \Plasma\Types\TypeExtensionResultInterface {
if($type === null && $this->enabledFuzzySearch) {
/** @var \Plasma\Types\TypeExtensionInterface $decoder */
foreach($this->dbTypes as $dbType => $decoder) {
if($decoder->canHandleType($value, null)) {
return $decoder->decode($value);
}
}
} elseif(isset($this->dbTypes[$type])) {
return $this->dbTypes[$type]->decode($value);
}
throw new \Plasma\Exception('Unable to decode given value');
} | [
"function",
"decodeType",
"(",
"$",
"type",
",",
"$",
"value",
")",
":",
"\\",
"Plasma",
"\\",
"Types",
"\\",
"TypeExtensionResultInterface",
"{",
"if",
"(",
"$",
"type",
"===",
"null",
"&&",
"$",
"this",
"->",
"enabledFuzzySearch",
")",
"{",
"/** @var \\P... | Tries to decode a value.
@param mixed|null $type The driver-dependent database type identifier. Can be `null` to not use the fast-path.
@param mixed $value
@return \Plasma\Types\TypeExtensionResultInterface
@throws \Plasma\Exception Thrown if unable to decode the value. | [
"Tries",
"to",
"decode",
"a",
"value",
"."
] | ce9b1a206e3777f3cf884eec5eee686a073ddfb2 | https://github.com/PlasmaPHP/core/blob/ce9b1a206e3777f3cf884eec5eee686a073ddfb2/src/Types/TypeExtensionsManager.php#L246-L259 | train |
PlasmaPHP/core | src/ColumnDefinition.php | ColumnDefinition.parseValue | function parseValue($value) {
try {
return \Plasma\Types\TypeExtensionsManager::getManager()->decodeType($this->type, $value)->getValue();
} catch (\Plasma\Exception $e) {
/* Continue regardless of error */
}
return $value;
} | php | function parseValue($value) {
try {
return \Plasma\Types\TypeExtensionsManager::getManager()->decodeType($this->type, $value)->getValue();
} catch (\Plasma\Exception $e) {
/* Continue regardless of error */
}
return $value;
} | [
"function",
"parseValue",
"(",
"$",
"value",
")",
"{",
"try",
"{",
"return",
"\\",
"Plasma",
"\\",
"Types",
"\\",
"TypeExtensionsManager",
"::",
"getManager",
"(",
")",
"->",
"decodeType",
"(",
"$",
"this",
"->",
"type",
",",
"$",
"value",
")",
"->",
"... | Parses the row value into the field type.
@param mixed $value
@return mixed | [
"Parses",
"the",
"row",
"value",
"into",
"the",
"field",
"type",
"."
] | ce9b1a206e3777f3cf884eec5eee686a073ddfb2 | https://github.com/PlasmaPHP/core/blob/ce9b1a206e3777f3cf884eec5eee686a073ddfb2/src/ColumnDefinition.php#L147-L155 | train |
nyeholt/silverstripe-solr | code/extensions/SolrSearchPermissionIndexExtension.php | SolrSearchPermissionIndexExtension.updateQueryBuilder | public function updateQueryBuilder($builder) {
// Make sure the extension requirements have been met before enabling the custom search index.
if(SiteTree::has_extension('SolrIndexable') && SiteTree::has_extension('SiteTreePermissionIndexExtension') && ClassInfo::exists('QueuedJob')) {
// Define the initial user permissions using the general public access flag.
$groups = array(
'anyone'
);
// Apply the logged in access flag and listing of groups for the current authenticated user.
$user = Member::currentUser();
if($user) {
// Don't restrict the search results for an administrator.
if(Permission::checkMember($user, array('ADMIN', 'SITETREE_VIEW_ALL'))) {
return;
}
$groups[] = 'logged-in';
foreach($user->Groups() as $group) {
$groups[] = (string)$group->ID;
}
}
// Apply this permission filter.
$builder->andWith('Groups_ms', $groups);
}
} | php | public function updateQueryBuilder($builder) {
// Make sure the extension requirements have been met before enabling the custom search index.
if(SiteTree::has_extension('SolrIndexable') && SiteTree::has_extension('SiteTreePermissionIndexExtension') && ClassInfo::exists('QueuedJob')) {
// Define the initial user permissions using the general public access flag.
$groups = array(
'anyone'
);
// Apply the logged in access flag and listing of groups for the current authenticated user.
$user = Member::currentUser();
if($user) {
// Don't restrict the search results for an administrator.
if(Permission::checkMember($user, array('ADMIN', 'SITETREE_VIEW_ALL'))) {
return;
}
$groups[] = 'logged-in';
foreach($user->Groups() as $group) {
$groups[] = (string)$group->ID;
}
}
// Apply this permission filter.
$builder->andWith('Groups_ms', $groups);
}
} | [
"public",
"function",
"updateQueryBuilder",
"(",
"$",
"builder",
")",
"{",
"// Make sure the extension requirements have been met before enabling the custom search index.",
"if",
"(",
"SiteTree",
"::",
"has_extension",
"(",
"'SolrIndexable'",
")",
"&&",
"SiteTree",
"::",
"has... | Apply the current user permissions against the solr query builder.
@param SolrQueryBuilder | [
"Apply",
"the",
"current",
"user",
"permissions",
"against",
"the",
"solr",
"query",
"builder",
"."
] | a573df88167ba9b2bec51e2660a4edfdad446fcf | https://github.com/nyeholt/silverstripe-solr/blob/a573df88167ba9b2bec51e2660a4edfdad446fcf/code/extensions/SolrSearchPermissionIndexExtension.php#L16-L48 | train |
ynloultratech/graphql-bundle | src/Behat/Client/GraphQLClient.php | GraphQLClient.sendQuery | public function sendQuery(): Response
{
$data = [
'query' => $this->getGraphQL(),
'variables' => $this->getVariables(),
];
if ($this->operationName) {
$data['operationName'] = $this->operationName;
}
$content = json_encode($data);
$this->insulated = $this->config['insulated'] ?? false;
$this->sendRequest(Request::METHOD_POST, $this->getEndpoint(), $this->getRequestsParameters(), [], $this->getServerParameters(), $content);
return $this->response = $this->getResponse();
} | php | public function sendQuery(): Response
{
$data = [
'query' => $this->getGraphQL(),
'variables' => $this->getVariables(),
];
if ($this->operationName) {
$data['operationName'] = $this->operationName;
}
$content = json_encode($data);
$this->insulated = $this->config['insulated'] ?? false;
$this->sendRequest(Request::METHOD_POST, $this->getEndpoint(), $this->getRequestsParameters(), [], $this->getServerParameters(), $content);
return $this->response = $this->getResponse();
} | [
"public",
"function",
"sendQuery",
"(",
")",
":",
"Response",
"{",
"$",
"data",
"=",
"[",
"'query'",
"=>",
"$",
"this",
"->",
"getGraphQL",
"(",
")",
",",
"'variables'",
"=>",
"$",
"this",
"->",
"getVariables",
"(",
")",
",",
"]",
";",
"if",
"(",
"... | Send the configured query or mutation with given variables
@return Response | [
"Send",
"the",
"configured",
"query",
"or",
"mutation",
"with",
"given",
"variables"
] | 390aa1ca77cf00ae02688839ea4fca1026954501 | https://github.com/ynloultratech/graphql-bundle/blob/390aa1ca77cf00ae02688839ea4fca1026954501/src/Behat/Client/GraphQLClient.php#L206-L222 | train |
ynloultratech/graphql-bundle | src/Behat/Client/GraphQLClient.php | GraphQLClient.sendRequest | public function sendRequest($method, $uri, array $parameters = [], array $files = [], array $server = [], $content = null, $changeHistory = true)
{
set_error_handler(
function ($level, $message, $errFile, $errLine) {
if ($this->deprecationAdviser) {
$this->deprecationAdviser->addWarning($message, $errFile, $errLine);
}
},
E_USER_DEPRECATED
);
$result = parent::request($method, $uri, $parameters, $files, $server, $content, $changeHistory);
restore_error_handler();
return $result;
} | php | public function sendRequest($method, $uri, array $parameters = [], array $files = [], array $server = [], $content = null, $changeHistory = true)
{
set_error_handler(
function ($level, $message, $errFile, $errLine) {
if ($this->deprecationAdviser) {
$this->deprecationAdviser->addWarning($message, $errFile, $errLine);
}
},
E_USER_DEPRECATED
);
$result = parent::request($method, $uri, $parameters, $files, $server, $content, $changeHistory);
restore_error_handler();
return $result;
} | [
"public",
"function",
"sendRequest",
"(",
"$",
"method",
",",
"$",
"uri",
",",
"array",
"$",
"parameters",
"=",
"[",
"]",
",",
"array",
"$",
"files",
"=",
"[",
"]",
",",
"array",
"$",
"server",
"=",
"[",
"]",
",",
"$",
"content",
"=",
"null",
","... | This method works like `request` in the parent class, but has a error handler to catch all deprecation notices.
Can`t be named `request` to override the parent because in projects using symfony4 the signature for this method has been changed
using strict types on each argument.
@param string $method
@param string $uri
@param array $parameters
@param array $files
@param array $server
@param null $content
@param bool $changeHistory
@return \Symfony\Component\DomCrawler\Crawler | [
"This",
"method",
"works",
"like",
"request",
"in",
"the",
"parent",
"class",
"but",
"has",
"a",
"error",
"handler",
"to",
"catch",
"all",
"deprecation",
"notices",
".",
"Can",
"t",
"be",
"named",
"request",
"to",
"override",
"the",
"parent",
"because",
"i... | 390aa1ca77cf00ae02688839ea4fca1026954501 | https://github.com/ynloultratech/graphql-bundle/blob/390aa1ca77cf00ae02688839ea4fca1026954501/src/Behat/Client/GraphQLClient.php#L239-L255 | train |
drmonkeyninja/social-share-url | src/SocialShareUrl.php | SocialShareUrl.getUrl | public function getUrl($service, $url, $params = [])
{
if (!empty($this->stubs[$service])) {
$tokens = [];
$params['url'] = $url;
foreach ($this->tokens as $token) {
$tokens['/{' . $token . '}/'] = urlencode(
!empty($params[$token]) ? $params[$token] : ''
);
}
return preg_replace(array_keys($tokens), $tokens, $this->stubs[$service]);
}
} | php | public function getUrl($service, $url, $params = [])
{
if (!empty($this->stubs[$service])) {
$tokens = [];
$params['url'] = $url;
foreach ($this->tokens as $token) {
$tokens['/{' . $token . '}/'] = urlencode(
!empty($params[$token]) ? $params[$token] : ''
);
}
return preg_replace(array_keys($tokens), $tokens, $this->stubs[$service]);
}
} | [
"public",
"function",
"getUrl",
"(",
"$",
"service",
",",
"$",
"url",
",",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"stubs",
"[",
"$",
"service",
"]",
")",
")",
"{",
"$",
"tokens",
"=",
"[",
"]"... | Creates a share URL
@param string $service Social Media service to create share link for
@param string $url URL to share
@param array $params Additional share parameters
@return string URL | [
"Creates",
"a",
"share",
"URL"
] | a91013f859a267f2837a60ff287f06578ea07d80 | https://github.com/drmonkeyninja/social-share-url/blob/a91013f859a267f2837a60ff287f06578ea07d80/src/SocialShareUrl.php#L48-L60 | train |
figdice/figdice | src/figdice/classes/NativeFunctionFactory.php | NativeFunctionFactory.create | public function create($funcName) {
$dirname = dirname(__FILE__).'/functions';
$filename = "$dirname/Function_$funcName.php";
if( !file_exists($filename) ) {
return null;
}
require_once "$dirname/Function_$funcName.php";
$funcClassName = '\\figdice\\classes\\functions\\Function_'.$funcName;
$reflection = new \ReflectionClass($funcClassName);
/** @var FigFunction $function */
$function = $reflection->newInstance();
return $function;
} | php | public function create($funcName) {
$dirname = dirname(__FILE__).'/functions';
$filename = "$dirname/Function_$funcName.php";
if( !file_exists($filename) ) {
return null;
}
require_once "$dirname/Function_$funcName.php";
$funcClassName = '\\figdice\\classes\\functions\\Function_'.$funcName;
$reflection = new \ReflectionClass($funcClassName);
/** @var FigFunction $function */
$function = $reflection->newInstance();
return $function;
} | [
"public",
"function",
"create",
"(",
"$",
"funcName",
")",
"{",
"$",
"dirname",
"=",
"dirname",
"(",
"__FILE__",
")",
".",
"'/functions'",
";",
"$",
"filename",
"=",
"\"$dirname/Function_$funcName.php\"",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"filena... | Returns an instance of the Function class that
handles the requested function.
@param string $funcName
@return FigFunction|null | [
"Returns",
"an",
"instance",
"of",
"the",
"Function",
"class",
"that",
"handles",
"the",
"requested",
"function",
"."
] | 896bbe3aec365c416e368dcc6b888a6cf1832afc | https://github.com/figdice/figdice/blob/896bbe3aec365c416e368dcc6b888a6cf1832afc/src/figdice/classes/NativeFunctionFactory.php#L31-L48 | train |
eloquent/composer-config-reader | src/Exception/InvalidConfigurationException.php | InvalidConfigurationException.buildMessage | protected function buildMessage(array $errors)
{
$errorList = array();
foreach ($errors as $error) {
$errorList[] = sprintf(
' - [%s] %s',
$error['property'],
$error['message']
);
}
return sprintf(
"The supplied Composer configuration is invalid:\n%s",
implode("\n", $errorList)
);
} | php | protected function buildMessage(array $errors)
{
$errorList = array();
foreach ($errors as $error) {
$errorList[] = sprintf(
' - [%s] %s',
$error['property'],
$error['message']
);
}
return sprintf(
"The supplied Composer configuration is invalid:\n%s",
implode("\n", $errorList)
);
} | [
"protected",
"function",
"buildMessage",
"(",
"array",
"$",
"errors",
")",
"{",
"$",
"errorList",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"errors",
"as",
"$",
"error",
")",
"{",
"$",
"errorList",
"[",
"]",
"=",
"sprintf",
"(",
"' - [%s] %s'"... | Build the exception message.
@param array<integer,array<integer,string>> $errors The errors in the configuration.
@return string The exception message. | [
"Build",
"the",
"exception",
"message",
"."
] | ee83a1cad8f68508f05b30c376003045a7cdfcd8 | https://github.com/eloquent/composer-config-reader/blob/ee83a1cad8f68508f05b30c376003045a7cdfcd8/src/Exception/InvalidConfigurationException.php#L52-L67 | train |
syntaxera/cakephp-sparkpost-plugin | src/Mailer/Transport/SparkPostTransport.php | SparkPostTransport.send | public function send(Email $email)
{
// Load SparkPost configuration settings
$apiKey = $this->config('apiKey');
// Set up HTTP request adapter
$adapter = new CakeHttpAdapter(new Client());
// Create SparkPost API accessor
$sparkpost = new SparkPost($adapter, [ 'key' => $apiKey ]);
// Pre-process CakePHP email object fields
$from = (array) $email->from();
$sender = sprintf('%s <%s>', mb_encode_mimeheader(array_values($from)[0]), array_keys($from)[0]);
$to = (array) $email->to();
$replyTo = $email->getReplyTo() ? array_values($email->getReplyTo())[0] : null;
foreach ($to as $toEmail => $toName) {
$recipients[] = ['address' => [ 'name' => mb_encode_mimeheader($toName), 'email' => $toEmail]];
}
// Build message to send
$message = [
'from' => $sender,
'html' => empty($email->message('html')) ? $email->message('text') : $email->message('html'),
'text' => $email->message('text'),
'subject' => mb_decode_mimeheader($email->subject()),
'recipients' => $recipients
];
if ($replyTo) {
$message['replyTo'] = $replyTo;
}
// Send message
try {
$sparkpost->transmission->send($message);
} catch(APIResponseException $e) {
// TODO: Determine if BRE is the best exception type
throw new BadRequestException(sprintf('SparkPost API error %d (%d): %s (%s)',
$e->getAPICode(), $e->getCode(), ucfirst($e->getAPIMessage()), $e->getAPIDescription()));
}
} | php | public function send(Email $email)
{
// Load SparkPost configuration settings
$apiKey = $this->config('apiKey');
// Set up HTTP request adapter
$adapter = new CakeHttpAdapter(new Client());
// Create SparkPost API accessor
$sparkpost = new SparkPost($adapter, [ 'key' => $apiKey ]);
// Pre-process CakePHP email object fields
$from = (array) $email->from();
$sender = sprintf('%s <%s>', mb_encode_mimeheader(array_values($from)[0]), array_keys($from)[0]);
$to = (array) $email->to();
$replyTo = $email->getReplyTo() ? array_values($email->getReplyTo())[0] : null;
foreach ($to as $toEmail => $toName) {
$recipients[] = ['address' => [ 'name' => mb_encode_mimeheader($toName), 'email' => $toEmail]];
}
// Build message to send
$message = [
'from' => $sender,
'html' => empty($email->message('html')) ? $email->message('text') : $email->message('html'),
'text' => $email->message('text'),
'subject' => mb_decode_mimeheader($email->subject()),
'recipients' => $recipients
];
if ($replyTo) {
$message['replyTo'] = $replyTo;
}
// Send message
try {
$sparkpost->transmission->send($message);
} catch(APIResponseException $e) {
// TODO: Determine if BRE is the best exception type
throw new BadRequestException(sprintf('SparkPost API error %d (%d): %s (%s)',
$e->getAPICode(), $e->getCode(), ucfirst($e->getAPIMessage()), $e->getAPIDescription()));
}
} | [
"public",
"function",
"send",
"(",
"Email",
"$",
"email",
")",
"{",
"// Load SparkPost configuration settings",
"$",
"apiKey",
"=",
"$",
"this",
"->",
"config",
"(",
"'apiKey'",
")",
";",
"// Set up HTTP request adapter",
"$",
"adapter",
"=",
"new",
"CakeHttpAdapt... | Send mail via SparkPost REST API
@param \Cake\Mailer\Email $email Email message
@return array | [
"Send",
"mail",
"via",
"SparkPost",
"REST",
"API"
] | 48294a6f8efc2ccda82d209e9619440de61f70ca | https://github.com/syntaxera/cakephp-sparkpost-plugin/blob/48294a6f8efc2ccda82d209e9619440de61f70ca/src/Mailer/Transport/SparkPostTransport.php#L44-L86 | train |
tinymighty/skinny | includes/Slim.php | Slim.get | protected function get($place, $args=array()){
$sep = isset($args['seperator']) ? $args['seperator'] : ' ';
$content = '';
if(isset($this->content[$place])){
foreach($this->content[$place] as $item){
if($this->options['debug']===true){
$content.='<!--Skinny:Place: '.$place.'-->';
}
switch($item['type']){
case 'hook':
//method will be called with two arrays as arguments
//the first is the args passed to this method (ie. in a template call to $this->insert() )
//the second are the args passed when the hook was bound
$content .= call_user_method_array($item['hook'][0], $item['hook'][1], array($args, $item['arguments']));
break;
case 'html':
$content .= $sep . (string) $item['html'];
break;
case 'template':
$content .= $this->render($item['template'], $item['params']);
break;
}
}
}
//content from #movetoskin and #skintemplate
/*if( Skinny::hasContent($place) ){
foreach(Skinny::getContent($place) as $item){
//pre-rendered html from #movetoskin
if(isset($item['html'])){
if($this->options['debug']===true){
$content.='<!--Skinny:MoveToSkin: '.$template.'-->';
}
$content .= $sep . $item['html'];
}
else
//a template name to render
if(isset($item['template'])){
if($this->options['debug']===true){
$content.='<!--Skinny:Template (via #skintemplate): '.$item['template'].'-->';
}
$content .= $this->render( $item['template'], $item['params'] );
}
}
}*/
return $content;
} | php | protected function get($place, $args=array()){
$sep = isset($args['seperator']) ? $args['seperator'] : ' ';
$content = '';
if(isset($this->content[$place])){
foreach($this->content[$place] as $item){
if($this->options['debug']===true){
$content.='<!--Skinny:Place: '.$place.'-->';
}
switch($item['type']){
case 'hook':
//method will be called with two arrays as arguments
//the first is the args passed to this method (ie. in a template call to $this->insert() )
//the second are the args passed when the hook was bound
$content .= call_user_method_array($item['hook'][0], $item['hook'][1], array($args, $item['arguments']));
break;
case 'html':
$content .= $sep . (string) $item['html'];
break;
case 'template':
$content .= $this->render($item['template'], $item['params']);
break;
}
}
}
//content from #movetoskin and #skintemplate
/*if( Skinny::hasContent($place) ){
foreach(Skinny::getContent($place) as $item){
//pre-rendered html from #movetoskin
if(isset($item['html'])){
if($this->options['debug']===true){
$content.='<!--Skinny:MoveToSkin: '.$template.'-->';
}
$content .= $sep . $item['html'];
}
else
//a template name to render
if(isset($item['template'])){
if($this->options['debug']===true){
$content.='<!--Skinny:Template (via #skintemplate): '.$item['template'].'-->';
}
$content .= $this->render( $item['template'], $item['params'] );
}
}
}*/
return $content;
} | [
"protected",
"function",
"get",
"(",
"$",
"place",
",",
"$",
"args",
"=",
"array",
"(",
")",
")",
"{",
"$",
"sep",
"=",
"isset",
"(",
"$",
"args",
"[",
"'seperator'",
"]",
")",
"?",
"$",
"args",
"[",
"'seperator'",
"]",
":",
"' '",
";",
"$",
"c... | Run content content, optionally passing arguments to provide to
object methods | [
"Run",
"content",
"content",
"optionally",
"passing",
"arguments",
"to",
"provide",
"to",
"object",
"methods"
] | c653369c68e61522e6a22a729182a49f070cff21 | https://github.com/tinymighty/skinny/blob/c653369c68e61522e6a22a729182a49f070cff21/includes/Slim.php#L146-L194 | train |
joomla-framework/console | src/Application.php | Application.configureIO | protected function configureIO()
{
if ($this->consoleInput->hasParameterOption(['--ansi'], true))
{
$this->consoleOutput->setDecorated(true);
}
elseif ($this->consoleInput->hasParameterOption(['--no-ansi'], true))
{
$this->consoleOutput->setDecorated(false);
}
if ($this->consoleInput->hasParameterOption(['--no-interaction', '-n'], true))
{
$this->consoleInput->setInteractive(false);
}
if ($this->consoleInput->hasParameterOption(['--quiet', '-q'], true))
{
$this->consoleOutput->setVerbosity(OutputInterface::VERBOSITY_QUIET);
$this->consoleInput->setInteractive(false);
}
else
{
if ($this->consoleInput->hasParameterOption('-vvv', true)
|| $this->consoleInput->hasParameterOption('--verbose=3', true)
|| $this->consoleInput->getParameterOption('--verbose', false, true) === 3
)
{
$this->consoleOutput->setVerbosity(OutputInterface::VERBOSITY_DEBUG);
}
elseif ($this->consoleInput->hasParameterOption('-vv', true)
|| $this->consoleInput->hasParameterOption('--verbose=2', true)
|| $this->consoleInput->getParameterOption('--verbose', false, true) === 2
)
{
$this->consoleOutput->setVerbosity(OutputInterface::VERBOSITY_VERY_VERBOSE);
}
elseif ($this->consoleInput->hasParameterOption('-v', true)
|| $this->consoleInput->hasParameterOption('--verbose=1', true)
|| $this->consoleInput->hasParameterOption('--verbose', true)
|| $this->consoleInput->getParameterOption('--verbose', false, true)
)
{
$this->consoleOutput->setVerbosity(OutputInterface::VERBOSITY_VERBOSE);
}
}
} | php | protected function configureIO()
{
if ($this->consoleInput->hasParameterOption(['--ansi'], true))
{
$this->consoleOutput->setDecorated(true);
}
elseif ($this->consoleInput->hasParameterOption(['--no-ansi'], true))
{
$this->consoleOutput->setDecorated(false);
}
if ($this->consoleInput->hasParameterOption(['--no-interaction', '-n'], true))
{
$this->consoleInput->setInteractive(false);
}
if ($this->consoleInput->hasParameterOption(['--quiet', '-q'], true))
{
$this->consoleOutput->setVerbosity(OutputInterface::VERBOSITY_QUIET);
$this->consoleInput->setInteractive(false);
}
else
{
if ($this->consoleInput->hasParameterOption('-vvv', true)
|| $this->consoleInput->hasParameterOption('--verbose=3', true)
|| $this->consoleInput->getParameterOption('--verbose', false, true) === 3
)
{
$this->consoleOutput->setVerbosity(OutputInterface::VERBOSITY_DEBUG);
}
elseif ($this->consoleInput->hasParameterOption('-vv', true)
|| $this->consoleInput->hasParameterOption('--verbose=2', true)
|| $this->consoleInput->getParameterOption('--verbose', false, true) === 2
)
{
$this->consoleOutput->setVerbosity(OutputInterface::VERBOSITY_VERY_VERBOSE);
}
elseif ($this->consoleInput->hasParameterOption('-v', true)
|| $this->consoleInput->hasParameterOption('--verbose=1', true)
|| $this->consoleInput->hasParameterOption('--verbose', true)
|| $this->consoleInput->getParameterOption('--verbose', false, true)
)
{
$this->consoleOutput->setVerbosity(OutputInterface::VERBOSITY_VERBOSE);
}
}
} | [
"protected",
"function",
"configureIO",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"consoleInput",
"->",
"hasParameterOption",
"(",
"[",
"'--ansi'",
"]",
",",
"true",
")",
")",
"{",
"$",
"this",
"->",
"consoleOutput",
"->",
"setDecorated",
"(",
"true",
... | Configures the console input and output instances for the process.
@return void
@since __DEPLOY_VERSION__ | [
"Configures",
"the",
"console",
"input",
"and",
"output",
"instances",
"for",
"the",
"process",
"."
] | b8ab98ec0fab96002b22399dea8c2ff206a87380 | https://github.com/joomla-framework/console/blob/b8ab98ec0fab96002b22399dea8c2ff206a87380/src/Application.php#L249-L295 | train |
joomla-framework/console | src/Application.php | Application.findNamespace | public function findNamespace(string $namespace): string
{
$allNamespaces = $this->getNamespaces();
$expr = preg_replace_callback(
'{([^:]+|)}',
function ($matches)
{
return preg_quote($matches[1]) . '[^:]*';
},
$namespace
);
$namespaces = preg_grep('{^' . $expr . '}', $allNamespaces);
if (empty($namespaces))
{
throw new NamespaceNotFoundException(sprintf('There are no commands defined in the "%s" namespace.', $namespace));
}
$exact = \in_array($namespace, $namespaces, true);
if (\count($namespaces) > 1 && !$exact)
{
throw new NamespaceNotFoundException(sprintf('The namespace "%s" is ambiguous.', $namespace));
}
return $exact ? $namespace : reset($namespaces);
} | php | public function findNamespace(string $namespace): string
{
$allNamespaces = $this->getNamespaces();
$expr = preg_replace_callback(
'{([^:]+|)}',
function ($matches)
{
return preg_quote($matches[1]) . '[^:]*';
},
$namespace
);
$namespaces = preg_grep('{^' . $expr . '}', $allNamespaces);
if (empty($namespaces))
{
throw new NamespaceNotFoundException(sprintf('There are no commands defined in the "%s" namespace.', $namespace));
}
$exact = \in_array($namespace, $namespaces, true);
if (\count($namespaces) > 1 && !$exact)
{
throw new NamespaceNotFoundException(sprintf('The namespace "%s" is ambiguous.', $namespace));
}
return $exact ? $namespace : reset($namespaces);
} | [
"public",
"function",
"findNamespace",
"(",
"string",
"$",
"namespace",
")",
":",
"string",
"{",
"$",
"allNamespaces",
"=",
"$",
"this",
"->",
"getNamespaces",
"(",
")",
";",
"$",
"expr",
"=",
"preg_replace_callback",
"(",
"'{([^:]+|)}'",
",",
"function",
"(... | Finds a registered namespace by a name.
@param string $namespace A namespace to search for
@return string
@since __DEPLOY_VERSION__
@throws NamespaceNotFoundException When namespace is incorrect or ambiguous | [
"Finds",
"a",
"registered",
"namespace",
"by",
"a",
"name",
"."
] | b8ab98ec0fab96002b22399dea8c2ff206a87380 | https://github.com/joomla-framework/console/blob/b8ab98ec0fab96002b22399dea8c2ff206a87380/src/Application.php#L462-L490 | train |
joomla-framework/console | src/Application.php | Application.getAllCommands | public function getAllCommands(string $namespace = ''): array
{
$this->initCommands();
if ($namespace === '')
{
$commands = $this->commands;
if (!$this->commandLoader)
{
return $commands;
}
foreach ($this->commandLoader->getNames() as $name)
{
if (!isset($commands[$name]))
{
$commands[$name] = $this->getCommand($name);
}
}
return $commands;
}
$commands = [];
foreach ($this->commands as $name => $command)
{
if ($namespace === $this->extractNamespace($name, substr_count($namespace, ':') + 1))
{
$commands[$name] = $command;
}
}
if ($this->commandLoader)
{
foreach ($this->commandLoader->getNames() as $name)
{
if (!isset($commands[$name]) && $namespace === $this->extractNamespace($name, substr_count($namespace, ':') + 1))
{
$commands[$name] = $this->getCommand($name);
}
}
}
return $commands;
} | php | public function getAllCommands(string $namespace = ''): array
{
$this->initCommands();
if ($namespace === '')
{
$commands = $this->commands;
if (!$this->commandLoader)
{
return $commands;
}
foreach ($this->commandLoader->getNames() as $name)
{
if (!isset($commands[$name]))
{
$commands[$name] = $this->getCommand($name);
}
}
return $commands;
}
$commands = [];
foreach ($this->commands as $name => $command)
{
if ($namespace === $this->extractNamespace($name, substr_count($namespace, ':') + 1))
{
$commands[$name] = $command;
}
}
if ($this->commandLoader)
{
foreach ($this->commandLoader->getNames() as $name)
{
if (!isset($commands[$name]) && $namespace === $this->extractNamespace($name, substr_count($namespace, ':') + 1))
{
$commands[$name] = $this->getCommand($name);
}
}
}
return $commands;
} | [
"public",
"function",
"getAllCommands",
"(",
"string",
"$",
"namespace",
"=",
"''",
")",
":",
"array",
"{",
"$",
"this",
"->",
"initCommands",
"(",
")",
";",
"if",
"(",
"$",
"namespace",
"===",
"''",
")",
"{",
"$",
"commands",
"=",
"$",
"this",
"->",... | Gets all commands, including those available through a command loader, optionally filtered on a command namespace.
@param string $namespace An optional command namespace to filter by.
@return AbstractCommand[]
@since __DEPLOY_VERSION__ | [
"Gets",
"all",
"commands",
"including",
"those",
"available",
"through",
"a",
"command",
"loader",
"optionally",
"filtered",
"on",
"a",
"command",
"namespace",
"."
] | b8ab98ec0fab96002b22399dea8c2ff206a87380 | https://github.com/joomla-framework/console/blob/b8ab98ec0fab96002b22399dea8c2ff206a87380/src/Application.php#L501-L547 | train |
joomla-framework/console | src/Application.php | Application.getDefaultInputDefinition | protected function getDefaultInputDefinition(): InputDefinition
{
return new InputDefinition(
[
new InputArgument('command', InputArgument::REQUIRED, 'The command to execute'),
new InputOption('--help', '-h', InputOption::VALUE_NONE, 'Display the help information'),
new InputOption('--quiet', '-q', InputOption::VALUE_NONE, 'Flag indicating that all output should be silenced'),
new InputOption(
'--verbose',
'-v|vv|vvv',
InputOption::VALUE_NONE,
'Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug'
),
new InputOption('--ansi', '', InputOption::VALUE_NONE, 'Force ANSI output'),
new InputOption('--no-ansi', '', InputOption::VALUE_NONE, 'Disable ANSI output'),
new InputOption('--no-interaction', '-n', InputOption::VALUE_NONE, 'Flag to disable interacting with the user'),
]
);
} | php | protected function getDefaultInputDefinition(): InputDefinition
{
return new InputDefinition(
[
new InputArgument('command', InputArgument::REQUIRED, 'The command to execute'),
new InputOption('--help', '-h', InputOption::VALUE_NONE, 'Display the help information'),
new InputOption('--quiet', '-q', InputOption::VALUE_NONE, 'Flag indicating that all output should be silenced'),
new InputOption(
'--verbose',
'-v|vv|vvv',
InputOption::VALUE_NONE,
'Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug'
),
new InputOption('--ansi', '', InputOption::VALUE_NONE, 'Force ANSI output'),
new InputOption('--no-ansi', '', InputOption::VALUE_NONE, 'Disable ANSI output'),
new InputOption('--no-interaction', '-n', InputOption::VALUE_NONE, 'Flag to disable interacting with the user'),
]
);
} | [
"protected",
"function",
"getDefaultInputDefinition",
"(",
")",
":",
"InputDefinition",
"{",
"return",
"new",
"InputDefinition",
"(",
"[",
"new",
"InputArgument",
"(",
"'command'",
",",
"InputArgument",
"::",
"REQUIRED",
",",
"'The command to execute'",
")",
",",
"n... | Builds the defauilt input definition.
@return InputDefinition
@since __DEPLOY_VERSION__ | [
"Builds",
"the",
"defauilt",
"input",
"definition",
"."
] | b8ab98ec0fab96002b22399dea8c2ff206a87380 | https://github.com/joomla-framework/console/blob/b8ab98ec0fab96002b22399dea8c2ff206a87380/src/Application.php#L666-L684 | train |
joomla-framework/console | src/Application.php | Application.getHelperSet | public function getHelperSet(): HelperSet
{
if (!$this->helperSet)
{
$this->helperSet = $this->getDefaultHelperSet();
}
return $this->helperSet;
} | php | public function getHelperSet(): HelperSet
{
if (!$this->helperSet)
{
$this->helperSet = $this->getDefaultHelperSet();
}
return $this->helperSet;
} | [
"public",
"function",
"getHelperSet",
"(",
")",
":",
"HelperSet",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"helperSet",
")",
"{",
"$",
"this",
"->",
"helperSet",
"=",
"$",
"this",
"->",
"getDefaultHelperSet",
"(",
")",
";",
"}",
"return",
"$",
"this",
... | Get the helper set associated with the application.
@return HelperSet | [
"Get",
"the",
"helper",
"set",
"associated",
"with",
"the",
"application",
"."
] | b8ab98ec0fab96002b22399dea8c2ff206a87380 | https://github.com/joomla-framework/console/blob/b8ab98ec0fab96002b22399dea8c2ff206a87380/src/Application.php#L727-L735 | train |
joomla-framework/console | src/Application.php | Application.getLongVersion | public function getLongVersion(): string
{
$name = $this->getName();
if ($name === '')
{
$name = 'Joomla Console Application';
}
if ($this->getVersion() !== '')
{
return sprintf('%s <info>%s</info>', $name, $this->getVersion());
}
return $name;
} | php | public function getLongVersion(): string
{
$name = $this->getName();
if ($name === '')
{
$name = 'Joomla Console Application';
}
if ($this->getVersion() !== '')
{
return sprintf('%s <info>%s</info>', $name, $this->getVersion());
}
return $name;
} | [
"public",
"function",
"getLongVersion",
"(",
")",
":",
"string",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"getName",
"(",
")",
";",
"if",
"(",
"$",
"name",
"===",
"''",
")",
"{",
"$",
"name",
"=",
"'Joomla Console Application'",
";",
"}",
"if",
"(",... | Get the long version string for the application.
Typically, this is the application name and version and is used in the application help output.
@return string
@since __DEPLOY_VERSION__ | [
"Get",
"the",
"long",
"version",
"string",
"for",
"the",
"application",
"."
] | b8ab98ec0fab96002b22399dea8c2ff206a87380 | https://github.com/joomla-framework/console/blob/b8ab98ec0fab96002b22399dea8c2ff206a87380/src/Application.php#L746-L761 | train |
joomla-framework/console | src/Application.php | Application.hasCommand | public function hasCommand(string $name): bool
{
$this->initCommands();
// If command is already registered, we're good
if (isset($this->commands[$name]))
{
return true;
}
// If there is no loader, we can't look for a command there
if (!$this->commandLoader)
{
return false;
}
return $this->commandLoader->has($name);
} | php | public function hasCommand(string $name): bool
{
$this->initCommands();
// If command is already registered, we're good
if (isset($this->commands[$name]))
{
return true;
}
// If there is no loader, we can't look for a command there
if (!$this->commandLoader)
{
return false;
}
return $this->commandLoader->has($name);
} | [
"public",
"function",
"hasCommand",
"(",
"string",
"$",
"name",
")",
":",
"bool",
"{",
"$",
"this",
"->",
"initCommands",
"(",
")",
";",
"// If command is already registered, we're good",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"commands",
"[",
"$",
"nam... | Check if the application has a command with the given name.
@param string $name The name of the command to check for existence.
@return boolean
@since __DEPLOY_VERSION__ | [
"Check",
"if",
"the",
"application",
"has",
"a",
"command",
"with",
"the",
"given",
"name",
"."
] | b8ab98ec0fab96002b22399dea8c2ff206a87380 | https://github.com/joomla-framework/console/blob/b8ab98ec0fab96002b22399dea8c2ff206a87380/src/Application.php#L822-L839 | train |
joomla-framework/console | src/Application.php | Application.initCommands | private function initCommands()
{
if ($this->initialised)
{
return;
}
$this->initialised = true;
foreach ($this->getDefaultCommands() as $command)
{
$this->addCommand($command);
}
} | php | private function initCommands()
{
if ($this->initialised)
{
return;
}
$this->initialised = true;
foreach ($this->getDefaultCommands() as $command)
{
$this->addCommand($command);
}
} | [
"private",
"function",
"initCommands",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"initialised",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"initialised",
"=",
"true",
";",
"foreach",
"(",
"$",
"this",
"->",
"getDefaultCommands",
"(",
")",
"as"... | Internal function to initialise the command store, this allows the store to be lazy loaded only when needed.
@return void
@since __DEPLOY_VERSION__ | [
"Internal",
"function",
"to",
"initialise",
"the",
"command",
"store",
"this",
"allows",
"the",
"store",
"to",
"be",
"lazy",
"loaded",
"only",
"when",
"needed",
"."
] | b8ab98ec0fab96002b22399dea8c2ff206a87380 | https://github.com/joomla-framework/console/blob/b8ab98ec0fab96002b22399dea8c2ff206a87380/src/Application.php#L1103-L1116 | train |
orchestral/control | src/Validations/Role.php | Role.extendCreate | protected function extendCreate(ValidatorResolver $validator)
{
$name = Keyword::make($validator->getData()['name']);
$validator->after(function (ValidatorResolver $v) use ($name) {
if ($this->isRoleNameAlreadyUsed($name)) {
$v->errors()->add('name', trans('orchestra/control::response.roles.reserved-word'));
}
});
} | php | protected function extendCreate(ValidatorResolver $validator)
{
$name = Keyword::make($validator->getData()['name']);
$validator->after(function (ValidatorResolver $v) use ($name) {
if ($this->isRoleNameAlreadyUsed($name)) {
$v->errors()->add('name', trans('orchestra/control::response.roles.reserved-word'));
}
});
} | [
"protected",
"function",
"extendCreate",
"(",
"ValidatorResolver",
"$",
"validator",
")",
"{",
"$",
"name",
"=",
"Keyword",
"::",
"make",
"(",
"$",
"validator",
"->",
"getData",
"(",
")",
"[",
"'name'",
"]",
")",
";",
"$",
"validator",
"->",
"after",
"("... | Extend create validations.
@param \Illuminate\Contracts\Validation\Validator $validator
@return void | [
"Extend",
"create",
"validations",
"."
] | 7c23db19373adbb0fe44491af12f370ba6547d2a | https://github.com/orchestral/control/blob/7c23db19373adbb0fe44491af12f370ba6547d2a/src/Validations/Role.php#L57-L66 | train |
orchestral/control | src/Validations/Role.php | Role.extendUpdate | protected function extendUpdate(ValidatorResolver $validator)
{
$name = Keyword::make($validator->getData()['name']);
$validator->after(function (ValidatorResolver $v) use ($name) {
if ($this->isRoleNameGuest($name)) {
$v->errors()->add('name', trans('orchestra/control::response.roles.reserved-word'));
}
});
} | php | protected function extendUpdate(ValidatorResolver $validator)
{
$name = Keyword::make($validator->getData()['name']);
$validator->after(function (ValidatorResolver $v) use ($name) {
if ($this->isRoleNameGuest($name)) {
$v->errors()->add('name', trans('orchestra/control::response.roles.reserved-word'));
}
});
} | [
"protected",
"function",
"extendUpdate",
"(",
"ValidatorResolver",
"$",
"validator",
")",
"{",
"$",
"name",
"=",
"Keyword",
"::",
"make",
"(",
"$",
"validator",
"->",
"getData",
"(",
")",
"[",
"'name'",
"]",
")",
";",
"$",
"validator",
"->",
"after",
"("... | Extend update validations.
@param \Illuminate\Contracts\Validation\Validator $validator
@return void | [
"Extend",
"update",
"validations",
"."
] | 7c23db19373adbb0fe44491af12f370ba6547d2a | https://github.com/orchestral/control/blob/7c23db19373adbb0fe44491af12f370ba6547d2a/src/Validations/Role.php#L75-L84 | train |
orchestral/control | src/Validations/Role.php | Role.isRoleNameAlreadyUsed | protected function isRoleNameAlreadyUsed(Keyword $name): bool
{
$roles = Foundation::acl()->roles()->get();
return $name->searchIn($roles) !== false;
} | php | protected function isRoleNameAlreadyUsed(Keyword $name): bool
{
$roles = Foundation::acl()->roles()->get();
return $name->searchIn($roles) !== false;
} | [
"protected",
"function",
"isRoleNameAlreadyUsed",
"(",
"Keyword",
"$",
"name",
")",
":",
"bool",
"{",
"$",
"roles",
"=",
"Foundation",
"::",
"acl",
"(",
")",
"->",
"roles",
"(",
")",
"->",
"get",
"(",
")",
";",
"return",
"$",
"name",
"->",
"searchIn",
... | Check if role name is already used.
@param \Orchestra\Support\Keyword $name
@return bool | [
"Check",
"if",
"role",
"name",
"is",
"already",
"used",
"."
] | 7c23db19373adbb0fe44491af12f370ba6547d2a | https://github.com/orchestral/control/blob/7c23db19373adbb0fe44491af12f370ba6547d2a/src/Validations/Role.php#L93-L98 | train |
tlapnet/report | src/Bridges/Nette/DI/ReportExtension.php | ReportExtension.decorateSubreportsDataSource | protected function decorateSubreportsDataSource(): void
{
$builder = $this->getContainerBuilder();
$subreports = $builder->findByTag(self::TAG_CACHE);
foreach ($subreports as $service => $tag) {
$serviceDef = $builder->getDefinition($service);
// Validate datasource class
if (!is_subclass_of((string) $serviceDef->getType(), DataSource::class)) {
throw new AssertionException(sprintf(
'Please use tag "%s" only on datasource (object %s found in %s).',
self::TAG_CACHE,
$serviceDef->getType(),
$service
));
}
// If cache.key is not provided, pick subreport name (fullname)
if (!isset($tag['key'])) $tag['key'] = $serviceDef->getTag(self::TAG_SUBREPORT_DATASOURCE);
// Validate cache scheme
$this->validateConfig($this->scheme['tags'][self::TAG_CACHE], $tag, sprintf('%s', self::TAG_CACHE));
// Wrap factory to cache
$wrappedDef = $builder->addDefinition(sprintf('%s_cached', $service), $serviceDef);
// Remove definition
$builder->removeDefinition($service);
// Add cached defition of datasource with wrapped original datasource
$builder->addDefinition($service)
->setFactory(CachedDataSource::class, [1 => $wrappedDef])
->addSetup('setKey', [$tag['key']])
->addSetup('setExpiration', [$tag['expiration']])
->addTag(self::TAG_SUBREPORT_DATASOURCE, $wrappedDef->getTag(self::TAG_SUBREPORT_DATASOURCE));
// Append cache tags to subreport introspection
$subreportDef = $builder->getDefinition($wrappedDef->getTag(self::TAG_SUBREPORT_DATASOURCE));
$introspection = $subreportDef->getTag(self::TAG_INTROSPECTION);
$introspection['cache'] = ['datasource' => $tag];
$subreportDef->addTag(self::TAG_INTROSPECTION, $introspection);
}
} | php | protected function decorateSubreportsDataSource(): void
{
$builder = $this->getContainerBuilder();
$subreports = $builder->findByTag(self::TAG_CACHE);
foreach ($subreports as $service => $tag) {
$serviceDef = $builder->getDefinition($service);
// Validate datasource class
if (!is_subclass_of((string) $serviceDef->getType(), DataSource::class)) {
throw new AssertionException(sprintf(
'Please use tag "%s" only on datasource (object %s found in %s).',
self::TAG_CACHE,
$serviceDef->getType(),
$service
));
}
// If cache.key is not provided, pick subreport name (fullname)
if (!isset($tag['key'])) $tag['key'] = $serviceDef->getTag(self::TAG_SUBREPORT_DATASOURCE);
// Validate cache scheme
$this->validateConfig($this->scheme['tags'][self::TAG_CACHE], $tag, sprintf('%s', self::TAG_CACHE));
// Wrap factory to cache
$wrappedDef = $builder->addDefinition(sprintf('%s_cached', $service), $serviceDef);
// Remove definition
$builder->removeDefinition($service);
// Add cached defition of datasource with wrapped original datasource
$builder->addDefinition($service)
->setFactory(CachedDataSource::class, [1 => $wrappedDef])
->addSetup('setKey', [$tag['key']])
->addSetup('setExpiration', [$tag['expiration']])
->addTag(self::TAG_SUBREPORT_DATASOURCE, $wrappedDef->getTag(self::TAG_SUBREPORT_DATASOURCE));
// Append cache tags to subreport introspection
$subreportDef = $builder->getDefinition($wrappedDef->getTag(self::TAG_SUBREPORT_DATASOURCE));
$introspection = $subreportDef->getTag(self::TAG_INTROSPECTION);
$introspection['cache'] = ['datasource' => $tag];
$subreportDef->addTag(self::TAG_INTROSPECTION, $introspection);
}
} | [
"protected",
"function",
"decorateSubreportsDataSource",
"(",
")",
":",
"void",
"{",
"$",
"builder",
"=",
"$",
"this",
"->",
"getContainerBuilder",
"(",
")",
";",
"$",
"subreports",
"=",
"$",
"builder",
"->",
"findByTag",
"(",
"self",
"::",
"TAG_CACHE",
")",... | Make subreport cachable
- cache tags | [
"Make",
"subreport",
"cachable",
"-",
"cache",
"tags"
] | 6852caf0d78422888795432242128d9ce6c491e2 | https://github.com/tlapnet/report/blob/6852caf0d78422888795432242128d9ce6c491e2/src/Bridges/Nette/DI/ReportExtension.php#L568-L611 | train |
figdice/figdice | src/figdice/classes/ViewElement.php | ViewElement.evaluate | public function evaluate(Context $context, $expression) {
if(is_numeric($expression)) {
$expression = (string)$expression;
}
if(! isset($context->view->lexers[$expression]) ) {
$lexer = new Lexer($expression);
$context->view->lexers[$expression] = & $lexer;
$lexer->parse($context);
} else {
$lexer = & $context->view->lexers[$expression];
}
$result = $lexer->evaluate($context);
return $result;
} | php | public function evaluate(Context $context, $expression) {
if(is_numeric($expression)) {
$expression = (string)$expression;
}
if(! isset($context->view->lexers[$expression]) ) {
$lexer = new Lexer($expression);
$context->view->lexers[$expression] = & $lexer;
$lexer->parse($context);
} else {
$lexer = & $context->view->lexers[$expression];
}
$result = $lexer->evaluate($context);
return $result;
} | [
"public",
"function",
"evaluate",
"(",
"Context",
"$",
"context",
",",
"$",
"expression",
")",
"{",
"if",
"(",
"is_numeric",
"(",
"$",
"expression",
")",
")",
"{",
"$",
"expression",
"=",
"(",
"string",
")",
"$",
"expression",
";",
"}",
"if",
"(",
"!... | Evaluate the XPath-like expression
on the data object associated to the view.
@param Context $context
@param string $expression
@return string
@throws \figdice\exceptions\LexerSyntaxErrorException
@throws \figdice\exceptions\LexerUnbalancedParenthesesException
@throws \figdice\exceptions\LexerUnexpectedCharException | [
"Evaluate",
"the",
"XPath",
"-",
"like",
"expression",
"on",
"the",
"data",
"object",
"associated",
"to",
"the",
"view",
"."
] | 896bbe3aec365c416e368dcc6b888a6cf1832afc | https://github.com/figdice/figdice/blob/896bbe3aec365c416e368dcc6b888a6cf1832afc/src/figdice/classes/ViewElement.php#L82-L96 | train |
tlapnet/report | src/Utils/Html.php | Html.el | public static function el($name = NULL, $attrs = NULL)
{
$el = new static;
$parts = explode(' ', (string)$name, 2);
$el->setName($parts[0]);
if (is_array($attrs)) {
$el->attrs = $attrs;
} elseif ($attrs !== NULL) {
$el->setText($attrs);
}
if (isset($parts[1])) {
$matches = preg_match_all('#([a-z0-9:-]+)(?:=(["\'])?(.*?)(?(2)\\2|\s))?#i', $parts[1] . ' ', $matches, PREG_SET_ORDER);
foreach ($matches as $m) {
$el->attrs[$m[1]] = isset($m[3]) ? $m[3] : TRUE;
}
}
return $el;
} | php | public static function el($name = NULL, $attrs = NULL)
{
$el = new static;
$parts = explode(' ', (string)$name, 2);
$el->setName($parts[0]);
if (is_array($attrs)) {
$el->attrs = $attrs;
} elseif ($attrs !== NULL) {
$el->setText($attrs);
}
if (isset($parts[1])) {
$matches = preg_match_all('#([a-z0-9:-]+)(?:=(["\'])?(.*?)(?(2)\\2|\s))?#i', $parts[1] . ' ', $matches, PREG_SET_ORDER);
foreach ($matches as $m) {
$el->attrs[$m[1]] = isset($m[3]) ? $m[3] : TRUE;
}
}
return $el;
} | [
"public",
"static",
"function",
"el",
"(",
"$",
"name",
"=",
"NULL",
",",
"$",
"attrs",
"=",
"NULL",
")",
"{",
"$",
"el",
"=",
"new",
"static",
";",
"$",
"parts",
"=",
"explode",
"(",
"' '",
",",
"(",
"string",
")",
"$",
"name",
",",
"2",
")",
... | Static factory.
@param string element name (or NULL)
@param array|string element 's attributes or plain text content
@return self | [
"Static",
"factory",
"."
] | 6852caf0d78422888795432242128d9ce6c491e2 | https://github.com/tlapnet/report/blob/6852caf0d78422888795432242128d9ce6c491e2/src/Utils/Html.php#L62-L83 | train |
tlapnet/report | src/Utils/Html.php | Html.setName | public function setName($name, $isEmpty = NULL)
{
if ($name !== NULL && !is_string($name)) {
throw new InvalidArgumentException(sprintf('Name must be string or NULL, %s given.', gettype($name)));
}
$this->name = $name;
$this->isEmpty = $isEmpty === NULL ? isset(static::$emptyElements[$name]) : (bool)$isEmpty;
return $this;
} | php | public function setName($name, $isEmpty = NULL)
{
if ($name !== NULL && !is_string($name)) {
throw new InvalidArgumentException(sprintf('Name must be string or NULL, %s given.', gettype($name)));
}
$this->name = $name;
$this->isEmpty = $isEmpty === NULL ? isset(static::$emptyElements[$name]) : (bool)$isEmpty;
return $this;
} | [
"public",
"function",
"setName",
"(",
"$",
"name",
",",
"$",
"isEmpty",
"=",
"NULL",
")",
"{",
"if",
"(",
"$",
"name",
"!==",
"NULL",
"&&",
"!",
"is_string",
"(",
"$",
"name",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
... | Changes element's name.
@param string
@param bool Is element empty?
@return self
@throws InvalidArgumentException | [
"Changes",
"element",
"s",
"name",
"."
] | 6852caf0d78422888795432242128d9ce6c491e2 | https://github.com/tlapnet/report/blob/6852caf0d78422888795432242128d9ce6c491e2/src/Utils/Html.php#L94-L104 | train |
tlapnet/report | src/Utils/Html.php | Html.appendAttribute | public function appendAttribute($name, $value, $option = TRUE)
{
if (is_array($value)) {
$prev = isset($this->attrs[$name]) ? (array)$this->attrs[$name] : [];
$this->attrs[$name] = $value + $prev;
} elseif ((string)$value === '') {
$tmp = &$this->attrs[$name]; // appending empty value? -> ignore, but ensure it exists
} elseif (!isset($this->attrs[$name]) || is_array($this->attrs[$name])) { // needs array
$this->attrs[$name][$value] = $option;
} else {
$this->attrs[$name] = [$this->attrs[$name] => TRUE, $value => $option];
}
return $this;
} | php | public function appendAttribute($name, $value, $option = TRUE)
{
if (is_array($value)) {
$prev = isset($this->attrs[$name]) ? (array)$this->attrs[$name] : [];
$this->attrs[$name] = $value + $prev;
} elseif ((string)$value === '') {
$tmp = &$this->attrs[$name]; // appending empty value? -> ignore, but ensure it exists
} elseif (!isset($this->attrs[$name]) || is_array($this->attrs[$name])) { // needs array
$this->attrs[$name][$value] = $option;
} else {
$this->attrs[$name] = [$this->attrs[$name] => TRUE, $value => $option];
}
return $this;
} | [
"public",
"function",
"appendAttribute",
"(",
"$",
"name",
",",
"$",
"value",
",",
"$",
"option",
"=",
"TRUE",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"prev",
"=",
"isset",
"(",
"$",
"this",
"->",
"attrs",
"[",
"$"... | Appends value to element's attribute.
@param string
@param string|array value to append
@param string|bool value option
@return self | [
"Appends",
"value",
"to",
"element",
"s",
"attribute",
"."
] | 6852caf0d78422888795432242128d9ce6c491e2 | https://github.com/tlapnet/report/blob/6852caf0d78422888795432242128d9ce6c491e2/src/Utils/Html.php#L151-L168 | train |
tlapnet/report | src/Utils/Html.php | Html.getAttribute | public function getAttribute($name)
{
return isset($this->attrs[$name]) ? $this->attrs[$name] : NULL;
} | php | public function getAttribute($name)
{
return isset($this->attrs[$name]) ? $this->attrs[$name] : NULL;
} | [
"public",
"function",
"getAttribute",
"(",
"$",
"name",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"attrs",
"[",
"$",
"name",
"]",
")",
"?",
"$",
"this",
"->",
"attrs",
"[",
"$",
"name",
"]",
":",
"NULL",
";",
"}"
] | Returns element's attribute.
@param string
@return mixed | [
"Returns",
"element",
"s",
"attribute",
"."
] | 6852caf0d78422888795432242128d9ce6c491e2 | https://github.com/tlapnet/report/blob/6852caf0d78422888795432242128d9ce6c491e2/src/Utils/Html.php#L192-L195 | train |
tlapnet/report | src/Utils/Html.php | Html.href | public function href($path, $query = NULL)
{
if ($query) {
$query = http_build_query($query, '', '&');
if ($query !== '') {
$path .= '?' . $query;
}
}
$this->attrs['href'] = $path;
return $this;
} | php | public function href($path, $query = NULL)
{
if ($query) {
$query = http_build_query($query, '', '&');
if ($query !== '') {
$path .= '?' . $query;
}
}
$this->attrs['href'] = $path;
return $this;
} | [
"public",
"function",
"href",
"(",
"$",
"path",
",",
"$",
"query",
"=",
"NULL",
")",
"{",
"if",
"(",
"$",
"query",
")",
"{",
"$",
"query",
"=",
"http_build_query",
"(",
"$",
"query",
",",
"''",
",",
"'&'",
")",
";",
"if",
"(",
"$",
"query",
"!=... | Special setter for element's attribute.
@param string path
@param array query
@return self | [
"Special",
"setter",
"for",
"element",
"s",
"attribute",
"."
] | 6852caf0d78422888795432242128d9ce6c491e2 | https://github.com/tlapnet/report/blob/6852caf0d78422888795432242128d9ce6c491e2/src/Utils/Html.php#L302-L313 | train |
tlapnet/report | src/Utils/Html.php | Html.setHtml | public function setHtml($html)
{
if (is_array($html)) {
throw new InvalidArgumentException(sprintf('Textual content must be a scalar, %s given.', gettype($html)));
}
$this->removeChildren();
$this->children[] = (string)$html;
return $this;
} | php | public function setHtml($html)
{
if (is_array($html)) {
throw new InvalidArgumentException(sprintf('Textual content must be a scalar, %s given.', gettype($html)));
}
$this->removeChildren();
$this->children[] = (string)$html;
return $this;
} | [
"public",
"function",
"setHtml",
"(",
"$",
"html",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"html",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Textual content must be a scalar, %s given.'",
",",
"gettype",
"(",
"$",
"ht... | Sets element's HTML content.
@param string raw HTML string
@return self
@throws InvalidArgumentException | [
"Sets",
"element",
"s",
"HTML",
"content",
"."
] | 6852caf0d78422888795432242128d9ce6c491e2 | https://github.com/tlapnet/report/blob/6852caf0d78422888795432242128d9ce6c491e2/src/Utils/Html.php#L340-L349 | train |
tlapnet/report | src/Utils/Html.php | Html.getHtml | public function getHtml()
{
$s = '';
foreach ($this->children as $child) {
if (is_object($child)) {
$s .= $child->render();
} else {
$s .= $child;
}
}
return $s;
} | php | public function getHtml()
{
$s = '';
foreach ($this->children as $child) {
if (is_object($child)) {
$s .= $child->render();
} else {
$s .= $child;
}
}
return $s;
} | [
"public",
"function",
"getHtml",
"(",
")",
"{",
"$",
"s",
"=",
"''",
";",
"foreach",
"(",
"$",
"this",
"->",
"children",
"as",
"$",
"child",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"child",
")",
")",
"{",
"$",
"s",
".=",
"$",
"child",
"->",... | Returns element's HTML content.
@return string | [
"Returns",
"element",
"s",
"HTML",
"content",
"."
] | 6852caf0d78422888795432242128d9ce6c491e2 | https://github.com/tlapnet/report/blob/6852caf0d78422888795432242128d9ce6c491e2/src/Utils/Html.php#L357-L369 | train |
tlapnet/report | src/Utils/Html.php | Html.setText | public function setText($text)
{
if (!is_array($text) && !$text instanceof self) {
$text = htmlspecialchars((string)$text, ENT_NOQUOTES, 'UTF-8');
}
return $this->setHtml($text);
} | php | public function setText($text)
{
if (!is_array($text) && !$text instanceof self) {
$text = htmlspecialchars((string)$text, ENT_NOQUOTES, 'UTF-8');
}
return $this->setHtml($text);
} | [
"public",
"function",
"setText",
"(",
"$",
"text",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"text",
")",
"&&",
"!",
"$",
"text",
"instanceof",
"self",
")",
"{",
"$",
"text",
"=",
"htmlspecialchars",
"(",
"(",
"string",
")",
"$",
"text",
",",... | Sets element's textual content.
@param string
@return self
@throws InvalidArgumentException | [
"Sets",
"element",
"s",
"textual",
"content",
"."
] | 6852caf0d78422888795432242128d9ce6c491e2 | https://github.com/tlapnet/report/blob/6852caf0d78422888795432242128d9ce6c491e2/src/Utils/Html.php#L379-L386 | train |
tlapnet/report | src/Utils/Html.php | Html.create | public function create($name, $attrs = NULL)
{
$this->insert(NULL, $child = static::el($name, $attrs));
return $child;
} | php | public function create($name, $attrs = NULL)
{
$this->insert(NULL, $child = static::el($name, $attrs));
return $child;
} | [
"public",
"function",
"create",
"(",
"$",
"name",
",",
"$",
"attrs",
"=",
"NULL",
")",
"{",
"$",
"this",
"->",
"insert",
"(",
"NULL",
",",
"$",
"child",
"=",
"static",
"::",
"el",
"(",
"$",
"name",
",",
"$",
"attrs",
")",
")",
";",
"return",
"$... | Creates and adds a new Html child.
@param string elements's name
@param array|string element 's attributes or raw HTML string
@return self created element | [
"Creates",
"and",
"adds",
"a",
"new",
"Html",
"child",
"."
] | 6852caf0d78422888795432242128d9ce6c491e2 | https://github.com/tlapnet/report/blob/6852caf0d78422888795432242128d9ce6c491e2/src/Utils/Html.php#L419-L424 | train |
tlapnet/report | src/Utils/Html.php | Html.insert | public function insert($index, $child, $replace = FALSE)
{
if ($child instanceof self || is_scalar($child)) {
if ($index === NULL) { // append
$this->children[] = $child;
} else { // insert or replace
array_splice($this->children, (int)$index, $replace ? 1 : 0, [$child]);
}
} else {
throw new InvalidArgumentException(sprintf('Child node must be scalar or Html object, %s given.', is_object($child) ? get_class($child) : gettype($child)));
}
return $this;
} | php | public function insert($index, $child, $replace = FALSE)
{
if ($child instanceof self || is_scalar($child)) {
if ($index === NULL) { // append
$this->children[] = $child;
} else { // insert or replace
array_splice($this->children, (int)$index, $replace ? 1 : 0, [$child]);
}
} else {
throw new InvalidArgumentException(sprintf('Child node must be scalar or Html object, %s given.', is_object($child) ? get_class($child) : gettype($child)));
}
return $this;
} | [
"public",
"function",
"insert",
"(",
"$",
"index",
",",
"$",
"child",
",",
"$",
"replace",
"=",
"FALSE",
")",
"{",
"if",
"(",
"$",
"child",
"instanceof",
"self",
"||",
"is_scalar",
"(",
"$",
"child",
")",
")",
"{",
"if",
"(",
"$",
"index",
"===",
... | Inserts child node.
@param int|NULL position or NULL for appending
@param Html|string Html node or raw HTML string
@param bool
@return self
@throws InvalidArgumentException | [
"Inserts",
"child",
"node",
"."
] | 6852caf0d78422888795432242128d9ce6c491e2 | https://github.com/tlapnet/report/blob/6852caf0d78422888795432242128d9ce6c491e2/src/Utils/Html.php#L436-L451 | train |
tlapnet/report | src/Utils/Html.php | Html.render | public function render($indent = NULL)
{
$s = $this->startTag();
if (!$this->isEmpty) {
// add content
if ($indent !== NULL) {
$indent++;
}
foreach ($this->children as $child) {
if (is_object($child)) {
$s .= $child->render($indent);
} else {
$s .= $child;
}
}
// add end tag
$s .= $this->endTag();
}
if ($indent !== NULL) {
return "\n" . str_repeat("\t", $indent - 1) . $s . "\n" . str_repeat("\t", max(0, $indent - 2));
}
return $s;
} | php | public function render($indent = NULL)
{
$s = $this->startTag();
if (!$this->isEmpty) {
// add content
if ($indent !== NULL) {
$indent++;
}
foreach ($this->children as $child) {
if (is_object($child)) {
$s .= $child->render($indent);
} else {
$s .= $child;
}
}
// add end tag
$s .= $this->endTag();
}
if ($indent !== NULL) {
return "\n" . str_repeat("\t", $indent - 1) . $s . "\n" . str_repeat("\t", max(0, $indent - 2));
}
return $s;
} | [
"public",
"function",
"render",
"(",
"$",
"indent",
"=",
"NULL",
")",
"{",
"$",
"s",
"=",
"$",
"this",
"->",
"startTag",
"(",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"isEmpty",
")",
"{",
"// add content",
"if",
"(",
"$",
"indent",
"!==",
"NU... | Renders element's start tag, content and end tag.
@param int
@return string | [
"Renders",
"element",
"s",
"start",
"tag",
"content",
"and",
"end",
"tag",
"."
] | 6852caf0d78422888795432242128d9ce6c491e2 | https://github.com/tlapnet/report/blob/6852caf0d78422888795432242128d9ce6c491e2/src/Utils/Html.php#L555-L581 | train |
tlapnet/report | src/Utils/Html.php | Html.startTag | public function startTag()
{
if ($this->name) {
return '<' . $this->name . $this->attributes() . (static::$xhtml && $this->isEmpty ? ' />' : '>');
} else {
return '';
}
} | php | public function startTag()
{
if ($this->name) {
return '<' . $this->name . $this->attributes() . (static::$xhtml && $this->isEmpty ? ' />' : '>');
} else {
return '';
}
} | [
"public",
"function",
"startTag",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"name",
")",
"{",
"return",
"'<'",
".",
"$",
"this",
"->",
"name",
".",
"$",
"this",
"->",
"attributes",
"(",
")",
".",
"(",
"static",
"::",
"$",
"xhtml",
"&&",
"$",
... | Returns element's start tag.
@return string | [
"Returns",
"element",
"s",
"start",
"tag",
"."
] | 6852caf0d78422888795432242128d9ce6c491e2 | https://github.com/tlapnet/report/blob/6852caf0d78422888795432242128d9ce6c491e2/src/Utils/Html.php#L600-L608 | train |
tlapnet/report | src/Utils/Html.php | Html.attributes | public function attributes()
{
if (!is_array($this->attrs)) {
return '';
}
$s = '';
$attrs = $this->attrs;
foreach ($attrs as $key => $value) {
if ($value === NULL || $value === FALSE) {
continue;
} elseif ($value === TRUE) {
if (static::$xhtml) {
$s .= ' ' . $key . '="' . $key . '"';
} else {
$s .= ' ' . $key;
}
continue;
} elseif (is_array($value)) {
if (strncmp($key, 'data-', 5) === 0) {
$value = json_encode($value);
} else {
$tmp = NULL;
foreach ($value as $k => $v) {
if ($v != NULL) { // intentionally ==, skip NULLs & empty string
// composite 'style' vs. 'others'
$tmp[] = $v === TRUE ? $k : (is_string($k) ? $k . ':' . $v : $v);
}
}
if ($tmp === NULL) {
continue;
}
$value = implode($key === 'style' || !strncmp($key, 'on', 2) ? ';' : ' ', $tmp);
}
} elseif (is_float($value)) {
$value = rtrim(rtrim(number_format($value, 10, '.', ''), '0'), '.');
} else {
$value = (string)$value;
}
$q = strpos($value, '"') === FALSE ? '"' : "'";
$s .= ' ' . $key . '=' . $q
. str_replace(
['&', $q, '<'],
['&', $q === '"' ? '"' : ''', self::$xhtml ? '<' : '<'],
$value
)
. (strpos($value, '`') !== FALSE && strpbrk($value, ' <>"\'') === FALSE ? ' ' : '')
. $q;
}
$s = str_replace('@', '@', $s);
return $s;
} | php | public function attributes()
{
if (!is_array($this->attrs)) {
return '';
}
$s = '';
$attrs = $this->attrs;
foreach ($attrs as $key => $value) {
if ($value === NULL || $value === FALSE) {
continue;
} elseif ($value === TRUE) {
if (static::$xhtml) {
$s .= ' ' . $key . '="' . $key . '"';
} else {
$s .= ' ' . $key;
}
continue;
} elseif (is_array($value)) {
if (strncmp($key, 'data-', 5) === 0) {
$value = json_encode($value);
} else {
$tmp = NULL;
foreach ($value as $k => $v) {
if ($v != NULL) { // intentionally ==, skip NULLs & empty string
// composite 'style' vs. 'others'
$tmp[] = $v === TRUE ? $k : (is_string($k) ? $k . ':' . $v : $v);
}
}
if ($tmp === NULL) {
continue;
}
$value = implode($key === 'style' || !strncmp($key, 'on', 2) ? ';' : ' ', $tmp);
}
} elseif (is_float($value)) {
$value = rtrim(rtrim(number_format($value, 10, '.', ''), '0'), '.');
} else {
$value = (string)$value;
}
$q = strpos($value, '"') === FALSE ? '"' : "'";
$s .= ' ' . $key . '=' . $q
. str_replace(
['&', $q, '<'],
['&', $q === '"' ? '"' : ''', self::$xhtml ? '<' : '<'],
$value
)
. (strpos($value, '`') !== FALSE && strpbrk($value, ' <>"\'') === FALSE ? ' ' : '')
. $q;
}
$s = str_replace('@', '@', $s);
return $s;
} | [
"public",
"function",
"attributes",
"(",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"this",
"->",
"attrs",
")",
")",
"{",
"return",
"''",
";",
"}",
"$",
"s",
"=",
"''",
";",
"$",
"attrs",
"=",
"$",
"this",
"->",
"attrs",
";",
"foreach",
"(... | Returns element's attributes.
@return string
@internal | [
"Returns",
"element",
"s",
"attributes",
"."
] | 6852caf0d78422888795432242128d9ce6c491e2 | https://github.com/tlapnet/report/blob/6852caf0d78422888795432242128d9ce6c491e2/src/Utils/Html.php#L628-L689 | train |
BeastPHP/easy-geetest | src/Traits/Request.php | Request.request | protected function request($method, $endpoint, $options = [])
{
return $this->unwrapResponse($this->getHttpClient($this->getBaseOptions())->{$method}($endpoint, $options));
} | php | protected function request($method, $endpoint, $options = [])
{
return $this->unwrapResponse($this->getHttpClient($this->getBaseOptions())->{$method}($endpoint, $options));
} | [
"protected",
"function",
"request",
"(",
"$",
"method",
",",
"$",
"endpoint",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"unwrapResponse",
"(",
"$",
"this",
"->",
"getHttpClient",
"(",
"$",
"this",
"->",
"getBaseOptions",
... | Make a http request.
@param string $method
@param string $endpoint
@param array $options http://docs.guzzlephp.org/en/latest/request-options.html
@return array | [
"Make",
"a",
"http",
"request",
"."
] | 13e64f8dca17cdb0cf48a8cf73042e108f9bb699 | https://github.com/BeastPHP/easy-geetest/blob/13e64f8dca17cdb0cf48a8cf73042e108f9bb699/src/Traits/Request.php#L79-L82 | train |
ynloultratech/graphql-bundle | src/Subscription/SubscriptionManager.php | SubscriptionManager.subscribe | public function subscribe($id, string $channel, $args, Request $request, \DateTime $expireAt = null): void
{
$this->convertNodes($args);
$this->pubSubHandler->sub(
$channel,
$id,
[
'channel' => $channel,
'arguments' => $args,
'request' => $request,
],
$expireAt
);
} | php | public function subscribe($id, string $channel, $args, Request $request, \DateTime $expireAt = null): void
{
$this->convertNodes($args);
$this->pubSubHandler->sub(
$channel,
$id,
[
'channel' => $channel,
'arguments' => $args,
'request' => $request,
],
$expireAt
);
} | [
"public",
"function",
"subscribe",
"(",
"$",
"id",
",",
"string",
"$",
"channel",
",",
"$",
"args",
",",
"Request",
"$",
"request",
",",
"\\",
"DateTime",
"$",
"expireAt",
"=",
"null",
")",
":",
"void",
"{",
"$",
"this",
"->",
"convertNodes",
"(",
"$... | Subscribe given request to given subscription,
when this subscription is dispatched this request will be executed
@param string $id
@param string $channel
@param array $args
@param Request $request
@param \DateTime|null $expireAt | [
"Subscribe",
"given",
"request",
"to",
"given",
"subscription",
"when",
"this",
"subscription",
"is",
"dispatched",
"this",
"request",
"will",
"be",
"executed"
] | 390aa1ca77cf00ae02688839ea4fca1026954501 | https://github.com/ynloultratech/graphql-bundle/blob/390aa1ca77cf00ae02688839ea4fca1026954501/src/Subscription/SubscriptionManager.php#L64-L77 | train |
ynloultratech/graphql-bundle | src/Subscription/SubscriptionManager.php | SubscriptionManager.convertNodes | private function convertNodes(array &$data): void
{
array_walk_recursive(
$data,
function (&$value) {
if ($value instanceof NodeInterface) {
$value = IDEncoder::encode($value);
}
}
);
} | php | private function convertNodes(array &$data): void
{
array_walk_recursive(
$data,
function (&$value) {
if ($value instanceof NodeInterface) {
$value = IDEncoder::encode($value);
}
}
);
} | [
"private",
"function",
"convertNodes",
"(",
"array",
"&",
"$",
"data",
")",
":",
"void",
"{",
"array_walk_recursive",
"(",
"$",
"data",
",",
"function",
"(",
"&",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"instanceof",
"NodeInterface",
")",
"{",
... | Convert nodes to ID
@param array $data | [
"Convert",
"nodes",
"to",
"ID"
] | 390aa1ca77cf00ae02688839ea4fca1026954501 | https://github.com/ynloultratech/graphql-bundle/blob/390aa1ca77cf00ae02688839ea4fca1026954501/src/Subscription/SubscriptionManager.php#L159-L169 | train |
ynloultratech/graphql-bundle | src/Subscription/SubscriptionManager.php | SubscriptionManager.sendRequest | private function sendRequest(Request $originRequest, SubscriptionMessage $message, OutputInterface $output, bool $debug = false): void
{
$host = $originRequest->getHost();
$port = $originRequest->getPort();
$path = $originRequest->getPathInfo();
$handle = fsockopen($originRequest->isSecure() ? 'ssl://'.$host : $host, $port, $errno, $errstr, 10);
$signer = new Sha256();
$subscriptionToken = (new Builder())->setId($message->getId())
->set('data', serialize($message->getData()))
->setIssuedAt(time())
->setNotBefore(time() + 60)
->setExpiration(time() + 60)
->sign($signer, $this->secret)
->getToken();
$body = $originRequest->getContent();
$length = strlen($body);
$out = "POST $path HTTP/1.1\r\n";
$out .= "Host: $host\r\n";
$auth = $originRequest->headers->get('Authorization');
$out .= "Authorization: $auth\r\n";
$out .= "Subscription: $subscriptionToken\r\n";
$out .= "Content-Length: $length\r\n";
$out .= "Content-Type: application/json\r\n";
$out .= "Connection: Close\r\n\r\n";
$out .= $body;
fwrite($handle, $out);
if ($debug) {
/// in debug mode wait for response
$output->writeln(sprintf('[DEBUG] Getting response for subscription %s', $message->getId()));
while (true) {
$buffer = fgets($handle);
if (!$buffer) {
break;
}
$output->write($buffer);
}
}
fclose($handle);
} | php | private function sendRequest(Request $originRequest, SubscriptionMessage $message, OutputInterface $output, bool $debug = false): void
{
$host = $originRequest->getHost();
$port = $originRequest->getPort();
$path = $originRequest->getPathInfo();
$handle = fsockopen($originRequest->isSecure() ? 'ssl://'.$host : $host, $port, $errno, $errstr, 10);
$signer = new Sha256();
$subscriptionToken = (new Builder())->setId($message->getId())
->set('data', serialize($message->getData()))
->setIssuedAt(time())
->setNotBefore(time() + 60)
->setExpiration(time() + 60)
->sign($signer, $this->secret)
->getToken();
$body = $originRequest->getContent();
$length = strlen($body);
$out = "POST $path HTTP/1.1\r\n";
$out .= "Host: $host\r\n";
$auth = $originRequest->headers->get('Authorization');
$out .= "Authorization: $auth\r\n";
$out .= "Subscription: $subscriptionToken\r\n";
$out .= "Content-Length: $length\r\n";
$out .= "Content-Type: application/json\r\n";
$out .= "Connection: Close\r\n\r\n";
$out .= $body;
fwrite($handle, $out);
if ($debug) {
/// in debug mode wait for response
$output->writeln(sprintf('[DEBUG] Getting response for subscription %s', $message->getId()));
while (true) {
$buffer = fgets($handle);
if (!$buffer) {
break;
}
$output->write($buffer);
}
}
fclose($handle);
} | [
"private",
"function",
"sendRequest",
"(",
"Request",
"$",
"originRequest",
",",
"SubscriptionMessage",
"$",
"message",
",",
"OutputInterface",
"$",
"output",
",",
"bool",
"$",
"debug",
"=",
"false",
")",
":",
"void",
"{",
"$",
"host",
"=",
"$",
"originReque... | Send a subscription request
@param Request $originRequest
@param SubscriptionMessage $message
@param OutputInterface $output
@param boolean $debug | [
"Send",
"a",
"subscription",
"request"
] | 390aa1ca77cf00ae02688839ea4fca1026954501 | https://github.com/ynloultratech/graphql-bundle/blob/390aa1ca77cf00ae02688839ea4fca1026954501/src/Subscription/SubscriptionManager.php#L179-L222 | train |
joomla-framework/console | src/Descriptor/TextDescriptor.php | TextDescriptor.describe | public function describe(OutputInterface $output, $object, array $options = [])
{
$this->output = $output;
switch (true)
{
case $object instanceof Application:
$this->describeJoomlaApplication($object, $options);
break;
case $object instanceof AbstractCommand:
$this->describeConsoleCommand($object, $options);
break;
default:
parent::describe($output, $object, $options);
}
} | php | public function describe(OutputInterface $output, $object, array $options = [])
{
$this->output = $output;
switch (true)
{
case $object instanceof Application:
$this->describeJoomlaApplication($object, $options);
break;
case $object instanceof AbstractCommand:
$this->describeConsoleCommand($object, $options);
break;
default:
parent::describe($output, $object, $options);
}
} | [
"public",
"function",
"describe",
"(",
"OutputInterface",
"$",
"output",
",",
"$",
"object",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"output",
"=",
"$",
"output",
";",
"switch",
"(",
"true",
")",
"{",
"case",
"$",
... | Describes an object.
@param OutputInterface $output The output object to use.
@param object $object The object to describe.
@param array $options Descriptor options.
@return void
@since __DEPLOY_VERSION__ | [
"Describes",
"an",
"object",
"."
] | b8ab98ec0fab96002b22399dea8c2ff206a87380 | https://github.com/joomla-framework/console/blob/b8ab98ec0fab96002b22399dea8c2ff206a87380/src/Descriptor/TextDescriptor.php#L36-L55 | train |
joomla-framework/console | src/Descriptor/TextDescriptor.php | TextDescriptor.describeConsoleCommand | private function describeConsoleCommand(AbstractCommand $command, array $options)
{
$command->getSynopsis(true);
$command->getSynopsis(false);
$command->mergeApplicationDefinition(false);
$this->writeText('<comment>Usage:</comment>', $options);
foreach (array_merge([$command->getSynopsis(true)], $command->getAliases()) as $usage)
{
$this->writeText("\n");
$this->writeText(' ' . $usage, $options);
}
$this->writeText("\n");
$definition = $command->getDefinition();
if ($definition->getOptions() || $definition->getArguments())
{
$this->writeText("\n");
$this->describeInputDefinition($definition, $options);
$this->writeText("\n");
}
if ($help = $command->getProcessedHelp())
{
$this->writeText("\n");
$this->writeText('<comment>Help:</comment>', $options);
$this->writeText("\n");
$this->writeText(' ' . str_replace("\n", "\n ", $help), $options);
$this->writeText("\n");
}
} | php | private function describeConsoleCommand(AbstractCommand $command, array $options)
{
$command->getSynopsis(true);
$command->getSynopsis(false);
$command->mergeApplicationDefinition(false);
$this->writeText('<comment>Usage:</comment>', $options);
foreach (array_merge([$command->getSynopsis(true)], $command->getAliases()) as $usage)
{
$this->writeText("\n");
$this->writeText(' ' . $usage, $options);
}
$this->writeText("\n");
$definition = $command->getDefinition();
if ($definition->getOptions() || $definition->getArguments())
{
$this->writeText("\n");
$this->describeInputDefinition($definition, $options);
$this->writeText("\n");
}
if ($help = $command->getProcessedHelp())
{
$this->writeText("\n");
$this->writeText('<comment>Help:</comment>', $options);
$this->writeText("\n");
$this->writeText(' ' . str_replace("\n", "\n ", $help), $options);
$this->writeText("\n");
}
} | [
"private",
"function",
"describeConsoleCommand",
"(",
"AbstractCommand",
"$",
"command",
",",
"array",
"$",
"options",
")",
"{",
"$",
"command",
"->",
"getSynopsis",
"(",
"true",
")",
";",
"$",
"command",
"->",
"getSynopsis",
"(",
"false",
")",
";",
"$",
"... | Describes a command.
@param AbstractCommand $command The command being described.
@param array $options Descriptor options.
@return void
@since __DEPLOY_VERSION__ | [
"Describes",
"a",
"command",
"."
] | b8ab98ec0fab96002b22399dea8c2ff206a87380 | https://github.com/joomla-framework/console/blob/b8ab98ec0fab96002b22399dea8c2ff206a87380/src/Descriptor/TextDescriptor.php#L89-L122 | train |
joomla-framework/console | src/Descriptor/TextDescriptor.php | TextDescriptor.describeJoomlaApplication | private function describeJoomlaApplication(Application $app, array $options)
{
$describedNamespace = $options['namespace'] ?? '';
$description = new ApplicationDescription($app, $describedNamespace);
$version = $app->getLongVersion();
if ($version !== '')
{
$this->writeText("$version\n\n", $options);
}
$this->writeText("<comment>Usage:</comment>\n");
$this->writeText(" command [options] [arguments]\n\n");
$this->describeInputDefinition(new InputDefinition($app->getDefinition()->getOptions()), $options);
$this->writeText("\n");
$this->writeText("\n");
$commands = $description->getCommands();
$namespaces = $description->getNamespaces();
if ($describedNamespace && $namespaces)
{
// Ensure all aliased commands are included when describing a specific namespace
$describedNamespaceInfo = reset($namespaces);
foreach ($describedNamespaceInfo['commands'] as $name)
{
$commands[$name] = $description->getCommand($name);
}
}
$width = $this->getColumnWidth(
\call_user_func_array(
'array_merge',
array_map(
function ($namespace) use ($commands)
{
return array_intersect($namespace['commands'], array_keys($commands));
},
$namespaces
)
)
);
if ($describedNamespace)
{
$this->writeText(sprintf('<comment>Available commands for the "%s" namespace:</comment>', $describedNamespace), $options);
}
else
{
$this->writeText('<comment>Available commands:</comment>', $options);
}
foreach ($namespaces as $namespace)
{
$namespace['commands'] = array_filter(
$namespace['commands'],
function ($name) use ($commands)
{
return isset($commands[$name]);
}
);
if (!$namespace['commands'])
{
continue;
}
if (!$describedNamespace && $namespace['id'] !== ApplicationDescription::GLOBAL_NAMESPACE)
{
$this->writeText("\n");
$this->writeText(' <comment>' . $namespace['id'] . '</comment>', $options);
}
foreach ($namespace['commands'] as $name)
{
$this->writeText("\n");
$spacingWidth = $width - StringHelper::strlen($name);
$command = $commands[$name];
$commandAliases = $name === $command->getName() ? $this->getCommandAliasesText($command) : '';
$this->writeText(
sprintf(
' <info>%s</info>%s%s', $name, str_repeat(' ', $spacingWidth), $commandAliases . $command->getDescription()
),
$options
);
}
}
$this->writeText("\n");
} | php | private function describeJoomlaApplication(Application $app, array $options)
{
$describedNamespace = $options['namespace'] ?? '';
$description = new ApplicationDescription($app, $describedNamespace);
$version = $app->getLongVersion();
if ($version !== '')
{
$this->writeText("$version\n\n", $options);
}
$this->writeText("<comment>Usage:</comment>\n");
$this->writeText(" command [options] [arguments]\n\n");
$this->describeInputDefinition(new InputDefinition($app->getDefinition()->getOptions()), $options);
$this->writeText("\n");
$this->writeText("\n");
$commands = $description->getCommands();
$namespaces = $description->getNamespaces();
if ($describedNamespace && $namespaces)
{
// Ensure all aliased commands are included when describing a specific namespace
$describedNamespaceInfo = reset($namespaces);
foreach ($describedNamespaceInfo['commands'] as $name)
{
$commands[$name] = $description->getCommand($name);
}
}
$width = $this->getColumnWidth(
\call_user_func_array(
'array_merge',
array_map(
function ($namespace) use ($commands)
{
return array_intersect($namespace['commands'], array_keys($commands));
},
$namespaces
)
)
);
if ($describedNamespace)
{
$this->writeText(sprintf('<comment>Available commands for the "%s" namespace:</comment>', $describedNamespace), $options);
}
else
{
$this->writeText('<comment>Available commands:</comment>', $options);
}
foreach ($namespaces as $namespace)
{
$namespace['commands'] = array_filter(
$namespace['commands'],
function ($name) use ($commands)
{
return isset($commands[$name]);
}
);
if (!$namespace['commands'])
{
continue;
}
if (!$describedNamespace && $namespace['id'] !== ApplicationDescription::GLOBAL_NAMESPACE)
{
$this->writeText("\n");
$this->writeText(' <comment>' . $namespace['id'] . '</comment>', $options);
}
foreach ($namespace['commands'] as $name)
{
$this->writeText("\n");
$spacingWidth = $width - StringHelper::strlen($name);
$command = $commands[$name];
$commandAliases = $name === $command->getName() ? $this->getCommandAliasesText($command) : '';
$this->writeText(
sprintf(
' <info>%s</info>%s%s', $name, str_repeat(' ', $spacingWidth), $commandAliases . $command->getDescription()
),
$options
);
}
}
$this->writeText("\n");
} | [
"private",
"function",
"describeJoomlaApplication",
"(",
"Application",
"$",
"app",
",",
"array",
"$",
"options",
")",
"{",
"$",
"describedNamespace",
"=",
"$",
"options",
"[",
"'namespace'",
"]",
"??",
"''",
";",
"$",
"description",
"=",
"new",
"ApplicationDe... | Describes an application.
@param Application $app The application being described.
@param array $options Descriptor options.
@return void
@since __DEPLOY_VERSION__ | [
"Describes",
"an",
"application",
"."
] | b8ab98ec0fab96002b22399dea8c2ff206a87380 | https://github.com/joomla-framework/console/blob/b8ab98ec0fab96002b22399dea8c2ff206a87380/src/Descriptor/TextDescriptor.php#L134-L228 | train |
joomla-framework/console | src/Descriptor/TextDescriptor.php | TextDescriptor.getColumnWidth | private function getColumnWidth(array $commands): int
{
$widths = [];
foreach ($commands as $command)
{
if ($command instanceof AbstractCommand)
{
$widths[] = StringHelper::strlen($command->getName());
foreach ($command->getAliases() as $alias)
{
$widths[] = StringHelper::strlen($alias);
}
}
else
{
$widths[] = StringHelper::strlen($command);
}
}
return $widths ? max($widths) + 2 : 0;
} | php | private function getColumnWidth(array $commands): int
{
$widths = [];
foreach ($commands as $command)
{
if ($command instanceof AbstractCommand)
{
$widths[] = StringHelper::strlen($command->getName());
foreach ($command->getAliases() as $alias)
{
$widths[] = StringHelper::strlen($alias);
}
}
else
{
$widths[] = StringHelper::strlen($command);
}
}
return $widths ? max($widths) + 2 : 0;
} | [
"private",
"function",
"getColumnWidth",
"(",
"array",
"$",
"commands",
")",
":",
"int",
"{",
"$",
"widths",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"commands",
"as",
"$",
"command",
")",
"{",
"if",
"(",
"$",
"command",
"instanceof",
"AbstractCommand",
... | Calculate the column width for a group of commands.
@param AbstractCommand[]|string[] $commands The commands to use for processing a width.
@return integer
@since __DEPLOY_VERSION__ | [
"Calculate",
"the",
"column",
"width",
"for",
"a",
"group",
"of",
"commands",
"."
] | b8ab98ec0fab96002b22399dea8c2ff206a87380 | https://github.com/joomla-framework/console/blob/b8ab98ec0fab96002b22399dea8c2ff206a87380/src/Descriptor/TextDescriptor.php#L239-L261 | train |
alt3/cakephp-tokens | src/Model/Table/TokensTable.php | TokensTable.findValidToken | public function findValidToken(Query $query, array $options)
{
$options += [
'token' => null,
'expires >' => new DateTimeImmutable(),
'status' => false
];
return $query->where($options);
} | php | public function findValidToken(Query $query, array $options)
{
$options += [
'token' => null,
'expires >' => new DateTimeImmutable(),
'status' => false
];
return $query->where($options);
} | [
"public",
"function",
"findValidToken",
"(",
"Query",
"$",
"query",
",",
"array",
"$",
"options",
")",
"{",
"$",
"options",
"+=",
"[",
"'token'",
"=>",
"null",
",",
"'expires >'",
"=>",
"new",
"DateTimeImmutable",
"(",
")",
",",
"'status'",
"=>",
"false",
... | Custom finder "validToken".
@param \Cake\ORM\Query $query Query
@param array $options Options
@return \Cake\ORM\Query | [
"Custom",
"finder",
"validToken",
"."
] | 335718081cb545278c7ab821c083ca84b0d57ca9 | https://github.com/alt3/cakephp-tokens/blob/335718081cb545278c7ab821c083ca84b0d57ca9/src/Model/Table/TokensTable.php#L106-L115 | train |
alt3/cakephp-tokens | src/Model/Table/TokensTable.php | TokensTable.setStatus | public function setStatus($id, $status)
{
if (!is_numeric($status)) {
throw new Exception('Status argument must be an integer');
}
$entity = $this->findById($id)->firstOrFail();
$entity->status = $status;
$this->save($entity);
return $entity;
} | php | public function setStatus($id, $status)
{
if (!is_numeric($status)) {
throw new Exception('Status argument must be an integer');
}
$entity = $this->findById($id)->firstOrFail();
$entity->status = $status;
$this->save($entity);
return $entity;
} | [
"public",
"function",
"setStatus",
"(",
"$",
"id",
",",
"$",
"status",
")",
"{",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"status",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Status argument must be an integer'",
")",
";",
"}",
"$",
"entity",
"=",... | Set token status.
@param int $id Token id
@param int $status Token status
@return bool|\Cake\ORM\Entity | [
"Set",
"token",
"status",
"."
] | 335718081cb545278c7ab821c083ca84b0d57ca9 | https://github.com/alt3/cakephp-tokens/blob/335718081cb545278c7ab821c083ca84b0d57ca9/src/Model/Table/TokensTable.php#L124-L135 | train |
orchestral/control | src/Http/Controllers/ThemesController.php | ThemesController.activate | public function activate(Processor $processor, $type, $id)
{
return $processor->activate($this, $type, $id);
} | php | public function activate(Processor $processor, $type, $id)
{
return $processor->activate($this, $type, $id);
} | [
"public",
"function",
"activate",
"(",
"Processor",
"$",
"processor",
",",
"$",
"type",
",",
"$",
"id",
")",
"{",
"return",
"$",
"processor",
"->",
"activate",
"(",
"$",
"this",
",",
"$",
"type",
",",
"$",
"id",
")",
";",
"}"
] | Set active theme for Orchestra Platform.
@param string $type
@param int $id
@return mixed | [
"Set",
"active",
"theme",
"for",
"Orchestra",
"Platform",
"."
] | 7c23db19373adbb0fe44491af12f370ba6547d2a | https://github.com/orchestral/control/blob/7c23db19373adbb0fe44491af12f370ba6547d2a/src/Http/Controllers/ThemesController.php#L68-L71 | train |
orchestral/control | src/Http/Controllers/ThemesController.php | ThemesController.themeHasActivated | public function themeHasActivated($type, $id)
{
$message = \trans('orchestra/control::response.themes.update', [
'type' => Str::title($type),
]);
return $this->redirectWithMessage(
\handles("orchestra::control/themes/{$type}"), $message
);
} | php | public function themeHasActivated($type, $id)
{
$message = \trans('orchestra/control::response.themes.update', [
'type' => Str::title($type),
]);
return $this->redirectWithMessage(
\handles("orchestra::control/themes/{$type}"), $message
);
} | [
"public",
"function",
"themeHasActivated",
"(",
"$",
"type",
",",
"$",
"id",
")",
"{",
"$",
"message",
"=",
"\\",
"trans",
"(",
"'orchestra/control::response.themes.update'",
",",
"[",
"'type'",
"=>",
"Str",
"::",
"title",
"(",
"$",
"type",
")",
",",
"]",
... | Response when theme activation succeed.
@param string $type
@param string $id
@return mixed | [
"Response",
"when",
"theme",
"activation",
"succeed",
"."
] | 7c23db19373adbb0fe44491af12f370ba6547d2a | https://github.com/orchestral/control/blob/7c23db19373adbb0fe44491af12f370ba6547d2a/src/Http/Controllers/ThemesController.php#L97-L106 | train |
figdice/figdice | src/figdice/classes/tags/TagFigDictionary.php | TagFigDictionary.fig_dictionary | private function fig_dictionary(Context $context) {
//If a @source attribute is specified,
//it means that when the target (view's language) is the same as @source,
//then don't bother loading dictionary file, nor translating: just render the tag's children.
$file = $this->dicFile;
$filename = $context->view->getTranslationPath() . '/' . $context->view->getLanguage() . '/' . $file;
$dictionary = new Dictionary($filename, $this->source);
if ( ($context->view->getLanguage() == '') || ($this->source == $context->view->getLanguage()) ) {
// If the current View does not specify a Language,
// or if the dictionary to load is same language as View,
// let's not care about i18n.
// We will activate i18n only if the dictionary explicitly specifies a source,
// which means that we cannot simply rely on contents of the fig:trans tags.
// However, we still need to hook the Dictionary object as a placeholder,
// so that subsequent trans tag for the given dic name and source will
// simply render their contents.
$context->addDictionary($dictionary, $this->dicName);
return '';
}
//TODO: Please optimize here: cache the realpath of the loaded dictionaries,
//so as not to re-load an already loaded dictionary in same View hierarchy.
try {
//Determine whether this dictionary was pre-compiled:
if($context->view->getCachePath()) {
$tmpFile = $context->getView()->getCachePath() . '/' . 'Dictionary' . '/' . $context->getView()->getLanguage() . '/' . $file . '.php';
//If the tmp file already exists,
if(file_exists($tmpFile)) {
//but is older than the source file,
if(file_exists($filename) && (filemtime($tmpFile) < filemtime($filename)) ) {
Dictionary::compile($filename, $tmpFile);
}
} else {
Dictionary::compile($filename, $tmpFile);
}
$dictionary->restore($tmpFile);
}
//If we don't even have a temp folder specified, load the dictionary for the first time.
else {
$dictionary->load();
}
} catch(FileNotFoundException $ex) {
throw new FileNotFoundException('Translation file not found: file=' . $filename .
', language=' . $context->view->getLanguage() .
', source=' . $context->getFilename(),
$context->getFilename() );
}
//Hook the dictionary to the current file.
//(in fact this will bubble up the message as high as possible, ie:
//to the highest parent which does not bear a dictionary of same name)
$context->addDictionary($dictionary, $this->dicName);
return '';
} | php | private function fig_dictionary(Context $context) {
//If a @source attribute is specified,
//it means that when the target (view's language) is the same as @source,
//then don't bother loading dictionary file, nor translating: just render the tag's children.
$file = $this->dicFile;
$filename = $context->view->getTranslationPath() . '/' . $context->view->getLanguage() . '/' . $file;
$dictionary = new Dictionary($filename, $this->source);
if ( ($context->view->getLanguage() == '') || ($this->source == $context->view->getLanguage()) ) {
// If the current View does not specify a Language,
// or if the dictionary to load is same language as View,
// let's not care about i18n.
// We will activate i18n only if the dictionary explicitly specifies a source,
// which means that we cannot simply rely on contents of the fig:trans tags.
// However, we still need to hook the Dictionary object as a placeholder,
// so that subsequent trans tag for the given dic name and source will
// simply render their contents.
$context->addDictionary($dictionary, $this->dicName);
return '';
}
//TODO: Please optimize here: cache the realpath of the loaded dictionaries,
//so as not to re-load an already loaded dictionary in same View hierarchy.
try {
//Determine whether this dictionary was pre-compiled:
if($context->view->getCachePath()) {
$tmpFile = $context->getView()->getCachePath() . '/' . 'Dictionary' . '/' . $context->getView()->getLanguage() . '/' . $file . '.php';
//If the tmp file already exists,
if(file_exists($tmpFile)) {
//but is older than the source file,
if(file_exists($filename) && (filemtime($tmpFile) < filemtime($filename)) ) {
Dictionary::compile($filename, $tmpFile);
}
} else {
Dictionary::compile($filename, $tmpFile);
}
$dictionary->restore($tmpFile);
}
//If we don't even have a temp folder specified, load the dictionary for the first time.
else {
$dictionary->load();
}
} catch(FileNotFoundException $ex) {
throw new FileNotFoundException('Translation file not found: file=' . $filename .
', language=' . $context->view->getLanguage() .
', source=' . $context->getFilename(),
$context->getFilename() );
}
//Hook the dictionary to the current file.
//(in fact this will bubble up the message as high as possible, ie:
//to the highest parent which does not bear a dictionary of same name)
$context->addDictionary($dictionary, $this->dicName);
return '';
} | [
"private",
"function",
"fig_dictionary",
"(",
"Context",
"$",
"context",
")",
"{",
"//If a @source attribute is specified,",
"//it means that when the target (view's language) is the same as @source,",
"//then don't bother loading dictionary file, nor translating: just render the tag's childre... | Loads a language XML file, to be used within the current view.
If a Temp path was specified in the View,
we try to compile (serialize) the XML key-value collection and store
the serialized form in a 'Dictionary/(langcode)' subfolder of the temp path.
@param Context $context
@return string
@throws FileNotFoundException
@throws \figdice\exceptions\DictionaryDuplicateKeyException | [
"Loads",
"a",
"language",
"XML",
"file",
"to",
"be",
"used",
"within",
"the",
"current",
"view",
"."
] | 896bbe3aec365c416e368dcc6b888a6cf1832afc | https://github.com/figdice/figdice/blob/896bbe3aec365c416e368dcc6b888a6cf1832afc/src/figdice/classes/tags/TagFigDictionary.php#L85-L146 | train |
ynloultratech/graphql-bundle | src/Util/Json.php | Json.decode | public static function decode($json, $assoc = false)
{
if ($json instanceof Response) {
return json_decode($json->getContent(), $assoc);
}
return json_decode($json, $assoc);
} | php | public static function decode($json, $assoc = false)
{
if ($json instanceof Response) {
return json_decode($json->getContent(), $assoc);
}
return json_decode($json, $assoc);
} | [
"public",
"static",
"function",
"decode",
"(",
"$",
"json",
",",
"$",
"assoc",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"json",
"instanceof",
"Response",
")",
"{",
"return",
"json_decode",
"(",
"$",
"json",
"->",
"getContent",
"(",
")",
",",
"$",
"ass... | Decode a json, unlike the build-in
decode, support a Response as argument
@param string|array|Response $json
@param boolean $assoc
@return mixed | [
"Decode",
"a",
"json",
"unlike",
"the",
"build",
"-",
"in",
"decode",
"support",
"a",
"Response",
"as",
"argument"
] | 390aa1ca77cf00ae02688839ea4fca1026954501 | https://github.com/ynloultratech/graphql-bundle/blob/390aa1ca77cf00ae02688839ea4fca1026954501/src/Util/Json.php#L49-L56 | train |
eloquent/composer-config-reader | src/ConfigurationValidator.php | ConfigurationValidator.validate | public function validate($data)
{
$this->validator->reset();
$this->validator->check($data, $this->schema());
if (!$this->validator->isValid()) {
throw new InvalidConfigurationException(
$this->validator->getErrors()
);
}
} | php | public function validate($data)
{
$this->validator->reset();
$this->validator->check($data, $this->schema());
if (!$this->validator->isValid()) {
throw new InvalidConfigurationException(
$this->validator->getErrors()
);
}
} | [
"public",
"function",
"validate",
"(",
"$",
"data",
")",
"{",
"$",
"this",
"->",
"validator",
"->",
"reset",
"(",
")",
";",
"$",
"this",
"->",
"validator",
"->",
"check",
"(",
"$",
"data",
",",
"$",
"this",
"->",
"schema",
"(",
")",
")",
";",
"if... | Validate Composer configuration data.
@param mixed $data The configuration data.
@throws ConfigurationExceptionInterface If the data is invalid. | [
"Validate",
"Composer",
"configuration",
"data",
"."
] | ee83a1cad8f68508f05b30c376003045a7cdfcd8 | https://github.com/eloquent/composer-config-reader/blob/ee83a1cad8f68508f05b30c376003045a7cdfcd8/src/ConfigurationValidator.php#L62-L72 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.