id
int32 0
241k
| 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
|
---|---|---|---|---|---|---|---|---|---|---|---|
14,100 | incraigulous/contentful-sdk | src/ManagementResources/IsArchivable.php | IsArchivable.archive | function archive($id)
{
$this->requestDecorator->setId($id . '/archived');
$result = $this->client->put($this->requestDecorator->makeResource(), $this->requestDecorator->makePayload(), $this->requestDecorator->makeHeaders());
$this->refresh();
return $result;
} | php | function archive($id)
{
$this->requestDecorator->setId($id . '/archived');
$result = $this->client->put($this->requestDecorator->makeResource(), $this->requestDecorator->makePayload(), $this->requestDecorator->makeHeaders());
$this->refresh();
return $result;
} | [
"function",
"archive",
"(",
"$",
"id",
")",
"{",
"$",
"this",
"->",
"requestDecorator",
"->",
"setId",
"(",
"$",
"id",
".",
"'/archived'",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"client",
"->",
"put",
"(",
"$",
"this",
"->",
"requestDecorator",
"->",
"makeResource",
"(",
")",
",",
"$",
"this",
"->",
"requestDecorator",
"->",
"makePayload",
"(",
")",
",",
"$",
"this",
"->",
"requestDecorator",
"->",
"makeHeaders",
"(",
")",
")",
";",
"$",
"this",
"->",
"refresh",
"(",
")",
";",
"return",
"$",
"result",
";",
"}"
]
| Archive a record.
@param $id
@return mixed | [
"Archive",
"a",
"record",
"."
]
| 29399b11b0e085a06ea5976661378c379fe5a731 | https://github.com/incraigulous/contentful-sdk/blob/29399b11b0e085a06ea5976661378c379fe5a731/src/ManagementResources/IsArchivable.php#L13-L19 |
14,101 | fostam/php-getopts | src/Config/Option.php | Option.short | public function short($short) {
$this->validated = false;
if (!self::validateShort($short)) {
throw new OptionConfigException('short option must be a single character: ' . $short);
}
$this->config[self::SHORT] = $short;
return $this;
} | php | public function short($short) {
$this->validated = false;
if (!self::validateShort($short)) {
throw new OptionConfigException('short option must be a single character: ' . $short);
}
$this->config[self::SHORT] = $short;
return $this;
} | [
"public",
"function",
"short",
"(",
"$",
"short",
")",
"{",
"$",
"this",
"->",
"validated",
"=",
"false",
";",
"if",
"(",
"!",
"self",
"::",
"validateShort",
"(",
"$",
"short",
")",
")",
"{",
"throw",
"new",
"OptionConfigException",
"(",
"'short option must be a single character: '",
".",
"$",
"short",
")",
";",
"}",
"$",
"this",
"->",
"config",
"[",
"self",
"::",
"SHORT",
"]",
"=",
"$",
"short",
";",
"return",
"$",
"this",
";",
"}"
]
| set the option's short name
@param string $short
@return $this | [
"set",
"the",
"option",
"s",
"short",
"name"
]
| 0d0209eb48201e3e0b28305ae8d28d4657d6d979 | https://github.com/fostam/php-getopts/blob/0d0209eb48201e3e0b28305ae8d28d4657d6d979/src/Config/Option.php#L50-L57 |
14,102 | fostam/php-getopts | src/Config/Option.php | Option.long | public function long($long) {
$this->validated = false;
if (!self::validateLong($long)) {
throw new OptionConfigException('invalid long option format: ' . $long);
}
$this->config[self::LONG] = $long;
return $this;
} | php | public function long($long) {
$this->validated = false;
if (!self::validateLong($long)) {
throw new OptionConfigException('invalid long option format: ' . $long);
}
$this->config[self::LONG] = $long;
return $this;
} | [
"public",
"function",
"long",
"(",
"$",
"long",
")",
"{",
"$",
"this",
"->",
"validated",
"=",
"false",
";",
"if",
"(",
"!",
"self",
"::",
"validateLong",
"(",
"$",
"long",
")",
")",
"{",
"throw",
"new",
"OptionConfigException",
"(",
"'invalid long option format: '",
".",
"$",
"long",
")",
";",
"}",
"$",
"this",
"->",
"config",
"[",
"self",
"::",
"LONG",
"]",
"=",
"$",
"long",
";",
"return",
"$",
"this",
";",
"}"
]
| set the option's long name
@param string $long
@return $this | [
"set",
"the",
"option",
"s",
"long",
"name"
]
| 0d0209eb48201e3e0b28305ae8d28d4657d6d979 | https://github.com/fostam/php-getopts/blob/0d0209eb48201e3e0b28305ae8d28d4657d6d979/src/Config/Option.php#L65-L72 |
14,103 | fostam/php-getopts | src/Config/Option.php | Option.argument | public function argument($name) {
$this->validated = false;
if (!preg_match('#^[a-zA-Z0-9\-\_]+$#', $name)) {
throw new OptionConfigException('illegal characters in name: ' . $name);
}
$this->config[self::ARGUMENT] = $name;
return $this;
} | php | public function argument($name) {
$this->validated = false;
if (!preg_match('#^[a-zA-Z0-9\-\_]+$#', $name)) {
throw new OptionConfigException('illegal characters in name: ' . $name);
}
$this->config[self::ARGUMENT] = $name;
return $this;
} | [
"public",
"function",
"argument",
"(",
"$",
"name",
")",
"{",
"$",
"this",
"->",
"validated",
"=",
"false",
";",
"if",
"(",
"!",
"preg_match",
"(",
"'#^[a-zA-Z0-9\\-\\_]+$#'",
",",
"$",
"name",
")",
")",
"{",
"throw",
"new",
"OptionConfigException",
"(",
"'illegal characters in name: '",
".",
"$",
"name",
")",
";",
"}",
"$",
"this",
"->",
"config",
"[",
"self",
"::",
"ARGUMENT",
"]",
"=",
"$",
"name",
";",
"return",
"$",
"this",
";",
"}"
]
| let the option require an argument with the given name
@param string $name
@return $this | [
"let",
"the",
"option",
"require",
"an",
"argument",
"with",
"the",
"given",
"name"
]
| 0d0209eb48201e3e0b28305ae8d28d4657d6d979 | https://github.com/fostam/php-getopts/blob/0d0209eb48201e3e0b28305ae8d28d4657d6d979/src/Config/Option.php#L91-L98 |
14,104 | fostam/php-getopts | src/Config/Option.php | Option.get | public function get($param = '') {
$this->validate();
if ($param) {
if (array_key_exists($param, $this->config)) {
return $this->config[$param];
}
else {
throw new OptionConfigException('option param not valid: ' . $param);
}
}
return $this->config;
} | php | public function get($param = '') {
$this->validate();
if ($param) {
if (array_key_exists($param, $this->config)) {
return $this->config[$param];
}
else {
throw new OptionConfigException('option param not valid: ' . $param);
}
}
return $this->config;
} | [
"public",
"function",
"get",
"(",
"$",
"param",
"=",
"''",
")",
"{",
"$",
"this",
"->",
"validate",
"(",
")",
";",
"if",
"(",
"$",
"param",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"param",
",",
"$",
"this",
"->",
"config",
")",
")",
"{",
"return",
"$",
"this",
"->",
"config",
"[",
"$",
"param",
"]",
";",
"}",
"else",
"{",
"throw",
"new",
"OptionConfigException",
"(",
"'option param not valid: '",
".",
"$",
"param",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"config",
";",
"}"
]
| return full option configuration, or a specific parameter of the configuration
@param string $param
@return mixed | [
"return",
"full",
"option",
"configuration",
"or",
"a",
"specific",
"parameter",
"of",
"the",
"configuration"
]
| 0d0209eb48201e3e0b28305ae8d28d4657d6d979 | https://github.com/fostam/php-getopts/blob/0d0209eb48201e3e0b28305ae8d28d4657d6d979/src/Config/Option.php#L174-L187 |
14,105 | ptlis/conneg | src/Negotiator/Negotiator.php | Negotiator.matchClientPreferences | private function matchClientPreferences($fromField, array $clientPrefList, array $matchingList)
{
foreach ($clientPrefList as $clientPref) {
$matchingList = $this->matchSingleClientPreference($fromField, $clientPref, $matchingList);
}
return $matchingList;
} | php | private function matchClientPreferences($fromField, array $clientPrefList, array $matchingList)
{
foreach ($clientPrefList as $clientPref) {
$matchingList = $this->matchSingleClientPreference($fromField, $clientPref, $matchingList);
}
return $matchingList;
} | [
"private",
"function",
"matchClientPreferences",
"(",
"$",
"fromField",
",",
"array",
"$",
"clientPrefList",
",",
"array",
"$",
"matchingList",
")",
"{",
"foreach",
"(",
"$",
"clientPrefList",
"as",
"$",
"clientPref",
")",
"{",
"$",
"matchingList",
"=",
"$",
"this",
"->",
"matchSingleClientPreference",
"(",
"$",
"fromField",
",",
"$",
"clientPref",
",",
"$",
"matchingList",
")",
";",
"}",
"return",
"$",
"matchingList",
";",
"}"
]
| Match client variants to server variants.
@param string $fromField
@param PreferenceInterface[] $clientPrefList
@param MatchedPreferenceInterface[] $matchingList
@return MatchedPreferenceInterface[] | [
"Match",
"client",
"variants",
"to",
"server",
"variants",
"."
]
| 04afb568f368ecdd81c13277006c4be041ccb58b | https://github.com/ptlis/conneg/blob/04afb568f368ecdd81c13277006c4be041ccb58b/src/Negotiator/Negotiator.php#L129-L136 |
14,106 | ptlis/conneg | src/Negotiator/Negotiator.php | Negotiator.matchSingleClientPreference | private function matchSingleClientPreference($fromField, PreferenceInterface $clientPreference, array $matchingList)
{
foreach ($this->matcherList as $matcher) {
if ($matcher->hasMatch($fromField, $matchingList, $clientPreference)) {
$matchingList = $matcher->match($fromField, $matchingList, $clientPreference);
break;
}
}
return $matchingList;
} | php | private function matchSingleClientPreference($fromField, PreferenceInterface $clientPreference, array $matchingList)
{
foreach ($this->matcherList as $matcher) {
if ($matcher->hasMatch($fromField, $matchingList, $clientPreference)) {
$matchingList = $matcher->match($fromField, $matchingList, $clientPreference);
break;
}
}
return $matchingList;
} | [
"private",
"function",
"matchSingleClientPreference",
"(",
"$",
"fromField",
",",
"PreferenceInterface",
"$",
"clientPreference",
",",
"array",
"$",
"matchingList",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"matcherList",
"as",
"$",
"matcher",
")",
"{",
"if",
"(",
"$",
"matcher",
"->",
"hasMatch",
"(",
"$",
"fromField",
",",
"$",
"matchingList",
",",
"$",
"clientPreference",
")",
")",
"{",
"$",
"matchingList",
"=",
"$",
"matcher",
"->",
"match",
"(",
"$",
"fromField",
",",
"$",
"matchingList",
",",
"$",
"clientPreference",
")",
";",
"break",
";",
"}",
"}",
"return",
"$",
"matchingList",
";",
"}"
]
| Match a single client variant to the server variants.
@param string $fromField
@param PreferenceInterface $clientPreference
@param MatchedPreferenceInterface[] $matchingList
@return MatchedPreferenceInterface[] | [
"Match",
"a",
"single",
"client",
"variant",
"to",
"the",
"server",
"variants",
"."
]
| 04afb568f368ecdd81c13277006c4be041ccb58b | https://github.com/ptlis/conneg/blob/04afb568f368ecdd81c13277006c4be041ccb58b/src/Negotiator/Negotiator.php#L147-L158 |
14,107 | myzero1/yii2-theme-layui | src/controllers/Z1UserController.php | Z1UserController.actionIndex | public function actionIndex()
{
$searchModel = new Z1UserSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
$pageSize = intval(trim(Yii::$app->request->get('per-page')));
if ($pageSize) {
$dataProvider->pagination->pageSize = $pageSize;
}
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
} | php | public function actionIndex()
{
$searchModel = new Z1UserSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
$pageSize = intval(trim(Yii::$app->request->get('per-page')));
if ($pageSize) {
$dataProvider->pagination->pageSize = $pageSize;
}
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
} | [
"public",
"function",
"actionIndex",
"(",
")",
"{",
"$",
"searchModel",
"=",
"new",
"Z1UserSearch",
"(",
")",
";",
"$",
"dataProvider",
"=",
"$",
"searchModel",
"->",
"search",
"(",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"queryParams",
")",
";",
"$",
"pageSize",
"=",
"intval",
"(",
"trim",
"(",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"get",
"(",
"'per-page'",
")",
")",
")",
";",
"if",
"(",
"$",
"pageSize",
")",
"{",
"$",
"dataProvider",
"->",
"pagination",
"->",
"pageSize",
"=",
"$",
"pageSize",
";",
"}",
"return",
"$",
"this",
"->",
"render",
"(",
"'index'",
",",
"[",
"'searchModel'",
"=>",
"$",
"searchModel",
",",
"'dataProvider'",
"=>",
"$",
"dataProvider",
",",
"]",
")",
";",
"}"
]
| Lists all Z1User models.
@return mixed | [
"Lists",
"all",
"Z1User",
"models",
"."
]
| 47e4796b35b8354e50359a489499ee598edd68e1 | https://github.com/myzero1/yii2-theme-layui/blob/47e4796b35b8354e50359a489499ee598edd68e1/src/controllers/Z1UserController.php#L44-L59 |
14,108 | reinvanoyen/aegis | lib/Aegis/Compiler.php | Compiler.compile | public function compile(Node $node) : string
{
$this->head = $this->body = '';
$node->compile($this);
return $this->getResult();
} | php | public function compile(Node $node) : string
{
$this->head = $this->body = '';
$node->compile($this);
return $this->getResult();
} | [
"public",
"function",
"compile",
"(",
"Node",
"$",
"node",
")",
":",
"string",
"{",
"$",
"this",
"->",
"head",
"=",
"$",
"this",
"->",
"body",
"=",
"''",
";",
"$",
"node",
"->",
"compile",
"(",
"$",
"this",
")",
";",
"return",
"$",
"this",
"->",
"getResult",
"(",
")",
";",
"}"
]
| Compiles a node into a string
@param Node $node
@return string | [
"Compiles",
"a",
"node",
"into",
"a",
"string"
]
| ecd831fd6f3ceb4fb20fb5af83483d73cad8e323 | https://github.com/reinvanoyen/aegis/blob/ecd831fd6f3ceb4fb20fb5af83483d73cad8e323/lib/Aegis/Compiler.php#L28-L33 |
14,109 | dphn/ScContent | src/ScContent/Entity/Back/WidgetConfig.php | WidgetConfig.setRoles | public function setRoles($roles)
{
$widget = $this->widget;
$newRoles = [];
foreach ($this->availableRoles as $role) {
$newRoles[$role] = in_array($role, $roles);
}
$widget->setOption('roles', $newRoles);
} | php | public function setRoles($roles)
{
$widget = $this->widget;
$newRoles = [];
foreach ($this->availableRoles as $role) {
$newRoles[$role] = in_array($role, $roles);
}
$widget->setOption('roles', $newRoles);
} | [
"public",
"function",
"setRoles",
"(",
"$",
"roles",
")",
"{",
"$",
"widget",
"=",
"$",
"this",
"->",
"widget",
";",
"$",
"newRoles",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"availableRoles",
"as",
"$",
"role",
")",
"{",
"$",
"newRoles",
"[",
"$",
"role",
"]",
"=",
"in_array",
"(",
"$",
"role",
",",
"$",
"roles",
")",
";",
"}",
"$",
"widget",
"->",
"setOption",
"(",
"'roles'",
",",
"$",
"newRoles",
")",
";",
"}"
]
| This data comes from the form. It is the applicable roles list.
@param string[] $roles
@return void | [
"This",
"data",
"comes",
"from",
"the",
"form",
".",
"It",
"is",
"the",
"applicable",
"roles",
"list",
"."
]
| 9dd5732490c45fd788b96cedf7b3c7adfacb30d2 | https://github.com/dphn/ScContent/blob/9dd5732490c45fd788b96cedf7b3c7adfacb30d2/src/ScContent/Entity/Back/WidgetConfig.php#L85-L93 |
14,110 | dphn/ScContent | src/ScContent/Entity/Back/WidgetConfig.php | WidgetConfig.findApplicableRoles | public function findApplicableRoles()
{
$widget = $this->widget;
$array = [];
foreach ($this->availableRoles as $role) {
if ($widget->isApplicable($role)) {
$array[] = $role;
}
}
return $array;
} | php | public function findApplicableRoles()
{
$widget = $this->widget;
$array = [];
foreach ($this->availableRoles as $role) {
if ($widget->isApplicable($role)) {
$array[] = $role;
}
}
return $array;
} | [
"public",
"function",
"findApplicableRoles",
"(",
")",
"{",
"$",
"widget",
"=",
"$",
"this",
"->",
"widget",
";",
"$",
"array",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"availableRoles",
"as",
"$",
"role",
")",
"{",
"if",
"(",
"$",
"widget",
"->",
"isApplicable",
"(",
"$",
"role",
")",
")",
"{",
"$",
"array",
"[",
"]",
"=",
"$",
"role",
";",
"}",
"}",
"return",
"$",
"array",
";",
"}"
]
| Find applicable roles.
@return string[] | [
"Find",
"applicable",
"roles",
"."
]
| 9dd5732490c45fd788b96cedf7b3c7adfacb30d2 | https://github.com/dphn/ScContent/blob/9dd5732490c45fd788b96cedf7b3c7adfacb30d2/src/ScContent/Entity/Back/WidgetConfig.php#L110-L120 |
14,111 | serverdensity/sd-php-wrapper | lib/serverdensity/Api/Tags.php | Tags.find | public function find($name)
{
$tags = $this->all();
$found = array();
foreach ($tags as $tag){
if ($tag['name'] === $name){
$found = $tag;
break;
}
}
return $found;
} | php | public function find($name)
{
$tags = $this->all();
$found = array();
foreach ($tags as $tag){
if ($tag['name'] === $name){
$found = $tag;
break;
}
}
return $found;
} | [
"public",
"function",
"find",
"(",
"$",
"name",
")",
"{",
"$",
"tags",
"=",
"$",
"this",
"->",
"all",
"(",
")",
";",
"$",
"found",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"tags",
"as",
"$",
"tag",
")",
"{",
"if",
"(",
"$",
"tag",
"[",
"'name'",
"]",
"===",
"$",
"name",
")",
"{",
"$",
"found",
"=",
"$",
"tag",
";",
"break",
";",
"}",
"}",
"return",
"$",
"found",
";",
"}"
]
| Find a tag by name
@param string $name of the tag
@return an array of the tag in question or an empty array if not found | [
"Find",
"a",
"tag",
"by",
"name"
]
| 9c742a9ee61e32a9bc4ed17b5fe0eca1f4c3015e | https://github.com/serverdensity/sd-php-wrapper/blob/9c742a9ee61e32a9bc4ed17b5fe0eca1f4c3015e/lib/serverdensity/Api/Tags.php#L49-L61 |
14,112 | serverdensity/sd-php-wrapper | lib/serverdensity/Api/Tags.php | Tags.findAll | public function findAll(array $names)
{
$tags = $this->all();
$transformTags = function($array) {
$newArray = array();
foreach($array as $entry){
$newArray[$entry['name']] = $entry;
}
return $newArray;
};
$tagNames = $transformTags($tags);
$found = array(
'tags' => array(),
'notFound' => array()
);
foreach ($names as $name){
if (in_array($name, array_keys($tagNames))){
$found['tags'][] = $tagNames[$name];
} else {
$found['notFound'][] = $name;
}
}
return $found;
} | php | public function findAll(array $names)
{
$tags = $this->all();
$transformTags = function($array) {
$newArray = array();
foreach($array as $entry){
$newArray[$entry['name']] = $entry;
}
return $newArray;
};
$tagNames = $transformTags($tags);
$found = array(
'tags' => array(),
'notFound' => array()
);
foreach ($names as $name){
if (in_array($name, array_keys($tagNames))){
$found['tags'][] = $tagNames[$name];
} else {
$found['notFound'][] = $name;
}
}
return $found;
} | [
"public",
"function",
"findAll",
"(",
"array",
"$",
"names",
")",
"{",
"$",
"tags",
"=",
"$",
"this",
"->",
"all",
"(",
")",
";",
"$",
"transformTags",
"=",
"function",
"(",
"$",
"array",
")",
"{",
"$",
"newArray",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"array",
"as",
"$",
"entry",
")",
"{",
"$",
"newArray",
"[",
"$",
"entry",
"[",
"'name'",
"]",
"]",
"=",
"$",
"entry",
";",
"}",
"return",
"$",
"newArray",
";",
"}",
";",
"$",
"tagNames",
"=",
"$",
"transformTags",
"(",
"$",
"tags",
")",
";",
"$",
"found",
"=",
"array",
"(",
"'tags'",
"=>",
"array",
"(",
")",
",",
"'notFound'",
"=>",
"array",
"(",
")",
")",
";",
"foreach",
"(",
"$",
"names",
"as",
"$",
"name",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"name",
",",
"array_keys",
"(",
"$",
"tagNames",
")",
")",
")",
"{",
"$",
"found",
"[",
"'tags'",
"]",
"[",
"]",
"=",
"$",
"tagNames",
"[",
"$",
"name",
"]",
";",
"}",
"else",
"{",
"$",
"found",
"[",
"'notFound'",
"]",
"[",
"]",
"=",
"$",
"name",
";",
"}",
"}",
"return",
"$",
"found",
";",
"}"
]
| Find all tags by name
@param array names tag names in an array
@return an array of array objects. | [
"Find",
"all",
"tags",
"by",
"name"
]
| 9c742a9ee61e32a9bc4ed17b5fe0eca1f4c3015e | https://github.com/serverdensity/sd-php-wrapper/blob/9c742a9ee61e32a9bc4ed17b5fe0eca1f4c3015e/lib/serverdensity/Api/Tags.php#L68-L91 |
14,113 | serverdensity/sd-php-wrapper | lib/serverdensity/Api/Tags.php | Tags.format | public function format($tags, $type)
{
$formattedTags = array();
if ($type === 'user'){
$formattedTags['tags'] = array();
foreach($tags as $tag){
$formattedTags['tags'][$tag['_id']] = array(
'mode' => 'readWrite'
);
}
} else if ($type === 'other'){
foreach($tags as $tag){
$formattedTags['tags'][] = $tag['_id'];
}
} else {
throw ErrorException("Only 'user' and 'other' are allowed types");
}
return $formattedTags;
} | php | public function format($tags, $type)
{
$formattedTags = array();
if ($type === 'user'){
$formattedTags['tags'] = array();
foreach($tags as $tag){
$formattedTags['tags'][$tag['_id']] = array(
'mode' => 'readWrite'
);
}
} else if ($type === 'other'){
foreach($tags as $tag){
$formattedTags['tags'][] = $tag['_id'];
}
} else {
throw ErrorException("Only 'user' and 'other' are allowed types");
}
return $formattedTags;
} | [
"public",
"function",
"format",
"(",
"$",
"tags",
",",
"$",
"type",
")",
"{",
"$",
"formattedTags",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"type",
"===",
"'user'",
")",
"{",
"$",
"formattedTags",
"[",
"'tags'",
"]",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"tags",
"as",
"$",
"tag",
")",
"{",
"$",
"formattedTags",
"[",
"'tags'",
"]",
"[",
"$",
"tag",
"[",
"'_id'",
"]",
"]",
"=",
"array",
"(",
"'mode'",
"=>",
"'readWrite'",
")",
";",
"}",
"}",
"else",
"if",
"(",
"$",
"type",
"===",
"'other'",
")",
"{",
"foreach",
"(",
"$",
"tags",
"as",
"$",
"tag",
")",
"{",
"$",
"formattedTags",
"[",
"'tags'",
"]",
"[",
"]",
"=",
"$",
"tag",
"[",
"'_id'",
"]",
";",
"}",
"}",
"else",
"{",
"throw",
"ErrorException",
"(",
"\"Only 'user' and 'other' are allowed types\"",
")",
";",
"}",
"return",
"$",
"formattedTags",
";",
"}"
]
| Format tags to be inserted
@param array tags an array of tags
@param string type either user or other
@return formatted tags | [
"Format",
"tags",
"to",
"be",
"inserted"
]
| 9c742a9ee61e32a9bc4ed17b5fe0eca1f4c3015e | https://github.com/serverdensity/sd-php-wrapper/blob/9c742a9ee61e32a9bc4ed17b5fe0eca1f4c3015e/lib/serverdensity/Api/Tags.php#L99-L118 |
14,114 | incraigulous/contentful-sdk | src/PayloadBuilders/EntryField.php | EntryField.addLanguage | function addLanguage($languageKey, $content) {
//If the langage exists and it's an array, add to it instead of replacing it.
if (is_array($this->getLanguage($languageKey))) {
$this->languages[$languageKey][] = $content[0];
return;
}
$this->languages[$languageKey] = $content;
return $this;
} | php | function addLanguage($languageKey, $content) {
//If the langage exists and it's an array, add to it instead of replacing it.
if (is_array($this->getLanguage($languageKey))) {
$this->languages[$languageKey][] = $content[0];
return;
}
$this->languages[$languageKey] = $content;
return $this;
} | [
"function",
"addLanguage",
"(",
"$",
"languageKey",
",",
"$",
"content",
")",
"{",
"//If the langage exists and it's an array, add to it instead of replacing it.",
"if",
"(",
"is_array",
"(",
"$",
"this",
"->",
"getLanguage",
"(",
"$",
"languageKey",
")",
")",
")",
"{",
"$",
"this",
"->",
"languages",
"[",
"$",
"languageKey",
"]",
"[",
"]",
"=",
"$",
"content",
"[",
"0",
"]",
";",
"return",
";",
"}",
"$",
"this",
"->",
"languages",
"[",
"$",
"languageKey",
"]",
"=",
"$",
"content",
";",
"return",
"$",
"this",
";",
"}"
]
| Add a language to the field.
@param $languageKey
@param $content
@return $this | [
"Add",
"a",
"language",
"to",
"the",
"field",
"."
]
| 29399b11b0e085a06ea5976661378c379fe5a731 | https://github.com/incraigulous/contentful-sdk/blob/29399b11b0e085a06ea5976661378c379fe5a731/src/PayloadBuilders/EntryField.php#L31-L39 |
14,115 | incraigulous/contentful-sdk | src/PayloadBuilders/EntryField.php | EntryField.parseContent | protected function parseContent($content) {
if(is_bool($content)) {
$this->addLanguage($this->language, $content);
return;
}
if (!$content) {
return;
}
if (is_string($content)) {
$this->addLanguage($this->language, $content);
return;
}
foreach($content as $key => $data) {
if (!empty($data[0]['sys']['linkType'])) {
foreach($data as $link) {
$this->addLink($link['id'], $link['linkType'], $key);
}
} else {
if (is_numeric($key)) {
$this->addLanguage($this->language, [$data]);
} else {
$this->addLanguage($key, $data);
}
}
}
} | php | protected function parseContent($content) {
if(is_bool($content)) {
$this->addLanguage($this->language, $content);
return;
}
if (!$content) {
return;
}
if (is_string($content)) {
$this->addLanguage($this->language, $content);
return;
}
foreach($content as $key => $data) {
if (!empty($data[0]['sys']['linkType'])) {
foreach($data as $link) {
$this->addLink($link['id'], $link['linkType'], $key);
}
} else {
if (is_numeric($key)) {
$this->addLanguage($this->language, [$data]);
} else {
$this->addLanguage($key, $data);
}
}
}
} | [
"protected",
"function",
"parseContent",
"(",
"$",
"content",
")",
"{",
"if",
"(",
"is_bool",
"(",
"$",
"content",
")",
")",
"{",
"$",
"this",
"->",
"addLanguage",
"(",
"$",
"this",
"->",
"language",
",",
"$",
"content",
")",
";",
"return",
";",
"}",
"if",
"(",
"!",
"$",
"content",
")",
"{",
"return",
";",
"}",
"if",
"(",
"is_string",
"(",
"$",
"content",
")",
")",
"{",
"$",
"this",
"->",
"addLanguage",
"(",
"$",
"this",
"->",
"language",
",",
"$",
"content",
")",
";",
"return",
";",
"}",
"foreach",
"(",
"$",
"content",
"as",
"$",
"key",
"=>",
"$",
"data",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"data",
"[",
"0",
"]",
"[",
"'sys'",
"]",
"[",
"'linkType'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"data",
"as",
"$",
"link",
")",
"{",
"$",
"this",
"->",
"addLink",
"(",
"$",
"link",
"[",
"'id'",
"]",
",",
"$",
"link",
"[",
"'linkType'",
"]",
",",
"$",
"key",
")",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"is_numeric",
"(",
"$",
"key",
")",
")",
"{",
"$",
"this",
"->",
"addLanguage",
"(",
"$",
"this",
"->",
"language",
",",
"[",
"$",
"data",
"]",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"addLanguage",
"(",
"$",
"key",
",",
"$",
"data",
")",
";",
"}",
"}",
"}",
"}"
]
| Parse loaded content. Tests to see if it's a link or if languages are provided and handle appropriately.
@param $content | [
"Parse",
"loaded",
"content",
".",
"Tests",
"to",
"see",
"if",
"it",
"s",
"a",
"link",
"or",
"if",
"languages",
"are",
"provided",
"and",
"handle",
"appropriately",
"."
]
| 29399b11b0e085a06ea5976661378c379fe5a731 | https://github.com/incraigulous/contentful-sdk/blob/29399b11b0e085a06ea5976661378c379fe5a731/src/PayloadBuilders/EntryField.php#L89-L114 |
14,116 | incraigulous/contentful-sdk | src/PayloadBuilders/EntryField.php | EntryField.make | function make()
{
if ($this->links) {
return $this->links;
} elseif ($this->link) {
return $this->link;
}
return $this->languages;
} | php | function make()
{
if ($this->links) {
return $this->links;
} elseif ($this->link) {
return $this->link;
}
return $this->languages;
} | [
"function",
"make",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"links",
")",
"{",
"return",
"$",
"this",
"->",
"links",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"link",
")",
"{",
"return",
"$",
"this",
"->",
"link",
";",
"}",
"return",
"$",
"this",
"->",
"languages",
";",
"}"
]
| Return the payload builder array part. If links are provided, return them instead of languages.
@return array | [
"Return",
"the",
"payload",
"builder",
"array",
"part",
".",
"If",
"links",
"are",
"provided",
"return",
"them",
"instead",
"of",
"languages",
"."
]
| 29399b11b0e085a06ea5976661378c379fe5a731 | https://github.com/incraigulous/contentful-sdk/blob/29399b11b0e085a06ea5976661378c379fe5a731/src/PayloadBuilders/EntryField.php#L119-L127 |
14,117 | euro-ix/ixf-client-php | lib/IXF/Util.php | Util.convertIxfObjectToArray | public static function convertIxfObjectToArray($values)
{
$results = array();
foreach ($values as $k => $v)
{
// FIXME: this is an encapsulation violation
if ($k[0] == '_') {
continue;
}
if ($v instanceof Object) {
$results[$k] = $v->__toArray(true);
} elseif (is_array($v)) {
$results[$k] = self::convertIxfObjectToArray($v);
} else {
$results[$k] = $v;
}
}
return $results;
} | php | public static function convertIxfObjectToArray($values)
{
$results = array();
foreach ($values as $k => $v)
{
// FIXME: this is an encapsulation violation
if ($k[0] == '_') {
continue;
}
if ($v instanceof Object) {
$results[$k] = $v->__toArray(true);
} elseif (is_array($v)) {
$results[$k] = self::convertIxfObjectToArray($v);
} else {
$results[$k] = $v;
}
}
return $results;
} | [
"public",
"static",
"function",
"convertIxfObjectToArray",
"(",
"$",
"values",
")",
"{",
"$",
"results",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"values",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"// FIXME: this is an encapsulation violation",
"if",
"(",
"$",
"k",
"[",
"0",
"]",
"==",
"'_'",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"$",
"v",
"instanceof",
"Object",
")",
"{",
"$",
"results",
"[",
"$",
"k",
"]",
"=",
"$",
"v",
"->",
"__toArray",
"(",
"true",
")",
";",
"}",
"elseif",
"(",
"is_array",
"(",
"$",
"v",
")",
")",
"{",
"$",
"results",
"[",
"$",
"k",
"]",
"=",
"self",
"::",
"convertIxfObjectToArray",
"(",
"$",
"v",
")",
";",
"}",
"else",
"{",
"$",
"results",
"[",
"$",
"k",
"]",
"=",
"$",
"v",
";",
"}",
"}",
"return",
"$",
"results",
";",
"}"
]
| Recursively converts the PHP IXF object to an array.
@param array $values The PHP IXF object to convert.
@return array | [
"Recursively",
"converts",
"the",
"PHP",
"IXF",
"object",
"to",
"an",
"array",
"."
]
| dd39f5c17dc2d3795fcacf5d06793ca28886f3c1 | https://github.com/euro-ix/ixf-client-php/blob/dd39f5c17dc2d3795fcacf5d06793ca28886f3c1/lib/IXF/Util.php#L43-L62 |
14,118 | euro-ix/ixf-client-php | lib/IXF/Util.php | Util.convertToIxfObject | public static function convertToIxfObject($resp)
{
if( self::isList( $resp ) )
{
$mapped = array();
foreach( $resp as $k => $i )
array_push( $mapped, self::convertToIxfObject($i) );
return $mapped;
}
elseif( is_array( $resp ) )
{
$type = null;
if( isset( $resp['_id'] ) )
$type = substr( $resp['_id'], 0, strpos( $resp['_id'], "." ) );
$class = ApiResource::resolveClassName( $type );
return Object::scopedConstructFrom($class, $resp);
}
else
return $resp;
} | php | public static function convertToIxfObject($resp)
{
if( self::isList( $resp ) )
{
$mapped = array();
foreach( $resp as $k => $i )
array_push( $mapped, self::convertToIxfObject($i) );
return $mapped;
}
elseif( is_array( $resp ) )
{
$type = null;
if( isset( $resp['_id'] ) )
$type = substr( $resp['_id'], 0, strpos( $resp['_id'], "." ) );
$class = ApiResource::resolveClassName( $type );
return Object::scopedConstructFrom($class, $resp);
}
else
return $resp;
} | [
"public",
"static",
"function",
"convertToIxfObject",
"(",
"$",
"resp",
")",
"{",
"if",
"(",
"self",
"::",
"isList",
"(",
"$",
"resp",
")",
")",
"{",
"$",
"mapped",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"resp",
"as",
"$",
"k",
"=>",
"$",
"i",
")",
"array_push",
"(",
"$",
"mapped",
",",
"self",
"::",
"convertToIxfObject",
"(",
"$",
"i",
")",
")",
";",
"return",
"$",
"mapped",
";",
"}",
"elseif",
"(",
"is_array",
"(",
"$",
"resp",
")",
")",
"{",
"$",
"type",
"=",
"null",
";",
"if",
"(",
"isset",
"(",
"$",
"resp",
"[",
"'_id'",
"]",
")",
")",
"$",
"type",
"=",
"substr",
"(",
"$",
"resp",
"[",
"'_id'",
"]",
",",
"0",
",",
"strpos",
"(",
"$",
"resp",
"[",
"'_id'",
"]",
",",
"\".\"",
")",
")",
";",
"$",
"class",
"=",
"ApiResource",
"::",
"resolveClassName",
"(",
"$",
"type",
")",
";",
"return",
"Object",
"::",
"scopedConstructFrom",
"(",
"$",
"class",
",",
"$",
"resp",
")",
";",
"}",
"else",
"return",
"$",
"resp",
";",
"}"
]
| Converts a response from the IXF API to the corresponding PHP object.
@param array $resp The response from the IXF API.
@return Object|array | [
"Converts",
"a",
"response",
"from",
"the",
"IXF",
"API",
"to",
"the",
"corresponding",
"PHP",
"object",
"."
]
| dd39f5c17dc2d3795fcacf5d06793ca28886f3c1 | https://github.com/euro-ix/ixf-client-php/blob/dd39f5c17dc2d3795fcacf5d06793ca28886f3c1/lib/IXF/Util.php#L70-L92 |
14,119 | ipunkt/social-auth | src/Ipunkt/SocialAuth/SocialAuthObject.php | SocialAuthObject.getProviders | public function getProviders() {
$hybridAuthProviders = $this->hybridAuth->getProviders();
$providerList = [];
foreach($hybridAuthProviders as $providerName => $config)
$providerList[] = $providerName;
$providers = $this->makeProviders($providerList);
return $providers;
} | php | public function getProviders() {
$hybridAuthProviders = $this->hybridAuth->getProviders();
$providerList = [];
foreach($hybridAuthProviders as $providerName => $config)
$providerList[] = $providerName;
$providers = $this->makeProviders($providerList);
return $providers;
} | [
"public",
"function",
"getProviders",
"(",
")",
"{",
"$",
"hybridAuthProviders",
"=",
"$",
"this",
"->",
"hybridAuth",
"->",
"getProviders",
"(",
")",
";",
"$",
"providerList",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"hybridAuthProviders",
"as",
"$",
"providerName",
"=>",
"$",
"config",
")",
"$",
"providerList",
"[",
"]",
"=",
"$",
"providerName",
";",
"$",
"providers",
"=",
"$",
"this",
"->",
"makeProviders",
"(",
"$",
"providerList",
")",
";",
"return",
"$",
"providers",
";",
"}"
]
| Returns all enabled provider from the config
@return ProviderInterface[] | [
"Returns",
"all",
"enabled",
"provider",
"from",
"the",
"config"
]
| 28723a8e449612789a2cd7d21137996c48b62229 | https://github.com/ipunkt/social-auth/blob/28723a8e449612789a2cd7d21137996c48b62229/src/Ipunkt/SocialAuth/SocialAuthObject.php#L77-L86 |
14,120 | ipunkt/social-auth | src/Ipunkt/SocialAuth/SocialAuthObject.php | SocialAuthObject.getConnectedProviders | public function getConnectedProviders() {
$hybridAuthProviders = $this->hybridAuth->getConnectedProviders();
$providers = $this->makeProviders($hybridAuthProviders);
return $providers;
} | php | public function getConnectedProviders() {
$hybridAuthProviders = $this->hybridAuth->getConnectedProviders();
$providers = $this->makeProviders($hybridAuthProviders);
return $providers;
} | [
"public",
"function",
"getConnectedProviders",
"(",
")",
"{",
"$",
"hybridAuthProviders",
"=",
"$",
"this",
"->",
"hybridAuth",
"->",
"getConnectedProviders",
"(",
")",
";",
"$",
"providers",
"=",
"$",
"this",
"->",
"makeProviders",
"(",
"$",
"hybridAuthProviders",
")",
";",
"return",
"$",
"providers",
";",
"}"
]
| Returns only currently connected providers
@return mixed | [
"Returns",
"only",
"currently",
"connected",
"providers"
]
| 28723a8e449612789a2cd7d21137996c48b62229 | https://github.com/ipunkt/social-auth/blob/28723a8e449612789a2cd7d21137996c48b62229/src/Ipunkt/SocialAuth/SocialAuthObject.php#L93-L99 |
14,121 | cpliakas/search-framework | src/Search/Framework/CollectionAgentAbstract.php | CollectionAgentAbstract.dispatchEvent | public function dispatchEvent($name, SearchEvent $event, array $context = array())
{
$log = $this->getLogger();
$context['event'] = $name;
$log->debug('Throwing event', $context);
$this->getDispatcher()->dispatch($name, $event);
$log->debug('Event thrown', $context);
} | php | public function dispatchEvent($name, SearchEvent $event, array $context = array())
{
$log = $this->getLogger();
$context['event'] = $name;
$log->debug('Throwing event', $context);
$this->getDispatcher()->dispatch($name, $event);
$log->debug('Event thrown', $context);
} | [
"public",
"function",
"dispatchEvent",
"(",
"$",
"name",
",",
"SearchEvent",
"$",
"event",
",",
"array",
"$",
"context",
"=",
"array",
"(",
")",
")",
"{",
"$",
"log",
"=",
"$",
"this",
"->",
"getLogger",
"(",
")",
";",
"$",
"context",
"[",
"'event'",
"]",
"=",
"$",
"name",
";",
"$",
"log",
"->",
"debug",
"(",
"'Throwing event'",
",",
"$",
"context",
")",
";",
"$",
"this",
"->",
"getDispatcher",
"(",
")",
"->",
"dispatch",
"(",
"$",
"name",
",",
"$",
"event",
")",
";",
"$",
"log",
"->",
"debug",
"(",
"'Event thrown'",
",",
"$",
"context",
")",
";",
"}"
]
| Dispatches an event, wraps with debug messages.
@param string $name
The name of the event to dispatch.
@param SearchEvent $event
The event to pass to the event handlers/listeners.
@param array $context
Optional context to pass to the logger. | [
"Dispatches",
"an",
"event",
"wraps",
"with",
"debug",
"messages",
"."
]
| 7c5832d38ed998e04837c26e0daef59115563b98 | https://github.com/cpliakas/search-framework/blob/7c5832d38ed998e04837c26e0daef59115563b98/src/Search/Framework/CollectionAgentAbstract.php#L108-L115 |
14,122 | cpliakas/search-framework | src/Search/Framework/CollectionAgentAbstract.php | CollectionAgentAbstract.attachCollection | public function attachCollection(CollectionAbstract $collection)
{
$id = $collection->getId();
if (isset($this->_collections[$id])) {
throw new \InvalidArgumentException('Collection already attached: ' . $id);
}
$this->_collections[$id] = $collection;
$this->clearSchema();
$this->getLogger()->debug('Collection attached', array('collection' => $id));
return $this;
} | php | public function attachCollection(CollectionAbstract $collection)
{
$id = $collection->getId();
if (isset($this->_collections[$id])) {
throw new \InvalidArgumentException('Collection already attached: ' . $id);
}
$this->_collections[$id] = $collection;
$this->clearSchema();
$this->getLogger()->debug('Collection attached', array('collection' => $id));
return $this;
} | [
"public",
"function",
"attachCollection",
"(",
"CollectionAbstract",
"$",
"collection",
")",
"{",
"$",
"id",
"=",
"$",
"collection",
"->",
"getId",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_collections",
"[",
"$",
"id",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Collection already attached: '",
".",
"$",
"id",
")",
";",
"}",
"$",
"this",
"->",
"_collections",
"[",
"$",
"id",
"]",
"=",
"$",
"collection",
";",
"$",
"this",
"->",
"clearSchema",
"(",
")",
";",
"$",
"this",
"->",
"getLogger",
"(",
")",
"->",
"debug",
"(",
"'Collection attached'",
",",
"array",
"(",
"'collection'",
"=>",
"$",
"id",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Relates a collection to the object.
@param SearchCollectionAbstract $collection
The collection being related to this object.
@return CollectionAgentAbstract
@throws \InvalidArgumentException
Thrown when a collection with the same identifier is already attached. | [
"Relates",
"a",
"collection",
"to",
"the",
"object",
"."
]
| 7c5832d38ed998e04837c26e0daef59115563b98 | https://github.com/cpliakas/search-framework/blob/7c5832d38ed998e04837c26e0daef59115563b98/src/Search/Framework/CollectionAgentAbstract.php#L141-L155 |
14,123 | cpliakas/search-framework | src/Search/Framework/CollectionAgentAbstract.php | CollectionAgentAbstract.getCollection | public function getCollection($id)
{
if (!isset($this->_collections[$id])) {
throw new \InvalidArgumentException('Collection not attached: ' . $id);
}
return $this->_collections;
} | php | public function getCollection($id)
{
if (!isset($this->_collections[$id])) {
throw new \InvalidArgumentException('Collection not attached: ' . $id);
}
return $this->_collections;
} | [
"public",
"function",
"getCollection",
"(",
"$",
"id",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_collections",
"[",
"$",
"id",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Collection not attached: '",
".",
"$",
"id",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_collections",
";",
"}"
]
| Returns a collection given it's unique identifier.
@param string $id
The unique identifier of the collection.
@return CollectionAbstract
@throws \InvalidArgumentException
Thrown when the collection is not attached. | [
"Returns",
"a",
"collection",
"given",
"it",
"s",
"unique",
"identifier",
"."
]
| 7c5832d38ed998e04837c26e0daef59115563b98 | https://github.com/cpliakas/search-framework/blob/7c5832d38ed998e04837c26e0daef59115563b98/src/Search/Framework/CollectionAgentAbstract.php#L185-L191 |
14,124 | cpliakas/search-framework | src/Search/Framework/CollectionAgentAbstract.php | CollectionAgentAbstract.removeCollection | public function removeCollection($id)
{
unset($this->_collections[$id]);
$this->clearSchema();
$this->getLogger()->debug('Collection removed', array('collection' => $id));
return $this;
} | php | public function removeCollection($id)
{
unset($this->_collections[$id]);
$this->clearSchema();
$this->getLogger()->debug('Collection removed', array('collection' => $id));
return $this;
} | [
"public",
"function",
"removeCollection",
"(",
"$",
"id",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"_collections",
"[",
"$",
"id",
"]",
")",
";",
"$",
"this",
"->",
"clearSchema",
"(",
")",
";",
"$",
"this",
"->",
"getLogger",
"(",
")",
"->",
"debug",
"(",
"'Collection removed'",
",",
"array",
"(",
"'collection'",
"=>",
"$",
"id",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Removes a collection from this server.
@param string $id
The unique identifier of the collection.
@return CollectionAgentAbstract | [
"Removes",
"a",
"collection",
"from",
"this",
"server",
"."
]
| 7c5832d38ed998e04837c26e0daef59115563b98 | https://github.com/cpliakas/search-framework/blob/7c5832d38ed998e04837c26e0daef59115563b98/src/Search/Framework/CollectionAgentAbstract.php#L211-L219 |
14,125 | cpliakas/search-framework | src/Search/Framework/CollectionAgentAbstract.php | CollectionAgentAbstract.getSchema | public function getSchema()
{
if (!isset($this->_schema)) {
$this->_schema = $this->loadSchemata();
}
return $this->_schema;
} | php | public function getSchema()
{
if (!isset($this->_schema)) {
$this->_schema = $this->loadSchemata();
}
return $this->_schema;
} | [
"public",
"function",
"getSchema",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_schema",
")",
")",
"{",
"$",
"this",
"->",
"_schema",
"=",
"$",
"this",
"->",
"loadSchemata",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_schema",
";",
"}"
]
| Returns the fused schema for all collections attached to this agent.
@return Schema | [
"Returns",
"the",
"fused",
"schema",
"for",
"all",
"collections",
"attached",
"to",
"this",
"agent",
"."
]
| 7c5832d38ed998e04837c26e0daef59115563b98 | https://github.com/cpliakas/search-framework/blob/7c5832d38ed998e04837c26e0daef59115563b98/src/Search/Framework/CollectionAgentAbstract.php#L245-L251 |
14,126 | cpliakas/search-framework | src/Search/Framework/CollectionAgentAbstract.php | CollectionAgentAbstract.loadSchemata | public function loadSchemata()
{
$fused_options = array();
foreach ($this->_collections as $collection) {
$context = array('collection' => $collection->getId());
$schema_options = $this->loadCollectionSchema($collection)->toArray();
// Just set the schema options on the first pass.
if (!$fused_options) {
$fused_options = $schema_options;
continue;
}
// The unique field must be the same across collections.
if ($schema_options['unique_field'] != $fused_options['unique_field']) {
$message = 'Collections must have the same unique field.';
throw new \InvalidArgumentException($message);
}
// Define the field or check for field incompatibilities.
foreach ($schema_options['fields'] as $field_id => $field_options) {
if (!isset($fused_options['fields'][$field_id])) {
$fused_options['fields'][$field_id] = $field_options;
} elseif ($fused_options['fields'][$field_id] != $field_options) {
$message = 'Field definitions for "'. $field_id . '"must match.';
throw new \InvalidArgumentException($message);
}
}
}
// Build the fused schema.
$schema = new Schema();
$schema->build($fused_options);
// Populate the field type cache.
foreach ($schema as $id => $field) {
$this->_fieldTypes[$id] = $field->getType();
}
return $schema;
} | php | public function loadSchemata()
{
$fused_options = array();
foreach ($this->_collections as $collection) {
$context = array('collection' => $collection->getId());
$schema_options = $this->loadCollectionSchema($collection)->toArray();
// Just set the schema options on the first pass.
if (!$fused_options) {
$fused_options = $schema_options;
continue;
}
// The unique field must be the same across collections.
if ($schema_options['unique_field'] != $fused_options['unique_field']) {
$message = 'Collections must have the same unique field.';
throw new \InvalidArgumentException($message);
}
// Define the field or check for field incompatibilities.
foreach ($schema_options['fields'] as $field_id => $field_options) {
if (!isset($fused_options['fields'][$field_id])) {
$fused_options['fields'][$field_id] = $field_options;
} elseif ($fused_options['fields'][$field_id] != $field_options) {
$message = 'Field definitions for "'. $field_id . '"must match.';
throw new \InvalidArgumentException($message);
}
}
}
// Build the fused schema.
$schema = new Schema();
$schema->build($fused_options);
// Populate the field type cache.
foreach ($schema as $id => $field) {
$this->_fieldTypes[$id] = $field->getType();
}
return $schema;
} | [
"public",
"function",
"loadSchemata",
"(",
")",
"{",
"$",
"fused_options",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"_collections",
"as",
"$",
"collection",
")",
"{",
"$",
"context",
"=",
"array",
"(",
"'collection'",
"=>",
"$",
"collection",
"->",
"getId",
"(",
")",
")",
";",
"$",
"schema_options",
"=",
"$",
"this",
"->",
"loadCollectionSchema",
"(",
"$",
"collection",
")",
"->",
"toArray",
"(",
")",
";",
"// Just set the schema options on the first pass.",
"if",
"(",
"!",
"$",
"fused_options",
")",
"{",
"$",
"fused_options",
"=",
"$",
"schema_options",
";",
"continue",
";",
"}",
"// The unique field must be the same across collections.",
"if",
"(",
"$",
"schema_options",
"[",
"'unique_field'",
"]",
"!=",
"$",
"fused_options",
"[",
"'unique_field'",
"]",
")",
"{",
"$",
"message",
"=",
"'Collections must have the same unique field.'",
";",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"$",
"message",
")",
";",
"}",
"// Define the field or check for field incompatibilities.",
"foreach",
"(",
"$",
"schema_options",
"[",
"'fields'",
"]",
"as",
"$",
"field_id",
"=>",
"$",
"field_options",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"fused_options",
"[",
"'fields'",
"]",
"[",
"$",
"field_id",
"]",
")",
")",
"{",
"$",
"fused_options",
"[",
"'fields'",
"]",
"[",
"$",
"field_id",
"]",
"=",
"$",
"field_options",
";",
"}",
"elseif",
"(",
"$",
"fused_options",
"[",
"'fields'",
"]",
"[",
"$",
"field_id",
"]",
"!=",
"$",
"field_options",
")",
"{",
"$",
"message",
"=",
"'Field definitions for \"'",
".",
"$",
"field_id",
".",
"'\"must match.'",
";",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"$",
"message",
")",
";",
"}",
"}",
"}",
"// Build the fused schema.",
"$",
"schema",
"=",
"new",
"Schema",
"(",
")",
";",
"$",
"schema",
"->",
"build",
"(",
"$",
"fused_options",
")",
";",
"// Populate the field type cache.",
"foreach",
"(",
"$",
"schema",
"as",
"$",
"id",
"=>",
"$",
"field",
")",
"{",
"$",
"this",
"->",
"_fieldTypes",
"[",
"$",
"id",
"]",
"=",
"$",
"field",
"->",
"getType",
"(",
")",
";",
"}",
"return",
"$",
"schema",
";",
"}"
]
| Loads and fuses the schemata for all collections attached to this agent.
@return Schema | [
"Loads",
"and",
"fuses",
"the",
"schemata",
"for",
"all",
"collections",
"attached",
"to",
"this",
"agent",
"."
]
| 7c5832d38ed998e04837c26e0daef59115563b98 | https://github.com/cpliakas/search-framework/blob/7c5832d38ed998e04837c26e0daef59115563b98/src/Search/Framework/CollectionAgentAbstract.php#L258-L299 |
14,127 | ignasbernotas/console | src/UI/Drawer.php | Drawer.fitText | public function fitText($width, $text = '', $padding = 0)
{
$spaces = $width - strlen($text) - $padding;
return $text . str_repeat(' ', $spaces < 0 ? 0 : $spaces);
} | php | public function fitText($width, $text = '', $padding = 0)
{
$spaces = $width - strlen($text) - $padding;
return $text . str_repeat(' ', $spaces < 0 ? 0 : $spaces);
} | [
"public",
"function",
"fitText",
"(",
"$",
"width",
",",
"$",
"text",
"=",
"''",
",",
"$",
"padding",
"=",
"0",
")",
"{",
"$",
"spaces",
"=",
"$",
"width",
"-",
"strlen",
"(",
"$",
"text",
")",
"-",
"$",
"padding",
";",
"return",
"$",
"text",
".",
"str_repeat",
"(",
"' '",
",",
"$",
"spaces",
"<",
"0",
"?",
"0",
":",
"$",
"spaces",
")",
";",
"}"
]
| Append spaces to the string to fit the whole terminal window
@param int $width
@param string $text
@param int $padding
@return string | [
"Append",
"spaces",
"to",
"the",
"string",
"to",
"fit",
"the",
"whole",
"terminal",
"window"
]
| 909e613b140413062424d6a465da08aac355be55 | https://github.com/ignasbernotas/console/blob/909e613b140413062424d6a465da08aac355be55/src/UI/Drawer.php#L74-L79 |
14,128 | ignasbernotas/console | src/UI/Drawer.php | Drawer.getFormattedChoices | public function getFormattedChoices(array $choices, $position, $selected)
{
$lines = [];
foreach ($choices as $index => $choice) {
$state = in_array($choice, $selected)
? self::CHOICE_SELECTED
: self::CHOICE_NORMAL;
$cursor = $index === $position
? self::CHOICE_HOVERED
: self::CHOICE_NORMAL;
// select which style to use
$line = $this->style[$state][$cursor];
// add the fancy fish eye symbol to make things prettier
$choice = ' ' . unicode_to_string('\u25C9') . ' ' . $choice;
$lines[] = sprintf($line, $this->fitText($this->window->getWidth(), $choice));
}
return $lines;
} | php | public function getFormattedChoices(array $choices, $position, $selected)
{
$lines = [];
foreach ($choices as $index => $choice) {
$state = in_array($choice, $selected)
? self::CHOICE_SELECTED
: self::CHOICE_NORMAL;
$cursor = $index === $position
? self::CHOICE_HOVERED
: self::CHOICE_NORMAL;
// select which style to use
$line = $this->style[$state][$cursor];
// add the fancy fish eye symbol to make things prettier
$choice = ' ' . unicode_to_string('\u25C9') . ' ' . $choice;
$lines[] = sprintf($line, $this->fitText($this->window->getWidth(), $choice));
}
return $lines;
} | [
"public",
"function",
"getFormattedChoices",
"(",
"array",
"$",
"choices",
",",
"$",
"position",
",",
"$",
"selected",
")",
"{",
"$",
"lines",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"choices",
"as",
"$",
"index",
"=>",
"$",
"choice",
")",
"{",
"$",
"state",
"=",
"in_array",
"(",
"$",
"choice",
",",
"$",
"selected",
")",
"?",
"self",
"::",
"CHOICE_SELECTED",
":",
"self",
"::",
"CHOICE_NORMAL",
";",
"$",
"cursor",
"=",
"$",
"index",
"===",
"$",
"position",
"?",
"self",
"::",
"CHOICE_HOVERED",
":",
"self",
"::",
"CHOICE_NORMAL",
";",
"// select which style to use",
"$",
"line",
"=",
"$",
"this",
"->",
"style",
"[",
"$",
"state",
"]",
"[",
"$",
"cursor",
"]",
";",
"// add the fancy fish eye symbol to make things prettier",
"$",
"choice",
"=",
"' '",
".",
"unicode_to_string",
"(",
"'\\u25C9'",
")",
".",
"' '",
".",
"$",
"choice",
";",
"$",
"lines",
"[",
"]",
"=",
"sprintf",
"(",
"$",
"line",
",",
"$",
"this",
"->",
"fitText",
"(",
"$",
"this",
"->",
"window",
"->",
"getWidth",
"(",
")",
",",
"$",
"choice",
")",
")",
";",
"}",
"return",
"$",
"lines",
";",
"}"
]
| Returns an array of styled options
@param $choices
@param $position
@param $selected
@return array | [
"Returns",
"an",
"array",
"of",
"styled",
"options"
]
| 909e613b140413062424d6a465da08aac355be55 | https://github.com/ignasbernotas/console/blob/909e613b140413062424d6a465da08aac355be55/src/UI/Drawer.php#L100-L123 |
14,129 | ignasbernotas/console | src/UI/Drawer.php | Drawer.drawWindow | public function drawWindow($title, $choices, $position, $answers)
{
$this->window->clearScreen();
$this->output->writeln($this->getTitle($title));
$this->output->writeln("");
$lines = $this->getFormattedChoices($choices, $position, $answers);
foreach ($lines as $line) {
$this->output->writeln($line);
}
return $this;
} | php | public function drawWindow($title, $choices, $position, $answers)
{
$this->window->clearScreen();
$this->output->writeln($this->getTitle($title));
$this->output->writeln("");
$lines = $this->getFormattedChoices($choices, $position, $answers);
foreach ($lines as $line) {
$this->output->writeln($line);
}
return $this;
} | [
"public",
"function",
"drawWindow",
"(",
"$",
"title",
",",
"$",
"choices",
",",
"$",
"position",
",",
"$",
"answers",
")",
"{",
"$",
"this",
"->",
"window",
"->",
"clearScreen",
"(",
")",
";",
"$",
"this",
"->",
"output",
"->",
"writeln",
"(",
"$",
"this",
"->",
"getTitle",
"(",
"$",
"title",
")",
")",
";",
"$",
"this",
"->",
"output",
"->",
"writeln",
"(",
"\"\"",
")",
";",
"$",
"lines",
"=",
"$",
"this",
"->",
"getFormattedChoices",
"(",
"$",
"choices",
",",
"$",
"position",
",",
"$",
"answers",
")",
";",
"foreach",
"(",
"$",
"lines",
"as",
"$",
"line",
")",
"{",
"$",
"this",
"->",
"output",
"->",
"writeln",
"(",
"$",
"line",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| Draw the window
@param $title
@param $choices
@param $position
@param $answers
@return $this | [
"Draw",
"the",
"window"
]
| 909e613b140413062424d6a465da08aac355be55 | https://github.com/ignasbernotas/console/blob/909e613b140413062424d6a465da08aac355be55/src/UI/Drawer.php#L134-L148 |
14,130 | nyeholt/silverstripe-simplewiki | thirdparty/htmlpurifier-4.0.0-lite/library/HTMLPurifier/AttrTypes.php | HTMLPurifier_AttrTypes.get | public function get($type) {
// determine if there is any extra info tacked on
if (strpos($type, '#') !== false) list($type, $string) = explode('#', $type, 2);
else $string = '';
if (!isset($this->info[$type])) {
trigger_error('Cannot retrieve undefined attribute type ' . $type, E_USER_ERROR);
return;
}
return $this->info[$type]->make($string);
} | php | public function get($type) {
// determine if there is any extra info tacked on
if (strpos($type, '#') !== false) list($type, $string) = explode('#', $type, 2);
else $string = '';
if (!isset($this->info[$type])) {
trigger_error('Cannot retrieve undefined attribute type ' . $type, E_USER_ERROR);
return;
}
return $this->info[$type]->make($string);
} | [
"public",
"function",
"get",
"(",
"$",
"type",
")",
"{",
"// determine if there is any extra info tacked on",
"if",
"(",
"strpos",
"(",
"$",
"type",
",",
"'#'",
")",
"!==",
"false",
")",
"list",
"(",
"$",
"type",
",",
"$",
"string",
")",
"=",
"explode",
"(",
"'#'",
",",
"$",
"type",
",",
"2",
")",
";",
"else",
"$",
"string",
"=",
"''",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"info",
"[",
"$",
"type",
"]",
")",
")",
"{",
"trigger_error",
"(",
"'Cannot retrieve undefined attribute type '",
".",
"$",
"type",
",",
"E_USER_ERROR",
")",
";",
"return",
";",
"}",
"return",
"$",
"this",
"->",
"info",
"[",
"$",
"type",
"]",
"->",
"make",
"(",
"$",
"string",
")",
";",
"}"
]
| Retrieves a type
@param $type String type name
@return Object AttrDef for type | [
"Retrieves",
"a",
"type"
]
| ecffed0d75be1454901e1cb24633472b8f67c967 | https://github.com/nyeholt/silverstripe-simplewiki/blob/ecffed0d75be1454901e1cb24633472b8f67c967/thirdparty/htmlpurifier-4.0.0-lite/library/HTMLPurifier/AttrTypes.php#L52-L65 |
14,131 | mimmi20/Wurfl | src/Device/DeviceRepositoryBuilder.php | DeviceRepositoryBuilder.process | private function process(DeviceIterator $deviceIterator, array $patchingDevices = array())
{
$usedPatches = array();
foreach ($deviceIterator as $device) {
/* @var $device \Wurfl\Device\ModelDeviceInterface */
$toPatch = isset($patchingDevices[$device->id]);
if ($toPatch) {
$device = $this->patchDevice($device, $patchingDevices [$device->id]);
$usedPatches[$device->id] = $device->id;
}
$this->classifyAndPersistDevice($device);
}
$this->classifyAndPersistNewDevices(array_diff_key($patchingDevices, $usedPatches));
$this->persistClassifiedDevicesUserAgentMap();
} | php | private function process(DeviceIterator $deviceIterator, array $patchingDevices = array())
{
$usedPatches = array();
foreach ($deviceIterator as $device) {
/* @var $device \Wurfl\Device\ModelDeviceInterface */
$toPatch = isset($patchingDevices[$device->id]);
if ($toPatch) {
$device = $this->patchDevice($device, $patchingDevices [$device->id]);
$usedPatches[$device->id] = $device->id;
}
$this->classifyAndPersistDevice($device);
}
$this->classifyAndPersistNewDevices(array_diff_key($patchingDevices, $usedPatches));
$this->persistClassifiedDevicesUserAgentMap();
} | [
"private",
"function",
"process",
"(",
"DeviceIterator",
"$",
"deviceIterator",
",",
"array",
"$",
"patchingDevices",
"=",
"array",
"(",
")",
")",
"{",
"$",
"usedPatches",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"deviceIterator",
"as",
"$",
"device",
")",
"{",
"/* @var $device \\Wurfl\\Device\\ModelDeviceInterface */",
"$",
"toPatch",
"=",
"isset",
"(",
"$",
"patchingDevices",
"[",
"$",
"device",
"->",
"id",
"]",
")",
";",
"if",
"(",
"$",
"toPatch",
")",
"{",
"$",
"device",
"=",
"$",
"this",
"->",
"patchDevice",
"(",
"$",
"device",
",",
"$",
"patchingDevices",
"[",
"$",
"device",
"->",
"id",
"]",
")",
";",
"$",
"usedPatches",
"[",
"$",
"device",
"->",
"id",
"]",
"=",
"$",
"device",
"->",
"id",
";",
"}",
"$",
"this",
"->",
"classifyAndPersistDevice",
"(",
"$",
"device",
")",
";",
"}",
"$",
"this",
"->",
"classifyAndPersistNewDevices",
"(",
"array_diff_key",
"(",
"$",
"patchingDevices",
",",
"$",
"usedPatches",
")",
")",
";",
"$",
"this",
"->",
"persistClassifiedDevicesUserAgentMap",
"(",
")",
";",
"}"
]
| Process device iterator
@param \Wurfl\Device\Xml\DeviceIterator $deviceIterator
@param array $patchingDevices | [
"Process",
"device",
"iterator"
]
| 443ed0d73a0b9a21ebd0d6ddf1e32669b9de44ec | https://github.com/mimmi20/Wurfl/blob/443ed0d73a0b9a21ebd0d6ddf1e32669b9de44ec/src/Device/DeviceRepositoryBuilder.php#L295-L313 |
14,132 | fostam/php-getopts | src/Handler.php | Handler.addOption | public function addOption($name, Option $opt = null) {
if (isset($this->configOpts[$name]) || isset($this->configArgs[$name])) {
throw new ConfigException('option/argument already set: ' . $name);
}
if (is_null($opt)) {
$opt = new Option();
}
$this->configOpts[$name] = $opt;
return $opt;
} | php | public function addOption($name, Option $opt = null) {
if (isset($this->configOpts[$name]) || isset($this->configArgs[$name])) {
throw new ConfigException('option/argument already set: ' . $name);
}
if (is_null($opt)) {
$opt = new Option();
}
$this->configOpts[$name] = $opt;
return $opt;
} | [
"public",
"function",
"addOption",
"(",
"$",
"name",
",",
"Option",
"$",
"opt",
"=",
"null",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"configOpts",
"[",
"$",
"name",
"]",
")",
"||",
"isset",
"(",
"$",
"this",
"->",
"configArgs",
"[",
"$",
"name",
"]",
")",
")",
"{",
"throw",
"new",
"ConfigException",
"(",
"'option/argument already set: '",
".",
"$",
"name",
")",
";",
"}",
"if",
"(",
"is_null",
"(",
"$",
"opt",
")",
")",
"{",
"$",
"opt",
"=",
"new",
"Option",
"(",
")",
";",
"}",
"$",
"this",
"->",
"configOpts",
"[",
"$",
"name",
"]",
"=",
"$",
"opt",
";",
"return",
"$",
"opt",
";",
"}"
]
| add a new option
@param string $name
@param Option $opt
@return Option
@throws ConfigException | [
"add",
"a",
"new",
"option"
]
| 0d0209eb48201e3e0b28305ae8d28d4657d6d979 | https://github.com/fostam/php-getopts/blob/0d0209eb48201e3e0b28305ae8d28d4657d6d979/src/Handler.php#L46-L57 |
14,133 | fostam/php-getopts | src/Handler.php | Handler.addArgument | public function addArgument($name, Argument $arg = null) {
if (isset($this->configOpts[$name]) || isset($this->configArgs[$name])) {
throw new ConfigException('option/argument already set: ' . $name);
}
if (is_null($arg)) {
$arg = new Argument();
}
$this->configArgs[$name] = $arg;
return $arg;
} | php | public function addArgument($name, Argument $arg = null) {
if (isset($this->configOpts[$name]) || isset($this->configArgs[$name])) {
throw new ConfigException('option/argument already set: ' . $name);
}
if (is_null($arg)) {
$arg = new Argument();
}
$this->configArgs[$name] = $arg;
return $arg;
} | [
"public",
"function",
"addArgument",
"(",
"$",
"name",
",",
"Argument",
"$",
"arg",
"=",
"null",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"configOpts",
"[",
"$",
"name",
"]",
")",
"||",
"isset",
"(",
"$",
"this",
"->",
"configArgs",
"[",
"$",
"name",
"]",
")",
")",
"{",
"throw",
"new",
"ConfigException",
"(",
"'option/argument already set: '",
".",
"$",
"name",
")",
";",
"}",
"if",
"(",
"is_null",
"(",
"$",
"arg",
")",
")",
"{",
"$",
"arg",
"=",
"new",
"Argument",
"(",
")",
";",
"}",
"$",
"this",
"->",
"configArgs",
"[",
"$",
"name",
"]",
"=",
"$",
"arg",
";",
"return",
"$",
"arg",
";",
"}"
]
| add a new argument
@param $name
@param Argument $arg
@return Argument
@throws ConfigException | [
"add",
"a",
"new",
"argument"
]
| 0d0209eb48201e3e0b28305ae8d28d4657d6d979 | https://github.com/fostam/php-getopts/blob/0d0209eb48201e3e0b28305ae8d28d4657d6d979/src/Handler.php#L67-L78 |
14,134 | fostam/php-getopts | src/Handler.php | Handler.setHelpOptionLong | public function setHelpOptionLong($str) {
if (!Option::validateLong($str)) {
throw new ConfigException('long help option has invalid format');
}
$this->helpLong = $str;
return $this;
} | php | public function setHelpOptionLong($str) {
if (!Option::validateLong($str)) {
throw new ConfigException('long help option has invalid format');
}
$this->helpLong = $str;
return $this;
} | [
"public",
"function",
"setHelpOptionLong",
"(",
"$",
"str",
")",
"{",
"if",
"(",
"!",
"Option",
"::",
"validateLong",
"(",
"$",
"str",
")",
")",
"{",
"throw",
"new",
"ConfigException",
"(",
"'long help option has invalid format'",
")",
";",
"}",
"$",
"this",
"->",
"helpLong",
"=",
"$",
"str",
";",
"return",
"$",
"this",
";",
"}"
]
| set the long option for help handling
@param string $str
@return $this | [
"set",
"the",
"long",
"option",
"for",
"help",
"handling"
]
| 0d0209eb48201e3e0b28305ae8d28d4657d6d979 | https://github.com/fostam/php-getopts/blob/0d0209eb48201e3e0b28305ae8d28d4657d6d979/src/Handler.php#L86-L92 |
14,135 | fostam/php-getopts | src/Handler.php | Handler.setHelpOptionShort | public function setHelpOptionShort($str) {
if (!Option::validateShort($str)) {
throw new ConfigException('short help option must be a single character');
}
$this->helpShort = $str;
return $this;
} | php | public function setHelpOptionShort($str) {
if (!Option::validateShort($str)) {
throw new ConfigException('short help option must be a single character');
}
$this->helpShort = $str;
return $this;
} | [
"public",
"function",
"setHelpOptionShort",
"(",
"$",
"str",
")",
"{",
"if",
"(",
"!",
"Option",
"::",
"validateShort",
"(",
"$",
"str",
")",
")",
"{",
"throw",
"new",
"ConfigException",
"(",
"'short help option must be a single character'",
")",
";",
"}",
"$",
"this",
"->",
"helpShort",
"=",
"$",
"str",
";",
"return",
"$",
"this",
";",
"}"
]
| set the short option for help handling
@param string $str
@return $this | [
"set",
"the",
"short",
"option",
"for",
"help",
"handling"
]
| 0d0209eb48201e3e0b28305ae8d28d4657d6d979 | https://github.com/fostam/php-getopts/blob/0d0209eb48201e3e0b28305ae8d28d4657d6d979/src/Handler.php#L100-L106 |
14,136 | fostam/php-getopts | src/Handler.php | Handler.parse | public function parse($inputArgs = null) {
$args = $this->getCommandLineArgs($inputArgs);
if (count($args)) {
$this->scriptName = array_shift($args);
}
// build help option
$helpOpt = false;
if ($this->helpLong) {
$helpOpt = new Option();
$helpOpt->long($this->helpLong);
}
if ($this->helpShort) {
if (!$helpOpt) {
$helpOpt = new Option();
}
$helpOpt->short($this->helpShort);
}
if ($helpOpt) {
$this->configOpts[Parser::HELP_OPTION_NAME] = $helpOpt;
}
try {
$parser = new Parser($this->configOpts, $this->configArgs);
$parser->parse($args);
}
catch (UsageException $e) {
if ($this->errorHandling) {
$this->handleUsageError($e);
}
else {
// re-throw exception
throw $e;
}
}
catch (ShowHelpException $e) {
$this->showHelp();
}
$this->result = $parser->getResult();
} | php | public function parse($inputArgs = null) {
$args = $this->getCommandLineArgs($inputArgs);
if (count($args)) {
$this->scriptName = array_shift($args);
}
// build help option
$helpOpt = false;
if ($this->helpLong) {
$helpOpt = new Option();
$helpOpt->long($this->helpLong);
}
if ($this->helpShort) {
if (!$helpOpt) {
$helpOpt = new Option();
}
$helpOpt->short($this->helpShort);
}
if ($helpOpt) {
$this->configOpts[Parser::HELP_OPTION_NAME] = $helpOpt;
}
try {
$parser = new Parser($this->configOpts, $this->configArgs);
$parser->parse($args);
}
catch (UsageException $e) {
if ($this->errorHandling) {
$this->handleUsageError($e);
}
else {
// re-throw exception
throw $e;
}
}
catch (ShowHelpException $e) {
$this->showHelp();
}
$this->result = $parser->getResult();
} | [
"public",
"function",
"parse",
"(",
"$",
"inputArgs",
"=",
"null",
")",
"{",
"$",
"args",
"=",
"$",
"this",
"->",
"getCommandLineArgs",
"(",
"$",
"inputArgs",
")",
";",
"if",
"(",
"count",
"(",
"$",
"args",
")",
")",
"{",
"$",
"this",
"->",
"scriptName",
"=",
"array_shift",
"(",
"$",
"args",
")",
";",
"}",
"// build help option\r",
"$",
"helpOpt",
"=",
"false",
";",
"if",
"(",
"$",
"this",
"->",
"helpLong",
")",
"{",
"$",
"helpOpt",
"=",
"new",
"Option",
"(",
")",
";",
"$",
"helpOpt",
"->",
"long",
"(",
"$",
"this",
"->",
"helpLong",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"helpShort",
")",
"{",
"if",
"(",
"!",
"$",
"helpOpt",
")",
"{",
"$",
"helpOpt",
"=",
"new",
"Option",
"(",
")",
";",
"}",
"$",
"helpOpt",
"->",
"short",
"(",
"$",
"this",
"->",
"helpShort",
")",
";",
"}",
"if",
"(",
"$",
"helpOpt",
")",
"{",
"$",
"this",
"->",
"configOpts",
"[",
"Parser",
"::",
"HELP_OPTION_NAME",
"]",
"=",
"$",
"helpOpt",
";",
"}",
"try",
"{",
"$",
"parser",
"=",
"new",
"Parser",
"(",
"$",
"this",
"->",
"configOpts",
",",
"$",
"this",
"->",
"configArgs",
")",
";",
"$",
"parser",
"->",
"parse",
"(",
"$",
"args",
")",
";",
"}",
"catch",
"(",
"UsageException",
"$",
"e",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"errorHandling",
")",
"{",
"$",
"this",
"->",
"handleUsageError",
"(",
"$",
"e",
")",
";",
"}",
"else",
"{",
"// re-throw exception\r",
"throw",
"$",
"e",
";",
"}",
"}",
"catch",
"(",
"ShowHelpException",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"showHelp",
"(",
")",
";",
"}",
"$",
"this",
"->",
"result",
"=",
"$",
"parser",
"->",
"getResult",
"(",
")",
";",
"}"
]
| parse arguments
the first element in the array is treated as script name
@param array $inputArgs
@throws UsageException | [
"parse",
"arguments",
"the",
"first",
"element",
"in",
"the",
"array",
"is",
"treated",
"as",
"script",
"name"
]
| 0d0209eb48201e3e0b28305ae8d28d4657d6d979 | https://github.com/fostam/php-getopts/blob/0d0209eb48201e3e0b28305ae8d28d4657d6d979/src/Handler.php#L146-L186 |
14,137 | fostam/php-getopts | src/Handler.php | Handler.getOptions | public function getOptions() {
if (is_null($this->result)) {
$this->parse();
}
return $this->result[Parser::RESULT_OPTIONS];
} | php | public function getOptions() {
if (is_null($this->result)) {
$this->parse();
}
return $this->result[Parser::RESULT_OPTIONS];
} | [
"public",
"function",
"getOptions",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"result",
")",
")",
"{",
"$",
"this",
"->",
"parse",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"result",
"[",
"Parser",
"::",
"RESULT_OPTIONS",
"]",
";",
"}"
]
| get the parsed options and their values
@return array
@throws \LogicException | [
"get",
"the",
"parsed",
"options",
"and",
"their",
"values"
]
| 0d0209eb48201e3e0b28305ae8d28d4657d6d979 | https://github.com/fostam/php-getopts/blob/0d0209eb48201e3e0b28305ae8d28d4657d6d979/src/Handler.php#L218-L223 |
14,138 | fostam/php-getopts | src/Handler.php | Handler.getArguments | public function getArguments() {
if (is_null($this->result)) {
$this->parse();
}
return $this->result[Parser::RESULT_ARGUMENTS];
} | php | public function getArguments() {
if (is_null($this->result)) {
$this->parse();
}
return $this->result[Parser::RESULT_ARGUMENTS];
} | [
"public",
"function",
"getArguments",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"result",
")",
")",
"{",
"$",
"this",
"->",
"parse",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"result",
"[",
"Parser",
"::",
"RESULT_ARGUMENTS",
"]",
";",
"}"
]
| get parsed argument values
@return array
@throws \LogicException | [
"get",
"parsed",
"argument",
"values"
]
| 0d0209eb48201e3e0b28305ae8d28d4657d6d979 | https://github.com/fostam/php-getopts/blob/0d0209eb48201e3e0b28305ae8d28d4657d6d979/src/Handler.php#L231-L236 |
14,139 | vi-kon/laravel-parser | src/ViKon/Parser/renderer/Renderer.php | Renderer.render | public function render(TokenList $tokenList, $skin = 'default') {
if (!array_key_exists($skin, $this->ruleRenderers)) {
throw new ParserException('Skin ' . $skin . ' not found');
}
if (!array_key_exists($skin, $this->tokenRenderers)) {
$this->tokenRenderers[$skin] = [];
foreach ($this->ruleRenderers[$skin] as $ruleRenderer) {
$ruleRenderer->register($this);
}
}
\Event::fire('vikon.parser.before.render', [$tokenList]);
$output = '';
foreach ($tokenList->getTokens() as $token) {
\Event::fire('vikon.parser.token.render.' . $token->getName(), [$token, $tokenList]);
if (array_key_exists($token->getName(), $this->tokenRenderers[$skin])) {
$output .= $this->tokenRenderers[$skin][$token->getName()]($token, $tokenList);
} else {
$output .= (string)$token;
}
}
return $output;
} | php | public function render(TokenList $tokenList, $skin = 'default') {
if (!array_key_exists($skin, $this->ruleRenderers)) {
throw new ParserException('Skin ' . $skin . ' not found');
}
if (!array_key_exists($skin, $this->tokenRenderers)) {
$this->tokenRenderers[$skin] = [];
foreach ($this->ruleRenderers[$skin] as $ruleRenderer) {
$ruleRenderer->register($this);
}
}
\Event::fire('vikon.parser.before.render', [$tokenList]);
$output = '';
foreach ($tokenList->getTokens() as $token) {
\Event::fire('vikon.parser.token.render.' . $token->getName(), [$token, $tokenList]);
if (array_key_exists($token->getName(), $this->tokenRenderers[$skin])) {
$output .= $this->tokenRenderers[$skin][$token->getName()]($token, $tokenList);
} else {
$output .= (string)$token;
}
}
return $output;
} | [
"public",
"function",
"render",
"(",
"TokenList",
"$",
"tokenList",
",",
"$",
"skin",
"=",
"'default'",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"skin",
",",
"$",
"this",
"->",
"ruleRenderers",
")",
")",
"{",
"throw",
"new",
"ParserException",
"(",
"'Skin '",
".",
"$",
"skin",
".",
"' not found'",
")",
";",
"}",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"skin",
",",
"$",
"this",
"->",
"tokenRenderers",
")",
")",
"{",
"$",
"this",
"->",
"tokenRenderers",
"[",
"$",
"skin",
"]",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"ruleRenderers",
"[",
"$",
"skin",
"]",
"as",
"$",
"ruleRenderer",
")",
"{",
"$",
"ruleRenderer",
"->",
"register",
"(",
"$",
"this",
")",
";",
"}",
"}",
"\\",
"Event",
"::",
"fire",
"(",
"'vikon.parser.before.render'",
",",
"[",
"$",
"tokenList",
"]",
")",
";",
"$",
"output",
"=",
"''",
";",
"foreach",
"(",
"$",
"tokenList",
"->",
"getTokens",
"(",
")",
"as",
"$",
"token",
")",
"{",
"\\",
"Event",
"::",
"fire",
"(",
"'vikon.parser.token.render.'",
".",
"$",
"token",
"->",
"getName",
"(",
")",
",",
"[",
"$",
"token",
",",
"$",
"tokenList",
"]",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"token",
"->",
"getName",
"(",
")",
",",
"$",
"this",
"->",
"tokenRenderers",
"[",
"$",
"skin",
"]",
")",
")",
"{",
"$",
"output",
".=",
"$",
"this",
"->",
"tokenRenderers",
"[",
"$",
"skin",
"]",
"[",
"$",
"token",
"->",
"getName",
"(",
")",
"]",
"(",
"$",
"token",
",",
"$",
"tokenList",
")",
";",
"}",
"else",
"{",
"$",
"output",
".=",
"(",
"string",
")",
"$",
"token",
";",
"}",
"}",
"return",
"$",
"output",
";",
"}"
]
| Render token list
@param \ViKon\Parser\TokenList $tokenList parsed token list
@param string $skin renderer skin
@return bool|string FALSE on failure otherwise output
@throws \ViKon\Parser\ParserException | [
"Render",
"token",
"list"
]
| 070f0bb9120cb9ca6ff836d4f418e78ee33ee182 | https://github.com/vi-kon/laravel-parser/blob/070f0bb9120cb9ca6ff836d4f418e78ee33ee182/src/ViKon/Parser/renderer/Renderer.php#L54-L81 |
14,140 | cpliakas/search-framework | src/Search/Framework/SchemaLoader.php | SchemaLoader.load | public function load()
{
$log = $this->_agent->getLogger();
$context = array('collection' => $this->_collection->getId());
// Allow the schema to be loaded from another source.
$event = new SchemaLoaderEvent($this->_agent, $this->_collection);
$this->_agent->dispatchEvent(SearchEvents::SCHEMA_LOAD, $event);
if (!$options = $event->getOptions()) {
if ($conf_dir = $this->getConfDir()) {
$filename = $this->_collection->getConfigBasename() . '.yml';
$filepath = $conf_dir . '/' . $filename;
$context['filepath'] = $filepath;
$log->debug('Attempting to parse schema configuration file', $context);
$options = Yaml::parse($filepath);
$log->debug('Schema options parsed from configuration file', $context);
} else {
$log->notice('Path to conf directory could not be resolved', $context);
}
} else {
$log->debug('Schema configuration loaded from an external source.', $context);
}
$schema = new Schema();
$schema->build($options);
return $schema;
} | php | public function load()
{
$log = $this->_agent->getLogger();
$context = array('collection' => $this->_collection->getId());
// Allow the schema to be loaded from another source.
$event = new SchemaLoaderEvent($this->_agent, $this->_collection);
$this->_agent->dispatchEvent(SearchEvents::SCHEMA_LOAD, $event);
if (!$options = $event->getOptions()) {
if ($conf_dir = $this->getConfDir()) {
$filename = $this->_collection->getConfigBasename() . '.yml';
$filepath = $conf_dir . '/' . $filename;
$context['filepath'] = $filepath;
$log->debug('Attempting to parse schema configuration file', $context);
$options = Yaml::parse($filepath);
$log->debug('Schema options parsed from configuration file', $context);
} else {
$log->notice('Path to conf directory could not be resolved', $context);
}
} else {
$log->debug('Schema configuration loaded from an external source.', $context);
}
$schema = new Schema();
$schema->build($options);
return $schema;
} | [
"public",
"function",
"load",
"(",
")",
"{",
"$",
"log",
"=",
"$",
"this",
"->",
"_agent",
"->",
"getLogger",
"(",
")",
";",
"$",
"context",
"=",
"array",
"(",
"'collection'",
"=>",
"$",
"this",
"->",
"_collection",
"->",
"getId",
"(",
")",
")",
";",
"// Allow the schema to be loaded from another source.",
"$",
"event",
"=",
"new",
"SchemaLoaderEvent",
"(",
"$",
"this",
"->",
"_agent",
",",
"$",
"this",
"->",
"_collection",
")",
";",
"$",
"this",
"->",
"_agent",
"->",
"dispatchEvent",
"(",
"SearchEvents",
"::",
"SCHEMA_LOAD",
",",
"$",
"event",
")",
";",
"if",
"(",
"!",
"$",
"options",
"=",
"$",
"event",
"->",
"getOptions",
"(",
")",
")",
"{",
"if",
"(",
"$",
"conf_dir",
"=",
"$",
"this",
"->",
"getConfDir",
"(",
")",
")",
"{",
"$",
"filename",
"=",
"$",
"this",
"->",
"_collection",
"->",
"getConfigBasename",
"(",
")",
".",
"'.yml'",
";",
"$",
"filepath",
"=",
"$",
"conf_dir",
".",
"'/'",
".",
"$",
"filename",
";",
"$",
"context",
"[",
"'filepath'",
"]",
"=",
"$",
"filepath",
";",
"$",
"log",
"->",
"debug",
"(",
"'Attempting to parse schema configuration file'",
",",
"$",
"context",
")",
";",
"$",
"options",
"=",
"Yaml",
"::",
"parse",
"(",
"$",
"filepath",
")",
";",
"$",
"log",
"->",
"debug",
"(",
"'Schema options parsed from configuration file'",
",",
"$",
"context",
")",
";",
"}",
"else",
"{",
"$",
"log",
"->",
"notice",
"(",
"'Path to conf directory could not be resolved'",
",",
"$",
"context",
")",
";",
"}",
"}",
"else",
"{",
"$",
"log",
"->",
"debug",
"(",
"'Schema configuration loaded from an external source.'",
",",
"$",
"context",
")",
";",
"}",
"$",
"schema",
"=",
"new",
"Schema",
"(",
")",
";",
"$",
"schema",
"->",
"build",
"(",
"$",
"options",
")",
";",
"return",
"$",
"schema",
";",
"}"
]
| Parses configuration options from YAML configuration files related to the
configurable object.
This method throws the SearchEvents::CONFIG_LOAD event. If configurations
are loaded during this event, processing stops and the directories are
not scanned for configuration files.
@return array
An associative array of options.
@throws ParseException | [
"Parses",
"configuration",
"options",
"from",
"YAML",
"configuration",
"files",
"related",
"to",
"the",
"configurable",
"object",
"."
]
| 7c5832d38ed998e04837c26e0daef59115563b98 | https://github.com/cpliakas/search-framework/blob/7c5832d38ed998e04837c26e0daef59115563b98/src/Search/Framework/SchemaLoader.php#L74-L104 |
14,141 | LIN3S/WPFoundation | src/LIN3S/WPFoundation/Configuration/Mailer/Mailer.php | Mailer.mailer | public function mailer($phpMailer)
{
if (MAILER_SMTP) {
$phpMailer->isSMTP();
$phpMailer->SMTPAuth = true;
}
$phpMailer->Host = MAILER_HOST;
$phpMailer->Port = MAILER_PORT;
$phpMailer->Username = MAILER_USERNAME;
$phpMailer->Password = MAILER_PASSWORD;
$phpMailer->SMTPSecure = MAILER_TRANSPORT;
$phpMailer->Sender = $phpMailer->From;
} | php | public function mailer($phpMailer)
{
if (MAILER_SMTP) {
$phpMailer->isSMTP();
$phpMailer->SMTPAuth = true;
}
$phpMailer->Host = MAILER_HOST;
$phpMailer->Port = MAILER_PORT;
$phpMailer->Username = MAILER_USERNAME;
$phpMailer->Password = MAILER_PASSWORD;
$phpMailer->SMTPSecure = MAILER_TRANSPORT;
$phpMailer->Sender = $phpMailer->From;
} | [
"public",
"function",
"mailer",
"(",
"$",
"phpMailer",
")",
"{",
"if",
"(",
"MAILER_SMTP",
")",
"{",
"$",
"phpMailer",
"->",
"isSMTP",
"(",
")",
";",
"$",
"phpMailer",
"->",
"SMTPAuth",
"=",
"true",
";",
"}",
"$",
"phpMailer",
"->",
"Host",
"=",
"MAILER_HOST",
";",
"$",
"phpMailer",
"->",
"Port",
"=",
"MAILER_PORT",
";",
"$",
"phpMailer",
"->",
"Username",
"=",
"MAILER_USERNAME",
";",
"$",
"phpMailer",
"->",
"Password",
"=",
"MAILER_PASSWORD",
";",
"$",
"phpMailer",
"->",
"SMTPSecure",
"=",
"MAILER_TRANSPORT",
";",
"$",
"phpMailer",
"->",
"Sender",
"=",
"$",
"phpMailer",
"->",
"From",
";",
"}"
]
| Configures the mailer according to the parameters in "wp-config-custom.php".
@param object $phpMailer The PhpMailer instance | [
"Configures",
"the",
"mailer",
"according",
"to",
"the",
"parameters",
"in",
"wp",
"-",
"config",
"-",
"custom",
".",
"php",
"."
]
| 4f5674b0544b770809f1ffa7bd7d8fdfe013e4bf | https://github.com/LIN3S/WPFoundation/blob/4f5674b0544b770809f1ffa7bd7d8fdfe013e4bf/src/LIN3S/WPFoundation/Configuration/Mailer/Mailer.php#L46-L58 |
14,142 | codezero-be/flash | src/FlashServiceProvider.php | FlashServiceProvider.registerFlash | private function registerFlash()
{
$this->app->singleton('CodeZero\Flash\Flash', function () {
$config = config('flash');
$session = app()->make('CodeZero\Flash\SessionStore\SessionStore');
$translator = app()->make('CodeZero\Flash\Translator\Translator');
return new Flash($config, $session, $translator);
});
} | php | private function registerFlash()
{
$this->app->singleton('CodeZero\Flash\Flash', function () {
$config = config('flash');
$session = app()->make('CodeZero\Flash\SessionStore\SessionStore');
$translator = app()->make('CodeZero\Flash\Translator\Translator');
return new Flash($config, $session, $translator);
});
} | [
"private",
"function",
"registerFlash",
"(",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"singleton",
"(",
"'CodeZero\\Flash\\Flash'",
",",
"function",
"(",
")",
"{",
"$",
"config",
"=",
"config",
"(",
"'flash'",
")",
";",
"$",
"session",
"=",
"app",
"(",
")",
"->",
"make",
"(",
"'CodeZero\\Flash\\SessionStore\\SessionStore'",
")",
";",
"$",
"translator",
"=",
"app",
"(",
")",
"->",
"make",
"(",
"'CodeZero\\Flash\\Translator\\Translator'",
")",
";",
"return",
"new",
"Flash",
"(",
"$",
"config",
",",
"$",
"session",
",",
"$",
"translator",
")",
";",
"}",
")",
";",
"}"
]
| Register the Flash binding.
@return void | [
"Register",
"the",
"Flash",
"binding",
"."
]
| ad65fd730ab5a594f9cf9e8c62b2c16c1eae3ce0 | https://github.com/codezero-be/flash/blob/ad65fd730ab5a594f9cf9e8c62b2c16c1eae3ce0/src/FlashServiceProvider.php#L77-L86 |
14,143 | wpup/digster | src/engines/class-twig-engine.php | Twig_Engine.add_extension | public function add_extension( Twig_ExtensionInterface $extension ) {
$env = $this->instance();
$exts = $env->getExtensions();
if ( isset( $exts[$extension->getName()] ) ) {
return;
}
try {
$env->addExtension( $extension );
} catch ( LogicException $e ) {
return;
}
} | php | public function add_extension( Twig_ExtensionInterface $extension ) {
$env = $this->instance();
$exts = $env->getExtensions();
if ( isset( $exts[$extension->getName()] ) ) {
return;
}
try {
$env->addExtension( $extension );
} catch ( LogicException $e ) {
return;
}
} | [
"public",
"function",
"add_extension",
"(",
"Twig_ExtensionInterface",
"$",
"extension",
")",
"{",
"$",
"env",
"=",
"$",
"this",
"->",
"instance",
"(",
")",
";",
"$",
"exts",
"=",
"$",
"env",
"->",
"getExtensions",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"exts",
"[",
"$",
"extension",
"->",
"getName",
"(",
")",
"]",
")",
")",
"{",
"return",
";",
"}",
"try",
"{",
"$",
"env",
"->",
"addExtension",
"(",
"$",
"extension",
")",
";",
"}",
"catch",
"(",
"LogicException",
"$",
"e",
")",
"{",
"return",
";",
"}",
"}"
]
| Add extension if it don't exists.
@param \Twig_ExtensionInterface $extension | [
"Add",
"extension",
"if",
"it",
"don",
"t",
"exists",
"."
]
| 9ef9626ce82673af698bc0976d6c38a532e4a6d9 | https://github.com/wpup/digster/blob/9ef9626ce82673af698bc0976d6c38a532e4a6d9/src/engines/class-twig-engine.php#L34-L47 |
14,144 | wpup/digster | src/engines/class-twig-engine.php | Twig_Engine.boot | private function boot() {
list( $locations, $config ) = $this->get_engine_config();
$loader = new Twig_Loader_Filesystem( $locations );
$env = new Twig_Environment( $loader, $config );
if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
$env->addExtension( new Twig_Extension_Debug() );
}
return $env;
} | php | private function boot() {
list( $locations, $config ) = $this->get_engine_config();
$loader = new Twig_Loader_Filesystem( $locations );
$env = new Twig_Environment( $loader, $config );
if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
$env->addExtension( new Twig_Extension_Debug() );
}
return $env;
} | [
"private",
"function",
"boot",
"(",
")",
"{",
"list",
"(",
"$",
"locations",
",",
"$",
"config",
")",
"=",
"$",
"this",
"->",
"get_engine_config",
"(",
")",
";",
"$",
"loader",
"=",
"new",
"Twig_Loader_Filesystem",
"(",
"$",
"locations",
")",
";",
"$",
"env",
"=",
"new",
"Twig_Environment",
"(",
"$",
"loader",
",",
"$",
"config",
")",
";",
"if",
"(",
"defined",
"(",
"'WP_DEBUG'",
")",
"&&",
"WP_DEBUG",
")",
"{",
"$",
"env",
"->",
"addExtension",
"(",
"new",
"Twig_Extension_Debug",
"(",
")",
")",
";",
"}",
"return",
"$",
"env",
";",
"}"
]
| Boot Twig environment.
@return \Twig_Environment | [
"Boot",
"Twig",
"environment",
"."
]
| 9ef9626ce82673af698bc0976d6c38a532e4a6d9 | https://github.com/wpup/digster/blob/9ef9626ce82673af698bc0976d6c38a532e4a6d9/src/engines/class-twig-engine.php#L54-L65 |
14,145 | wpup/digster | src/engines/class-twig-engine.php | Twig_Engine.instance | public function instance() {
if ( ! isset( self::$environment ) ) {
self::$environment = $this->boot();
}
return self::$environment;
} | php | public function instance() {
if ( ! isset( self::$environment ) ) {
self::$environment = $this->boot();
}
return self::$environment;
} | [
"public",
"function",
"instance",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"environment",
")",
")",
"{",
"self",
"::",
"$",
"environment",
"=",
"$",
"this",
"->",
"boot",
"(",
")",
";",
"}",
"return",
"self",
"::",
"$",
"environment",
";",
"}"
]
| Get the Twig environment instance.
@return \Twig_Environment | [
"Get",
"the",
"Twig",
"environment",
"instance",
"."
]
| 9ef9626ce82673af698bc0976d6c38a532e4a6d9 | https://github.com/wpup/digster/blob/9ef9626ce82673af698bc0976d6c38a532e4a6d9/src/engines/class-twig-engine.php#L72-L78 |
14,146 | wpup/digster | src/engines/class-twig-engine.php | Twig_Engine.register_extensions | public function register_extensions() {
$extensions = func_get_args();
foreach ( $extensions as $extension ) {
if ( $extension instanceof Twig_ExtensionInterface ) {
$this->add_extension( $extension );
} else if ( is_string( $extension ) && class_exists( $extension ) ) {
$this->add_extension( new $extension );
} else {
foreach ( (array) $extension as $ext ) {
$this->register_extensions( $ext );
}
}
}
} | php | public function register_extensions() {
$extensions = func_get_args();
foreach ( $extensions as $extension ) {
if ( $extension instanceof Twig_ExtensionInterface ) {
$this->add_extension( $extension );
} else if ( is_string( $extension ) && class_exists( $extension ) ) {
$this->add_extension( new $extension );
} else {
foreach ( (array) $extension as $ext ) {
$this->register_extensions( $ext );
}
}
}
} | [
"public",
"function",
"register_extensions",
"(",
")",
"{",
"$",
"extensions",
"=",
"func_get_args",
"(",
")",
";",
"foreach",
"(",
"$",
"extensions",
"as",
"$",
"extension",
")",
"{",
"if",
"(",
"$",
"extension",
"instanceof",
"Twig_ExtensionInterface",
")",
"{",
"$",
"this",
"->",
"add_extension",
"(",
"$",
"extension",
")",
";",
"}",
"else",
"if",
"(",
"is_string",
"(",
"$",
"extension",
")",
"&&",
"class_exists",
"(",
"$",
"extension",
")",
")",
"{",
"$",
"this",
"->",
"add_extension",
"(",
"new",
"$",
"extension",
")",
";",
"}",
"else",
"{",
"foreach",
"(",
"(",
"array",
")",
"$",
"extension",
"as",
"$",
"ext",
")",
"{",
"$",
"this",
"->",
"register_extensions",
"(",
"$",
"ext",
")",
";",
"}",
"}",
"}",
"}"
]
| Register Twig extensions that use `Twig_ExtensionInterface`. | [
"Register",
"Twig",
"extensions",
"that",
"use",
"Twig_ExtensionInterface",
"."
]
| 9ef9626ce82673af698bc0976d6c38a532e4a6d9 | https://github.com/wpup/digster/blob/9ef9626ce82673af698bc0976d6c38a532e4a6d9/src/engines/class-twig-engine.php#L101-L115 |
14,147 | wpup/digster | src/engines/class-twig-engine.php | Twig_Engine.render | public function render( $view, array $data = [] ) {
if ( in_array( $view, $this->extensions ) ) {
return '';
}
try {
return $this->instance()->render( $view, $data );
} catch ( Twig_Error $e ) {
do_action( 'digster/twig_render_exception', $e );
$this->render_error( $e );
}
} | php | public function render( $view, array $data = [] ) {
if ( in_array( $view, $this->extensions ) ) {
return '';
}
try {
return $this->instance()->render( $view, $data );
} catch ( Twig_Error $e ) {
do_action( 'digster/twig_render_exception', $e );
$this->render_error( $e );
}
} | [
"public",
"function",
"render",
"(",
"$",
"view",
",",
"array",
"$",
"data",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"view",
",",
"$",
"this",
"->",
"extensions",
")",
")",
"{",
"return",
"''",
";",
"}",
"try",
"{",
"return",
"$",
"this",
"->",
"instance",
"(",
")",
"->",
"render",
"(",
"$",
"view",
",",
"$",
"data",
")",
";",
"}",
"catch",
"(",
"Twig_Error",
"$",
"e",
")",
"{",
"do_action",
"(",
"'digster/twig_render_exception'",
",",
"$",
"e",
")",
";",
"$",
"this",
"->",
"render_error",
"(",
"$",
"e",
")",
";",
"}",
"}"
]
| Get the rendered view string.
@param string $view
@param array $data | [
"Get",
"the",
"rendered",
"view",
"string",
"."
]
| 9ef9626ce82673af698bc0976d6c38a532e4a6d9 | https://github.com/wpup/digster/blob/9ef9626ce82673af698bc0976d6c38a532e4a6d9/src/engines/class-twig-engine.php#L123-L134 |
14,148 | wpup/digster | src/engines/class-twig-engine.php | Twig_Engine.render_error | protected function render_error( Twig_Error $e ) {
$title = 'Error';
$message = 'An error occurred while rendering the template for this page. Turn on the "debug" option for more information.';
$file = '';
$code = '';
list( $locations, $config ) = $this->get_engine_config();
if ( $config['debug'] ) {
$template_file = $e->getTemplateFile();
foreach ( $locations as $location ) {
if ( file_exists( $location . '/' . $template_file ) ) {
$file = $locations[0] . '/' . $template_file;
break;
}
}
if ( ! file_exists( $file ) ) {
throw $e;
return;
}
$line = $e->getTemplateLine();
$plus = 4;
$content = file_get_contents( $file );
$lines = preg_split( "/(\r\n|\n|\r)/", $content );
$start = max( 1, $line - $plus );
$limit = min( count( $lines ), $line + $plus );
$excerpt = [];
for ( $i = $start - 1; $i < $limit; $i++ ) {
$attr = sprintf( 'data-line="%d"', ( $i+1 ) );
if ( $i === $line - 1 ) {
$excerpt[] = sprintf( '<mark %s>%s</mark>', $attr, $lines[$i] );
continue;
}
$excerpt[] = sprintf( '<span %s>%s</span>', $attr, $lines[$i] );
}
$title = get_class( $e );
$message = $e->getMessage();
$code = implode( "\n", $excerpt );
$file = $file . ':' . $line;
$message = $e->getRawMessage();
}
$view = 'error.php';
$path = __DIR__ . '/../views/';
$path = rtrim( $path, '/' ) . '/';
$path = $path . $view;
$path = apply_filters( 'digster/twig_error_view', $path );
if ( file_exists( $path ) ) {
require $path;
die;
}
throw $e;
} | php | protected function render_error( Twig_Error $e ) {
$title = 'Error';
$message = 'An error occurred while rendering the template for this page. Turn on the "debug" option for more information.';
$file = '';
$code = '';
list( $locations, $config ) = $this->get_engine_config();
if ( $config['debug'] ) {
$template_file = $e->getTemplateFile();
foreach ( $locations as $location ) {
if ( file_exists( $location . '/' . $template_file ) ) {
$file = $locations[0] . '/' . $template_file;
break;
}
}
if ( ! file_exists( $file ) ) {
throw $e;
return;
}
$line = $e->getTemplateLine();
$plus = 4;
$content = file_get_contents( $file );
$lines = preg_split( "/(\r\n|\n|\r)/", $content );
$start = max( 1, $line - $plus );
$limit = min( count( $lines ), $line + $plus );
$excerpt = [];
for ( $i = $start - 1; $i < $limit; $i++ ) {
$attr = sprintf( 'data-line="%d"', ( $i+1 ) );
if ( $i === $line - 1 ) {
$excerpt[] = sprintf( '<mark %s>%s</mark>', $attr, $lines[$i] );
continue;
}
$excerpt[] = sprintf( '<span %s>%s</span>', $attr, $lines[$i] );
}
$title = get_class( $e );
$message = $e->getMessage();
$code = implode( "\n", $excerpt );
$file = $file . ':' . $line;
$message = $e->getRawMessage();
}
$view = 'error.php';
$path = __DIR__ . '/../views/';
$path = rtrim( $path, '/' ) . '/';
$path = $path . $view;
$path = apply_filters( 'digster/twig_error_view', $path );
if ( file_exists( $path ) ) {
require $path;
die;
}
throw $e;
} | [
"protected",
"function",
"render_error",
"(",
"Twig_Error",
"$",
"e",
")",
"{",
"$",
"title",
"=",
"'Error'",
";",
"$",
"message",
"=",
"'An error occurred while rendering the template for this page. Turn on the \"debug\" option for more information.'",
";",
"$",
"file",
"=",
"''",
";",
"$",
"code",
"=",
"''",
";",
"list",
"(",
"$",
"locations",
",",
"$",
"config",
")",
"=",
"$",
"this",
"->",
"get_engine_config",
"(",
")",
";",
"if",
"(",
"$",
"config",
"[",
"'debug'",
"]",
")",
"{",
"$",
"template_file",
"=",
"$",
"e",
"->",
"getTemplateFile",
"(",
")",
";",
"foreach",
"(",
"$",
"locations",
"as",
"$",
"location",
")",
"{",
"if",
"(",
"file_exists",
"(",
"$",
"location",
".",
"'/'",
".",
"$",
"template_file",
")",
")",
"{",
"$",
"file",
"=",
"$",
"locations",
"[",
"0",
"]",
".",
"'/'",
".",
"$",
"template_file",
";",
"break",
";",
"}",
"}",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"file",
")",
")",
"{",
"throw",
"$",
"e",
";",
"return",
";",
"}",
"$",
"line",
"=",
"$",
"e",
"->",
"getTemplateLine",
"(",
")",
";",
"$",
"plus",
"=",
"4",
";",
"$",
"content",
"=",
"file_get_contents",
"(",
"$",
"file",
")",
";",
"$",
"lines",
"=",
"preg_split",
"(",
"\"/(\\r\\n|\\n|\\r)/\"",
",",
"$",
"content",
")",
";",
"$",
"start",
"=",
"max",
"(",
"1",
",",
"$",
"line",
"-",
"$",
"plus",
")",
";",
"$",
"limit",
"=",
"min",
"(",
"count",
"(",
"$",
"lines",
")",
",",
"$",
"line",
"+",
"$",
"plus",
")",
";",
"$",
"excerpt",
"=",
"[",
"]",
";",
"for",
"(",
"$",
"i",
"=",
"$",
"start",
"-",
"1",
";",
"$",
"i",
"<",
"$",
"limit",
";",
"$",
"i",
"++",
")",
"{",
"$",
"attr",
"=",
"sprintf",
"(",
"'data-line=\"%d\"'",
",",
"(",
"$",
"i",
"+",
"1",
")",
")",
";",
"if",
"(",
"$",
"i",
"===",
"$",
"line",
"-",
"1",
")",
"{",
"$",
"excerpt",
"[",
"]",
"=",
"sprintf",
"(",
"'<mark %s>%s</mark>'",
",",
"$",
"attr",
",",
"$",
"lines",
"[",
"$",
"i",
"]",
")",
";",
"continue",
";",
"}",
"$",
"excerpt",
"[",
"]",
"=",
"sprintf",
"(",
"'<span %s>%s</span>'",
",",
"$",
"attr",
",",
"$",
"lines",
"[",
"$",
"i",
"]",
")",
";",
"}",
"$",
"title",
"=",
"get_class",
"(",
"$",
"e",
")",
";",
"$",
"message",
"=",
"$",
"e",
"->",
"getMessage",
"(",
")",
";",
"$",
"code",
"=",
"implode",
"(",
"\"\\n\"",
",",
"$",
"excerpt",
")",
";",
"$",
"file",
"=",
"$",
"file",
".",
"':'",
".",
"$",
"line",
";",
"$",
"message",
"=",
"$",
"e",
"->",
"getRawMessage",
"(",
")",
";",
"}",
"$",
"view",
"=",
"'error.php'",
";",
"$",
"path",
"=",
"__DIR__",
".",
"'/../views/'",
";",
"$",
"path",
"=",
"rtrim",
"(",
"$",
"path",
",",
"'/'",
")",
".",
"'/'",
";",
"$",
"path",
"=",
"$",
"path",
".",
"$",
"view",
";",
"$",
"path",
"=",
"apply_filters",
"(",
"'digster/twig_error_view'",
",",
"$",
"path",
")",
";",
"if",
"(",
"file_exists",
"(",
"$",
"path",
")",
")",
"{",
"require",
"$",
"path",
";",
"die",
";",
"}",
"throw",
"$",
"e",
";",
"}"
]
| Render error view.
@param \Twig_Error $e | [
"Render",
"error",
"view",
"."
]
| 9ef9626ce82673af698bc0976d6c38a532e4a6d9 | https://github.com/wpup/digster/blob/9ef9626ce82673af698bc0976d6c38a532e4a6d9/src/engines/class-twig-engine.php#L141-L202 |
14,149 | eleven-lab/php-ogc | src/DataTypes/LineString.php | LineString.fromArray | public static function fromArray(array $points)
{
$parsed_points = array_map(function($p){
if( !is_array($p) or sizeof($p) != 2)
throw new GeoSpatialException('Error: array of array containing lat, lon expected.');
return new Point($p[0], $p[1]);
}, $points);
return new static($parsed_points);
} | php | public static function fromArray(array $points)
{
$parsed_points = array_map(function($p){
if( !is_array($p) or sizeof($p) != 2)
throw new GeoSpatialException('Error: array of array containing lat, lon expected.');
return new Point($p[0], $p[1]);
}, $points);
return new static($parsed_points);
} | [
"public",
"static",
"function",
"fromArray",
"(",
"array",
"$",
"points",
")",
"{",
"$",
"parsed_points",
"=",
"array_map",
"(",
"function",
"(",
"$",
"p",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"p",
")",
"or",
"sizeof",
"(",
"$",
"p",
")",
"!=",
"2",
")",
"throw",
"new",
"GeoSpatialException",
"(",
"'Error: array of array containing lat, lon expected.'",
")",
";",
"return",
"new",
"Point",
"(",
"$",
"p",
"[",
"0",
"]",
",",
"$",
"p",
"[",
"1",
"]",
")",
";",
"}",
",",
"$",
"points",
")",
";",
"return",
"new",
"static",
"(",
"$",
"parsed_points",
")",
";",
"}"
]
| A Linestring could be constructed with an array of points-array.
es. [[lat, lon], [lat, lon], [lat, lon], ..]
@param array $points
@return LineString | [
"A",
"Linestring",
"could",
"be",
"constructed",
"with",
"an",
"array",
"of",
"points",
"-",
"array",
"."
]
| ba15cea3ba71a65f14f3cadcb08bfce34f4489ce | https://github.com/eleven-lab/php-ogc/blob/ba15cea3ba71a65f14f3cadcb08bfce34f4489ce/src/DataTypes/LineString.php#L49-L57 |
14,150 | eleven-lab/php-ogc | src/DataTypes/LineString.php | LineString.fromString | public static function fromString($points, $points_separator = ",", $coords_separator = " ")
{
if($points_separator == $coords_separator)
throw new GeoSpatialException("Error: separators must be different");
$parsed_points = array_map(function($p) use ($coords_separator){
return Point::fromString($p, $coords_separator);
}, explode($points_separator, trim($points)));
return new static($parsed_points);
} | php | public static function fromString($points, $points_separator = ",", $coords_separator = " ")
{
if($points_separator == $coords_separator)
throw new GeoSpatialException("Error: separators must be different");
$parsed_points = array_map(function($p) use ($coords_separator){
return Point::fromString($p, $coords_separator);
}, explode($points_separator, trim($points)));
return new static($parsed_points);
} | [
"public",
"static",
"function",
"fromString",
"(",
"$",
"points",
",",
"$",
"points_separator",
"=",
"\",\"",
",",
"$",
"coords_separator",
"=",
"\" \"",
")",
"{",
"if",
"(",
"$",
"points_separator",
"==",
"$",
"coords_separator",
")",
"throw",
"new",
"GeoSpatialException",
"(",
"\"Error: separators must be different\"",
")",
";",
"$",
"parsed_points",
"=",
"array_map",
"(",
"function",
"(",
"$",
"p",
")",
"use",
"(",
"$",
"coords_separator",
")",
"{",
"return",
"Point",
"::",
"fromString",
"(",
"$",
"p",
",",
"$",
"coords_separator",
")",
";",
"}",
",",
"explode",
"(",
"$",
"points_separator",
",",
"trim",
"(",
"$",
"points",
")",
")",
")",
";",
"return",
"new",
"static",
"(",
"$",
"parsed_points",
")",
";",
"}"
]
| A Linestring could be instantiated using a string where points are divided by a "," and coordinates
are divided by " ". Separators must be different.
es. "lat lon, lat lon"
@param $points
@param string $points_separator
@param string $coords_separator
@throws GeoSpatialException
@return LineString | [
"A",
"Linestring",
"could",
"be",
"instantiated",
"using",
"a",
"string",
"where",
"points",
"are",
"divided",
"by",
"a",
"and",
"coordinates",
"are",
"divided",
"by",
".",
"Separators",
"must",
"be",
"different",
".",
"es",
".",
"lat",
"lon",
"lat",
"lon"
]
| ba15cea3ba71a65f14f3cadcb08bfce34f4489ce | https://github.com/eleven-lab/php-ogc/blob/ba15cea3ba71a65f14f3cadcb08bfce34f4489ce/src/DataTypes/LineString.php#L70-L78 |
14,151 | eleven-lab/php-ogc | src/DataTypes/LineString.php | LineString.isCircular | public function isCircular()
{
return count($this->points) > 3 && $this->points[0] == $this->points[ count($this->points) -1 ];
} | php | public function isCircular()
{
return count($this->points) > 3 && $this->points[0] == $this->points[ count($this->points) -1 ];
} | [
"public",
"function",
"isCircular",
"(",
")",
"{",
"return",
"count",
"(",
"$",
"this",
"->",
"points",
")",
">",
"3",
"&&",
"$",
"this",
"->",
"points",
"[",
"0",
"]",
"==",
"$",
"this",
"->",
"points",
"[",
"count",
"(",
"$",
"this",
"->",
"points",
")",
"-",
"1",
"]",
";",
"}"
]
| Check if the LineString is circular, that is the first and the last Point are the same.
@return bool | [
"Check",
"if",
"the",
"LineString",
"is",
"circular",
"that",
"is",
"the",
"first",
"and",
"the",
"last",
"Point",
"are",
"the",
"same",
"."
]
| ba15cea3ba71a65f14f3cadcb08bfce34f4489ce | https://github.com/eleven-lab/php-ogc/blob/ba15cea3ba71a65f14f3cadcb08bfce34f4489ce/src/DataTypes/LineString.php#L115-L118 |
14,152 | eleven-lab/php-ogc | src/DataTypes/LineString.php | LineString.lenght | public function lenght($provider = "haversine")
{
$length = 0;
for($i = 0; $i < count($this)-2 ; $i++ ){
$length += Point::distance($this->points[$i], $this->points[$i+1], $provider);
}
return $length;
} | php | public function lenght($provider = "haversine")
{
$length = 0;
for($i = 0; $i < count($this)-2 ; $i++ ){
$length += Point::distance($this->points[$i], $this->points[$i+1], $provider);
}
return $length;
} | [
"public",
"function",
"lenght",
"(",
"$",
"provider",
"=",
"\"haversine\"",
")",
"{",
"$",
"length",
"=",
"0",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"count",
"(",
"$",
"this",
")",
"-",
"2",
";",
"$",
"i",
"++",
")",
"{",
"$",
"length",
"+=",
"Point",
"::",
"distance",
"(",
"$",
"this",
"->",
"points",
"[",
"$",
"i",
"]",
",",
"$",
"this",
"->",
"points",
"[",
"$",
"i",
"+",
"1",
"]",
",",
"$",
"provider",
")",
";",
"}",
"return",
"$",
"length",
";",
"}"
]
| Return the lenght of the linestring expressed in meters.
@return int | [
"Return",
"the",
"lenght",
"of",
"the",
"linestring",
"expressed",
"in",
"meters",
"."
]
| ba15cea3ba71a65f14f3cadcb08bfce34f4489ce | https://github.com/eleven-lab/php-ogc/blob/ba15cea3ba71a65f14f3cadcb08bfce34f4489ce/src/DataTypes/LineString.php#L126-L134 |
14,153 | raphaelstolt/composer-travis-lint | src/Travis/Api.php | Api.post | public function post($travisConfiguration)
{
$headers = [
'Accept: application/vnd.travis-ci.2+json',
'Content-Type: text/yaml',
'Content-Length: ' . strlen($travisConfiguration),
];
curl_setopt($this->curlChannel, CURLOPT_USERAGENT, self::CURL_USERAGENT);
curl_setopt($this->curlChannel, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($this->curlChannel, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($this->curlChannel, CURLOPT_CONNECTTIMEOUT, self::CURL_TIMEOUT_IN_SECONDS);
curl_setopt($this->curlChannel, CURLOPT_TIMEOUT, self::CURL_TIMEOUT_IN_SECONDS);
curl_setopt($this->curlChannel, CURLOPT_MAXREDIRS, 3);
curl_setopt($this->curlChannel, CURLOPT_POSTFIELDS, $travisConfiguration);
curl_setopt($this->curlChannel, CURLOPT_HTTPHEADER, $headers);
curl_setopt($this->curlChannel, CURLOPT_URL, self::API_ENDPOINT);
curl_setopt($this->curlChannel, CURLOPT_RETURNTRANSFER, true);
curl_setopt($this->curlChannel, CURLOPT_SSL_VERIFYPEER, false);
$lintResult = curl_exec($this->curlChannel);
$responseInfo = curl_getinfo($this->curlChannel);
curl_close($this->curlChannel);
$apiRequestStatusCode = intval($responseInfo['http_code']);
if ($apiRequestStatusCode >= 400) {
$message = 'Travis CI lint API request '
. " failed with HTTP Code '$apiRequestStatusCode'.";
throw new ConnectivityFailure($message);
}
$lintResult = json_decode($lintResult, true);
if (!isset($lintResult['lint']) || !isset($lintResult['lint']['warnings'])) {
$message = 'Travis CI lint API responded '
. 'with a non expected structure.';
throw new NonExpectedReponseStructure($message);
}
if (count($lintResult['lint']['warnings']) === 0) {
return new Result;
}
if (count($lintResult['lint']['warnings']) > 0) {
$lintWarningsMessages = PHP_EOL;
foreach ($lintResult['lint']['warnings'] as $warning) {
$lintWarningsMessages .= ' - ' . $warning['message'] . PHP_EOL;
}
$failure = 'Travis CI configuration is invalid. '
. 'Warnings:' . rtrim($lintWarningsMessages);
return new Result(false, $failure);
}
} | php | public function post($travisConfiguration)
{
$headers = [
'Accept: application/vnd.travis-ci.2+json',
'Content-Type: text/yaml',
'Content-Length: ' . strlen($travisConfiguration),
];
curl_setopt($this->curlChannel, CURLOPT_USERAGENT, self::CURL_USERAGENT);
curl_setopt($this->curlChannel, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($this->curlChannel, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($this->curlChannel, CURLOPT_CONNECTTIMEOUT, self::CURL_TIMEOUT_IN_SECONDS);
curl_setopt($this->curlChannel, CURLOPT_TIMEOUT, self::CURL_TIMEOUT_IN_SECONDS);
curl_setopt($this->curlChannel, CURLOPT_MAXREDIRS, 3);
curl_setopt($this->curlChannel, CURLOPT_POSTFIELDS, $travisConfiguration);
curl_setopt($this->curlChannel, CURLOPT_HTTPHEADER, $headers);
curl_setopt($this->curlChannel, CURLOPT_URL, self::API_ENDPOINT);
curl_setopt($this->curlChannel, CURLOPT_RETURNTRANSFER, true);
curl_setopt($this->curlChannel, CURLOPT_SSL_VERIFYPEER, false);
$lintResult = curl_exec($this->curlChannel);
$responseInfo = curl_getinfo($this->curlChannel);
curl_close($this->curlChannel);
$apiRequestStatusCode = intval($responseInfo['http_code']);
if ($apiRequestStatusCode >= 400) {
$message = 'Travis CI lint API request '
. " failed with HTTP Code '$apiRequestStatusCode'.";
throw new ConnectivityFailure($message);
}
$lintResult = json_decode($lintResult, true);
if (!isset($lintResult['lint']) || !isset($lintResult['lint']['warnings'])) {
$message = 'Travis CI lint API responded '
. 'with a non expected structure.';
throw new NonExpectedReponseStructure($message);
}
if (count($lintResult['lint']['warnings']) === 0) {
return new Result;
}
if (count($lintResult['lint']['warnings']) > 0) {
$lintWarningsMessages = PHP_EOL;
foreach ($lintResult['lint']['warnings'] as $warning) {
$lintWarningsMessages .= ' - ' . $warning['message'] . PHP_EOL;
}
$failure = 'Travis CI configuration is invalid. '
. 'Warnings:' . rtrim($lintWarningsMessages);
return new Result(false, $failure);
}
} | [
"public",
"function",
"post",
"(",
"$",
"travisConfiguration",
")",
"{",
"$",
"headers",
"=",
"[",
"'Accept: application/vnd.travis-ci.2+json'",
",",
"'Content-Type: text/yaml'",
",",
"'Content-Length: '",
".",
"strlen",
"(",
"$",
"travisConfiguration",
")",
",",
"]",
";",
"curl_setopt",
"(",
"$",
"this",
"->",
"curlChannel",
",",
"CURLOPT_USERAGENT",
",",
"self",
"::",
"CURL_USERAGENT",
")",
";",
"curl_setopt",
"(",
"$",
"this",
"->",
"curlChannel",
",",
"CURLOPT_CUSTOMREQUEST",
",",
"'POST'",
")",
";",
"curl_setopt",
"(",
"$",
"this",
"->",
"curlChannel",
",",
"CURLOPT_FOLLOWLOCATION",
",",
"true",
")",
";",
"curl_setopt",
"(",
"$",
"this",
"->",
"curlChannel",
",",
"CURLOPT_CONNECTTIMEOUT",
",",
"self",
"::",
"CURL_TIMEOUT_IN_SECONDS",
")",
";",
"curl_setopt",
"(",
"$",
"this",
"->",
"curlChannel",
",",
"CURLOPT_TIMEOUT",
",",
"self",
"::",
"CURL_TIMEOUT_IN_SECONDS",
")",
";",
"curl_setopt",
"(",
"$",
"this",
"->",
"curlChannel",
",",
"CURLOPT_MAXREDIRS",
",",
"3",
")",
";",
"curl_setopt",
"(",
"$",
"this",
"->",
"curlChannel",
",",
"CURLOPT_POSTFIELDS",
",",
"$",
"travisConfiguration",
")",
";",
"curl_setopt",
"(",
"$",
"this",
"->",
"curlChannel",
",",
"CURLOPT_HTTPHEADER",
",",
"$",
"headers",
")",
";",
"curl_setopt",
"(",
"$",
"this",
"->",
"curlChannel",
",",
"CURLOPT_URL",
",",
"self",
"::",
"API_ENDPOINT",
")",
";",
"curl_setopt",
"(",
"$",
"this",
"->",
"curlChannel",
",",
"CURLOPT_RETURNTRANSFER",
",",
"true",
")",
";",
"curl_setopt",
"(",
"$",
"this",
"->",
"curlChannel",
",",
"CURLOPT_SSL_VERIFYPEER",
",",
"false",
")",
";",
"$",
"lintResult",
"=",
"curl_exec",
"(",
"$",
"this",
"->",
"curlChannel",
")",
";",
"$",
"responseInfo",
"=",
"curl_getinfo",
"(",
"$",
"this",
"->",
"curlChannel",
")",
";",
"curl_close",
"(",
"$",
"this",
"->",
"curlChannel",
")",
";",
"$",
"apiRequestStatusCode",
"=",
"intval",
"(",
"$",
"responseInfo",
"[",
"'http_code'",
"]",
")",
";",
"if",
"(",
"$",
"apiRequestStatusCode",
">=",
"400",
")",
"{",
"$",
"message",
"=",
"'Travis CI lint API request '",
".",
"\" failed with HTTP Code '$apiRequestStatusCode'.\"",
";",
"throw",
"new",
"ConnectivityFailure",
"(",
"$",
"message",
")",
";",
"}",
"$",
"lintResult",
"=",
"json_decode",
"(",
"$",
"lintResult",
",",
"true",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"lintResult",
"[",
"'lint'",
"]",
")",
"||",
"!",
"isset",
"(",
"$",
"lintResult",
"[",
"'lint'",
"]",
"[",
"'warnings'",
"]",
")",
")",
"{",
"$",
"message",
"=",
"'Travis CI lint API responded '",
".",
"'with a non expected structure.'",
";",
"throw",
"new",
"NonExpectedReponseStructure",
"(",
"$",
"message",
")",
";",
"}",
"if",
"(",
"count",
"(",
"$",
"lintResult",
"[",
"'lint'",
"]",
"[",
"'warnings'",
"]",
")",
"===",
"0",
")",
"{",
"return",
"new",
"Result",
";",
"}",
"if",
"(",
"count",
"(",
"$",
"lintResult",
"[",
"'lint'",
"]",
"[",
"'warnings'",
"]",
")",
">",
"0",
")",
"{",
"$",
"lintWarningsMessages",
"=",
"PHP_EOL",
";",
"foreach",
"(",
"$",
"lintResult",
"[",
"'lint'",
"]",
"[",
"'warnings'",
"]",
"as",
"$",
"warning",
")",
"{",
"$",
"lintWarningsMessages",
".=",
"' - '",
".",
"$",
"warning",
"[",
"'message'",
"]",
".",
"PHP_EOL",
";",
"}",
"$",
"failure",
"=",
"'Travis CI configuration is invalid. '",
".",
"'Warnings:'",
".",
"rtrim",
"(",
"$",
"lintWarningsMessages",
")",
";",
"return",
"new",
"Result",
"(",
"false",
",",
"$",
"failure",
")",
";",
"}",
"}"
]
| Posts the Travis CI configuration to the Travis CI Api.
@param string $travisConfiguration The content of .travis.yml.
@throws ConnectivityFailure
@throws NonExpectedReponseStructure
@return Stolt\Composer\Travis\Api\Result The post/lint result. | [
"Posts",
"the",
"Travis",
"CI",
"configuration",
"to",
"the",
"Travis",
"CI",
"Api",
"."
]
| e6e005350b3c8981826aa718bc2282ddfd03caef | https://github.com/raphaelstolt/composer-travis-lint/blob/e6e005350b3c8981826aa718bc2282ddfd03caef/src/Travis/Api.php#L33-L92 |
14,154 | incraigulous/contentful-sdk | src/ManagementResources/Entries.php | Entries.contentType | function contentType($contentType)
{
$this->requestDecorator->addHeader('X-Contentful-Content-Type', $contentType);
$this->requestDecorator->addParameter('content_type', '=', $contentType);
return $this;
} | php | function contentType($contentType)
{
$this->requestDecorator->addHeader('X-Contentful-Content-Type', $contentType);
$this->requestDecorator->addParameter('content_type', '=', $contentType);
return $this;
} | [
"function",
"contentType",
"(",
"$",
"contentType",
")",
"{",
"$",
"this",
"->",
"requestDecorator",
"->",
"addHeader",
"(",
"'X-Contentful-Content-Type'",
",",
"$",
"contentType",
")",
";",
"$",
"this",
"->",
"requestDecorator",
"->",
"addParameter",
"(",
"'content_type'",
",",
"'='",
",",
"$",
"contentType",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Target content type.
@param $contentType
@return $this | [
"Target",
"content",
"type",
"."
]
| 29399b11b0e085a06ea5976661378c379fe5a731 | https://github.com/incraigulous/contentful-sdk/blob/29399b11b0e085a06ea5976661378c379fe5a731/src/ManagementResources/Entries.php#L28-L33 |
14,155 | DevGroup-ru/yii2-data-structure-tools | src/helpers/PropertyHandlerHelper.php | PropertyHandlerHelper.handlers | public function handlers()
{
if ($this->_handlers === null) {
$this->_handlers = Yii::$app->cache->lazy(function () {
$models = PropertyHandlers::find()
->orderBy(['sort_order' => SORT_ASC])
->all();
$handlers = [];
foreach ($models as $model) {
$className = $model->class_name;
$handlers[$model->id] = new $className($model->default_config);
}
return $handlers;
}, 'AllPropertyHandlers', 86400, PropertyHandlers::commonTag());
}
return $this->_handlers;
} | php | public function handlers()
{
if ($this->_handlers === null) {
$this->_handlers = Yii::$app->cache->lazy(function () {
$models = PropertyHandlers::find()
->orderBy(['sort_order' => SORT_ASC])
->all();
$handlers = [];
foreach ($models as $model) {
$className = $model->class_name;
$handlers[$model->id] = new $className($model->default_config);
}
return $handlers;
}, 'AllPropertyHandlers', 86400, PropertyHandlers::commonTag());
}
return $this->_handlers;
} | [
"public",
"function",
"handlers",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_handlers",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"_handlers",
"=",
"Yii",
"::",
"$",
"app",
"->",
"cache",
"->",
"lazy",
"(",
"function",
"(",
")",
"{",
"$",
"models",
"=",
"PropertyHandlers",
"::",
"find",
"(",
")",
"->",
"orderBy",
"(",
"[",
"'sort_order'",
"=>",
"SORT_ASC",
"]",
")",
"->",
"all",
"(",
")",
";",
"$",
"handlers",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"models",
"as",
"$",
"model",
")",
"{",
"$",
"className",
"=",
"$",
"model",
"->",
"class_name",
";",
"$",
"handlers",
"[",
"$",
"model",
"->",
"id",
"]",
"=",
"new",
"$",
"className",
"(",
"$",
"model",
"->",
"default_config",
")",
";",
"}",
"return",
"$",
"handlers",
";",
"}",
",",
"'AllPropertyHandlers'",
",",
"86400",
",",
"PropertyHandlers",
"::",
"commonTag",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_handlers",
";",
"}"
]
| Retrieves handlers from database.
Uses lazy cache.
@return \DevGroup\DataStructure\propertyHandler\AbstractPropertyHandler[] | [
"Retrieves",
"handlers",
"from",
"database",
".",
"Uses",
"lazy",
"cache",
"."
]
| a5b24d7c0b24d4b0d58cacd91ec7fd876e979097 | https://github.com/DevGroup-ru/yii2-data-structure-tools/blob/a5b24d7c0b24d4b0d58cacd91ec7fd876e979097/src/helpers/PropertyHandlerHelper.php#L47-L65 |
14,156 | DevGroup-ru/yii2-data-structure-tools | src/helpers/PropertyHandlerHelper.php | PropertyHandlerHelper.handlerById | public function handlerById($id)
{
if (isset($this->_handlers[$id])) {
return $this->_handlers[$id];
}
throw new \Exception("Property handler with id {$id} not found");
} | php | public function handlerById($id)
{
if (isset($this->_handlers[$id])) {
return $this->_handlers[$id];
}
throw new \Exception("Property handler with id {$id} not found");
} | [
"public",
"function",
"handlerById",
"(",
"$",
"id",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_handlers",
"[",
"$",
"id",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"_handlers",
"[",
"$",
"id",
"]",
";",
"}",
"throw",
"new",
"\\",
"Exception",
"(",
"\"Property handler with id {$id} not found\"",
")",
";",
"}"
]
| Returns handler by ID
@param integer $id
@return \DevGroup\DataStructure\propertyHandler\AbstractPropertyHandler
@throws \Exception | [
"Returns",
"handler",
"by",
"ID"
]
| a5b24d7c0b24d4b0d58cacd91ec7fd876e979097 | https://github.com/DevGroup-ru/yii2-data-structure-tools/blob/a5b24d7c0b24d4b0d58cacd91ec7fd876e979097/src/helpers/PropertyHandlerHelper.php#L75-L81 |
14,157 | DevGroup-ru/yii2-data-structure-tools | src/helpers/PropertyHandlerHelper.php | PropertyHandlerHelper.handlerIdByClassName | public function handlerIdByClassName($className)
{
foreach ($this->handlers() as $id => $class) {
if ($class->className() === $className) {
return $id;
}
}
throw new Exception("Handler with classname {$className} not found.");
} | php | public function handlerIdByClassName($className)
{
foreach ($this->handlers() as $id => $class) {
if ($class->className() === $className) {
return $id;
}
}
throw new Exception("Handler with classname {$className} not found.");
} | [
"public",
"function",
"handlerIdByClassName",
"(",
"$",
"className",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"handlers",
"(",
")",
"as",
"$",
"id",
"=>",
"$",
"class",
")",
"{",
"if",
"(",
"$",
"class",
"->",
"className",
"(",
")",
"===",
"$",
"className",
")",
"{",
"return",
"$",
"id",
";",
"}",
"}",
"throw",
"new",
"Exception",
"(",
"\"Handler with classname {$className} not found.\"",
")",
";",
"}"
]
| Returns handler id bu it's class name
@param string $className
@return int
@throws Exception | [
"Returns",
"handler",
"id",
"bu",
"it",
"s",
"class",
"name"
]
| a5b24d7c0b24d4b0d58cacd91ec7fd876e979097 | https://github.com/DevGroup-ru/yii2-data-structure-tools/blob/a5b24d7c0b24d4b0d58cacd91ec7fd876e979097/src/helpers/PropertyHandlerHelper.php#L91-L100 |
14,158 | liip/LiipDrupalConnectorModule | src/Liip/Drupal/Modules/DrupalConnector/Common.php | Common.drupal_add_library | public function drupal_add_library($module = null, $name = null, $every_page = null)
{
return drupal_add_library($module, $name, $every_page);
} | php | public function drupal_add_library($module = null, $name = null, $every_page = null)
{
return drupal_add_library($module, $name, $every_page);
} | [
"public",
"function",
"drupal_add_library",
"(",
"$",
"module",
"=",
"null",
",",
"$",
"name",
"=",
"null",
",",
"$",
"every_page",
"=",
"null",
")",
"{",
"return",
"drupal_add_library",
"(",
"$",
"module",
",",
"$",
"name",
",",
"$",
"every_page",
")",
";",
"}"
]
| Adds multiple JavaScript or CSS files at the same time.
A library defines a set of JavaScript and/or CSS files, optionally using
settings, and optionally requiring another library. For example, a library
can be a jQuery plugin, a JavaScript framework, or a CSS framework. This
function allows modules to load a library defined/shipped by itself or a
depending module, without having to add all files of the library separately.
Each library is only loaded once.
@param null $data
@param null $options
@internal param $module The name of the module that registered the library.* The name of the module that registered the library.
@internal param $name The name of the library to add.* The name of the library to add.
@internal param $every_page Set to TRUE if this library is added to every page on the site. Only items* Set to TRUE if this library is added to every page on the site. Only items
with the every_page flag set to TRUE can participate in aggregation.
@return mixed TRUE if the library was successfully added; FALSE if the library or one of@see drupal_get_library()
@see hook_library()
@see hook_library_alter() | [
"Adds",
"multiple",
"JavaScript",
"or",
"CSS",
"files",
"at",
"the",
"same",
"time",
"."
]
| 6ba161ef0d3a27c108e533f1adbea22ed73b78ce | https://github.com/liip/LiipDrupalConnectorModule/blob/6ba161ef0d3a27c108e533f1adbea22ed73b78ce/src/Liip/Drupal/Modules/DrupalConnector/Common.php#L325-L328 |
14,159 | liip/LiipDrupalConnectorModule | src/Liip/Drupal/Modules/DrupalConnector/Common.php | Common.format_date | public function format_date($timestamp, $type = 'medium', $format = '', $timezone = null, $langcode = null)
{
return format_date($timestamp, $type, $format, $timezone, $langcode);
} | php | public function format_date($timestamp, $type = 'medium', $format = '', $timezone = null, $langcode = null)
{
return format_date($timestamp, $type, $format, $timezone, $langcode);
} | [
"public",
"function",
"format_date",
"(",
"$",
"timestamp",
",",
"$",
"type",
"=",
"'medium'",
",",
"$",
"format",
"=",
"''",
",",
"$",
"timezone",
"=",
"null",
",",
"$",
"langcode",
"=",
"null",
")",
"{",
"return",
"format_date",
"(",
"$",
"timestamp",
",",
"$",
"type",
",",
"$",
"format",
",",
"$",
"timezone",
",",
"$",
"langcode",
")",
";",
"}"
]
| Formats a date, using a date type or a custom date format string.
@param $timestamp
A UNIX timestamp to format.
@param $type
(optional) The format to use, one of:
- 'short', 'medium', or 'long' (the corresponding built-in date formats).
- The name of a date type defined by a module in hook_date_format_types(),
if it's been assigned a format.
- The machine name of an administrator-defined date format.
- 'custom', to use $format.
Defaults to 'medium'.
@param $format
(optional) If $type is 'custom', a PHP date format string suitable for
input to date(). Use a backslash to escape ordinary text, so it does not
get interpreted as date format characters.
@param $timezone
(optional) Time zone identifier, as described at
http://php.net/manual/en/timezones.php Defaults to the time zone used to
display the page.
@param $langcode
(optional) Language code to translate to. Defaults to the language used to
display the page.
@return mixed
A translated date string in the requested format. | [
"Formats",
"a",
"date",
"using",
"a",
"date",
"type",
"or",
"a",
"custom",
"date",
"format",
"string",
"."
]
| 6ba161ef0d3a27c108e533f1adbea22ed73b78ce | https://github.com/liip/LiipDrupalConnectorModule/blob/6ba161ef0d3a27c108e533f1adbea22ed73b78ce/src/Liip/Drupal/Modules/DrupalConnector/Common.php#L747-L750 |
14,160 | liip/LiipDrupalConnectorModule | src/Liip/Drupal/Modules/DrupalConnector/Common.php | Common.watchdog | public function watchdog($type, $message, $variables = array(), $severity = WATCHDOG_NOTICE, $link = null)
{
return watchdog($type, $message, $variables, $severity, $link);
} | php | public function watchdog($type, $message, $variables = array(), $severity = WATCHDOG_NOTICE, $link = null)
{
return watchdog($type, $message, $variables, $severity, $link);
} | [
"public",
"function",
"watchdog",
"(",
"$",
"type",
",",
"$",
"message",
",",
"$",
"variables",
"=",
"array",
"(",
")",
",",
"$",
"severity",
"=",
"WATCHDOG_NOTICE",
",",
"$",
"link",
"=",
"null",
")",
"{",
"return",
"watchdog",
"(",
"$",
"type",
",",
"$",
"message",
",",
"$",
"variables",
",",
"$",
"severity",
",",
"$",
"link",
")",
";",
"}"
]
| Logs a system message.
@param string $type The category to which this message belongs. Can be any string, but the
general practice is to use the name of the module calling watchdog().
@param string $message The message to store in the log. Keep $message translatable
by not concatenating dynamic values into it! Variables in the
message should be added by using placeholder strings alongside
the variables argument to declare the value of the placeholders.
See t() for documentation on how $message and $variables interact.
@param array $variables Array of variables to replace in the message on display or
null if message is already translated or not possible to translate.
@param integer $severity The severity of the message; one of the following values as defined in
@link http://www.faqs.org/rfcs/rfc3164.html RFC 3164: @endlink
- WATCHDOG_EMERGENCY: Emergency, system is unusable.
- WATCHDOG_ALERT: Alert, action must be taken immediately.
- WATCHDOG_CRITICAL: Critical conditions.
- WATCHDOG_ERROR: Error conditions.
- WATCHDOG_WARNING: Warning conditions.
- WATCHDOG_NOTICE: (default) Normal but significant conditions.
- WATCHDOG_INFO: Informational messages.
- WATCHDOG_DEBUG: Debug-level messages.
@param string $link A link to associate with the message.
@link http://api.drupal.org/api/drupal/includes!bootstrap.inc/function/watchdog/7 | [
"Logs",
"a",
"system",
"message",
"."
]
| 6ba161ef0d3a27c108e533f1adbea22ed73b78ce | https://github.com/liip/LiipDrupalConnectorModule/blob/6ba161ef0d3a27c108e533f1adbea22ed73b78ce/src/Liip/Drupal/Modules/DrupalConnector/Common.php#L1004-L1007 |
14,161 | nyeholt/silverstripe-simplewiki | thirdparty/htmlpurifier-4.0.0-lite/library/HTMLPurifier/ContentSets.php | HTMLPurifier_ContentSets.convertToLookup | protected function convertToLookup($string) {
$array = explode('|', str_replace(' ', '', $string));
$ret = array();
foreach ($array as $i => $k) {
$ret[$k] = true;
}
return $ret;
} | php | protected function convertToLookup($string) {
$array = explode('|', str_replace(' ', '', $string));
$ret = array();
foreach ($array as $i => $k) {
$ret[$k] = true;
}
return $ret;
} | [
"protected",
"function",
"convertToLookup",
"(",
"$",
"string",
")",
"{",
"$",
"array",
"=",
"explode",
"(",
"'|'",
",",
"str_replace",
"(",
"' '",
",",
"''",
",",
"$",
"string",
")",
")",
";",
"$",
"ret",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"array",
"as",
"$",
"i",
"=>",
"$",
"k",
")",
"{",
"$",
"ret",
"[",
"$",
"k",
"]",
"=",
"true",
";",
"}",
"return",
"$",
"ret",
";",
"}"
]
| Converts a string list of elements separated by pipes into
a lookup array.
@param $string List of elements
@return Lookup array of elements | [
"Converts",
"a",
"string",
"list",
"of",
"elements",
"separated",
"by",
"pipes",
"into",
"a",
"lookup",
"array",
"."
]
| ecffed0d75be1454901e1cb24633472b8f67c967 | https://github.com/nyeholt/silverstripe-simplewiki/blob/ecffed0d75be1454901e1cb24633472b8f67c967/thirdparty/htmlpurifier-4.0.0-lite/library/HTMLPurifier/ContentSets.php#L144-L151 |
14,162 | markwatkinson/luminous | src/Luminous/Scanners/PerlScanner.php | PerlScanner.consumeString | public function consumeString($delimiter, $type)
{
$close = Utils::balanceDelimiter($delimiter);
$balanced = $close !== $delimiter;
$patterns = array('/(?<!\\\\)((?:\\\\\\\\)*)(' . preg_quote($close, '/') . ')/');
if ($balanced) {
$patterns[] = '/(?<!\\\\)((?:\\\\\\\\)*)(' . preg_quote($delimiter, '/') . ')/';
}
$stack = 1; // we're already inside the string
$start = $this->pos();
$closeDelimiterMatch = null;
while ($stack) {
$next = $this->getNext($patterns);
if ($next[0] === -1) {
$this->terminate();
$finish = $this->pos();
break;
} elseif ($balanced && $next[1][2] === $delimiter) {
$stack++;
$finish = $next[0] + strlen($next[1][0]);
} elseif ($next[1][2] === $close) {
$stack--;
if (!$stack) {
$closeDelimiterMatch = $next[1][2];
}
$finish = $next[0] + strlen($next[1][1]);
} else {
assert(0);
}
$this->pos($next[0] + strlen($next[1][0]));
}
$substr = substr($this->string(), $start, $finish - $start);
// special case for qw, the string is not a 'STRING', it is actually
// a whitespace separated list of strings. So we need to split it and
// record them separately
if ($type === 'SPLIT_STRING') {
foreach (preg_split('/(\s+)/', $substr, -1, PREG_SPLIT_DELIM_CAPTURE) as $token) {
if (preg_match('/^\s/', $token)) {
$this->record($token, null);
} else {
$this->record($token, 'STRING');
}
}
} else {
$this->record($substr, $type);
}
if ($closeDelimiterMatch !== null) {
$this->record($closeDelimiterMatch, 'DELIMITER');
}
} | php | public function consumeString($delimiter, $type)
{
$close = Utils::balanceDelimiter($delimiter);
$balanced = $close !== $delimiter;
$patterns = array('/(?<!\\\\)((?:\\\\\\\\)*)(' . preg_quote($close, '/') . ')/');
if ($balanced) {
$patterns[] = '/(?<!\\\\)((?:\\\\\\\\)*)(' . preg_quote($delimiter, '/') . ')/';
}
$stack = 1; // we're already inside the string
$start = $this->pos();
$closeDelimiterMatch = null;
while ($stack) {
$next = $this->getNext($patterns);
if ($next[0] === -1) {
$this->terminate();
$finish = $this->pos();
break;
} elseif ($balanced && $next[1][2] === $delimiter) {
$stack++;
$finish = $next[0] + strlen($next[1][0]);
} elseif ($next[1][2] === $close) {
$stack--;
if (!$stack) {
$closeDelimiterMatch = $next[1][2];
}
$finish = $next[0] + strlen($next[1][1]);
} else {
assert(0);
}
$this->pos($next[0] + strlen($next[1][0]));
}
$substr = substr($this->string(), $start, $finish - $start);
// special case for qw, the string is not a 'STRING', it is actually
// a whitespace separated list of strings. So we need to split it and
// record them separately
if ($type === 'SPLIT_STRING') {
foreach (preg_split('/(\s+)/', $substr, -1, PREG_SPLIT_DELIM_CAPTURE) as $token) {
if (preg_match('/^\s/', $token)) {
$this->record($token, null);
} else {
$this->record($token, 'STRING');
}
}
} else {
$this->record($substr, $type);
}
if ($closeDelimiterMatch !== null) {
$this->record($closeDelimiterMatch, 'DELIMITER');
}
} | [
"public",
"function",
"consumeString",
"(",
"$",
"delimiter",
",",
"$",
"type",
")",
"{",
"$",
"close",
"=",
"Utils",
"::",
"balanceDelimiter",
"(",
"$",
"delimiter",
")",
";",
"$",
"balanced",
"=",
"$",
"close",
"!==",
"$",
"delimiter",
";",
"$",
"patterns",
"=",
"array",
"(",
"'/(?<!\\\\\\\\)((?:\\\\\\\\\\\\\\\\)*)('",
".",
"preg_quote",
"(",
"$",
"close",
",",
"'/'",
")",
".",
"')/'",
")",
";",
"if",
"(",
"$",
"balanced",
")",
"{",
"$",
"patterns",
"[",
"]",
"=",
"'/(?<!\\\\\\\\)((?:\\\\\\\\\\\\\\\\)*)('",
".",
"preg_quote",
"(",
"$",
"delimiter",
",",
"'/'",
")",
".",
"')/'",
";",
"}",
"$",
"stack",
"=",
"1",
";",
"// we're already inside the string",
"$",
"start",
"=",
"$",
"this",
"->",
"pos",
"(",
")",
";",
"$",
"closeDelimiterMatch",
"=",
"null",
";",
"while",
"(",
"$",
"stack",
")",
"{",
"$",
"next",
"=",
"$",
"this",
"->",
"getNext",
"(",
"$",
"patterns",
")",
";",
"if",
"(",
"$",
"next",
"[",
"0",
"]",
"===",
"-",
"1",
")",
"{",
"$",
"this",
"->",
"terminate",
"(",
")",
";",
"$",
"finish",
"=",
"$",
"this",
"->",
"pos",
"(",
")",
";",
"break",
";",
"}",
"elseif",
"(",
"$",
"balanced",
"&&",
"$",
"next",
"[",
"1",
"]",
"[",
"2",
"]",
"===",
"$",
"delimiter",
")",
"{",
"$",
"stack",
"++",
";",
"$",
"finish",
"=",
"$",
"next",
"[",
"0",
"]",
"+",
"strlen",
"(",
"$",
"next",
"[",
"1",
"]",
"[",
"0",
"]",
")",
";",
"}",
"elseif",
"(",
"$",
"next",
"[",
"1",
"]",
"[",
"2",
"]",
"===",
"$",
"close",
")",
"{",
"$",
"stack",
"--",
";",
"if",
"(",
"!",
"$",
"stack",
")",
"{",
"$",
"closeDelimiterMatch",
"=",
"$",
"next",
"[",
"1",
"]",
"[",
"2",
"]",
";",
"}",
"$",
"finish",
"=",
"$",
"next",
"[",
"0",
"]",
"+",
"strlen",
"(",
"$",
"next",
"[",
"1",
"]",
"[",
"1",
"]",
")",
";",
"}",
"else",
"{",
"assert",
"(",
"0",
")",
";",
"}",
"$",
"this",
"->",
"pos",
"(",
"$",
"next",
"[",
"0",
"]",
"+",
"strlen",
"(",
"$",
"next",
"[",
"1",
"]",
"[",
"0",
"]",
")",
")",
";",
"}",
"$",
"substr",
"=",
"substr",
"(",
"$",
"this",
"->",
"string",
"(",
")",
",",
"$",
"start",
",",
"$",
"finish",
"-",
"$",
"start",
")",
";",
"// special case for qw, the string is not a 'STRING', it is actually",
"// a whitespace separated list of strings. So we need to split it and",
"// record them separately",
"if",
"(",
"$",
"type",
"===",
"'SPLIT_STRING'",
")",
"{",
"foreach",
"(",
"preg_split",
"(",
"'/(\\s+)/'",
",",
"$",
"substr",
",",
"-",
"1",
",",
"PREG_SPLIT_DELIM_CAPTURE",
")",
"as",
"$",
"token",
")",
"{",
"if",
"(",
"preg_match",
"(",
"'/^\\s/'",
",",
"$",
"token",
")",
")",
"{",
"$",
"this",
"->",
"record",
"(",
"$",
"token",
",",
"null",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"record",
"(",
"$",
"token",
",",
"'STRING'",
")",
";",
"}",
"}",
"}",
"else",
"{",
"$",
"this",
"->",
"record",
"(",
"$",
"substr",
",",
"$",
"type",
")",
";",
"}",
"if",
"(",
"$",
"closeDelimiterMatch",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"record",
"(",
"$",
"closeDelimiterMatch",
",",
"'DELIMITER'",
")",
";",
"}",
"}"
]
| expects the initial opening delim to already have been consumed | [
"expects",
"the",
"initial",
"opening",
"delim",
"to",
"already",
"have",
"been",
"consumed"
]
| 4adc18f414534abe986133d6d38e8e9787d32e69 | https://github.com/markwatkinson/luminous/blob/4adc18f414534abe986133d6d38e8e9787d32e69/src/Luminous/Scanners/PerlScanner.php#L31-L83 |
14,163 | markwatkinson/luminous | src/Luminous/Scanners/PerlScanner.php | PerlScanner.isDelimiter | public function isDelimiter()
{
for ($i = count($this->tokens) - 1; $i >= 0; $i--) {
$t = $this->tokens[$i];
if ($t[0] === null || $t[0] === 'COMMENT') {
continue;
} elseif ($t[0] === 'OPENER' || $t[0] === 'OPERATOR') {
return true;
} elseif ($t[0] === 'IDENT') {
switch ($t[1]) {
// named operators
case 'lt':
case 'gt':
case 'le':
case 'ge':
case 'eq':
case 'ne':
case 'cmp':
case 'and':
case 'or':
case 'xor':
// other keywords/functions
case 'if':
case 'elsif':
case 'while':
case 'unless':
case 'split':
case 'print':
return true;
}
}
return false;
}
return true;
} | php | public function isDelimiter()
{
for ($i = count($this->tokens) - 1; $i >= 0; $i--) {
$t = $this->tokens[$i];
if ($t[0] === null || $t[0] === 'COMMENT') {
continue;
} elseif ($t[0] === 'OPENER' || $t[0] === 'OPERATOR') {
return true;
} elseif ($t[0] === 'IDENT') {
switch ($t[1]) {
// named operators
case 'lt':
case 'gt':
case 'le':
case 'ge':
case 'eq':
case 'ne':
case 'cmp':
case 'and':
case 'or':
case 'xor':
// other keywords/functions
case 'if':
case 'elsif':
case 'while':
case 'unless':
case 'split':
case 'print':
return true;
}
}
return false;
}
return true;
} | [
"public",
"function",
"isDelimiter",
"(",
")",
"{",
"for",
"(",
"$",
"i",
"=",
"count",
"(",
"$",
"this",
"->",
"tokens",
")",
"-",
"1",
";",
"$",
"i",
">=",
"0",
";",
"$",
"i",
"--",
")",
"{",
"$",
"t",
"=",
"$",
"this",
"->",
"tokens",
"[",
"$",
"i",
"]",
";",
"if",
"(",
"$",
"t",
"[",
"0",
"]",
"===",
"null",
"||",
"$",
"t",
"[",
"0",
"]",
"===",
"'COMMENT'",
")",
"{",
"continue",
";",
"}",
"elseif",
"(",
"$",
"t",
"[",
"0",
"]",
"===",
"'OPENER'",
"||",
"$",
"t",
"[",
"0",
"]",
"===",
"'OPERATOR'",
")",
"{",
"return",
"true",
";",
"}",
"elseif",
"(",
"$",
"t",
"[",
"0",
"]",
"===",
"'IDENT'",
")",
"{",
"switch",
"(",
"$",
"t",
"[",
"1",
"]",
")",
"{",
"// named operators",
"case",
"'lt'",
":",
"case",
"'gt'",
":",
"case",
"'le'",
":",
"case",
"'ge'",
":",
"case",
"'eq'",
":",
"case",
"'ne'",
":",
"case",
"'cmp'",
":",
"case",
"'and'",
":",
"case",
"'or'",
":",
"case",
"'xor'",
":",
"// other keywords/functions",
"case",
"'if'",
":",
"case",
"'elsif'",
":",
"case",
"'while'",
":",
"case",
"'unless'",
":",
"case",
"'split'",
":",
"case",
"'print'",
":",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
]
| by looking behind in the token stream. | [
"by",
"looking",
"behind",
"in",
"the",
"token",
"stream",
"."
]
| 4adc18f414534abe986133d6d38e8e9787d32e69 | https://github.com/markwatkinson/luminous/blob/4adc18f414534abe986133d6d38e8e9787d32e69/src/Luminous/Scanners/PerlScanner.php#L87-L121 |
14,164 | markwatkinson/luminous | src/Luminous/Scanners/PerlScanner.php | PerlScanner.heredocRealOverride | public function heredocRealOverride($matches)
{
$this->record($matches[0], null);
$this->posShift(strlen($matches[0]));
// don't need this anymore
$this->removePattern('HEREDOC_NL');
assert($this->heredoc !== null);
$delim = preg_quote($this->heredoc);
$substr = $this->scanUntil('/^' . $delim . '\\b/m');
if ($substr !== null) {
$this->record($substr, 'HEREDOC');
$delim_ = $this->scan('/' . $delim . '/');
assert($delim !== null);
$this->record($delim_, 'DELIMITER');
} else {
$this->record($this->rest(), 'HEREDOC');
$this->terminate();
}
} | php | public function heredocRealOverride($matches)
{
$this->record($matches[0], null);
$this->posShift(strlen($matches[0]));
// don't need this anymore
$this->removePattern('HEREDOC_NL');
assert($this->heredoc !== null);
$delim = preg_quote($this->heredoc);
$substr = $this->scanUntil('/^' . $delim . '\\b/m');
if ($substr !== null) {
$this->record($substr, 'HEREDOC');
$delim_ = $this->scan('/' . $delim . '/');
assert($delim !== null);
$this->record($delim_, 'DELIMITER');
} else {
$this->record($this->rest(), 'HEREDOC');
$this->terminate();
}
} | [
"public",
"function",
"heredocRealOverride",
"(",
"$",
"matches",
")",
"{",
"$",
"this",
"->",
"record",
"(",
"$",
"matches",
"[",
"0",
"]",
",",
"null",
")",
";",
"$",
"this",
"->",
"posShift",
"(",
"strlen",
"(",
"$",
"matches",
"[",
"0",
"]",
")",
")",
";",
"// don't need this anymore",
"$",
"this",
"->",
"removePattern",
"(",
"'HEREDOC_NL'",
")",
";",
"assert",
"(",
"$",
"this",
"->",
"heredoc",
"!==",
"null",
")",
";",
"$",
"delim",
"=",
"preg_quote",
"(",
"$",
"this",
"->",
"heredoc",
")",
";",
"$",
"substr",
"=",
"$",
"this",
"->",
"scanUntil",
"(",
"'/^'",
".",
"$",
"delim",
".",
"'\\\\b/m'",
")",
";",
"if",
"(",
"$",
"substr",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"record",
"(",
"$",
"substr",
",",
"'HEREDOC'",
")",
";",
"$",
"delim_",
"=",
"$",
"this",
"->",
"scan",
"(",
"'/'",
".",
"$",
"delim",
".",
"'/'",
")",
";",
"assert",
"(",
"$",
"delim",
"!==",
"null",
")",
";",
"$",
"this",
"->",
"record",
"(",
"$",
"delim_",
",",
"'DELIMITER'",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"record",
"(",
"$",
"this",
"->",
"rest",
"(",
")",
",",
"'HEREDOC'",
")",
";",
"$",
"this",
"->",
"terminate",
"(",
")",
";",
"}",
"}"
]
| this override handles the actual heredoc text | [
"this",
"override",
"handles",
"the",
"actual",
"heredoc",
"text"
]
| 4adc18f414534abe986133d6d38e8e9787d32e69 | https://github.com/markwatkinson/luminous/blob/4adc18f414534abe986133d6d38e8e9787d32e69/src/Luminous/Scanners/PerlScanner.php#L215-L233 |
14,165 | markwatkinson/luminous | src/Luminous/Scanners/PerlScanner.php | PerlScanner.podCutOverride | public function podCutOverride($matches)
{
$line = $this->scan('/^=.*/m');
assert($line !== null);
$term = '/^=cut$|\\z/m';
$substr = $this->scanUntil($term);
assert($substr !== null);
$end = $this->scan($term);
assert($end !== null);
$this->record($line . $substr . $end, 'DOCCOMMENT');
} | php | public function podCutOverride($matches)
{
$line = $this->scan('/^=.*/m');
assert($line !== null);
$term = '/^=cut$|\\z/m';
$substr = $this->scanUntil($term);
assert($substr !== null);
$end = $this->scan($term);
assert($end !== null);
$this->record($line . $substr . $end, 'DOCCOMMENT');
} | [
"public",
"function",
"podCutOverride",
"(",
"$",
"matches",
")",
"{",
"$",
"line",
"=",
"$",
"this",
"->",
"scan",
"(",
"'/^=.*/m'",
")",
";",
"assert",
"(",
"$",
"line",
"!==",
"null",
")",
";",
"$",
"term",
"=",
"'/^=cut$|\\\\z/m'",
";",
"$",
"substr",
"=",
"$",
"this",
"->",
"scanUntil",
"(",
"$",
"term",
")",
";",
"assert",
"(",
"$",
"substr",
"!==",
"null",
")",
";",
"$",
"end",
"=",
"$",
"this",
"->",
"scan",
"(",
"$",
"term",
")",
";",
"assert",
"(",
"$",
"end",
"!==",
"null",
")",
";",
"$",
"this",
"->",
"record",
"(",
"$",
"line",
".",
"$",
"substr",
".",
"$",
"end",
",",
"'DOCCOMMENT'",
")",
";",
"}"
]
| we do it the old fashioned way | [
"we",
"do",
"it",
"the",
"old",
"fashioned",
"way"
]
| 4adc18f414534abe986133d6d38e8e9787d32e69 | https://github.com/markwatkinson/luminous/blob/4adc18f414534abe986133d6d38e8e9787d32e69/src/Luminous/Scanners/PerlScanner.php#L246-L256 |
14,166 | christophe-brachet/aspi-framework | src/Framework/Routing/Router.php | Router.generateI18n | protected function generateI18n($name, $locale, $parameters, $referenceType = self::ABSOLUTE_PATH)
{
try {
return $this->generator->generate(
$this->routeNameInflector->inflect($name, $locale),
$parameters,
$referenceType
);
} catch (RouteNotFoundException $e) {
throw new RouteNotFoundException(sprintf('I18nRoute "%s" (%s) does not exist.', $name, $locale));
}
} | php | protected function generateI18n($name, $locale, $parameters, $referenceType = self::ABSOLUTE_PATH)
{
try {
return $this->generator->generate(
$this->routeNameInflector->inflect($name, $locale),
$parameters,
$referenceType
);
} catch (RouteNotFoundException $e) {
throw new RouteNotFoundException(sprintf('I18nRoute "%s" (%s) does not exist.', $name, $locale));
}
} | [
"protected",
"function",
"generateI18n",
"(",
"$",
"name",
",",
"$",
"locale",
",",
"$",
"parameters",
",",
"$",
"referenceType",
"=",
"self",
"::",
"ABSOLUTE_PATH",
")",
"{",
"try",
"{",
"return",
"$",
"this",
"->",
"generator",
"->",
"generate",
"(",
"$",
"this",
"->",
"routeNameInflector",
"->",
"inflect",
"(",
"$",
"name",
",",
"$",
"locale",
")",
",",
"$",
"parameters",
",",
"$",
"referenceType",
")",
";",
"}",
"catch",
"(",
"RouteNotFoundException",
"$",
"e",
")",
"{",
"throw",
"new",
"RouteNotFoundException",
"(",
"sprintf",
"(",
"'I18nRoute \"%s\" (%s) does not exist.'",
",",
"$",
"name",
",",
"$",
"locale",
")",
")",
";",
"}",
"}"
]
| Generates a I18N URL from the given parameter
@param string $name The name of the I18N route
@param string $locale The locale of the I18N route
@param array $parameters An array of parameters
@param bool|int $referenceType The type of reference to be generated (one of the constants)
@return string The generated URL
@throws RouteNotFoundException When the route doesn't exists | [
"Generates",
"a",
"I18N",
"URL",
"from",
"the",
"given",
"parameter"
]
| 17a36c8a8582e0b8d8bff7087590c09a9bd4af1e | https://github.com/christophe-brachet/aspi-framework/blob/17a36c8a8582e0b8d8bff7087590c09a9bd4af1e/src/Framework/Routing/Router.php#L120-L131 |
14,167 | christophe-brachet/aspi-framework | src/Framework/Routing/Router.php | Router.getLocale | protected function getLocale($parameters)
{
if (isset($parameters['locale'])) {
return $parameters['locale'];
}
if ($this->getContext()->hasParameter('_locale')) {
return $this->getContext()->getParameter('_locale');
}
return $this->defaultLocale;
} | php | protected function getLocale($parameters)
{
if (isset($parameters['locale'])) {
return $parameters['locale'];
}
if ($this->getContext()->hasParameter('_locale')) {
return $this->getContext()->getParameter('_locale');
}
return $this->defaultLocale;
} | [
"protected",
"function",
"getLocale",
"(",
"$",
"parameters",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"parameters",
"[",
"'locale'",
"]",
")",
")",
"{",
"return",
"$",
"parameters",
"[",
"'locale'",
"]",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"getContext",
"(",
")",
"->",
"hasParameter",
"(",
"'_locale'",
")",
")",
"{",
"return",
"$",
"this",
"->",
"getContext",
"(",
")",
"->",
"getParameter",
"(",
"'_locale'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"defaultLocale",
";",
"}"
]
| Determine the locale to be used with this request
@param array $parameters the parameters determined by the route
@return string | [
"Determine",
"the",
"locale",
"to",
"be",
"used",
"with",
"this",
"request"
]
| 17a36c8a8582e0b8d8bff7087590c09a9bd4af1e | https://github.com/christophe-brachet/aspi-framework/blob/17a36c8a8582e0b8d8bff7087590c09a9bd4af1e/src/Framework/Routing/Router.php#L139-L148 |
14,168 | gorkalaucirica/HipchatAPIv2Client | Model/Room.php | Room.parseJson | public function parseJson($json)
{
$this->id = $json['id'];
$this->name = $json['name'];
$this->links = $json['links'];
if (isset($json['xmpp_jid'])) {
$this->xmppJid = $json['xmpp_jid'];
//Statistics need to be implemented
$this->created = new \DateTime($json['created']);
$this->archived = $json['is_archived'];
$this->privacy = $json['privacy'];
$this->guestAccessible = $json['is_guest_accessible'];
$this->topic = $json['topic'];
$this->participants = array();
foreach ($json['participants'] as $participant) {
$this->participants[] = new User($participant);
}
$this->owner = new User($json['owner']);
$this->guestAccessUrl = $json['guest_access_url'];
}
} | php | public function parseJson($json)
{
$this->id = $json['id'];
$this->name = $json['name'];
$this->links = $json['links'];
if (isset($json['xmpp_jid'])) {
$this->xmppJid = $json['xmpp_jid'];
//Statistics need to be implemented
$this->created = new \DateTime($json['created']);
$this->archived = $json['is_archived'];
$this->privacy = $json['privacy'];
$this->guestAccessible = $json['is_guest_accessible'];
$this->topic = $json['topic'];
$this->participants = array();
foreach ($json['participants'] as $participant) {
$this->participants[] = new User($participant);
}
$this->owner = new User($json['owner']);
$this->guestAccessUrl = $json['guest_access_url'];
}
} | [
"public",
"function",
"parseJson",
"(",
"$",
"json",
")",
"{",
"$",
"this",
"->",
"id",
"=",
"$",
"json",
"[",
"'id'",
"]",
";",
"$",
"this",
"->",
"name",
"=",
"$",
"json",
"[",
"'name'",
"]",
";",
"$",
"this",
"->",
"links",
"=",
"$",
"json",
"[",
"'links'",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"json",
"[",
"'xmpp_jid'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"xmppJid",
"=",
"$",
"json",
"[",
"'xmpp_jid'",
"]",
";",
"//Statistics need to be implemented",
"$",
"this",
"->",
"created",
"=",
"new",
"\\",
"DateTime",
"(",
"$",
"json",
"[",
"'created'",
"]",
")",
";",
"$",
"this",
"->",
"archived",
"=",
"$",
"json",
"[",
"'is_archived'",
"]",
";",
"$",
"this",
"->",
"privacy",
"=",
"$",
"json",
"[",
"'privacy'",
"]",
";",
"$",
"this",
"->",
"guestAccessible",
"=",
"$",
"json",
"[",
"'is_guest_accessible'",
"]",
";",
"$",
"this",
"->",
"topic",
"=",
"$",
"json",
"[",
"'topic'",
"]",
";",
"$",
"this",
"->",
"participants",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"json",
"[",
"'participants'",
"]",
"as",
"$",
"participant",
")",
"{",
"$",
"this",
"->",
"participants",
"[",
"]",
"=",
"new",
"User",
"(",
"$",
"participant",
")",
";",
"}",
"$",
"this",
"->",
"owner",
"=",
"new",
"User",
"(",
"$",
"json",
"[",
"'owner'",
"]",
")",
";",
"$",
"this",
"->",
"guestAccessUrl",
"=",
"$",
"json",
"[",
"'guest_access_url'",
"]",
";",
"}",
"}"
]
| Parses response given by the API and maps the fields to Room object
@param array $json json_decoded response in json given by the server
@return void | [
"Parses",
"response",
"given",
"by",
"the",
"API",
"and",
"maps",
"the",
"fields",
"to",
"Room",
"object"
]
| eef9c91d5efe5ae9cad27c503601ffff089c9547 | https://github.com/gorkalaucirica/HipchatAPIv2Client/blob/eef9c91d5efe5ae9cad27c503601ffff089c9547/Model/Room.php#L57-L78 |
14,169 | gorkalaucirica/HipchatAPIv2Client | Model/Room.php | Room.toJson | public function toJson()
{
$json = array();
$json['name'] = $this->getName();
$json['privacy'] = $this->getPrivacy();
//Parameters for PUT call (Room already exists)
if ($this->getId()) {
$json['is_archived'] = $this->isArchived();
$json['is_guest_accessible'] = $this->isGuestAccessible();
$json['topic'] = $this->getTopic();
$json['owner'] = array('id' => $this->getOwner()->getId());
} else { //Paramters for POST call
$json['guest_access'] = $this->isGuestAccessible();
if ($this->getOwner()) {
$json['owner_user_id'] = $this->getOwner()->getId();
}
}
return $json;
} | php | public function toJson()
{
$json = array();
$json['name'] = $this->getName();
$json['privacy'] = $this->getPrivacy();
//Parameters for PUT call (Room already exists)
if ($this->getId()) {
$json['is_archived'] = $this->isArchived();
$json['is_guest_accessible'] = $this->isGuestAccessible();
$json['topic'] = $this->getTopic();
$json['owner'] = array('id' => $this->getOwner()->getId());
} else { //Paramters for POST call
$json['guest_access'] = $this->isGuestAccessible();
if ($this->getOwner()) {
$json['owner_user_id'] = $this->getOwner()->getId();
}
}
return $json;
} | [
"public",
"function",
"toJson",
"(",
")",
"{",
"$",
"json",
"=",
"array",
"(",
")",
";",
"$",
"json",
"[",
"'name'",
"]",
"=",
"$",
"this",
"->",
"getName",
"(",
")",
";",
"$",
"json",
"[",
"'privacy'",
"]",
"=",
"$",
"this",
"->",
"getPrivacy",
"(",
")",
";",
"//Parameters for PUT call (Room already exists)",
"if",
"(",
"$",
"this",
"->",
"getId",
"(",
")",
")",
"{",
"$",
"json",
"[",
"'is_archived'",
"]",
"=",
"$",
"this",
"->",
"isArchived",
"(",
")",
";",
"$",
"json",
"[",
"'is_guest_accessible'",
"]",
"=",
"$",
"this",
"->",
"isGuestAccessible",
"(",
")",
";",
"$",
"json",
"[",
"'topic'",
"]",
"=",
"$",
"this",
"->",
"getTopic",
"(",
")",
";",
"$",
"json",
"[",
"'owner'",
"]",
"=",
"array",
"(",
"'id'",
"=>",
"$",
"this",
"->",
"getOwner",
"(",
")",
"->",
"getId",
"(",
")",
")",
";",
"}",
"else",
"{",
"//Paramters for POST call",
"$",
"json",
"[",
"'guest_access'",
"]",
"=",
"$",
"this",
"->",
"isGuestAccessible",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"getOwner",
"(",
")",
")",
"{",
"$",
"json",
"[",
"'owner_user_id'",
"]",
"=",
"$",
"this",
"->",
"getOwner",
"(",
")",
"->",
"getId",
"(",
")",
";",
"}",
"}",
"return",
"$",
"json",
";",
"}"
]
| Serializes Room object
@return array | [
"Serializes",
"Room",
"object"
]
| eef9c91d5efe5ae9cad27c503601ffff089c9547 | https://github.com/gorkalaucirica/HipchatAPIv2Client/blob/eef9c91d5efe5ae9cad27c503601ffff089c9547/Model/Room.php#L85-L104 |
14,170 | ssnepenthe/soter | src/class-check-site-job.php | Check_Site_Job.run | public function run() {
try {
$vulnerabilities = $this->checker->check_site( $this->options->ignored_packages );
do_action( 'soter_site_check_complete', $vulnerabilities );
$this->options->get_store()->set( 'last_scan_hash', $vulnerabilities->hash() );
} catch ( \RuntimeException $e ) {
// Gross?
$options = _soter_instance( 'options_manager' );
$use_html = 'html' === $options->email_type;
wp_mail(
// @todo Should this go straight to admin email instead?
$options->email_address,
'HTTP error while checking ' . get_bloginfo( 'name' ) . ' for vulnerabilities',
$use_html
? $this->render_html_error_email( $e )
: $this->render_text_error_email( $e ),
$use_html ? [ 'Content-type: text/html' ] : []
);
}
} | php | public function run() {
try {
$vulnerabilities = $this->checker->check_site( $this->options->ignored_packages );
do_action( 'soter_site_check_complete', $vulnerabilities );
$this->options->get_store()->set( 'last_scan_hash', $vulnerabilities->hash() );
} catch ( \RuntimeException $e ) {
// Gross?
$options = _soter_instance( 'options_manager' );
$use_html = 'html' === $options->email_type;
wp_mail(
// @todo Should this go straight to admin email instead?
$options->email_address,
'HTTP error while checking ' . get_bloginfo( 'name' ) . ' for vulnerabilities',
$use_html
? $this->render_html_error_email( $e )
: $this->render_text_error_email( $e ),
$use_html ? [ 'Content-type: text/html' ] : []
);
}
} | [
"public",
"function",
"run",
"(",
")",
"{",
"try",
"{",
"$",
"vulnerabilities",
"=",
"$",
"this",
"->",
"checker",
"->",
"check_site",
"(",
"$",
"this",
"->",
"options",
"->",
"ignored_packages",
")",
";",
"do_action",
"(",
"'soter_site_check_complete'",
",",
"$",
"vulnerabilities",
")",
";",
"$",
"this",
"->",
"options",
"->",
"get_store",
"(",
")",
"->",
"set",
"(",
"'last_scan_hash'",
",",
"$",
"vulnerabilities",
"->",
"hash",
"(",
")",
")",
";",
"}",
"catch",
"(",
"\\",
"RuntimeException",
"$",
"e",
")",
"{",
"// Gross?",
"$",
"options",
"=",
"_soter_instance",
"(",
"'options_manager'",
")",
";",
"$",
"use_html",
"=",
"'html'",
"===",
"$",
"options",
"->",
"email_type",
";",
"wp_mail",
"(",
"// @todo Should this go straight to admin email instead?",
"$",
"options",
"->",
"email_address",
",",
"'HTTP error while checking '",
".",
"get_bloginfo",
"(",
"'name'",
")",
".",
"' for vulnerabilities'",
",",
"$",
"use_html",
"?",
"$",
"this",
"->",
"render_html_error_email",
"(",
"$",
"e",
")",
":",
"$",
"this",
"->",
"render_text_error_email",
"(",
"$",
"e",
")",
",",
"$",
"use_html",
"?",
"[",
"'Content-type: text/html'",
"]",
":",
"[",
"]",
")",
";",
"}",
"}"
]
| Run the site check.
@return void | [
"Run",
"the",
"site",
"check",
"."
]
| f6d7032f8562e23c2ee8dbf9d60ef1114c8cdce7 | https://github.com/ssnepenthe/soter/blob/f6d7032f8562e23c2ee8dbf9d60ef1114c8cdce7/src/class-check-site-job.php#L51-L73 |
14,171 | ssnepenthe/soter | src/class-check-site-job.php | Check_Site_Job.render_html_error_email | public function render_html_error_email( $exception, CssToInlineStyles $inliner = null ) {
$plates = _soter_instance( 'plates' );
$html = $plates->render( 'emails/html/error.php', [
'message' => $exception->getMessage(),
] );
$css = $plates->render( 'emails/style.css' );
$inliner = $inliner ?: new CssToInlineStyles();
return $inliner->convert( $html, $css );
} | php | public function render_html_error_email( $exception, CssToInlineStyles $inliner = null ) {
$plates = _soter_instance( 'plates' );
$html = $plates->render( 'emails/html/error.php', [
'message' => $exception->getMessage(),
] );
$css = $plates->render( 'emails/style.css' );
$inliner = $inliner ?: new CssToInlineStyles();
return $inliner->convert( $html, $css );
} | [
"public",
"function",
"render_html_error_email",
"(",
"$",
"exception",
",",
"CssToInlineStyles",
"$",
"inliner",
"=",
"null",
")",
"{",
"$",
"plates",
"=",
"_soter_instance",
"(",
"'plates'",
")",
";",
"$",
"html",
"=",
"$",
"plates",
"->",
"render",
"(",
"'emails/html/error.php'",
",",
"[",
"'message'",
"=>",
"$",
"exception",
"->",
"getMessage",
"(",
")",
",",
"]",
")",
";",
"$",
"css",
"=",
"$",
"plates",
"->",
"render",
"(",
"'emails/style.css'",
")",
";",
"$",
"inliner",
"=",
"$",
"inliner",
"?",
":",
"new",
"CssToInlineStyles",
"(",
")",
";",
"return",
"$",
"inliner",
"->",
"convert",
"(",
"$",
"html",
",",
"$",
"css",
")",
";",
"}"
]
| Render the contents of the HTML error notification.
@param \RuntimeException $exception Exception instance.
@param CssToInlineStyles|null $inliner Style inliner.
@return string | [
"Render",
"the",
"contents",
"of",
"the",
"HTML",
"error",
"notification",
"."
]
| f6d7032f8562e23c2ee8dbf9d60ef1114c8cdce7 | https://github.com/ssnepenthe/soter/blob/f6d7032f8562e23c2ee8dbf9d60ef1114c8cdce7/src/class-check-site-job.php#L83-L92 |
14,172 | sifophp/sifo-common-instance | controllers/manager/rebuild.php | ManagerRebuildController.rebuildFiles | protected function rebuildFiles( Array $files )
{
// Generate the dependencies declaration file.
DependencyInjector::getInstance()->generateDependenciesDeclaration();
$this->setLayout( 'manager/templates.tpl' );
$output = array( );
$instance_inheritance = array_unique( \Sifo\Domains::getInstance()->getInstanceInheritance() );
$instance_inheritance_reverse = array_reverse( $instance_inheritance );
// Build the instance configuration: instance name and his parent instance name is exists.
foreach( $instance_inheritance_reverse as $key => $instance )
{
$instance_config['current'] = $instance;
if ( isset( $instance_inheritance[ $key+1 ] ) )
{
$instance_config['parent'] = $instance_inheritance_reverse[$key+1];
}
$instances_configuration[] = $instance_config;
unset( $instance_config );
}
// For each instance in the inheritance it regenerates his configuration files.
foreach( $instances_configuration as $instance )
{
$current_instance = $instance['current'];
$this->assign( 'instance_parent', null );
if ( isset( $instance['parent'] ) )
{
$this->assign( 'instance_parent', $instance['parent'] );
}
foreach ( $files as $file => $folders )
{
$configs = array( );
foreach ( $folders as $folder )
{
$configs = array_merge( $configs, $this->getAvailableFiles( $folder, $current_instance ) );
}
$this->assign( 'config', $configs );
$this->assign( 'file_name', $this->filenames[$file] );
$configs_content = $this->grabHtml();
$file_destination = ROOT_PATH . "/instances/" . $current_instance . "/config/" . $this->filenames[$file];
if ($current_instance == 'common')
{
$file_destination = ROOT_PATH . "/vendor/sifophp/sifo-common-instance/config/" . $this->filenames[$file];
}
$success = file_put_contents( $file_destination, $configs_content );
if ( !$success )
{
$this->failed_files[] = $file_destination;
}
$output[$current_instance][$file] = $configs_content;
}
}
return $output;
} | php | protected function rebuildFiles( Array $files )
{
// Generate the dependencies declaration file.
DependencyInjector::getInstance()->generateDependenciesDeclaration();
$this->setLayout( 'manager/templates.tpl' );
$output = array( );
$instance_inheritance = array_unique( \Sifo\Domains::getInstance()->getInstanceInheritance() );
$instance_inheritance_reverse = array_reverse( $instance_inheritance );
// Build the instance configuration: instance name and his parent instance name is exists.
foreach( $instance_inheritance_reverse as $key => $instance )
{
$instance_config['current'] = $instance;
if ( isset( $instance_inheritance[ $key+1 ] ) )
{
$instance_config['parent'] = $instance_inheritance_reverse[$key+1];
}
$instances_configuration[] = $instance_config;
unset( $instance_config );
}
// For each instance in the inheritance it regenerates his configuration files.
foreach( $instances_configuration as $instance )
{
$current_instance = $instance['current'];
$this->assign( 'instance_parent', null );
if ( isset( $instance['parent'] ) )
{
$this->assign( 'instance_parent', $instance['parent'] );
}
foreach ( $files as $file => $folders )
{
$configs = array( );
foreach ( $folders as $folder )
{
$configs = array_merge( $configs, $this->getAvailableFiles( $folder, $current_instance ) );
}
$this->assign( 'config', $configs );
$this->assign( 'file_name', $this->filenames[$file] );
$configs_content = $this->grabHtml();
$file_destination = ROOT_PATH . "/instances/" . $current_instance . "/config/" . $this->filenames[$file];
if ($current_instance == 'common')
{
$file_destination = ROOT_PATH . "/vendor/sifophp/sifo-common-instance/config/" . $this->filenames[$file];
}
$success = file_put_contents( $file_destination, $configs_content );
if ( !$success )
{
$this->failed_files[] = $file_destination;
}
$output[$current_instance][$file] = $configs_content;
}
}
return $output;
} | [
"protected",
"function",
"rebuildFiles",
"(",
"Array",
"$",
"files",
")",
"{",
"// Generate the dependencies declaration file.",
"DependencyInjector",
"::",
"getInstance",
"(",
")",
"->",
"generateDependenciesDeclaration",
"(",
")",
";",
"$",
"this",
"->",
"setLayout",
"(",
"'manager/templates.tpl'",
")",
";",
"$",
"output",
"=",
"array",
"(",
")",
";",
"$",
"instance_inheritance",
"=",
"array_unique",
"(",
"\\",
"Sifo",
"\\",
"Domains",
"::",
"getInstance",
"(",
")",
"->",
"getInstanceInheritance",
"(",
")",
")",
";",
"$",
"instance_inheritance_reverse",
"=",
"array_reverse",
"(",
"$",
"instance_inheritance",
")",
";",
"// Build the instance configuration: instance name and his parent instance name is exists.",
"foreach",
"(",
"$",
"instance_inheritance_reverse",
"as",
"$",
"key",
"=>",
"$",
"instance",
")",
"{",
"$",
"instance_config",
"[",
"'current'",
"]",
"=",
"$",
"instance",
";",
"if",
"(",
"isset",
"(",
"$",
"instance_inheritance",
"[",
"$",
"key",
"+",
"1",
"]",
")",
")",
"{",
"$",
"instance_config",
"[",
"'parent'",
"]",
"=",
"$",
"instance_inheritance_reverse",
"[",
"$",
"key",
"+",
"1",
"]",
";",
"}",
"$",
"instances_configuration",
"[",
"]",
"=",
"$",
"instance_config",
";",
"unset",
"(",
"$",
"instance_config",
")",
";",
"}",
"// For each instance in the inheritance it regenerates his configuration files.",
"foreach",
"(",
"$",
"instances_configuration",
"as",
"$",
"instance",
")",
"{",
"$",
"current_instance",
"=",
"$",
"instance",
"[",
"'current'",
"]",
";",
"$",
"this",
"->",
"assign",
"(",
"'instance_parent'",
",",
"null",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"instance",
"[",
"'parent'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"assign",
"(",
"'instance_parent'",
",",
"$",
"instance",
"[",
"'parent'",
"]",
")",
";",
"}",
"foreach",
"(",
"$",
"files",
"as",
"$",
"file",
"=>",
"$",
"folders",
")",
"{",
"$",
"configs",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"folders",
"as",
"$",
"folder",
")",
"{",
"$",
"configs",
"=",
"array_merge",
"(",
"$",
"configs",
",",
"$",
"this",
"->",
"getAvailableFiles",
"(",
"$",
"folder",
",",
"$",
"current_instance",
")",
")",
";",
"}",
"$",
"this",
"->",
"assign",
"(",
"'config'",
",",
"$",
"configs",
")",
";",
"$",
"this",
"->",
"assign",
"(",
"'file_name'",
",",
"$",
"this",
"->",
"filenames",
"[",
"$",
"file",
"]",
")",
";",
"$",
"configs_content",
"=",
"$",
"this",
"->",
"grabHtml",
"(",
")",
";",
"$",
"file_destination",
"=",
"ROOT_PATH",
".",
"\"/instances/\"",
".",
"$",
"current_instance",
".",
"\"/config/\"",
".",
"$",
"this",
"->",
"filenames",
"[",
"$",
"file",
"]",
";",
"if",
"(",
"$",
"current_instance",
"==",
"'common'",
")",
"{",
"$",
"file_destination",
"=",
"ROOT_PATH",
".",
"\"/vendor/sifophp/sifo-common-instance/config/\"",
".",
"$",
"this",
"->",
"filenames",
"[",
"$",
"file",
"]",
";",
"}",
"$",
"success",
"=",
"file_put_contents",
"(",
"$",
"file_destination",
",",
"$",
"configs_content",
")",
";",
"if",
"(",
"!",
"$",
"success",
")",
"{",
"$",
"this",
"->",
"failed_files",
"[",
"]",
"=",
"$",
"file_destination",
";",
"}",
"$",
"output",
"[",
"$",
"current_instance",
"]",
"[",
"$",
"file",
"]",
"=",
"$",
"configs_content",
";",
"}",
"}",
"return",
"$",
"output",
";",
"}"
]
| Writes all the configurattion files to disk.
Input expected is:
array( 'filename' => array( 'folder_to_parse1', 'folder_to_parse2', '...' ) )
@param array $files
@return array Array of contents write to each file. | [
"Writes",
"all",
"the",
"configurattion",
"files",
"to",
"disk",
"."
]
| 52d54ea3e565bd2bccd77e0b0a6a99b5cae3aff5 | https://github.com/sifophp/sifo-common-instance/blob/52d54ea3e565bd2bccd77e0b0a6a99b5cae3aff5/controllers/manager/rebuild.php#L37-L103 |
14,173 | terdia/legato-framework | src/Console/Command.php | Command.setArguments | public function setArguments($name, $required = false, $description = 'Argument description')
{
$required ? $required = InputArgument::REQUIRED : $required = InputArgument::OPTIONAL;
$this->addArgument($name, $required, $description);
} | php | public function setArguments($name, $required = false, $description = 'Argument description')
{
$required ? $required = InputArgument::REQUIRED : $required = InputArgument::OPTIONAL;
$this->addArgument($name, $required, $description);
} | [
"public",
"function",
"setArguments",
"(",
"$",
"name",
",",
"$",
"required",
"=",
"false",
",",
"$",
"description",
"=",
"'Argument description'",
")",
"{",
"$",
"required",
"?",
"$",
"required",
"=",
"InputArgument",
"::",
"REQUIRED",
":",
"$",
"required",
"=",
"InputArgument",
"::",
"OPTIONAL",
";",
"$",
"this",
"->",
"addArgument",
"(",
"$",
"name",
",",
"$",
"required",
",",
"$",
"description",
")",
";",
"}"
]
| Add argument to a command.
@param $name, the argument name
@param bool $required, is it required
@param string $description | [
"Add",
"argument",
"to",
"a",
"command",
"."
]
| 44057c1c3c6f3e9643e9fade51bd417860fafda8 | https://github.com/terdia/legato-framework/blob/44057c1c3c6f3e9643e9fade51bd417860fafda8/src/Console/Command.php#L49-L53 |
14,174 | terdia/legato-framework | src/Console/Command.php | Command.setOption | public function setOption($name, $shortcut = null, $inputRequired = false, $description = 'option does what?')
{
$inputRequired ? $inputRequired = InputOption::VALUE_REQUIRED :
$inputRequired = InputOption::VALUE_OPTIONAL;
$this->addOption($name, $shortcut, $inputRequired, $description);
} | php | public function setOption($name, $shortcut = null, $inputRequired = false, $description = 'option does what?')
{
$inputRequired ? $inputRequired = InputOption::VALUE_REQUIRED :
$inputRequired = InputOption::VALUE_OPTIONAL;
$this->addOption($name, $shortcut, $inputRequired, $description);
} | [
"public",
"function",
"setOption",
"(",
"$",
"name",
",",
"$",
"shortcut",
"=",
"null",
",",
"$",
"inputRequired",
"=",
"false",
",",
"$",
"description",
"=",
"'option does what?'",
")",
"{",
"$",
"inputRequired",
"?",
"$",
"inputRequired",
"=",
"InputOption",
"::",
"VALUE_REQUIRED",
":",
"$",
"inputRequired",
"=",
"InputOption",
"::",
"VALUE_OPTIONAL",
";",
"$",
"this",
"->",
"addOption",
"(",
"$",
"name",
",",
"$",
"shortcut",
",",
"$",
"inputRequired",
",",
"$",
"description",
")",
";",
"}"
]
| Add options to command.
@param $name, the option name
@param null $shortcut
@param bool $inputRequired, whether it is required
@param $description, description | [
"Add",
"options",
"to",
"command",
"."
]
| 44057c1c3c6f3e9643e9fade51bd417860fafda8 | https://github.com/terdia/legato-framework/blob/44057c1c3c6f3e9643e9fade51bd417860fafda8/src/Console/Command.php#L63-L69 |
14,175 | crysalead/net | src/Http/Cookie/Cookies.php | Cookies.offsetSet | public function offsetSet($name, $value)
{
$cookie = $this->_classes['cookie'];
$value = $this->_autobox($name, $value);
if (!$value instanceof $cookie) {
throw new RuntimeException("Error, only `{$cookie}` instances are allowed in this collection.");
}
$hash = $name . ';' . $value->domain() . ';' . $value->path();
$this->_hashes[$name][] = $hash;
$this->_names[$hash] = $name;
return $this->_data[$hash] = $value;
} | php | public function offsetSet($name, $value)
{
$cookie = $this->_classes['cookie'];
$value = $this->_autobox($name, $value);
if (!$value instanceof $cookie) {
throw new RuntimeException("Error, only `{$cookie}` instances are allowed in this collection.");
}
$hash = $name . ';' . $value->domain() . ';' . $value->path();
$this->_hashes[$name][] = $hash;
$this->_names[$hash] = $name;
return $this->_data[$hash] = $value;
} | [
"public",
"function",
"offsetSet",
"(",
"$",
"name",
",",
"$",
"value",
")",
"{",
"$",
"cookie",
"=",
"$",
"this",
"->",
"_classes",
"[",
"'cookie'",
"]",
";",
"$",
"value",
"=",
"$",
"this",
"->",
"_autobox",
"(",
"$",
"name",
",",
"$",
"value",
")",
";",
"if",
"(",
"!",
"$",
"value",
"instanceof",
"$",
"cookie",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Error, only `{$cookie}` instances are allowed in this collection.\"",
")",
";",
"}",
"$",
"hash",
"=",
"$",
"name",
".",
"';'",
".",
"$",
"value",
"->",
"domain",
"(",
")",
".",
"';'",
".",
"$",
"value",
"->",
"path",
"(",
")",
";",
"$",
"this",
"->",
"_hashes",
"[",
"$",
"name",
"]",
"[",
"]",
"=",
"$",
"hash",
";",
"$",
"this",
"->",
"_names",
"[",
"$",
"hash",
"]",
"=",
"$",
"name",
";",
"return",
"$",
"this",
"->",
"_data",
"[",
"$",
"hash",
"]",
"=",
"$",
"value",
";",
"}"
]
| Adds a cookie to the collection.
@param string $name The cookie name.
@param object $value The cookie.
@return object The setted cookie. | [
"Adds",
"a",
"cookie",
"to",
"the",
"collection",
"."
]
| 4d75abead39e954529b56cbffa3841a9cd3044bb | https://github.com/crysalead/net/blob/4d75abead39e954529b56cbffa3841a9cd3044bb/src/Http/Cookie/Cookies.php#L69-L81 |
14,176 | crysalead/net | src/Http/Cookie/Cookies.php | Cookies.offsetGet | public function offsetGet($name)
{
$data = [];
if (!isset($this->_hashes[$name])) {
throw new RuntimeException("Unexisting Set-Cookie `'{$name}'`.");
}
foreach ($this->_hashes[$name] as $key => $hash) {
$data[] = $this->_data[$hash];
}
return $data;
} | php | public function offsetGet($name)
{
$data = [];
if (!isset($this->_hashes[$name])) {
throw new RuntimeException("Unexisting Set-Cookie `'{$name}'`.");
}
foreach ($this->_hashes[$name] as $key => $hash) {
$data[] = $this->_data[$hash];
}
return $data;
} | [
"public",
"function",
"offsetGet",
"(",
"$",
"name",
")",
"{",
"$",
"data",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_hashes",
"[",
"$",
"name",
"]",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Unexisting Set-Cookie `'{$name}'`.\"",
")",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"_hashes",
"[",
"$",
"name",
"]",
"as",
"$",
"key",
"=>",
"$",
"hash",
")",
"{",
"$",
"data",
"[",
"]",
"=",
"$",
"this",
"->",
"_data",
"[",
"$",
"hash",
"]",
";",
"}",
"return",
"$",
"data",
";",
"}"
]
| Gets a set-cookie.
@param string $name The cookie name.
@param object $value The cookie.
@return object The setted cookie. | [
"Gets",
"a",
"set",
"-",
"cookie",
"."
]
| 4d75abead39e954529b56cbffa3841a9cd3044bb | https://github.com/crysalead/net/blob/4d75abead39e954529b56cbffa3841a9cd3044bb/src/Http/Cookie/Cookies.php#L91-L101 |
14,177 | crysalead/net | src/Http/Cookie/Cookies.php | Cookies.offsetUnset | public function offsetUnset($name)
{
if (!isset($this->_hashes[$name])) {
return;
}
foreach ($this->_hashes[$name] as $hash) {
unset($this->_data[$hash]);
unset($this->_names[$hash]);
}
unset($this->_hashes[$name]);
} | php | public function offsetUnset($name)
{
if (!isset($this->_hashes[$name])) {
return;
}
foreach ($this->_hashes[$name] as $hash) {
unset($this->_data[$hash]);
unset($this->_names[$hash]);
}
unset($this->_hashes[$name]);
} | [
"public",
"function",
"offsetUnset",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_hashes",
"[",
"$",
"name",
"]",
")",
")",
"{",
"return",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"_hashes",
"[",
"$",
"name",
"]",
"as",
"$",
"hash",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"_data",
"[",
"$",
"hash",
"]",
")",
";",
"unset",
"(",
"$",
"this",
"->",
"_names",
"[",
"$",
"hash",
"]",
")",
";",
"}",
"unset",
"(",
"$",
"this",
"->",
"_hashes",
"[",
"$",
"name",
"]",
")",
";",
"}"
]
| Removes all set-cookies of a specific name.
@param string $name The cookie name. | [
"Removes",
"all",
"set",
"-",
"cookies",
"of",
"a",
"specific",
"name",
"."
]
| 4d75abead39e954529b56cbffa3841a9cd3044bb | https://github.com/crysalead/net/blob/4d75abead39e954529b56cbffa3841a9cd3044bb/src/Http/Cookie/Cookies.php#L119-L129 |
14,178 | crysalead/net | src/Http/Cookie/Cookies.php | Cookies._autobox | protected function _autobox($name, $value)
{
if (is_object($value)) {
return $value;
}
$cookie = $this->_classes['cookie'];
if (!is_array($value)) {
$value = ['value' => $value];
}
$value['name'] = $name;
return new $cookie($value);
} | php | protected function _autobox($name, $value)
{
if (is_object($value)) {
return $value;
}
$cookie = $this->_classes['cookie'];
if (!is_array($value)) {
$value = ['value' => $value];
}
$value['name'] = $name;
return new $cookie($value);
} | [
"protected",
"function",
"_autobox",
"(",
"$",
"name",
",",
"$",
"value",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"value",
")",
")",
"{",
"return",
"$",
"value",
";",
"}",
"$",
"cookie",
"=",
"$",
"this",
"->",
"_classes",
"[",
"'cookie'",
"]",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"[",
"'value'",
"=>",
"$",
"value",
"]",
";",
"}",
"$",
"value",
"[",
"'name'",
"]",
"=",
"$",
"name",
";",
"return",
"new",
"$",
"cookie",
"(",
"$",
"value",
")",
";",
"}"
]
| Autoboxes a cookie value.
@param mixed $value The cookie value.
@return object The cookie instance. | [
"Autoboxes",
"a",
"cookie",
"value",
"."
]
| 4d75abead39e954529b56cbffa3841a9cd3044bb | https://github.com/crysalead/net/blob/4d75abead39e954529b56cbffa3841a9cd3044bb/src/Http/Cookie/Cookies.php#L158-L169 |
14,179 | crysalead/net | src/Http/Cookie/Cookies.php | Cookies.flushExpired | public function flushExpired()
{
foreach ($this->_hashes as $name => $hashes) {
foreach ($hashes as $key => $hash) {
$cookie = $this->_data[$hash];
if ($cookie->expired()) {
unset($this->_data[$hash]);
unset($this->_names[$hash]);
unset($this->_hashes[$name][$key]);
if (!$this->_hashes[$name]) {
unset($this->_hashes[$name]);
}
}
}
}
return $this;
} | php | public function flushExpired()
{
foreach ($this->_hashes as $name => $hashes) {
foreach ($hashes as $key => $hash) {
$cookie = $this->_data[$hash];
if ($cookie->expired()) {
unset($this->_data[$hash]);
unset($this->_names[$hash]);
unset($this->_hashes[$name][$key]);
if (!$this->_hashes[$name]) {
unset($this->_hashes[$name]);
}
}
}
}
return $this;
} | [
"public",
"function",
"flushExpired",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"_hashes",
"as",
"$",
"name",
"=>",
"$",
"hashes",
")",
"{",
"foreach",
"(",
"$",
"hashes",
"as",
"$",
"key",
"=>",
"$",
"hash",
")",
"{",
"$",
"cookie",
"=",
"$",
"this",
"->",
"_data",
"[",
"$",
"hash",
"]",
";",
"if",
"(",
"$",
"cookie",
"->",
"expired",
"(",
")",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"_data",
"[",
"$",
"hash",
"]",
")",
";",
"unset",
"(",
"$",
"this",
"->",
"_names",
"[",
"$",
"hash",
"]",
")",
";",
"unset",
"(",
"$",
"this",
"->",
"_hashes",
"[",
"$",
"name",
"]",
"[",
"$",
"key",
"]",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"_hashes",
"[",
"$",
"name",
"]",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"_hashes",
"[",
"$",
"name",
"]",
")",
";",
"}",
"}",
"}",
"}",
"return",
"$",
"this",
";",
"}"
]
| Removes expired cookies.
@return object Returns `$this`. | [
"Removes",
"expired",
"cookies",
"."
]
| 4d75abead39e954529b56cbffa3841a9cd3044bb | https://github.com/crysalead/net/blob/4d75abead39e954529b56cbffa3841a9cd3044bb/src/Http/Cookie/Cookies.php#L176-L192 |
14,180 | crysalead/net | src/Http/Cookie/Cookies.php | Cookies.clear | public function clear($domain = null, $path = null, $name = null)
{
if (!$domain) {
$this->_data = [];
return;
} elseif (!$path) {
$this->_data = array_filter(
$this->_data,
function ($cookie) use ($path, $domain) {
return !$cookie->matchesDomain($domain);
}
);
} elseif (!$name) {
$this->_data = array_filter(
$this->_data,
function ($cookie) use ($path, $domain) {
return !($cookie->matchesPath($path) &&
$cookie->matchesDomain($domain));
}
);
} else {
$this->_data = array_filter(
$this->_data,
function ($cookie) use ($path, $domain, $name) {
return !($cookie->name() == $name &&
$cookie->matchesPath($path) &&
$cookie->matchesDomain($domain));
}
);
}
return $this;
} | php | public function clear($domain = null, $path = null, $name = null)
{
if (!$domain) {
$this->_data = [];
return;
} elseif (!$path) {
$this->_data = array_filter(
$this->_data,
function ($cookie) use ($path, $domain) {
return !$cookie->matchesDomain($domain);
}
);
} elseif (!$name) {
$this->_data = array_filter(
$this->_data,
function ($cookie) use ($path, $domain) {
return !($cookie->matchesPath($path) &&
$cookie->matchesDomain($domain));
}
);
} else {
$this->_data = array_filter(
$this->_data,
function ($cookie) use ($path, $domain, $name) {
return !($cookie->name() == $name &&
$cookie->matchesPath($path) &&
$cookie->matchesDomain($domain));
}
);
}
return $this;
} | [
"public",
"function",
"clear",
"(",
"$",
"domain",
"=",
"null",
",",
"$",
"path",
"=",
"null",
",",
"$",
"name",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"domain",
")",
"{",
"$",
"this",
"->",
"_data",
"=",
"[",
"]",
";",
"return",
";",
"}",
"elseif",
"(",
"!",
"$",
"path",
")",
"{",
"$",
"this",
"->",
"_data",
"=",
"array_filter",
"(",
"$",
"this",
"->",
"_data",
",",
"function",
"(",
"$",
"cookie",
")",
"use",
"(",
"$",
"path",
",",
"$",
"domain",
")",
"{",
"return",
"!",
"$",
"cookie",
"->",
"matchesDomain",
"(",
"$",
"domain",
")",
";",
"}",
")",
";",
"}",
"elseif",
"(",
"!",
"$",
"name",
")",
"{",
"$",
"this",
"->",
"_data",
"=",
"array_filter",
"(",
"$",
"this",
"->",
"_data",
",",
"function",
"(",
"$",
"cookie",
")",
"use",
"(",
"$",
"path",
",",
"$",
"domain",
")",
"{",
"return",
"!",
"(",
"$",
"cookie",
"->",
"matchesPath",
"(",
"$",
"path",
")",
"&&",
"$",
"cookie",
"->",
"matchesDomain",
"(",
"$",
"domain",
")",
")",
";",
"}",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"_data",
"=",
"array_filter",
"(",
"$",
"this",
"->",
"_data",
",",
"function",
"(",
"$",
"cookie",
")",
"use",
"(",
"$",
"path",
",",
"$",
"domain",
",",
"$",
"name",
")",
"{",
"return",
"!",
"(",
"$",
"cookie",
"->",
"name",
"(",
")",
"==",
"$",
"name",
"&&",
"$",
"cookie",
"->",
"matchesPath",
"(",
"$",
"path",
")",
"&&",
"$",
"cookie",
"->",
"matchesDomain",
"(",
"$",
"domain",
")",
")",
";",
"}",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| Remove some cookies from the Jar.
@param string $domain A domain name.
@param string $path A path name.
@param string $name A cookie name.
@return self | [
"Remove",
"some",
"cookies",
"from",
"the",
"Jar",
"."
]
| 4d75abead39e954529b56cbffa3841a9cd3044bb | https://github.com/crysalead/net/blob/4d75abead39e954529b56cbffa3841a9cd3044bb/src/Http/Cookie/Cookies.php#L202-L233 |
14,181 | crysalead/net | src/Http/Cookie/Cookies.php | Cookies.clearSessionCookies | public function clearSessionCookies()
{
$this->_data = array_filter(
$this->_data,
function ($cookie) {
return !$cookie->discard() && $cookie->expires();
}
);
return $this;
} | php | public function clearSessionCookies()
{
$this->_data = array_filter(
$this->_data,
function ($cookie) {
return !$cookie->discard() && $cookie->expires();
}
);
return $this;
} | [
"public",
"function",
"clearSessionCookies",
"(",
")",
"{",
"$",
"this",
"->",
"_data",
"=",
"array_filter",
"(",
"$",
"this",
"->",
"_data",
",",
"function",
"(",
"$",
"cookie",
")",
"{",
"return",
"!",
"$",
"cookie",
"->",
"discard",
"(",
")",
"&&",
"$",
"cookie",
"->",
"expires",
"(",
")",
";",
"}",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Clear session based cookies.
@return self | [
"Clear",
"session",
"based",
"cookies",
"."
]
| 4d75abead39e954529b56cbffa3841a9cd3044bb | https://github.com/crysalead/net/blob/4d75abead39e954529b56cbffa3841a9cd3044bb/src/Http/Cookie/Cookies.php#L240-L249 |
14,182 | crysalead/net | src/Http/Cookie/Cookies.php | Cookies.fetchCookies | public function fetchCookies($request, $response)
{
foreach ($response->cookies($request) as $cookie) {
$this->add($cookie);
}
return $this;
} | php | public function fetchCookies($request, $response)
{
foreach ($response->cookies($request) as $cookie) {
$this->add($cookie);
}
return $this;
} | [
"public",
"function",
"fetchCookies",
"(",
"$",
"request",
",",
"$",
"response",
")",
"{",
"foreach",
"(",
"$",
"response",
"->",
"cookies",
"(",
"$",
"request",
")",
"as",
"$",
"cookie",
")",
"{",
"$",
"this",
"->",
"add",
"(",
"$",
"cookie",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| Collect the Set-Cookie header from a response.
@param RequestInterface $request The request.
@param ResponseInterface $response The response.
@return self | [
"Collect",
"the",
"Set",
"-",
"Cookie",
"header",
"from",
"a",
"response",
"."
]
| 4d75abead39e954529b56cbffa3841a9cd3044bb | https://github.com/crysalead/net/blob/4d75abead39e954529b56cbffa3841a9cd3044bb/src/Http/Cookie/Cookies.php#L329-L335 |
14,183 | crysalead/net | src/Http/Cookie/Cookies.php | Cookies.toArray | public static function toArray($cookies, $options = [])
{
$data = [];
foreach ($cookies as $name => $cookie) {
$data[$name][] = $cookie->data();
}
return $data;
} | php | public static function toArray($cookies, $options = [])
{
$data = [];
foreach ($cookies as $name => $cookie) {
$data[$name][] = $cookie->data();
}
return $data;
} | [
"public",
"static",
"function",
"toArray",
"(",
"$",
"cookies",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"data",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"cookies",
"as",
"$",
"name",
"=>",
"$",
"cookie",
")",
"{",
"$",
"data",
"[",
"$",
"name",
"]",
"[",
"]",
"=",
"$",
"cookie",
"->",
"data",
"(",
")",
";",
"}",
"return",
"$",
"data",
";",
"}"
]
| Exports set-cookies.
@param Traversable $setCookies The set-cookies.
@param array $options Options.
@return array The export array. | [
"Exports",
"set",
"-",
"cookies",
"."
]
| 4d75abead39e954529b56cbffa3841a9cd3044bb | https://github.com/crysalead/net/blob/4d75abead39e954529b56cbffa3841a9cd3044bb/src/Http/Cookie/Cookies.php#L381-L388 |
14,184 | FWidm/dwd-hourly-crawler | src/fwidm/dwdHourlyCrawler/util/FractalWrapper.php | FractalWrapper.toResource | public static function toResource($obj, $transformer): ResourceAbstract
{
if (!$obj)
return new NullResource();
$resource = null;
try {
if (is_array($obj)) {
$resource = new Collection($obj, new $transformer(), get_class($obj[0]));
} else {
$resource = new Item($obj, new $transformer(), get_class($obj));
}
} catch (\Error $e) {
throw new DWDLibException("Specified transformer is not a class. Got transformer with the class=" . get_class($transformer));
}
return $resource;
} | php | public static function toResource($obj, $transformer): ResourceAbstract
{
if (!$obj)
return new NullResource();
$resource = null;
try {
if (is_array($obj)) {
$resource = new Collection($obj, new $transformer(), get_class($obj[0]));
} else {
$resource = new Item($obj, new $transformer(), get_class($obj));
}
} catch (\Error $e) {
throw new DWDLibException("Specified transformer is not a class. Got transformer with the class=" . get_class($transformer));
}
return $resource;
} | [
"public",
"static",
"function",
"toResource",
"(",
"$",
"obj",
",",
"$",
"transformer",
")",
":",
"ResourceAbstract",
"{",
"if",
"(",
"!",
"$",
"obj",
")",
"return",
"new",
"NullResource",
"(",
")",
";",
"$",
"resource",
"=",
"null",
";",
"try",
"{",
"if",
"(",
"is_array",
"(",
"$",
"obj",
")",
")",
"{",
"$",
"resource",
"=",
"new",
"Collection",
"(",
"$",
"obj",
",",
"new",
"$",
"transformer",
"(",
")",
",",
"get_class",
"(",
"$",
"obj",
"[",
"0",
"]",
")",
")",
";",
"}",
"else",
"{",
"$",
"resource",
"=",
"new",
"Item",
"(",
"$",
"obj",
",",
"new",
"$",
"transformer",
"(",
")",
",",
"get_class",
"(",
"$",
"obj",
")",
")",
";",
"}",
"}",
"catch",
"(",
"\\",
"Error",
"$",
"e",
")",
"{",
"throw",
"new",
"DWDLibException",
"(",
"\"Specified transformer is not a class. Got transformer with the class=\"",
".",
"get_class",
"(",
"$",
"transformer",
")",
")",
";",
"}",
"return",
"$",
"resource",
";",
"}"
]
| Transform the given object or array with the given transformer to a Resource.
@param $obj
@param $transformer
@return ResourceAbstract
@throws DWDLibException | [
"Transform",
"the",
"given",
"object",
"or",
"array",
"with",
"the",
"given",
"transformer",
"to",
"a",
"Resource",
"."
]
| 36dec7d84a85af599e9d4fb6a3bcc302378ce4a8 | https://github.com/FWidm/dwd-hourly-crawler/blob/36dec7d84a85af599e9d4fb6a3bcc302378ce4a8/src/fwidm/dwdHourlyCrawler/util/FractalWrapper.php#L36-L51 |
14,185 | sifophp/sifo-common-instance | classes/Pagination.php | Pagination.setNextNumPage | protected function setNextNumPage()
{
$this->next_num_page = 0;
if ( $this->current_page_number < $this->num_pages )
{
$this->next_num_page = ( $this->current_page_number + 1 );
}
} | php | protected function setNextNumPage()
{
$this->next_num_page = 0;
if ( $this->current_page_number < $this->num_pages )
{
$this->next_num_page = ( $this->current_page_number + 1 );
}
} | [
"protected",
"function",
"setNextNumPage",
"(",
")",
"{",
"$",
"this",
"->",
"next_num_page",
"=",
"0",
";",
"if",
"(",
"$",
"this",
"->",
"current_page_number",
"<",
"$",
"this",
"->",
"num_pages",
")",
"{",
"$",
"this",
"->",
"next_num_page",
"=",
"(",
"$",
"this",
"->",
"current_page_number",
"+",
"1",
")",
";",
"}",
"}"
]
| Set next page number. | [
"Set",
"next",
"page",
"number",
"."
]
| 52d54ea3e565bd2bccd77e0b0a6a99b5cae3aff5 | https://github.com/sifophp/sifo-common-instance/blob/52d54ea3e565bd2bccd77e0b0a6a99b5cae3aff5/classes/Pagination.php#L356-L363 |
14,186 | sifophp/sifo-common-instance | classes/Pagination.php | Pagination.setItemsPerPage | public function setItemsPerPage( $items_per_page )
{
if ( !is_int( $items_per_page ) )
{
trigger_error( 'Pagination setItemsPerPage: Items per page must be an integer.' );
return false;
}
if ( $items_per_page <= 0 )
{
trigger_error( 'Pagination setItemsPerPage: Items per page must be a positive integer.' );
return false;
}
$this->items_per_page = $items_per_page;
} | php | public function setItemsPerPage( $items_per_page )
{
if ( !is_int( $items_per_page ) )
{
trigger_error( 'Pagination setItemsPerPage: Items per page must be an integer.' );
return false;
}
if ( $items_per_page <= 0 )
{
trigger_error( 'Pagination setItemsPerPage: Items per page must be a positive integer.' );
return false;
}
$this->items_per_page = $items_per_page;
} | [
"public",
"function",
"setItemsPerPage",
"(",
"$",
"items_per_page",
")",
"{",
"if",
"(",
"!",
"is_int",
"(",
"$",
"items_per_page",
")",
")",
"{",
"trigger_error",
"(",
"'Pagination setItemsPerPage: Items per page must be an integer.'",
")",
";",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"items_per_page",
"<=",
"0",
")",
"{",
"trigger_error",
"(",
"'Pagination setItemsPerPage: Items per page must be a positive integer.'",
")",
";",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"items_per_page",
"=",
"$",
"items_per_page",
";",
"}"
]
| Set number of items per page.
@param integer $items_per_page Number of items per page. | [
"Set",
"number",
"of",
"items",
"per",
"page",
"."
]
| 52d54ea3e565bd2bccd77e0b0a6a99b5cae3aff5 | https://github.com/sifophp/sifo-common-instance/blob/52d54ea3e565bd2bccd77e0b0a6a99b5cae3aff5/classes/Pagination.php#L438-L453 |
14,187 | sifophp/sifo-common-instance | classes/Pagination.php | Pagination.setMaxPages | public function setMaxPages( $max_num_pages )
{
if ( !is_int( $max_num_pages ) )
{
trigger_error( 'Pagination setMaxPages: Maxim number of pages must be an integer.' );
return false;
}
if ( $max_num_pages <= 0 )
{
trigger_error( 'Pagination setMaxPages: Maxim number of pages must be a positive integer.' );
return false;
}
$this->max_num_pages = $max_num_pages;
} | php | public function setMaxPages( $max_num_pages )
{
if ( !is_int( $max_num_pages ) )
{
trigger_error( 'Pagination setMaxPages: Maxim number of pages must be an integer.' );
return false;
}
if ( $max_num_pages <= 0 )
{
trigger_error( 'Pagination setMaxPages: Maxim number of pages must be a positive integer.' );
return false;
}
$this->max_num_pages = $max_num_pages;
} | [
"public",
"function",
"setMaxPages",
"(",
"$",
"max_num_pages",
")",
"{",
"if",
"(",
"!",
"is_int",
"(",
"$",
"max_num_pages",
")",
")",
"{",
"trigger_error",
"(",
"'Pagination setMaxPages: Maxim number of pages must be an integer.'",
")",
";",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"max_num_pages",
"<=",
"0",
")",
"{",
"trigger_error",
"(",
"'Pagination setMaxPages: Maxim number of pages must be a positive integer.'",
")",
";",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"max_num_pages",
"=",
"$",
"max_num_pages",
";",
"}"
]
| Set maxim number of pages to show.
@param integer $max_num_pages Maxim number of pages. | [
"Set",
"maxim",
"number",
"of",
"pages",
"to",
"show",
"."
]
| 52d54ea3e565bd2bccd77e0b0a6a99b5cae3aff5 | https://github.com/sifophp/sifo-common-instance/blob/52d54ea3e565bd2bccd77e0b0a6a99b5cae3aff5/classes/Pagination.php#L460-L475 |
14,188 | sifophp/sifo-common-instance | classes/Pagination.php | Pagination.setNumTotalResults | public function setNumTotalResults( $total )
{
$total = (int)$total;
if ( $total < 0 )
{
trigger_error( 'Pagination setNumTotalResults: Total must be positive.' );
return false;
}
$this->items_total = $total;
} | php | public function setNumTotalResults( $total )
{
$total = (int)$total;
if ( $total < 0 )
{
trigger_error( 'Pagination setNumTotalResults: Total must be positive.' );
return false;
}
$this->items_total = $total;
} | [
"public",
"function",
"setNumTotalResults",
"(",
"$",
"total",
")",
"{",
"$",
"total",
"=",
"(",
"int",
")",
"$",
"total",
";",
"if",
"(",
"$",
"total",
"<",
"0",
")",
"{",
"trigger_error",
"(",
"'Pagination setNumTotalResults: Total must be positive.'",
")",
";",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"items_total",
"=",
"$",
"total",
";",
"}"
]
| Set the total number of items.
@param integer $total The total number of items. | [
"Set",
"the",
"total",
"number",
"of",
"items",
"."
]
| 52d54ea3e565bd2bccd77e0b0a6a99b5cae3aff5 | https://github.com/sifophp/sifo-common-instance/blob/52d54ea3e565bd2bccd77e0b0a6a99b5cae3aff5/classes/Pagination.php#L482-L492 |
14,189 | sifophp/sifo-common-instance | classes/Pagination.php | Pagination.setTemplateParam | public function setTemplateParam( $param, $value )
{
if ( !isset( $param ) || empty( $param ) || !isset( $value ) )
{
trigger_error( "The parameter \$param or \$value can't be empty." );
return false;
}
$this->params_template[$param] = $value;
} | php | public function setTemplateParam( $param, $value )
{
if ( !isset( $param ) || empty( $param ) || !isset( $value ) )
{
trigger_error( "The parameter \$param or \$value can't be empty." );
return false;
}
$this->params_template[$param] = $value;
} | [
"public",
"function",
"setTemplateParam",
"(",
"$",
"param",
",",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"param",
")",
"||",
"empty",
"(",
"$",
"param",
")",
"||",
"!",
"isset",
"(",
"$",
"value",
")",
")",
"{",
"trigger_error",
"(",
"\"The parameter \\$param or \\$value can't be empty.\"",
")",
";",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"params_template",
"[",
"$",
"param",
"]",
"=",
"$",
"value",
";",
"}"
]
| Set a parameter assigned to the pagination template.
@param string $param Parameter name assigned to template.
@param mixed $value Value of the parameter. | [
"Set",
"a",
"parameter",
"assigned",
"to",
"the",
"pagination",
"template",
"."
]
| 52d54ea3e565bd2bccd77e0b0a6a99b5cae3aff5 | https://github.com/sifophp/sifo-common-instance/blob/52d54ea3e565bd2bccd77e0b0a6a99b5cae3aff5/classes/Pagination.php#L516-L524 |
14,190 | sifophp/sifo-common-instance | classes/Pagination.php | Pagination.setTemplate | public function setTemplate( $layout_template )
{
$tpl_config = $this->config->getConfig( 'templates' );
if ( !isset( $tpl_config[$layout_template] ) )
{
trigger_error( "Template file '$layout_template' not found." );
return false;
}
$this->layout_template = ROOT_PATH . '/'. $tpl_config[$layout_template];
} | php | public function setTemplate( $layout_template )
{
$tpl_config = $this->config->getConfig( 'templates' );
if ( !isset( $tpl_config[$layout_template] ) )
{
trigger_error( "Template file '$layout_template' not found." );
return false;
}
$this->layout_template = ROOT_PATH . '/'. $tpl_config[$layout_template];
} | [
"public",
"function",
"setTemplate",
"(",
"$",
"layout_template",
")",
"{",
"$",
"tpl_config",
"=",
"$",
"this",
"->",
"config",
"->",
"getConfig",
"(",
"'templates'",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"tpl_config",
"[",
"$",
"layout_template",
"]",
")",
")",
"{",
"trigger_error",
"(",
"\"Template file '$layout_template' not found.\"",
")",
";",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"layout_template",
"=",
"ROOT_PATH",
".",
"'/'",
".",
"$",
"tpl_config",
"[",
"$",
"layout_template",
"]",
";",
"}"
]
| Set the pagination template.
@param string $layout_template Name pagination template (this is the .tpl file).
@return boolean | [
"Set",
"the",
"pagination",
"template",
"."
]
| 52d54ea3e565bd2bccd77e0b0a6a99b5cae3aff5 | https://github.com/sifophp/sifo-common-instance/blob/52d54ea3e565bd2bccd77e0b0a6a99b5cae3aff5/classes/Pagination.php#L548-L559 |
14,191 | sifophp/sifo-common-instance | classes/Pagination.php | Pagination.setDisplayItemsPerPage | public function setDisplayItemsPerPage( $values_to_show )
{
$this->display_items_per_page['display'] = false;
if ( !empty( $values_to_show ) && is_array( $values_to_show ) )
{
$result = array_filter( $values_to_show, "is_integer" );
$this->display_items_per_page['display'] = true;
$this->display_items_per_page['values'] = $result;
}
} | php | public function setDisplayItemsPerPage( $values_to_show )
{
$this->display_items_per_page['display'] = false;
if ( !empty( $values_to_show ) && is_array( $values_to_show ) )
{
$result = array_filter( $values_to_show, "is_integer" );
$this->display_items_per_page['display'] = true;
$this->display_items_per_page['values'] = $result;
}
} | [
"public",
"function",
"setDisplayItemsPerPage",
"(",
"$",
"values_to_show",
")",
"{",
"$",
"this",
"->",
"display_items_per_page",
"[",
"'display'",
"]",
"=",
"false",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"values_to_show",
")",
"&&",
"is_array",
"(",
"$",
"values_to_show",
")",
")",
"{",
"$",
"result",
"=",
"array_filter",
"(",
"$",
"values_to_show",
",",
"\"is_integer\"",
")",
";",
"$",
"this",
"->",
"display_items_per_page",
"[",
"'display'",
"]",
"=",
"true",
";",
"$",
"this",
"->",
"display_items_per_page",
"[",
"'values'",
"]",
"=",
"$",
"result",
";",
"}",
"}"
]
| Set display items per page.
@param array $values_to_show Values to show. | [
"Set",
"display",
"items",
"per",
"page",
"."
]
| 52d54ea3e565bd2bccd77e0b0a6a99b5cae3aff5 | https://github.com/sifophp/sifo-common-instance/blob/52d54ea3e565bd2bccd77e0b0a6a99b5cae3aff5/classes/Pagination.php#L566-L575 |
14,192 | guillaumemonet/Rad | src/Rad/Encryption/MCryptEncryption.php | MCryptEncryption.sign | public function sign(string $data, string $secret): string {
return base64_encode(hash_hmac('md5', $data, $secret, true));
} | php | public function sign(string $data, string $secret): string {
return base64_encode(hash_hmac('md5', $data, $secret, true));
} | [
"public",
"function",
"sign",
"(",
"string",
"$",
"data",
",",
"string",
"$",
"secret",
")",
":",
"string",
"{",
"return",
"base64_encode",
"(",
"hash_hmac",
"(",
"'md5'",
",",
"$",
"data",
",",
"$",
"secret",
",",
"true",
")",
")",
";",
"}"
]
| Sign current datas
@param string $data
@param string $secret
@return string | [
"Sign",
"current",
"datas"
]
| cb9932f570cf3c2a7197f81e1d959c2729989e59 | https://github.com/guillaumemonet/Rad/blob/cb9932f570cf3c2a7197f81e1d959c2729989e59/src/Rad/Encryption/MCryptEncryption.php#L71-L73 |
14,193 | vardius/crud-bundle | Command/AbstractCommand.php | AbstractCommand.getFinalSchemas | protected function getFinalSchemas(KernelInterface $kernel, BundleInterface $bundle = null)
{
if (null !== $bundle) {
return $this->getSchemasFromBundle($bundle);
}
$finalSchemas = array();
foreach ($kernel->getBundles() as $bundle) {
$finalSchemas = array_merge($finalSchemas, $this->getSchemasFromBundle($bundle));
}
return $finalSchemas;
} | php | protected function getFinalSchemas(KernelInterface $kernel, BundleInterface $bundle = null)
{
if (null !== $bundle) {
return $this->getSchemasFromBundle($bundle);
}
$finalSchemas = array();
foreach ($kernel->getBundles() as $bundle) {
$finalSchemas = array_merge($finalSchemas, $this->getSchemasFromBundle($bundle));
}
return $finalSchemas;
} | [
"protected",
"function",
"getFinalSchemas",
"(",
"KernelInterface",
"$",
"kernel",
",",
"BundleInterface",
"$",
"bundle",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"bundle",
")",
"{",
"return",
"$",
"this",
"->",
"getSchemasFromBundle",
"(",
"$",
"bundle",
")",
";",
"}",
"$",
"finalSchemas",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"kernel",
"->",
"getBundles",
"(",
")",
"as",
"$",
"bundle",
")",
"{",
"$",
"finalSchemas",
"=",
"array_merge",
"(",
"$",
"finalSchemas",
",",
"$",
"this",
"->",
"getSchemasFromBundle",
"(",
"$",
"bundle",
")",
")",
";",
"}",
"return",
"$",
"finalSchemas",
";",
"}"
]
| Return a list of final schema files that will be processed.
@param \Symfony\Component\HttpKernel\KernelInterface $kernel
@return array | [
"Return",
"a",
"list",
"of",
"final",
"schema",
"files",
"that",
"will",
"be",
"processed",
"."
]
| dda957e3f8516c3b0d6270ea5a6eb50d98e71444 | https://github.com/vardius/crud-bundle/blob/dda957e3f8516c3b0d6270ea5a6eb50d98e71444/Command/AbstractCommand.php#L100-L112 |
14,194 | AymDev/Phunder | src/User/UserManager.php | UserManager.logIn | public function logIn(array $user_infos) : void
{
$_SESSION['phunder']['user']['logged_in'] = true;
$this->infos = array_merge($this->infos, $user_infos);
$this->save();
} | php | public function logIn(array $user_infos) : void
{
$_SESSION['phunder']['user']['logged_in'] = true;
$this->infos = array_merge($this->infos, $user_infos);
$this->save();
} | [
"public",
"function",
"logIn",
"(",
"array",
"$",
"user_infos",
")",
":",
"void",
"{",
"$",
"_SESSION",
"[",
"'phunder'",
"]",
"[",
"'user'",
"]",
"[",
"'logged_in'",
"]",
"=",
"true",
";",
"$",
"this",
"->",
"infos",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"infos",
",",
"$",
"user_infos",
")",
";",
"$",
"this",
"->",
"save",
"(",
")",
";",
"}"
]
| Declare the current user as logged in
@param array $user_infos infos to save | [
"Declare",
"the",
"current",
"user",
"as",
"logged",
"in"
]
| 32dbe6c81100f1ac3fc2a0080e323d8ab31cab10 | https://github.com/AymDev/Phunder/blob/32dbe6c81100f1ac3fc2a0080e323d8ab31cab10/src/User/UserManager.php#L38-L43 |
14,195 | dphn/ScContent | src/ScContent/Service/Dir.php | Dir.setModule | public function setModule($namespace)
{
$nsParts = explode('\\', $namespace);
$moduleClass = $nsParts[0] . '\Module';
if (! class_exists($moduleClass, true)) {
throw new InvalidArgumentException(sprintf(
"The Module class was not found in the '%s' namespace.",
$namespace
));
}
$module = new $moduleClass();
/* Recommended.
* If you Module class extends 'ZfcBase\Module\AbstractModule'.
*/
if ($module instanceof AbstractModule) {
$this->moduleDir = realpath($module->getDir());
return $this;
}
/* Otherwise - get a path using of Reflection.
*/
$reflection = new ReflectionClass($module);
$this->moduleDir = realpath(dirname($reflection->getFileName()));
return $this;
} | php | public function setModule($namespace)
{
$nsParts = explode('\\', $namespace);
$moduleClass = $nsParts[0] . '\Module';
if (! class_exists($moduleClass, true)) {
throw new InvalidArgumentException(sprintf(
"The Module class was not found in the '%s' namespace.",
$namespace
));
}
$module = new $moduleClass();
/* Recommended.
* If you Module class extends 'ZfcBase\Module\AbstractModule'.
*/
if ($module instanceof AbstractModule) {
$this->moduleDir = realpath($module->getDir());
return $this;
}
/* Otherwise - get a path using of Reflection.
*/
$reflection = new ReflectionClass($module);
$this->moduleDir = realpath(dirname($reflection->getFileName()));
return $this;
} | [
"public",
"function",
"setModule",
"(",
"$",
"namespace",
")",
"{",
"$",
"nsParts",
"=",
"explode",
"(",
"'\\\\'",
",",
"$",
"namespace",
")",
";",
"$",
"moduleClass",
"=",
"$",
"nsParts",
"[",
"0",
"]",
".",
"'\\Module'",
";",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"moduleClass",
",",
"true",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"\"The Module class was not found in the '%s' namespace.\"",
",",
"$",
"namespace",
")",
")",
";",
"}",
"$",
"module",
"=",
"new",
"$",
"moduleClass",
"(",
")",
";",
"/* Recommended.\n * If you Module class extends 'ZfcBase\\Module\\AbstractModule'.\n */",
"if",
"(",
"$",
"module",
"instanceof",
"AbstractModule",
")",
"{",
"$",
"this",
"->",
"moduleDir",
"=",
"realpath",
"(",
"$",
"module",
"->",
"getDir",
"(",
")",
")",
";",
"return",
"$",
"this",
";",
"}",
"/* Otherwise - get a path using of Reflection.\n */",
"$",
"reflection",
"=",
"new",
"ReflectionClass",
"(",
"$",
"module",
")",
";",
"$",
"this",
"->",
"moduleDir",
"=",
"realpath",
"(",
"dirname",
"(",
"$",
"reflection",
"->",
"getFileName",
"(",
")",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Allows you to change the module.
The root directory of the module is calculated as the directory,
that contains the file of the Module class.
Usage:
<code>
$scDir = $serviceLocator->get('ScService.Dir');
$dir = clone($scDir);
$dir->setModule('MyModuleNamespace');
$myModuleConfigFile = $dir->module('/config/module.config.php');
$myModuleDataDir = $dir->module('/data');
</code>
@api
@param string $namespace
@throws \ScContent\Exception\InvalidArgumentException
@return \ScContent\Service\Dir | [
"Allows",
"you",
"to",
"change",
"the",
"module",
".",
"The",
"root",
"directory",
"of",
"the",
"module",
"is",
"calculated",
"as",
"the",
"directory",
"that",
"contains",
"the",
"file",
"of",
"the",
"Module",
"class",
"."
]
| 9dd5732490c45fd788b96cedf7b3c7adfacb30d2 | https://github.com/dphn/ScContent/blob/9dd5732490c45fd788b96cedf7b3c7adfacb30d2/src/ScContent/Service/Dir.php#L66-L94 |
14,196 | dphn/ScContent | src/ScContent/Service/Dir.php | Dir.module | public function module($path = '', $checkIfExists = false)
{
$moduleDir = $this->moduleDir;
if ($checkIfExists) {
return realpath($moduleDir . DS . $path);
}
if (empty($path)) {
return $moduleDir;
}
return $moduleDir . DS . $this->normalizePath($path);
} | php | public function module($path = '', $checkIfExists = false)
{
$moduleDir = $this->moduleDir;
if ($checkIfExists) {
return realpath($moduleDir . DS . $path);
}
if (empty($path)) {
return $moduleDir;
}
return $moduleDir . DS . $this->normalizePath($path);
} | [
"public",
"function",
"module",
"(",
"$",
"path",
"=",
"''",
",",
"$",
"checkIfExists",
"=",
"false",
")",
"{",
"$",
"moduleDir",
"=",
"$",
"this",
"->",
"moduleDir",
";",
"if",
"(",
"$",
"checkIfExists",
")",
"{",
"return",
"realpath",
"(",
"$",
"moduleDir",
".",
"DS",
".",
"$",
"path",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"path",
")",
")",
"{",
"return",
"$",
"moduleDir",
";",
"}",
"return",
"$",
"moduleDir",
".",
"DS",
".",
"$",
"this",
"->",
"normalizePath",
"(",
"$",
"path",
")",
";",
"}"
]
| Returns the path to the root directory of the module or any
child path.
The root directory of the module is calculated as the
directory, that contains the file of the Module class.
If the flag "checkIfExists" is set to TRUE, checks for the specified path
and if the path was not found, returns FALSE.
Usage:
<code>
$scDir = $serviceLocator->get('ScService.Dir');
$dir = clone($scDir);
$dir->setModule('MyModuleNamespace');
$myModuleConfigFile = $dir->module('/config/module.config.php');
$myModuleDataDir = $dir->module('/data');
</code>
@api
@param string $path optional
@param boolean $checkIfExists optional default false
@return string|false | [
"Returns",
"the",
"path",
"to",
"the",
"root",
"directory",
"of",
"the",
"module",
"or",
"any",
"child",
"path",
"."
]
| 9dd5732490c45fd788b96cedf7b3c7adfacb30d2 | https://github.com/dphn/ScContent/blob/9dd5732490c45fd788b96cedf7b3c7adfacb30d2/src/ScContent/Service/Dir.php#L120-L130 |
14,197 | dphn/ScContent | src/ScContent/Service/Dir.php | Dir.app | public function app($path = '', $checkIfExists = false)
{
$appDir = getcwd();
if ($checkIfExists) {
return realpath($appDir . DS . $path);
}
if (empty($path)) {
return $appDir;
}
return $appDir . DS . $this->normalizePath($path);
} | php | public function app($path = '', $checkIfExists = false)
{
$appDir = getcwd();
if ($checkIfExists) {
return realpath($appDir . DS . $path);
}
if (empty($path)) {
return $appDir;
}
return $appDir . DS . $this->normalizePath($path);
} | [
"public",
"function",
"app",
"(",
"$",
"path",
"=",
"''",
",",
"$",
"checkIfExists",
"=",
"false",
")",
"{",
"$",
"appDir",
"=",
"getcwd",
"(",
")",
";",
"if",
"(",
"$",
"checkIfExists",
")",
"{",
"return",
"realpath",
"(",
"$",
"appDir",
".",
"DS",
".",
"$",
"path",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"path",
")",
")",
"{",
"return",
"$",
"appDir",
";",
"}",
"return",
"$",
"appDir",
".",
"DS",
".",
"$",
"this",
"->",
"normalizePath",
"(",
"$",
"path",
")",
";",
"}"
]
| Returns the path to the root directory of the appliacation
or any child path.
If the flag "checkIfExists" is set to TRUE, checks for the specified
path and if the path was not found, returns FALSE.
@param string $path optional
@param boolean $checkIfExists optional default false
@return string|false | [
"Returns",
"the",
"path",
"to",
"the",
"root",
"directory",
"of",
"the",
"appliacation",
"or",
"any",
"child",
"path",
"."
]
| 9dd5732490c45fd788b96cedf7b3c7adfacb30d2 | https://github.com/dphn/ScContent/blob/9dd5732490c45fd788b96cedf7b3c7adfacb30d2/src/ScContent/Service/Dir.php#L143-L153 |
14,198 | dphn/ScContent | src/ScContent/Service/Dir.php | Dir.appAutoload | public function appAutoload($path = '', $checkIfExists = false)
{
$appAutoloadDir = getcwd() . $this->getRelativeAppAutoloadDir();
if ($checkIfExists) {
return realpath($appAutoloadDir . DS . $path);
}
if (empty($path)) {
return $appAutoloadDir;
}
return $appAutoloadDir . DS . $this->normalizePath($path);
} | php | public function appAutoload($path = '', $checkIfExists = false)
{
$appAutoloadDir = getcwd() . $this->getRelativeAppAutoloadDir();
if ($checkIfExists) {
return realpath($appAutoloadDir . DS . $path);
}
if (empty($path)) {
return $appAutoloadDir;
}
return $appAutoloadDir . DS . $this->normalizePath($path);
} | [
"public",
"function",
"appAutoload",
"(",
"$",
"path",
"=",
"''",
",",
"$",
"checkIfExists",
"=",
"false",
")",
"{",
"$",
"appAutoloadDir",
"=",
"getcwd",
"(",
")",
".",
"$",
"this",
"->",
"getRelativeAppAutoloadDir",
"(",
")",
";",
"if",
"(",
"$",
"checkIfExists",
")",
"{",
"return",
"realpath",
"(",
"$",
"appAutoloadDir",
".",
"DS",
".",
"$",
"path",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"path",
")",
")",
"{",
"return",
"$",
"appAutoloadDir",
";",
"}",
"return",
"$",
"appAutoloadDir",
".",
"DS",
".",
"$",
"this",
"->",
"normalizePath",
"(",
"$",
"path",
")",
";",
"}"
]
| Returns the path to the application autoload directory or any
child path.
If the flag "checkIfExists" is set to TRUE, checks for the specified
path and if the path was not found, returns FALSE.
Usage:
<code>
$dir = $serviceLocator->get('ScService.Dir');
$myConfigFile = $dir->appAutoload('my.local.php');
</code>
@api
@param string $path
@param boolean $checkIfExists optional default false
@return string | [
"Returns",
"the",
"path",
"to",
"the",
"application",
"autoload",
"directory",
"or",
"any",
"child",
"path",
"."
]
| 9dd5732490c45fd788b96cedf7b3c7adfacb30d2 | https://github.com/dphn/ScContent/blob/9dd5732490c45fd788b96cedf7b3c7adfacb30d2/src/ScContent/Service/Dir.php#L174-L184 |
14,199 | dphn/ScContent | src/ScContent/Service/Dir.php | Dir.appPublic | public function appPublic($path = '', $checkIfExists = false)
{
$appPublicDir = getcwd() . $this->getRelativeAppPublicDir();
if ($checkIfExists) {
return realpath($appPublicDir . DS . $path);
}
if (empty($path)) {
return $appPublicDir;
}
return $appPublicDir . DS . $this->normalizePath($path);
} | php | public function appPublic($path = '', $checkIfExists = false)
{
$appPublicDir = getcwd() . $this->getRelativeAppPublicDir();
if ($checkIfExists) {
return realpath($appPublicDir . DS . $path);
}
if (empty($path)) {
return $appPublicDir;
}
return $appPublicDir . DS . $this->normalizePath($path);
} | [
"public",
"function",
"appPublic",
"(",
"$",
"path",
"=",
"''",
",",
"$",
"checkIfExists",
"=",
"false",
")",
"{",
"$",
"appPublicDir",
"=",
"getcwd",
"(",
")",
".",
"$",
"this",
"->",
"getRelativeAppPublicDir",
"(",
")",
";",
"if",
"(",
"$",
"checkIfExists",
")",
"{",
"return",
"realpath",
"(",
"$",
"appPublicDir",
".",
"DS",
".",
"$",
"path",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"path",
")",
")",
"{",
"return",
"$",
"appPublicDir",
";",
"}",
"return",
"$",
"appPublicDir",
".",
"DS",
".",
"$",
"this",
"->",
"normalizePath",
"(",
"$",
"path",
")",
";",
"}"
]
| Returns the path to the application public directory or any
child path.
If the flag "checkIfExists" is set to TRUE, checks for the specified
path and if the path was not found, returns FALSE.
Usage:
<code>
$dir = $serviceLocator->get('ScService.Dir');
$myAssetsDir = $dir->appPublic('/mydirectory');
$myCss = $dir->appPublic('/mydirectory/css/example.css');
</code>
@api
@param string $path
@param boolean $checkIfExists optional default false
@return string | [
"Returns",
"the",
"path",
"to",
"the",
"application",
"public",
"directory",
"or",
"any",
"child",
"path",
"."
]
| 9dd5732490c45fd788b96cedf7b3c7adfacb30d2 | https://github.com/dphn/ScContent/blob/9dd5732490c45fd788b96cedf7b3c7adfacb30d2/src/ScContent/Service/Dir.php#L206-L216 |
Subsets and Splits