repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1 value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 | partition stringclasses 1 value |
|---|---|---|---|---|---|---|---|---|---|---|---|
AmsTaFFix/extjs-bundle | Twig/ExtjsExtension.php | ExtjsExtension.injectModel | public function injectModel() {
$params = func_get_args();
$injection = array_shift($params);
if ($injection == false) {
$url = $this->router->generate('extjs_generate_model', array('model'=>$params), false);
return "<script type='text/javascript' src='$url'></script>";
} else {
$code = '';
foreach ($params as $model) {
$model = str_replace(".", "\\", $model);
$code .= $this->generator->generateMarkupForEntity($model);
}
return $code;
}
} | php | public function injectModel() {
$params = func_get_args();
$injection = array_shift($params);
if ($injection == false) {
$url = $this->router->generate('extjs_generate_model', array('model'=>$params), false);
return "<script type='text/javascript' src='$url'></script>";
} else {
$code = '';
foreach ($params as $model) {
$model = str_replace(".", "\\", $model);
$code .= $this->generator->generateMarkupForEntity($model);
}
return $code;
}
} | [
"public",
"function",
"injectModel",
"(",
")",
"{",
"$",
"params",
"=",
"func_get_args",
"(",
")",
";",
"$",
"injection",
"=",
"array_shift",
"(",
"$",
"params",
")",
";",
"if",
"(",
"$",
"injection",
"==",
"false",
")",
"{",
"$",
"url",
"=",
"$",
... | Inject ExtJs Model into the DOM.
@param boolean $injection Produce ExtJS model code on the page directly?
@param string $model Model Name. | [
"Inject",
"ExtJs",
"Model",
"into",
"the",
"DOM",
"."
] | c07bc2766f5af3f6d8460e0f025f31794b7d5ebd | https://github.com/AmsTaFFix/extjs-bundle/blob/c07bc2766f5af3f6d8460e0f025f31794b7d5ebd/Twig/ExtjsExtension.php#L54-L68 | train |
QoboLtd/cakephp-menu | src/Model/Table/MenuItemsTable.php | MenuItemsTable.beforeSave | public function beforeSave(Event $event, EntityInterface $entity, ArrayObject $options): void
{
// fallback to default icon
if (!$entity->get('icon')) {
$entity->set('icon', Configure::read('Icons.default'));
}
// fallback to hashtag as default url
if (!$entity->get('url')) {
$entity->set('url', '#');
}
} | php | public function beforeSave(Event $event, EntityInterface $entity, ArrayObject $options): void
{
// fallback to default icon
if (!$entity->get('icon')) {
$entity->set('icon', Configure::read('Icons.default'));
}
// fallback to hashtag as default url
if (!$entity->get('url')) {
$entity->set('url', '#');
}
} | [
"public",
"function",
"beforeSave",
"(",
"Event",
"$",
"event",
",",
"EntityInterface",
"$",
"entity",
",",
"ArrayObject",
"$",
"options",
")",
":",
"void",
"{",
"// fallback to default icon",
"if",
"(",
"!",
"$",
"entity",
"->",
"get",
"(",
"'icon'",
")",
... | Fallback to default values for icon and url
@param \Cake\Event\Event $event Triggered event instance.
@param \Cake\Datasource\EntityInterface $entity Entity to be saved.
@param \ArrayObject $options Options passed to the save() method.
@return void | [
"Fallback",
"to",
"default",
"values",
"for",
"icon",
"and",
"url"
] | 1b987b5a82727e3f19cd0036341ca4f3c276fa8c | https://github.com/QoboLtd/cakephp-menu/blob/1b987b5a82727e3f19cd0036341ca4f3c276fa8c/src/Model/Table/MenuItemsTable.php#L124-L135 | train |
hiqdev/yii2-collection | src/ObjectTrait.php | ObjectTrait.set | public function set($name, $value, $where = '')
{
if (($name && $this->canSetProperty($name)) || strpos($name, 'on ') === 0 || strpos($name, 'as ') === 0) {
parent::__set($name, $value);
} else {
$this->setItem($name, $value, $where);
}
} | php | public function set($name, $value, $where = '')
{
if (($name && $this->canSetProperty($name)) || strpos($name, 'on ') === 0 || strpos($name, 'as ') === 0) {
parent::__set($name, $value);
} else {
$this->setItem($name, $value, $where);
}
} | [
"public",
"function",
"set",
"(",
"$",
"name",
",",
"$",
"value",
",",
"$",
"where",
"=",
"''",
")",
"{",
"if",
"(",
"(",
"$",
"name",
"&&",
"$",
"this",
"->",
"canSetProperty",
"(",
"$",
"name",
")",
")",
"||",
"strpos",
"(",
"$",
"name",
",",... | Sets an item. Silently resets if already exists.
@param int|string $name
@param mixed $value the element value
@param string|array $where where to put, see [[setItem()]]
@see setItem() | [
"Sets",
"an",
"item",
".",
"Silently",
"resets",
"if",
"already",
"exists",
"."
] | 6d7c440849fcedf1160f77046fe5a75d497bdd48 | https://github.com/hiqdev/yii2-collection/blob/6d7c440849fcedf1160f77046fe5a75d497bdd48/src/ObjectTrait.php#L45-L52 | train |
hiqdev/yii2-collection | src/ObjectTrait.php | ObjectTrait.add | public function add($name, $value = null, $where = '')
{
if (!$this->has($name)) {
$this->set($name, $value, $where);
}
return $this;
} | php | public function add($name, $value = null, $where = '')
{
if (!$this->has($name)) {
$this->set($name, $value, $where);
}
return $this;
} | [
"public",
"function",
"add",
"(",
"$",
"name",
",",
"$",
"value",
"=",
"null",
",",
"$",
"where",
"=",
"''",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"has",
"(",
"$",
"name",
")",
")",
"{",
"$",
"this",
"->",
"set",
"(",
"$",
"name",
",... | Adds an item. Does not touch if already exists.
@param int|string $name item name
@param array $value item value
@param string|array $where where to put, see [[setItem()]]
@return $this for chaining
@see setItem() | [
"Adds",
"an",
"item",
".",
"Does",
"not",
"touch",
"if",
"already",
"exists",
"."
] | 6d7c440849fcedf1160f77046fe5a75d497bdd48 | https://github.com/hiqdev/yii2-collection/blob/6d7c440849fcedf1160f77046fe5a75d497bdd48/src/ObjectTrait.php#L62-L69 | train |
hostnet/phpcs-tool | src/Hostnet/Sniffs/Commenting/FileCommentCopyrightSniff.php | FileCommentCopyrightSniff.processCopyrightTags | private function processCopyrightTags(File $phpcs_file, $stack_ptr, $comment_start): void
{
$tokens = $phpcs_file->getTokens();
foreach ($tokens[$comment_start]['comment_tags'] as $tag) {
if ($tokens[$tag]['content'] === $this->copyright_tag) {
$this->checkForContentInCopyrightTag($phpcs_file, $tag, $tokens[$comment_start]['comment_closer']);
//Use default PEAR style copyright notation checking.
$this->processCopyright($phpcs_file, [$tag]);
return;
}
}
//No @copyright tag because not returned
$error = 'Missing ' . $this->copyright_tag . ' tag in file doc-block';
if (false === $phpcs_file->addFixableError($error, $stack_ptr, 'MissingCopyrightTag')) {
return;
}
if ($tokens[$tokens[$comment_start]['comment_closer']]['line'] === $tokens[$comment_start]['line']) {
$phpcs_file->fixer->replaceToken($tokens[$comment_start]['comment_closer'] - 1, '');
$phpcs_file->fixer->addContentBefore(
$tokens[$comment_start]['comment_closer'],
sprintf("\n * %s %s\n ", $this->copyright_tag, $this->getCopyrightLine())
);
return;
}
$phpcs_file->fixer->addContentBefore(
$tokens[$comment_start]['comment_closer'],
sprintf("* %s %s\n ", $this->copyright_tag, $this->getCopyrightLine())
);
} | php | private function processCopyrightTags(File $phpcs_file, $stack_ptr, $comment_start): void
{
$tokens = $phpcs_file->getTokens();
foreach ($tokens[$comment_start]['comment_tags'] as $tag) {
if ($tokens[$tag]['content'] === $this->copyright_tag) {
$this->checkForContentInCopyrightTag($phpcs_file, $tag, $tokens[$comment_start]['comment_closer']);
//Use default PEAR style copyright notation checking.
$this->processCopyright($phpcs_file, [$tag]);
return;
}
}
//No @copyright tag because not returned
$error = 'Missing ' . $this->copyright_tag . ' tag in file doc-block';
if (false === $phpcs_file->addFixableError($error, $stack_ptr, 'MissingCopyrightTag')) {
return;
}
if ($tokens[$tokens[$comment_start]['comment_closer']]['line'] === $tokens[$comment_start]['line']) {
$phpcs_file->fixer->replaceToken($tokens[$comment_start]['comment_closer'] - 1, '');
$phpcs_file->fixer->addContentBefore(
$tokens[$comment_start]['comment_closer'],
sprintf("\n * %s %s\n ", $this->copyright_tag, $this->getCopyrightLine())
);
return;
}
$phpcs_file->fixer->addContentBefore(
$tokens[$comment_start]['comment_closer'],
sprintf("* %s %s\n ", $this->copyright_tag, $this->getCopyrightLine())
);
} | [
"private",
"function",
"processCopyrightTags",
"(",
"File",
"$",
"phpcs_file",
",",
"$",
"stack_ptr",
",",
"$",
"comment_start",
")",
":",
"void",
"{",
"$",
"tokens",
"=",
"$",
"phpcs_file",
"->",
"getTokens",
"(",
")",
";",
"foreach",
"(",
"$",
"tokens",
... | Processes the file level doc-block tags, this function is executed once the parent class finds a file-level
doc-block.
@param File $phpcs_file The file being scanned.
@param int $stack_ptr The position of the current token in the stack passed in $tokens.
@param int $comment_start Position in the stack where the comment started.
@return void | [
"Processes",
"the",
"file",
"level",
"doc",
"-",
"block",
"tags",
"this",
"function",
"is",
"executed",
"once",
"the",
"parent",
"class",
"finds",
"a",
"file",
"-",
"level",
"doc",
"-",
"block",
"."
] | 0d50d253493f7b596faeccf47898fecabfbb2c88 | https://github.com/hostnet/phpcs-tool/blob/0d50d253493f7b596faeccf47898fecabfbb2c88/src/Hostnet/Sniffs/Commenting/FileCommentCopyrightSniff.php#L122-L156 | train |
hiqdev/yii2-collection | src/ManagerTrait.php | ManagerTrait.getItem | public function getItem($name, $default = null)
{
if (empty($this->_items[$name])) {
$this->_items[$name] = $default;
}
$item = &$this->_items[$name];
if (is_array($item) || is_null($item)) {
$item = $this->createItem($name, $item ?: []);
}
return $item;
} | php | public function getItem($name, $default = null)
{
if (empty($this->_items[$name])) {
$this->_items[$name] = $default;
}
$item = &$this->_items[$name];
if (is_array($item) || is_null($item)) {
$item = $this->createItem($name, $item ?: []);
}
return $item;
} | [
"public",
"function",
"getItem",
"(",
"$",
"name",
",",
"$",
"default",
"=",
"null",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"_items",
"[",
"$",
"name",
"]",
")",
")",
"{",
"$",
"this",
"->",
"_items",
"[",
"$",
"name",
"]",
"=",
... | Returns item by name. Instantiates it before.
@param string $name item name
@param mixed $default default value
@return object item instance | [
"Returns",
"item",
"by",
"name",
".",
"Instantiates",
"it",
"before",
"."
] | 6d7c440849fcedf1160f77046fe5a75d497bdd48 | https://github.com/hiqdev/yii2-collection/blob/6d7c440849fcedf1160f77046fe5a75d497bdd48/src/ManagerTrait.php#L73-L84 | train |
hiqdev/yii2-collection | src/ManagerTrait.php | ManagerTrait.getItems | public function getItems()
{
foreach ($this->_items as $name => $item) {
$this->getItem($name);
}
return $this->_items;
} | php | public function getItems()
{
foreach ($this->_items as $name => $item) {
$this->getItem($name);
}
return $this->_items;
} | [
"public",
"function",
"getItems",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"_items",
"as",
"$",
"name",
"=>",
"$",
"item",
")",
"{",
"$",
"this",
"->",
"getItem",
"(",
"$",
"name",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_items",
";... | Get them all as array of items!
Instantiates all the items.
@return array list of items
@see get | [
"Get",
"them",
"all",
"as",
"array",
"of",
"items!",
"Instantiates",
"all",
"the",
"items",
"."
] | 6d7c440849fcedf1160f77046fe5a75d497bdd48 | https://github.com/hiqdev/yii2-collection/blob/6d7c440849fcedf1160f77046fe5a75d497bdd48/src/ManagerTrait.php#L97-L104 | train |
chillerlan/php-httpinterface | src/Psr7/UriExtended.php | UriExtended.withoutQueryValue | public function withoutQueryValue($key):UriExtended{
$current = $this->getQuery();
if($current === ''){
return $this;
}
$decodedKey = \rawurldecode($key);
$result = \array_filter(\explode('&', $current), function($part) use ($decodedKey){
return \rawurldecode(\explode('=', $part)[0]) !== $decodedKey;
});
return $this->withQuery(\implode('&', $result));
} | php | public function withoutQueryValue($key):UriExtended{
$current = $this->getQuery();
if($current === ''){
return $this;
}
$decodedKey = \rawurldecode($key);
$result = \array_filter(\explode('&', $current), function($part) use ($decodedKey){
return \rawurldecode(\explode('=', $part)[0]) !== $decodedKey;
});
return $this->withQuery(\implode('&', $result));
} | [
"public",
"function",
"withoutQueryValue",
"(",
"$",
"key",
")",
":",
"UriExtended",
"{",
"$",
"current",
"=",
"$",
"this",
"->",
"getQuery",
"(",
")",
";",
"if",
"(",
"$",
"current",
"===",
"''",
")",
"{",
"return",
"$",
"this",
";",
"}",
"$",
"de... | removes a specific query string value.
Any existing query string values that exactly match the provided key are
removed.
@param string $key Query string key to remove.
@return \Psr\Http\Message\UriInterface|\chillerlan\HTTP\Psr7\UriExtended | [
"removes",
"a",
"specific",
"query",
"string",
"value",
"."
] | 4babf31a1e5a0946b808da01dfe3fa02dac31f69 | https://github.com/chillerlan/php-httpinterface/blob/4babf31a1e5a0946b808da01dfe3fa02dac31f69/src/Psr7/UriExtended.php#L106-L120 | train |
thelia-modules/AttributeType | Model/Base/AttributeType.php | AttributeType.initAttributeAttributeTypes | public function initAttributeAttributeTypes($overrideExisting = true)
{
if (null !== $this->collAttributeAttributeTypes && !$overrideExisting) {
return;
}
$this->collAttributeAttributeTypes = new ObjectCollection();
$this->collAttributeAttributeTypes->setModel('\AttributeType\Model\AttributeAttributeType');
} | php | public function initAttributeAttributeTypes($overrideExisting = true)
{
if (null !== $this->collAttributeAttributeTypes && !$overrideExisting) {
return;
}
$this->collAttributeAttributeTypes = new ObjectCollection();
$this->collAttributeAttributeTypes->setModel('\AttributeType\Model\AttributeAttributeType');
} | [
"public",
"function",
"initAttributeAttributeTypes",
"(",
"$",
"overrideExisting",
"=",
"true",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"collAttributeAttributeTypes",
"&&",
"!",
"$",
"overrideExisting",
")",
"{",
"return",
";",
"}",
"$",
"this",... | Initializes the collAttributeAttributeTypes collection.
By default this just sets the collAttributeAttributeTypes collection to an empty array (like clearcollAttributeAttributeTypes());
however, you may wish to override this method in your stub class to provide setting appropriate
to your application -- for example, setting the initial array to the values stored in database.
@param boolean $overrideExisting If set to true, the method call initializes
the collection even if it is not empty
@return void | [
"Initializes",
"the",
"collAttributeAttributeTypes",
"collection",
"."
] | 674a18afab276039a251720c1779726084b2a639 | https://github.com/thelia-modules/AttributeType/blob/674a18afab276039a251720c1779726084b2a639/Model/Base/AttributeType.php#L1943-L1950 | train |
thelia-modules/AttributeType | Model/Base/AttributeType.php | AttributeType.getAttributeAttributeTypes | public function getAttributeAttributeTypes($criteria = null, ConnectionInterface $con = null)
{
$partial = $this->collAttributeAttributeTypesPartial && !$this->isNew();
if (null === $this->collAttributeAttributeTypes || null !== $criteria || $partial) {
if ($this->isNew() && null === $this->collAttributeAttributeTypes) {
// return empty collection
$this->initAttributeAttributeTypes();
} else {
$collAttributeAttributeTypes = ChildAttributeAttributeTypeQuery::create(null, $criteria)
->filterByAttributeType($this)
->find($con);
if (null !== $criteria) {
if (false !== $this->collAttributeAttributeTypesPartial && count($collAttributeAttributeTypes)) {
$this->initAttributeAttributeTypes(false);
foreach ($collAttributeAttributeTypes as $obj) {
if (false == $this->collAttributeAttributeTypes->contains($obj)) {
$this->collAttributeAttributeTypes->append($obj);
}
}
$this->collAttributeAttributeTypesPartial = true;
}
reset($collAttributeAttributeTypes);
return $collAttributeAttributeTypes;
}
if ($partial && $this->collAttributeAttributeTypes) {
foreach ($this->collAttributeAttributeTypes as $obj) {
if ($obj->isNew()) {
$collAttributeAttributeTypes[] = $obj;
}
}
}
$this->collAttributeAttributeTypes = $collAttributeAttributeTypes;
$this->collAttributeAttributeTypesPartial = false;
}
}
return $this->collAttributeAttributeTypes;
} | php | public function getAttributeAttributeTypes($criteria = null, ConnectionInterface $con = null)
{
$partial = $this->collAttributeAttributeTypesPartial && !$this->isNew();
if (null === $this->collAttributeAttributeTypes || null !== $criteria || $partial) {
if ($this->isNew() && null === $this->collAttributeAttributeTypes) {
// return empty collection
$this->initAttributeAttributeTypes();
} else {
$collAttributeAttributeTypes = ChildAttributeAttributeTypeQuery::create(null, $criteria)
->filterByAttributeType($this)
->find($con);
if (null !== $criteria) {
if (false !== $this->collAttributeAttributeTypesPartial && count($collAttributeAttributeTypes)) {
$this->initAttributeAttributeTypes(false);
foreach ($collAttributeAttributeTypes as $obj) {
if (false == $this->collAttributeAttributeTypes->contains($obj)) {
$this->collAttributeAttributeTypes->append($obj);
}
}
$this->collAttributeAttributeTypesPartial = true;
}
reset($collAttributeAttributeTypes);
return $collAttributeAttributeTypes;
}
if ($partial && $this->collAttributeAttributeTypes) {
foreach ($this->collAttributeAttributeTypes as $obj) {
if ($obj->isNew()) {
$collAttributeAttributeTypes[] = $obj;
}
}
}
$this->collAttributeAttributeTypes = $collAttributeAttributeTypes;
$this->collAttributeAttributeTypesPartial = false;
}
}
return $this->collAttributeAttributeTypes;
} | [
"public",
"function",
"getAttributeAttributeTypes",
"(",
"$",
"criteria",
"=",
"null",
",",
"ConnectionInterface",
"$",
"con",
"=",
"null",
")",
"{",
"$",
"partial",
"=",
"$",
"this",
"->",
"collAttributeAttributeTypesPartial",
"&&",
"!",
"$",
"this",
"->",
"i... | Gets an array of ChildAttributeAttributeType objects which contain a foreign key that references this object.
If the $criteria is not null, it is used to always fetch the results from the database.
Otherwise the results are fetched from the database the first time, then cached.
Next time the same method is called without $criteria, the cached collection is returned.
If this ChildAttributeType is new, it will return
an empty collection or the current collection; the criteria is ignored on a new object.
@param Criteria $criteria optional Criteria object to narrow the query
@param ConnectionInterface $con optional connection object
@return Collection|ChildAttributeAttributeType[] List of ChildAttributeAttributeType objects
@throws PropelException | [
"Gets",
"an",
"array",
"of",
"ChildAttributeAttributeType",
"objects",
"which",
"contain",
"a",
"foreign",
"key",
"that",
"references",
"this",
"object",
"."
] | 674a18afab276039a251720c1779726084b2a639 | https://github.com/thelia-modules/AttributeType/blob/674a18afab276039a251720c1779726084b2a639/Model/Base/AttributeType.php#L1966-L2010 | train |
thelia-modules/AttributeType | Model/Base/AttributeType.php | AttributeType.countAttributeAttributeTypes | public function countAttributeAttributeTypes(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
{
$partial = $this->collAttributeAttributeTypesPartial && !$this->isNew();
if (null === $this->collAttributeAttributeTypes || null !== $criteria || $partial) {
if ($this->isNew() && null === $this->collAttributeAttributeTypes) {
return 0;
}
if ($partial && !$criteria) {
return count($this->getAttributeAttributeTypes());
}
$query = ChildAttributeAttributeTypeQuery::create(null, $criteria);
if ($distinct) {
$query->distinct();
}
return $query
->filterByAttributeType($this)
->count($con);
}
return count($this->collAttributeAttributeTypes);
} | php | public function countAttributeAttributeTypes(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
{
$partial = $this->collAttributeAttributeTypesPartial && !$this->isNew();
if (null === $this->collAttributeAttributeTypes || null !== $criteria || $partial) {
if ($this->isNew() && null === $this->collAttributeAttributeTypes) {
return 0;
}
if ($partial && !$criteria) {
return count($this->getAttributeAttributeTypes());
}
$query = ChildAttributeAttributeTypeQuery::create(null, $criteria);
if ($distinct) {
$query->distinct();
}
return $query
->filterByAttributeType($this)
->count($con);
}
return count($this->collAttributeAttributeTypes);
} | [
"public",
"function",
"countAttributeAttributeTypes",
"(",
"Criteria",
"$",
"criteria",
"=",
"null",
",",
"$",
"distinct",
"=",
"false",
",",
"ConnectionInterface",
"$",
"con",
"=",
"null",
")",
"{",
"$",
"partial",
"=",
"$",
"this",
"->",
"collAttributeAttrib... | Returns the number of related AttributeAttributeType objects.
@param Criteria $criteria
@param boolean $distinct
@param ConnectionInterface $con
@return int Count of related AttributeAttributeType objects.
@throws PropelException | [
"Returns",
"the",
"number",
"of",
"related",
"AttributeAttributeType",
"objects",
"."
] | 674a18afab276039a251720c1779726084b2a639 | https://github.com/thelia-modules/AttributeType/blob/674a18afab276039a251720c1779726084b2a639/Model/Base/AttributeType.php#L2053-L2076 | train |
thelia-modules/AttributeType | Model/Base/AttributeType.php | AttributeType.addAttributeAttributeType | public function addAttributeAttributeType(ChildAttributeAttributeType $l)
{
if ($this->collAttributeAttributeTypes === null) {
$this->initAttributeAttributeTypes();
$this->collAttributeAttributeTypesPartial = true;
}
if (!in_array($l, $this->collAttributeAttributeTypes->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
$this->doAddAttributeAttributeType($l);
}
return $this;
} | php | public function addAttributeAttributeType(ChildAttributeAttributeType $l)
{
if ($this->collAttributeAttributeTypes === null) {
$this->initAttributeAttributeTypes();
$this->collAttributeAttributeTypesPartial = true;
}
if (!in_array($l, $this->collAttributeAttributeTypes->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
$this->doAddAttributeAttributeType($l);
}
return $this;
} | [
"public",
"function",
"addAttributeAttributeType",
"(",
"ChildAttributeAttributeType",
"$",
"l",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"collAttributeAttributeTypes",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"initAttributeAttributeTypes",
"(",
")",
";",
"$",
... | Method called to associate a ChildAttributeAttributeType object to this object
through the ChildAttributeAttributeType foreign key attribute.
@param ChildAttributeAttributeType $l ChildAttributeAttributeType
@return \AttributeType\Model\AttributeType The current object (for fluent API support) | [
"Method",
"called",
"to",
"associate",
"a",
"ChildAttributeAttributeType",
"object",
"to",
"this",
"object",
"through",
"the",
"ChildAttributeAttributeType",
"foreign",
"key",
"attribute",
"."
] | 674a18afab276039a251720c1779726084b2a639 | https://github.com/thelia-modules/AttributeType/blob/674a18afab276039a251720c1779726084b2a639/Model/Base/AttributeType.php#L2085-L2097 | train |
thelia-modules/AttributeType | Model/Base/AttributeType.php | AttributeType.getAttributeAttributeTypesJoinAttribute | public function getAttributeAttributeTypesJoinAttribute($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
{
$query = ChildAttributeAttributeTypeQuery::create(null, $criteria);
$query->joinWith('Attribute', $joinBehavior);
return $this->getAttributeAttributeTypes($query, $con);
} | php | public function getAttributeAttributeTypesJoinAttribute($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
{
$query = ChildAttributeAttributeTypeQuery::create(null, $criteria);
$query->joinWith('Attribute', $joinBehavior);
return $this->getAttributeAttributeTypes($query, $con);
} | [
"public",
"function",
"getAttributeAttributeTypesJoinAttribute",
"(",
"$",
"criteria",
"=",
"null",
",",
"$",
"con",
"=",
"null",
",",
"$",
"joinBehavior",
"=",
"Criteria",
"::",
"LEFT_JOIN",
")",
"{",
"$",
"query",
"=",
"ChildAttributeAttributeTypeQuery",
"::",
... | If this collection has already been initialized with
an identical criteria, it returns the collection.
Otherwise if this AttributeType is new, it will return
an empty collection; or if this AttributeType has previously
been saved, it will retrieve related AttributeAttributeTypes from storage.
This method is protected by default in order to keep the public
api reasonable. You can provide public methods for those you
actually need in AttributeType.
@param Criteria $criteria optional Criteria object to narrow the query
@param ConnectionInterface $con optional connection object
@param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
@return Collection|ChildAttributeAttributeType[] List of ChildAttributeAttributeType objects | [
"If",
"this",
"collection",
"has",
"already",
"been",
"initialized",
"with",
"an",
"identical",
"criteria",
"it",
"returns",
"the",
"collection",
".",
"Otherwise",
"if",
"this",
"AttributeType",
"is",
"new",
"it",
"will",
"return",
"an",
"empty",
"collection",
... | 674a18afab276039a251720c1779726084b2a639 | https://github.com/thelia-modules/AttributeType/blob/674a18afab276039a251720c1779726084b2a639/Model/Base/AttributeType.php#L2144-L2150 | train |
thelia-modules/AttributeType | Model/Base/AttributeType.php | AttributeType.initAttributeTypeI18ns | public function initAttributeTypeI18ns($overrideExisting = true)
{
if (null !== $this->collAttributeTypeI18ns && !$overrideExisting) {
return;
}
$this->collAttributeTypeI18ns = new ObjectCollection();
$this->collAttributeTypeI18ns->setModel('\AttributeType\Model\AttributeTypeI18n');
} | php | public function initAttributeTypeI18ns($overrideExisting = true)
{
if (null !== $this->collAttributeTypeI18ns && !$overrideExisting) {
return;
}
$this->collAttributeTypeI18ns = new ObjectCollection();
$this->collAttributeTypeI18ns->setModel('\AttributeType\Model\AttributeTypeI18n');
} | [
"public",
"function",
"initAttributeTypeI18ns",
"(",
"$",
"overrideExisting",
"=",
"true",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"collAttributeTypeI18ns",
"&&",
"!",
"$",
"overrideExisting",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
... | Initializes the collAttributeTypeI18ns collection.
By default this just sets the collAttributeTypeI18ns collection to an empty array (like clearcollAttributeTypeI18ns());
however, you may wish to override this method in your stub class to provide setting appropriate
to your application -- for example, setting the initial array to the values stored in database.
@param boolean $overrideExisting If set to true, the method call initializes
the collection even if it is not empty
@return void | [
"Initializes",
"the",
"collAttributeTypeI18ns",
"collection",
"."
] | 674a18afab276039a251720c1779726084b2a639 | https://github.com/thelia-modules/AttributeType/blob/674a18afab276039a251720c1779726084b2a639/Model/Base/AttributeType.php#L2186-L2193 | train |
thelia-modules/AttributeType | Model/Base/AttributeType.php | AttributeType.getAttributeTypeI18ns | public function getAttributeTypeI18ns($criteria = null, ConnectionInterface $con = null)
{
$partial = $this->collAttributeTypeI18nsPartial && !$this->isNew();
if (null === $this->collAttributeTypeI18ns || null !== $criteria || $partial) {
if ($this->isNew() && null === $this->collAttributeTypeI18ns) {
// return empty collection
$this->initAttributeTypeI18ns();
} else {
$collAttributeTypeI18ns = ChildAttributeTypeI18nQuery::create(null, $criteria)
->filterByAttributeType($this)
->find($con);
if (null !== $criteria) {
if (false !== $this->collAttributeTypeI18nsPartial && count($collAttributeTypeI18ns)) {
$this->initAttributeTypeI18ns(false);
foreach ($collAttributeTypeI18ns as $obj) {
if (false == $this->collAttributeTypeI18ns->contains($obj)) {
$this->collAttributeTypeI18ns->append($obj);
}
}
$this->collAttributeTypeI18nsPartial = true;
}
reset($collAttributeTypeI18ns);
return $collAttributeTypeI18ns;
}
if ($partial && $this->collAttributeTypeI18ns) {
foreach ($this->collAttributeTypeI18ns as $obj) {
if ($obj->isNew()) {
$collAttributeTypeI18ns[] = $obj;
}
}
}
$this->collAttributeTypeI18ns = $collAttributeTypeI18ns;
$this->collAttributeTypeI18nsPartial = false;
}
}
return $this->collAttributeTypeI18ns;
} | php | public function getAttributeTypeI18ns($criteria = null, ConnectionInterface $con = null)
{
$partial = $this->collAttributeTypeI18nsPartial && !$this->isNew();
if (null === $this->collAttributeTypeI18ns || null !== $criteria || $partial) {
if ($this->isNew() && null === $this->collAttributeTypeI18ns) {
// return empty collection
$this->initAttributeTypeI18ns();
} else {
$collAttributeTypeI18ns = ChildAttributeTypeI18nQuery::create(null, $criteria)
->filterByAttributeType($this)
->find($con);
if (null !== $criteria) {
if (false !== $this->collAttributeTypeI18nsPartial && count($collAttributeTypeI18ns)) {
$this->initAttributeTypeI18ns(false);
foreach ($collAttributeTypeI18ns as $obj) {
if (false == $this->collAttributeTypeI18ns->contains($obj)) {
$this->collAttributeTypeI18ns->append($obj);
}
}
$this->collAttributeTypeI18nsPartial = true;
}
reset($collAttributeTypeI18ns);
return $collAttributeTypeI18ns;
}
if ($partial && $this->collAttributeTypeI18ns) {
foreach ($this->collAttributeTypeI18ns as $obj) {
if ($obj->isNew()) {
$collAttributeTypeI18ns[] = $obj;
}
}
}
$this->collAttributeTypeI18ns = $collAttributeTypeI18ns;
$this->collAttributeTypeI18nsPartial = false;
}
}
return $this->collAttributeTypeI18ns;
} | [
"public",
"function",
"getAttributeTypeI18ns",
"(",
"$",
"criteria",
"=",
"null",
",",
"ConnectionInterface",
"$",
"con",
"=",
"null",
")",
"{",
"$",
"partial",
"=",
"$",
"this",
"->",
"collAttributeTypeI18nsPartial",
"&&",
"!",
"$",
"this",
"->",
"isNew",
"... | Gets an array of ChildAttributeTypeI18n objects which contain a foreign key that references this object.
If the $criteria is not null, it is used to always fetch the results from the database.
Otherwise the results are fetched from the database the first time, then cached.
Next time the same method is called without $criteria, the cached collection is returned.
If this ChildAttributeType is new, it will return
an empty collection or the current collection; the criteria is ignored on a new object.
@param Criteria $criteria optional Criteria object to narrow the query
@param ConnectionInterface $con optional connection object
@return Collection|ChildAttributeTypeI18n[] List of ChildAttributeTypeI18n objects
@throws PropelException | [
"Gets",
"an",
"array",
"of",
"ChildAttributeTypeI18n",
"objects",
"which",
"contain",
"a",
"foreign",
"key",
"that",
"references",
"this",
"object",
"."
] | 674a18afab276039a251720c1779726084b2a639 | https://github.com/thelia-modules/AttributeType/blob/674a18afab276039a251720c1779726084b2a639/Model/Base/AttributeType.php#L2209-L2253 | train |
thelia-modules/AttributeType | Model/Base/AttributeType.php | AttributeType.countAttributeTypeI18ns | public function countAttributeTypeI18ns(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
{
$partial = $this->collAttributeTypeI18nsPartial && !$this->isNew();
if (null === $this->collAttributeTypeI18ns || null !== $criteria || $partial) {
if ($this->isNew() && null === $this->collAttributeTypeI18ns) {
return 0;
}
if ($partial && !$criteria) {
return count($this->getAttributeTypeI18ns());
}
$query = ChildAttributeTypeI18nQuery::create(null, $criteria);
if ($distinct) {
$query->distinct();
}
return $query
->filterByAttributeType($this)
->count($con);
}
return count($this->collAttributeTypeI18ns);
} | php | public function countAttributeTypeI18ns(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
{
$partial = $this->collAttributeTypeI18nsPartial && !$this->isNew();
if (null === $this->collAttributeTypeI18ns || null !== $criteria || $partial) {
if ($this->isNew() && null === $this->collAttributeTypeI18ns) {
return 0;
}
if ($partial && !$criteria) {
return count($this->getAttributeTypeI18ns());
}
$query = ChildAttributeTypeI18nQuery::create(null, $criteria);
if ($distinct) {
$query->distinct();
}
return $query
->filterByAttributeType($this)
->count($con);
}
return count($this->collAttributeTypeI18ns);
} | [
"public",
"function",
"countAttributeTypeI18ns",
"(",
"Criteria",
"$",
"criteria",
"=",
"null",
",",
"$",
"distinct",
"=",
"false",
",",
"ConnectionInterface",
"$",
"con",
"=",
"null",
")",
"{",
"$",
"partial",
"=",
"$",
"this",
"->",
"collAttributeTypeI18nsPa... | Returns the number of related AttributeTypeI18n objects.
@param Criteria $criteria
@param boolean $distinct
@param ConnectionInterface $con
@return int Count of related AttributeTypeI18n objects.
@throws PropelException | [
"Returns",
"the",
"number",
"of",
"related",
"AttributeTypeI18n",
"objects",
"."
] | 674a18afab276039a251720c1779726084b2a639 | https://github.com/thelia-modules/AttributeType/blob/674a18afab276039a251720c1779726084b2a639/Model/Base/AttributeType.php#L2299-L2322 | train |
thelia-modules/AttributeType | Model/Base/AttributeType.php | AttributeType.addAttributeTypeI18n | public function addAttributeTypeI18n(ChildAttributeTypeI18n $l)
{
if ($l && $locale = $l->getLocale()) {
$this->setLocale($locale);
$this->currentTranslations[$locale] = $l;
}
if ($this->collAttributeTypeI18ns === null) {
$this->initAttributeTypeI18ns();
$this->collAttributeTypeI18nsPartial = true;
}
if (!in_array($l, $this->collAttributeTypeI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
$this->doAddAttributeTypeI18n($l);
}
return $this;
} | php | public function addAttributeTypeI18n(ChildAttributeTypeI18n $l)
{
if ($l && $locale = $l->getLocale()) {
$this->setLocale($locale);
$this->currentTranslations[$locale] = $l;
}
if ($this->collAttributeTypeI18ns === null) {
$this->initAttributeTypeI18ns();
$this->collAttributeTypeI18nsPartial = true;
}
if (!in_array($l, $this->collAttributeTypeI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
$this->doAddAttributeTypeI18n($l);
}
return $this;
} | [
"public",
"function",
"addAttributeTypeI18n",
"(",
"ChildAttributeTypeI18n",
"$",
"l",
")",
"{",
"if",
"(",
"$",
"l",
"&&",
"$",
"locale",
"=",
"$",
"l",
"->",
"getLocale",
"(",
")",
")",
"{",
"$",
"this",
"->",
"setLocale",
"(",
"$",
"locale",
")",
... | Method called to associate a ChildAttributeTypeI18n object to this object
through the ChildAttributeTypeI18n foreign key attribute.
@param ChildAttributeTypeI18n $l ChildAttributeTypeI18n
@return \AttributeType\Model\AttributeType The current object (for fluent API support) | [
"Method",
"called",
"to",
"associate",
"a",
"ChildAttributeTypeI18n",
"object",
"to",
"this",
"object",
"through",
"the",
"ChildAttributeTypeI18n",
"foreign",
"key",
"attribute",
"."
] | 674a18afab276039a251720c1779726084b2a639 | https://github.com/thelia-modules/AttributeType/blob/674a18afab276039a251720c1779726084b2a639/Model/Base/AttributeType.php#L2331-L2347 | train |
thelia-modules/AttributeType | Model/Base/AttributeType.php | AttributeType.validate | public function validate(Validator $validator = null)
{
if (null === $validator) {
$validator = new Validator(new ClassMetadataFactory(new StaticMethodLoader()), new ConstraintValidatorFactory(), new DefaultTranslator());
}
$failureMap = new ConstraintViolationList();
if (!$this->alreadyInValidation) {
$this->alreadyInValidation = true;
$retval = null;
$retval = $validator->validate($this);
if (count($retval) > 0) {
$failureMap->addAll($retval);
}
if (null !== $this->collAttributeAttributeTypes) {
foreach ($this->collAttributeAttributeTypes as $referrerFK) {
if (method_exists($referrerFK, 'validate')) {
if (!$referrerFK->validate($validator)) {
$failureMap->addAll($referrerFK->getValidationFailures());
}
}
}
}
if (null !== $this->collAttributeTypeI18ns) {
foreach ($this->collAttributeTypeI18ns as $referrerFK) {
if (method_exists($referrerFK, 'validate')) {
if (!$referrerFK->validate($validator)) {
$failureMap->addAll($referrerFK->getValidationFailures());
}
}
}
}
$this->alreadyInValidation = false;
}
$this->validationFailures = $failureMap;
return (Boolean) (!(count($this->validationFailures) > 0));
} | php | public function validate(Validator $validator = null)
{
if (null === $validator) {
$validator = new Validator(new ClassMetadataFactory(new StaticMethodLoader()), new ConstraintValidatorFactory(), new DefaultTranslator());
}
$failureMap = new ConstraintViolationList();
if (!$this->alreadyInValidation) {
$this->alreadyInValidation = true;
$retval = null;
$retval = $validator->validate($this);
if (count($retval) > 0) {
$failureMap->addAll($retval);
}
if (null !== $this->collAttributeAttributeTypes) {
foreach ($this->collAttributeAttributeTypes as $referrerFK) {
if (method_exists($referrerFK, 'validate')) {
if (!$referrerFK->validate($validator)) {
$failureMap->addAll($referrerFK->getValidationFailures());
}
}
}
}
if (null !== $this->collAttributeTypeI18ns) {
foreach ($this->collAttributeTypeI18ns as $referrerFK) {
if (method_exists($referrerFK, 'validate')) {
if (!$referrerFK->validate($validator)) {
$failureMap->addAll($referrerFK->getValidationFailures());
}
}
}
}
$this->alreadyInValidation = false;
}
$this->validationFailures = $failureMap;
return (Boolean) (!(count($this->validationFailures) > 0));
} | [
"public",
"function",
"validate",
"(",
"Validator",
"$",
"validator",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"validator",
")",
"{",
"$",
"validator",
"=",
"new",
"Validator",
"(",
"new",
"ClassMetadataFactory",
"(",
"new",
"StaticMethodLoader"... | Validates the object and all objects related to this table.
@see getValidationFailures()
@param object $validator A Validator class instance
@return boolean Whether all objects pass validation. | [
"Validates",
"the",
"object",
"and",
"all",
"objects",
"related",
"to",
"this",
"table",
"."
] | 674a18afab276039a251720c1779726084b2a639 | https://github.com/thelia-modules/AttributeType/blob/674a18afab276039a251720c1779726084b2a639/Model/Base/AttributeType.php#L2614-L2658 | train |
FriendsOfCake/process-mq | src/Connection/RabbitMQConnection.php | RabbitMQConnection.logQueries | public function logQueries($enable = null)
{
if ($enable !== null) {
$this->_logQueries = $enable;
}
if ($this->_logQueries) {
return $this->_logQueries;
}
return $this->_logQueries = $enable;
} | php | public function logQueries($enable = null)
{
if ($enable !== null) {
$this->_logQueries = $enable;
}
if ($this->_logQueries) {
return $this->_logQueries;
}
return $this->_logQueries = $enable;
} | [
"public",
"function",
"logQueries",
"(",
"$",
"enable",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"enable",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"_logQueries",
"=",
"$",
"enable",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"_logQueries",
")",
"{",... | Enables or disables query logging for this connection.
@param bool $enable whether to turn logging on or disable it.
Use null to read current value.
@return bool | [
"Enables",
"or",
"disables",
"query",
"logging",
"for",
"this",
"connection",
"."
] | 184a868c2415781ebf4de48f85c45b93dfb60552 | https://github.com/FriendsOfCake/process-mq/blob/184a868c2415781ebf4de48f85c45b93dfb60552/src/Connection/RabbitMQConnection.php#L116-L127 | train |
FriendsOfCake/process-mq | src/Connection/RabbitMQConnection.php | RabbitMQConnection.logger | public function logger($logger = null)
{
if ($logger) {
$this->_logger = $logger;
}
if ($this->_logger) {
return $this->_logger;
}
$this->_logger = new QueryLogger();
return $this->_logger;
} | php | public function logger($logger = null)
{
if ($logger) {
$this->_logger = $logger;
}
if ($this->_logger) {
return $this->_logger;
}
$this->_logger = new QueryLogger();
return $this->_logger;
} | [
"public",
"function",
"logger",
"(",
"$",
"logger",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"logger",
")",
"{",
"$",
"this",
"->",
"_logger",
"=",
"$",
"logger",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"_logger",
")",
"{",
"return",
"$",
"this",
... | Sets the logger object instance. When called with no arguments
it returns the currently setup logger instance.
@param object $logger logger object instance
@return object logger instance | [
"Sets",
"the",
"logger",
"object",
"instance",
".",
"When",
"called",
"with",
"no",
"arguments",
"it",
"returns",
"the",
"currently",
"setup",
"logger",
"instance",
"."
] | 184a868c2415781ebf4de48f85c45b93dfb60552 | https://github.com/FriendsOfCake/process-mq/blob/184a868c2415781ebf4de48f85c45b93dfb60552/src/Connection/RabbitMQConnection.php#L136-L148 | train |
FriendsOfCake/process-mq | src/Connection/RabbitMQConnection.php | RabbitMQConnection.connect | public function connect()
{
$connection = $this->_connection;
$connection->setLogin($this->_config['user']);
$connection->setPassword($this->_config['password']);
$connection->setHost($this->_config['host']);
$connection->setPort($this->_config['port']);
$connection->setVhost($this->_config['vhost']);
$connection->setReadTimeout($this->_config['readTimeout']);
# You shall not use persistent connections
#
# AMQPChannelException' with message 'Could not create channel. Connection has no open channel slots remaining
#
# The PECL extension is foobar, http://stackoverflow.com/questions/23864647/how-to-avoid-max-channels-per-tcp-connection-with-amqp-php-persistent-connectio
#
$connection->connect();
} | php | public function connect()
{
$connection = $this->_connection;
$connection->setLogin($this->_config['user']);
$connection->setPassword($this->_config['password']);
$connection->setHost($this->_config['host']);
$connection->setPort($this->_config['port']);
$connection->setVhost($this->_config['vhost']);
$connection->setReadTimeout($this->_config['readTimeout']);
# You shall not use persistent connections
#
# AMQPChannelException' with message 'Could not create channel. Connection has no open channel slots remaining
#
# The PECL extension is foobar, http://stackoverflow.com/questions/23864647/how-to-avoid-max-channels-per-tcp-connection-with-amqp-php-persistent-connectio
#
$connection->connect();
} | [
"public",
"function",
"connect",
"(",
")",
"{",
"$",
"connection",
"=",
"$",
"this",
"->",
"_connection",
";",
"$",
"connection",
"->",
"setLogin",
"(",
"$",
"this",
"->",
"_config",
"[",
"'user'",
"]",
")",
";",
"$",
"connection",
"->",
"setPassword",
... | Connects to RabbitMQ
@return void | [
"Connects",
"to",
"RabbitMQ"
] | 184a868c2415781ebf4de48f85c45b93dfb60552 | https://github.com/FriendsOfCake/process-mq/blob/184a868c2415781ebf4de48f85c45b93dfb60552/src/Connection/RabbitMQConnection.php#L155-L173 | train |
FriendsOfCake/process-mq | src/Connection/RabbitMQConnection.php | RabbitMQConnection.channel | public function channel($name, $options = [])
{
if (empty($this->_channels[$name])) {
$this->_channels[$name] = new AMQPChannel($this->connection());
if (!empty($options['prefetchCount'])) {
$this->_channels[$name]->setPrefetchCount((int)$options['prefetchCount']);
}
}
return $this->_channels[$name];
} | php | public function channel($name, $options = [])
{
if (empty($this->_channels[$name])) {
$this->_channels[$name] = new AMQPChannel($this->connection());
if (!empty($options['prefetchCount'])) {
$this->_channels[$name]->setPrefetchCount((int)$options['prefetchCount']);
}
}
return $this->_channels[$name];
} | [
"public",
"function",
"channel",
"(",
"$",
"name",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"_channels",
"[",
"$",
"name",
"]",
")",
")",
"{",
"$",
"this",
"->",
"_channels",
"[",
"$",
"name",
"]... | Creates a new channel to communicate with an exchange or queue object
@param array $options
@return AMQPChannel | [
"Creates",
"a",
"new",
"channel",
"to",
"communicate",
"with",
"an",
"exchange",
"or",
"queue",
"object"
] | 184a868c2415781ebf4de48f85c45b93dfb60552 | https://github.com/FriendsOfCake/process-mq/blob/184a868c2415781ebf4de48f85c45b93dfb60552/src/Connection/RabbitMQConnection.php#L191-L201 | train |
FriendsOfCake/process-mq | src/Connection/RabbitMQConnection.php | RabbitMQConnection.exchange | public function exchange($name, $options = [])
{
if (empty($this->_exchanges[$name])) {
$channel = $this->channel($name, $options);
$exchange = new AMQPExchange($channel);
$exchange->setName($name);
if (!empty($options['type'])) {
$exchange->setType($options['type']);
}
if (!empty($options['flags'])) {
$exchange->setFlags($options['flags']);
}
$this->_exchanges[$name] = $exchange;
}
return $this->_exchanges[$name];
} | php | public function exchange($name, $options = [])
{
if (empty($this->_exchanges[$name])) {
$channel = $this->channel($name, $options);
$exchange = new AMQPExchange($channel);
$exchange->setName($name);
if (!empty($options['type'])) {
$exchange->setType($options['type']);
}
if (!empty($options['flags'])) {
$exchange->setFlags($options['flags']);
}
$this->_exchanges[$name] = $exchange;
}
return $this->_exchanges[$name];
} | [
"public",
"function",
"exchange",
"(",
"$",
"name",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"_exchanges",
"[",
"$",
"name",
"]",
")",
")",
"{",
"$",
"channel",
"=",
"$",
"this",
"->",
"channel",
... | Connects to an exchange with the given name, the object returned
can be used to configure and create a new one.
@param string $name
@param array $options
@return AMQPExchange | [
"Connects",
"to",
"an",
"exchange",
"with",
"the",
"given",
"name",
"the",
"object",
"returned",
"can",
"be",
"used",
"to",
"configure",
"and",
"create",
"a",
"new",
"one",
"."
] | 184a868c2415781ebf4de48f85c45b93dfb60552 | https://github.com/FriendsOfCake/process-mq/blob/184a868c2415781ebf4de48f85c45b93dfb60552/src/Connection/RabbitMQConnection.php#L211-L230 | train |
FriendsOfCake/process-mq | src/Connection/RabbitMQConnection.php | RabbitMQConnection.queue | public function queue($name, $options = [])
{
if (empty($this->_queues[$name])) {
$channel = $this->channel($name, $options);
$queue = new AMQPQueue($channel);
$queue->setName($name);
if (!empty($options['flags'])) {
$queue->setFlags($options['flags']);
}
$this->_queues[$name] = $queue;
}
return $this->_queues[$name];
} | php | public function queue($name, $options = [])
{
if (empty($this->_queues[$name])) {
$channel = $this->channel($name, $options);
$queue = new AMQPQueue($channel);
$queue->setName($name);
if (!empty($options['flags'])) {
$queue->setFlags($options['flags']);
}
$this->_queues[$name] = $queue;
}
return $this->_queues[$name];
} | [
"public",
"function",
"queue",
"(",
"$",
"name",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"_queues",
"[",
"$",
"name",
"]",
")",
")",
"{",
"$",
"channel",
"=",
"$",
"this",
"->",
"channel",
"(",
... | Connects to a queue with the given name, the object returned
can be used to configure and create a new one.
@param string $name
@param array $options
@return AMQPQueue | [
"Connects",
"to",
"a",
"queue",
"with",
"the",
"given",
"name",
"the",
"object",
"returned",
"can",
"be",
"used",
"to",
"configure",
"and",
"create",
"a",
"new",
"one",
"."
] | 184a868c2415781ebf4de48f85c45b93dfb60552 | https://github.com/FriendsOfCake/process-mq/blob/184a868c2415781ebf4de48f85c45b93dfb60552/src/Connection/RabbitMQConnection.php#L240-L255 | train |
FriendsOfCake/process-mq | src/Connection/RabbitMQConnection.php | RabbitMQConnection._prepareMessage | protected function _prepareMessage($data, array $options)
{
$attributes = [];
$options += [
'silent' => false,
'compress' => true,
'serializer' => extension_loaded('msgpack') ? 'msgpack' : 'json',
'delivery_mode' => 1
];
switch ($options['serializer']) {
case 'json':
$data = json_encode($data);
$attributes['content_type'] = 'application/json';
break;
case 'text':
$attributes['content_type'] = 'application/text';
break;
default:
throw new RuntimeException('Unknown serializer: ' . $options['serializer']);
}
if (!empty($options['compress'])) {
$data = gzcompress($data);
$attributes += ['content_encoding' => 'gzip'];
}
if (!empty($options['delivery_mode'])) {
$attributes['delivery_mode'] = $options['delivery_mode'];
}
return [$data, $attributes, $options];
} | php | protected function _prepareMessage($data, array $options)
{
$attributes = [];
$options += [
'silent' => false,
'compress' => true,
'serializer' => extension_loaded('msgpack') ? 'msgpack' : 'json',
'delivery_mode' => 1
];
switch ($options['serializer']) {
case 'json':
$data = json_encode($data);
$attributes['content_type'] = 'application/json';
break;
case 'text':
$attributes['content_type'] = 'application/text';
break;
default:
throw new RuntimeException('Unknown serializer: ' . $options['serializer']);
}
if (!empty($options['compress'])) {
$data = gzcompress($data);
$attributes += ['content_encoding' => 'gzip'];
}
if (!empty($options['delivery_mode'])) {
$attributes['delivery_mode'] = $options['delivery_mode'];
}
return [$data, $attributes, $options];
} | [
"protected",
"function",
"_prepareMessage",
"(",
"$",
"data",
",",
"array",
"$",
"options",
")",
"{",
"$",
"attributes",
"=",
"[",
"]",
";",
"$",
"options",
"+=",
"[",
"'silent'",
"=>",
"false",
",",
"'compress'",
"=>",
"true",
",",
"'serializer'",
"=>",... | Prepare a message by serializing, optionally compressing and setting the correct content type
and content type for the message going to RabbitMQ
@param mixed $data
@param array $options
@return array | [
"Prepare",
"a",
"message",
"by",
"serializing",
"optionally",
"compressing",
"and",
"setting",
"the",
"correct",
"content",
"type",
"and",
"content",
"type",
"for",
"the",
"message",
"going",
"to",
"RabbitMQ"
] | 184a868c2415781ebf4de48f85c45b93dfb60552 | https://github.com/FriendsOfCake/process-mq/blob/184a868c2415781ebf4de48f85c45b93dfb60552/src/Connection/RabbitMQConnection.php#L298-L333 | train |
wikiworldorder/survloop | src/Controllers/Tree/TreeSurvBasicNav.php | TreeSurvBasicNav.chkKidMapTrue | protected function chkKidMapTrue($nID)
{
$found = false;
if (sizeof($this->kidMaps) > 0) {
foreach ($this->kidMaps as $parent => $kids) {
if (sizeof($kids) > 0) {
foreach ($kids as $nKid => $ress) {
if ($nID == $nKid && sizeof($ress) > 0) {
$found = true;
foreach ($ress as $cnt => $res) {
if (isset($res[2]) && $res[2]) {
return 1;
}
}
}
}
}
}
}
return (($found) ? -1 : 0);
} | php | protected function chkKidMapTrue($nID)
{
$found = false;
if (sizeof($this->kidMaps) > 0) {
foreach ($this->kidMaps as $parent => $kids) {
if (sizeof($kids) > 0) {
foreach ($kids as $nKid => $ress) {
if ($nID == $nKid && sizeof($ress) > 0) {
$found = true;
foreach ($ress as $cnt => $res) {
if (isset($res[2]) && $res[2]) {
return 1;
}
}
}
}
}
}
}
return (($found) ? -1 : 0);
} | [
"protected",
"function",
"chkKidMapTrue",
"(",
"$",
"nID",
")",
"{",
"$",
"found",
"=",
"false",
";",
"if",
"(",
"sizeof",
"(",
"$",
"this",
"->",
"kidMaps",
")",
">",
"0",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"kidMaps",
"as",
"$",
"parent"... | returns -1 if nID is a conditional kid, and is false | [
"returns",
"-",
"1",
"if",
"nID",
"is",
"a",
"conditional",
"kid",
"and",
"is",
"false"
] | 7fbd61a453e2ea8c3e55bbdd6b0bed1c859c8f4a | https://github.com/wikiworldorder/survloop/blob/7fbd61a453e2ea8c3e55bbdd6b0bed1c859c8f4a/src/Controllers/Tree/TreeSurvBasicNav.php#L24-L44 | train |
usemarkup/contentful | src/Contentful.php | Contentful.getContentTypeByName | public function getContentTypeByName($name, $space, array $options = [])
{
$envelope = $this->findEnvelopeForSpace($space);
$promise = coroutine(
function () use ($name, $space, $envelope, $options) {
$contentTypeFromEnvelope = $envelope->findContentTypeByName($name);
if ($contentTypeFromEnvelope) {
yield promise_for($contentTypeFromEnvelope);
return;
}
$contentTypes = (yield $this->getContentTypes([], $space, array_merge($options, ['async' => true])));
$foundContentType = null;
foreach ($contentTypes as $contentType) {
if ($contentType->getName() === $name) {
$foundContentType = $contentType;
}
$envelope->insertContentType($contentType);
}
yield $foundContentType;
}
);
return (isset($options['async']) && $options['async']) ? $promise : $promise->wait();
} | php | public function getContentTypeByName($name, $space, array $options = [])
{
$envelope = $this->findEnvelopeForSpace($space);
$promise = coroutine(
function () use ($name, $space, $envelope, $options) {
$contentTypeFromEnvelope = $envelope->findContentTypeByName($name);
if ($contentTypeFromEnvelope) {
yield promise_for($contentTypeFromEnvelope);
return;
}
$contentTypes = (yield $this->getContentTypes([], $space, array_merge($options, ['async' => true])));
$foundContentType = null;
foreach ($contentTypes as $contentType) {
if ($contentType->getName() === $name) {
$foundContentType = $contentType;
}
$envelope->insertContentType($contentType);
}
yield $foundContentType;
}
);
return (isset($options['async']) && $options['async']) ? $promise : $promise->wait();
} | [
"public",
"function",
"getContentTypeByName",
"(",
"$",
"name",
",",
"$",
"space",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"envelope",
"=",
"$",
"this",
"->",
"findEnvelopeForSpace",
"(",
"$",
"space",
")",
";",
"$",
"promise",
"=",... | Gets a content type using its name. Assumes content types have unique names. Returns null if no content type with the given name can be found.
@param string $name
@param string|SpaceInterface $space
@param array $options
@return ContentTypeInterface|PromiseInterface|null | [
"Gets",
"a",
"content",
"type",
"using",
"its",
"name",
".",
"Assumes",
"content",
"types",
"have",
"unique",
"names",
".",
"Returns",
"null",
"if",
"no",
"content",
"type",
"with",
"the",
"given",
"name",
"can",
"be",
"found",
"."
] | ac5902bf891c52fd00d349bd5aae78d516dcd601 | https://github.com/usemarkup/contentful/blob/ac5902bf891c52fd00d349bd5aae78d516dcd601/src/Contentful.php#L481-L505 | train |
usemarkup/contentful | src/Contentful.php | Contentful.flushCache | public function flushCache($spaceName)
{
$spaceData = $this->getSpaceDataForName($spaceName);
return $this->ensureCache($spaceData['cache'])->clear();
} | php | public function flushCache($spaceName)
{
$spaceData = $this->getSpaceDataForName($spaceName);
return $this->ensureCache($spaceData['cache'])->clear();
} | [
"public",
"function",
"flushCache",
"(",
"$",
"spaceName",
")",
"{",
"$",
"spaceData",
"=",
"$",
"this",
"->",
"getSpaceDataForName",
"(",
"$",
"spaceName",
")",
";",
"return",
"$",
"this",
"->",
"ensureCache",
"(",
"$",
"spaceData",
"[",
"'cache'",
"]",
... | Flushes the whole cache. Returns true if flush was successful, false otherwise.
@return bool | [
"Flushes",
"the",
"whole",
"cache",
".",
"Returns",
"true",
"if",
"flush",
"was",
"successful",
"false",
"otherwise",
"."
] | ac5902bf891c52fd00d349bd5aae78d516dcd601 | https://github.com/usemarkup/contentful/blob/ac5902bf891c52fd00d349bd5aae78d516dcd601/src/Contentful.php#L581-L586 | train |
usemarkup/contentful | src/Contentful.php | Contentful.completeParameter | private function completeParameter(ParameterInterface $parameter, $spaceName)
{
if (!$parameter instanceof IncompleteParameterInterface) {
return $parameter;
}
switch ($parameter->getName()) {
case 'content_type_name':
$contentTypeFilter = $this->resolveContentTypeNameFilter($parameter, $spaceName);
if (null === $contentTypeFilter) {
throw new \RuntimeException(sprintf('Could not resolve content type with name "%s".', $parameter->getValue()));
}
return $contentTypeFilter;
break;
default:
throw new \LogicException(sprintf('Unknown incomplete parameter of type "%s" is being used.', $parameter->getName()));
break;
}
} | php | private function completeParameter(ParameterInterface $parameter, $spaceName)
{
if (!$parameter instanceof IncompleteParameterInterface) {
return $parameter;
}
switch ($parameter->getName()) {
case 'content_type_name':
$contentTypeFilter = $this->resolveContentTypeNameFilter($parameter, $spaceName);
if (null === $contentTypeFilter) {
throw new \RuntimeException(sprintf('Could not resolve content type with name "%s".', $parameter->getValue()));
}
return $contentTypeFilter;
break;
default:
throw new \LogicException(sprintf('Unknown incomplete parameter of type "%s" is being used.', $parameter->getName()));
break;
}
} | [
"private",
"function",
"completeParameter",
"(",
"ParameterInterface",
"$",
"parameter",
",",
"$",
"spaceName",
")",
"{",
"if",
"(",
"!",
"$",
"parameter",
"instanceof",
"IncompleteParameterInterface",
")",
"{",
"return",
"$",
"parameter",
";",
"}",
"switch",
"(... | Ensures that the provided parameter is complete.
@param ParameterInterface $parameter
@param string $spaceName
@return ParameterInterface | [
"Ensures",
"that",
"the",
"provided",
"parameter",
"is",
"complete",
"."
] | ac5902bf891c52fd00d349bd5aae78d516dcd601 | https://github.com/usemarkup/contentful/blob/ac5902bf891c52fd00d349bd5aae78d516dcd601/src/Contentful.php#L1093-L1112 | train |
apioo/psx-framework | src/Controller/SchemaApiAbstract.php | SchemaApiAbstract.parseRequest | protected function parseRequest(RequestInterface $request, MethodAbstract $method)
{
if ($method->hasRequest()) {
$schema = $method->getRequest();
if ($schema instanceof Passthru) {
$data = $this->requestReader->getBody($request);
} elseif ($schema instanceof SchemaInterface) {
$data = $this->requestReader->getBodyAs($request, $method->getRequest(), $this->getValidator($method));
} else {
$data = new Record();
}
} else {
$data = null;
}
return $data;
} | php | protected function parseRequest(RequestInterface $request, MethodAbstract $method)
{
if ($method->hasRequest()) {
$schema = $method->getRequest();
if ($schema instanceof Passthru) {
$data = $this->requestReader->getBody($request);
} elseif ($schema instanceof SchemaInterface) {
$data = $this->requestReader->getBodyAs($request, $method->getRequest(), $this->getValidator($method));
} else {
$data = new Record();
}
} else {
$data = null;
}
return $data;
} | [
"protected",
"function",
"parseRequest",
"(",
"RequestInterface",
"$",
"request",
",",
"MethodAbstract",
"$",
"method",
")",
"{",
"if",
"(",
"$",
"method",
"->",
"hasRequest",
"(",
")",
")",
"{",
"$",
"schema",
"=",
"$",
"method",
"->",
"getRequest",
"(",
... | Imports the request data based on the schema if available
@param \PSX\Http\RequestInterface $request
@param \PSX\Api\Resource\MethodAbstract $method
@return \PSX\Record\RecordInterface | [
"Imports",
"the",
"request",
"data",
"based",
"on",
"the",
"schema",
"if",
"available"
] | e8e550a1a87dae49b615b42a05583395088c1efb | https://github.com/apioo/psx-framework/blob/e8e550a1a87dae49b615b42a05583395088c1efb/src/Controller/SchemaApiAbstract.php#L270-L286 | train |
apioo/psx-framework | src/Controller/SchemaApiAbstract.php | SchemaApiAbstract.sendResponse | private function sendResponse(MethodAbstract $method, RequestInterface $request, ResponseInterface $response, $data)
{
$statusCode = $response->getStatusCode();
if (empty($statusCode)) {
// in case we have only one defined response use this code
$responses = $method->getResponses();
if (count($responses) == 1) {
$statusCode = key($responses);
} else {
$statusCode = 200;
}
$response->setStatus($statusCode);
}
$this->responseWriter->setBody($response, $data, $request);
} | php | private function sendResponse(MethodAbstract $method, RequestInterface $request, ResponseInterface $response, $data)
{
$statusCode = $response->getStatusCode();
if (empty($statusCode)) {
// in case we have only one defined response use this code
$responses = $method->getResponses();
if (count($responses) == 1) {
$statusCode = key($responses);
} else {
$statusCode = 200;
}
$response->setStatus($statusCode);
}
$this->responseWriter->setBody($response, $data, $request);
} | [
"private",
"function",
"sendResponse",
"(",
"MethodAbstract",
"$",
"method",
",",
"RequestInterface",
"$",
"request",
",",
"ResponseInterface",
"$",
"response",
",",
"$",
"data",
")",
"{",
"$",
"statusCode",
"=",
"$",
"response",
"->",
"getStatusCode",
"(",
")... | Checks whether a response schema is defined for the provided status code
and writes the data to the body if a status code is available. Otherwise
the API returns 204 no content
@param \PSX\Api\Resource\MethodAbstract $method
@param \PSX\Http\RequestInterface $request
@param \PSX\Http\ResponseInterface $response
@param mixed $data | [
"Checks",
"whether",
"a",
"response",
"schema",
"is",
"defined",
"for",
"the",
"provided",
"status",
"code",
"and",
"writes",
"the",
"data",
"to",
"the",
"body",
"if",
"a",
"status",
"code",
"is",
"available",
".",
"Otherwise",
"the",
"API",
"returns",
"20... | e8e550a1a87dae49b615b42a05583395088c1efb | https://github.com/apioo/psx-framework/blob/e8e550a1a87dae49b615b42a05583395088c1efb/src/Controller/SchemaApiAbstract.php#L309-L325 | train |
apioo/psx-framework | src/Controller/SchemaApiAbstract.php | SchemaApiAbstract.getResource | private function getResource()
{
$resource = $this->resourceListing->getResource($this->context->getPath(), $this->context->getVersion());
if (!$resource instanceof Resource) {
throw new StatusCode\InternalServerErrorException('Resource is not available');
}
return $resource;
} | php | private function getResource()
{
$resource = $this->resourceListing->getResource($this->context->getPath(), $this->context->getVersion());
if (!$resource instanceof Resource) {
throw new StatusCode\InternalServerErrorException('Resource is not available');
}
return $resource;
} | [
"private",
"function",
"getResource",
"(",
")",
"{",
"$",
"resource",
"=",
"$",
"this",
"->",
"resourceListing",
"->",
"getResource",
"(",
"$",
"this",
"->",
"context",
"->",
"getPath",
"(",
")",
",",
"$",
"this",
"->",
"context",
"->",
"getVersion",
"("... | Returns the resource from the listing for the current path
@return \PSX\Api\Resource | [
"Returns",
"the",
"resource",
"from",
"the",
"listing",
"for",
"the",
"current",
"path"
] | e8e550a1a87dae49b615b42a05583395088c1efb | https://github.com/apioo/psx-framework/blob/e8e550a1a87dae49b615b42a05583395088c1efb/src/Controller/SchemaApiAbstract.php#L332-L341 | train |
usemarkup/contentful | src/Promise/ContentTypePromise.php | ContentTypePromise.getField | public function getField($fieldId)
{
$resolved = $this->getResolved();
if (!$resolved instanceof ContentTypeInterface) {
return null;
}
return $resolved->getField($fieldId);
} | php | public function getField($fieldId)
{
$resolved = $this->getResolved();
if (!$resolved instanceof ContentTypeInterface) {
return null;
}
return $resolved->getField($fieldId);
} | [
"public",
"function",
"getField",
"(",
"$",
"fieldId",
")",
"{",
"$",
"resolved",
"=",
"$",
"this",
"->",
"getResolved",
"(",
")",
";",
"if",
"(",
"!",
"$",
"resolved",
"instanceof",
"ContentTypeInterface",
")",
"{",
"return",
"null",
";",
"}",
"return",... | Returns the content type field matching the passed ID, or null if field does not exist.
@param string $fieldId
@return ContentTypeFieldInterface|null | [
"Returns",
"the",
"content",
"type",
"field",
"matching",
"the",
"passed",
"ID",
"or",
"null",
"if",
"field",
"does",
"not",
"exist",
"."
] | ac5902bf891c52fd00d349bd5aae78d516dcd601 | https://github.com/usemarkup/contentful/blob/ac5902bf891c52fd00d349bd5aae78d516dcd601/src/Promise/ContentTypePromise.php#L60-L68 | train |
orchestral/model | src/Memory/UserProvider.php | UserProvider.get | public function get(string $key = null, $default = null)
{
$key = \str_replace('.', '/user-', $key);
$value = Arr::get($this->items, $key);
// We need to consider if the value pending to be deleted,
// in this case return the default.
if ($value === ':to-be-deleted:') {
return \value($default);
}
// If the result is available from data, simply return it so we
// don't have to fetch the same result again from the database.
if (! \is_null($value)) {
return $value;
}
if (\is_null($value = $this->handler->retrieve($key))) {
return \value($default);
}
$this->put($key, $value);
return $value;
} | php | public function get(string $key = null, $default = null)
{
$key = \str_replace('.', '/user-', $key);
$value = Arr::get($this->items, $key);
// We need to consider if the value pending to be deleted,
// in this case return the default.
if ($value === ':to-be-deleted:') {
return \value($default);
}
// If the result is available from data, simply return it so we
// don't have to fetch the same result again from the database.
if (! \is_null($value)) {
return $value;
}
if (\is_null($value = $this->handler->retrieve($key))) {
return \value($default);
}
$this->put($key, $value);
return $value;
} | [
"public",
"function",
"get",
"(",
"string",
"$",
"key",
"=",
"null",
",",
"$",
"default",
"=",
"null",
")",
"{",
"$",
"key",
"=",
"\\",
"str_replace",
"(",
"'.'",
",",
"'/user-'",
",",
"$",
"key",
")",
";",
"$",
"value",
"=",
"Arr",
"::",
"get",
... | Get value of a key.
@param string $key
@param mixed $default
@return mixed | [
"Get",
"value",
"of",
"a",
"key",
"."
] | 59eb60a022afb3caa0ac5824d6faac85f3255c0d | https://github.com/orchestral/model/blob/59eb60a022afb3caa0ac5824d6faac85f3255c0d/src/Memory/UserProvider.php#L18-L42 | train |
dreamfactorysoftware/df-script | src/Services/Python.php | Python.isJson | protected function isJson($string)
{
$output = json_decode($string, true);
if ($output === null) {
return false;
}
return true;
} | php | protected function isJson($string)
{
$output = json_decode($string, true);
if ($output === null) {
return false;
}
return true;
} | [
"protected",
"function",
"isJson",
"(",
"$",
"string",
")",
"{",
"$",
"output",
"=",
"json_decode",
"(",
"$",
"string",
",",
"true",
")",
";",
"if",
"(",
"$",
"output",
"===",
"null",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}... | Checks to see if a string is valid json or not.
@param $string
@return bool | [
"Checks",
"to",
"see",
"if",
"a",
"string",
"is",
"valid",
"json",
"or",
"not",
"."
] | 14941f5dada6077286a0d992d6aa8c3d9243d5a0 | https://github.com/dreamfactorysoftware/df-script/blob/14941f5dada6077286a0d992d6aa8c3d9243d5a0/src/Services/Python.php#L67-L75 | train |
AbcAeffchen/SepaDocumentor | src/BasicDocumentor.php | BasicDocumentor.getTemplate | protected static function getTemplate($path)
{
if(file_exists($path))
$template = file_get_contents($path);
elseif(file_exists(__DIR__ . '/templates/' . $path))
$template = file_get_contents(__DIR__ . '/templates/' . $path);
else
throw new \InvalidArgumentException('Template file not found.');
return $template;
} | php | protected static function getTemplate($path)
{
if(file_exists($path))
$template = file_get_contents($path);
elseif(file_exists(__DIR__ . '/templates/' . $path))
$template = file_get_contents(__DIR__ . '/templates/' . $path);
else
throw new \InvalidArgumentException('Template file not found.');
return $template;
} | [
"protected",
"static",
"function",
"getTemplate",
"(",
"$",
"path",
")",
"{",
"if",
"(",
"file_exists",
"(",
"$",
"path",
")",
")",
"$",
"template",
"=",
"file_get_contents",
"(",
"$",
"path",
")",
";",
"elseif",
"(",
"file_exists",
"(",
"__DIR__",
".",
... | Tries to load the content of a template file in path. If this is not possible, an
exception is thrown.
@param string $path
@return string
@throws \InvalidArgumentException | [
"Tries",
"to",
"load",
"the",
"content",
"of",
"a",
"template",
"file",
"in",
"path",
".",
"If",
"this",
"is",
"not",
"possible",
"an",
"exception",
"is",
"thrown",
"."
] | f9f980a7f2e02505816e6e8dcd6ee1e65b279e51 | https://github.com/AbcAeffchen/SepaDocumentor/blob/f9f980a7f2e02505816e6e8dcd6ee1e65b279e51/src/BasicDocumentor.php#L27-L37 | train |
syzygypl/kunstmaan-extra-bundle | src/Session/RedisSessionHandler.php | RedisSessionHandler.read | public function read($sessionId)
{
$sessionId = $this->keyPrefix . $sessionId;
$sessionData = $this->redis->get($sessionId);
$this->redis->expire($sessionId, $this->maxLifetime);
return $sessionData;
} | php | public function read($sessionId)
{
$sessionId = $this->keyPrefix . $sessionId;
$sessionData = $this->redis->get($sessionId);
$this->redis->expire($sessionId, $this->maxLifetime);
return $sessionData;
} | [
"public",
"function",
"read",
"(",
"$",
"sessionId",
")",
"{",
"$",
"sessionId",
"=",
"$",
"this",
"->",
"keyPrefix",
".",
"$",
"sessionId",
";",
"$",
"sessionData",
"=",
"$",
"this",
"->",
"redis",
"->",
"get",
"(",
"$",
"sessionId",
")",
";",
"$",
... | Read the session data from Redis.
@param string $sessionId The session id.
@return string The serialized session data. | [
"Read",
"the",
"session",
"data",
"from",
"Redis",
"."
] | 973d7226c3b19504e89a620cf045efb94e021c62 | https://github.com/syzygypl/kunstmaan-extra-bundle/blob/973d7226c3b19504e89a620cf045efb94e021c62/src/Session/RedisSessionHandler.php#L58-L66 | train |
kbond/ZenstruckRedirectBundle | src/Service/NotFoundManager.php | NotFoundManager.removeForRedirect | public function removeForRedirect(Redirect $redirect)
{
$notFounds = $this->om->getRepository($this->class)->findBy(array('path' => $redirect->getSource()));
foreach ($notFounds as $notFound) {
$this->om->remove($notFound);
}
$this->om->flush();
} | php | public function removeForRedirect(Redirect $redirect)
{
$notFounds = $this->om->getRepository($this->class)->findBy(array('path' => $redirect->getSource()));
foreach ($notFounds as $notFound) {
$this->om->remove($notFound);
}
$this->om->flush();
} | [
"public",
"function",
"removeForRedirect",
"(",
"Redirect",
"$",
"redirect",
")",
"{",
"$",
"notFounds",
"=",
"$",
"this",
"->",
"om",
"->",
"getRepository",
"(",
"$",
"this",
"->",
"class",
")",
"->",
"findBy",
"(",
"array",
"(",
"'path'",
"=>",
"$",
... | Deletes NotFound entities for a Redirect's path.
@param Redirect $redirect | [
"Deletes",
"NotFound",
"entities",
"for",
"a",
"Redirect",
"s",
"path",
"."
] | 52379e23a372c3c4209b48f5f51229a2ef9e5de2 | https://github.com/kbond/ZenstruckRedirectBundle/blob/52379e23a372c3c4209b48f5f51229a2ef9e5de2/src/Service/NotFoundManager.php#L53-L62 | train |
syzygypl/kunstmaan-extra-bundle | src/SiteTree/PublicNodeVersions.php | PublicNodeVersions.getRef | public function getRef($nodeVersionId)
{
$this->initNodeVersions();
return isset($this->refs[$nodeVersionId]) ? $this->refs[$nodeVersionId] : null;
} | php | public function getRef($nodeVersionId)
{
$this->initNodeVersions();
return isset($this->refs[$nodeVersionId]) ? $this->refs[$nodeVersionId] : null;
} | [
"public",
"function",
"getRef",
"(",
"$",
"nodeVersionId",
")",
"{",
"$",
"this",
"->",
"initNodeVersions",
"(",
")",
";",
"return",
"isset",
"(",
"$",
"this",
"->",
"refs",
"[",
"$",
"nodeVersionId",
"]",
")",
"?",
"$",
"this",
"->",
"refs",
"[",
"$... | Gets Page Id for given NodeVersion Id
@param integer$nodeVersionId
@return integer|null | [
"Gets",
"Page",
"Id",
"for",
"given",
"NodeVersion",
"Id"
] | 973d7226c3b19504e89a620cf045efb94e021c62 | https://github.com/syzygypl/kunstmaan-extra-bundle/blob/973d7226c3b19504e89a620cf045efb94e021c62/src/SiteTree/PublicNodeVersions.php#L140-L145 | train |
syzygypl/kunstmaan-extra-bundle | src/SiteTree/PublicNodeVersions.php | PublicNodeVersions.getNodeRef | public function getNodeRef($nodeId, $lang = null)
{
$this->initNodeVersions();
$lang = $lang ?: $this->currentLocale->getCurrentLocale();
return isset($this->nodeRefs[$lang][$nodeId]) ? $this->nodeRefs[$lang][$nodeId] : null;
} | php | public function getNodeRef($nodeId, $lang = null)
{
$this->initNodeVersions();
$lang = $lang ?: $this->currentLocale->getCurrentLocale();
return isset($this->nodeRefs[$lang][$nodeId]) ? $this->nodeRefs[$lang][$nodeId] : null;
} | [
"public",
"function",
"getNodeRef",
"(",
"$",
"nodeId",
",",
"$",
"lang",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"initNodeVersions",
"(",
")",
";",
"$",
"lang",
"=",
"$",
"lang",
"?",
":",
"$",
"this",
"->",
"currentLocale",
"->",
"getCurrentLocale"... | Gets Page Id for given Node Id
@param integer $nodeId
@param string $lang
@return int|null | [
"Gets",
"Page",
"Id",
"for",
"given",
"Node",
"Id"
] | 973d7226c3b19504e89a620cf045efb94e021c62 | https://github.com/syzygypl/kunstmaan-extra-bundle/blob/973d7226c3b19504e89a620cf045efb94e021c62/src/SiteTree/PublicNodeVersions.php#L155-L162 | train |
MAXakaWIZARD/PoParser | src/Parser.php | Parser.read | public function read($filePath)
{
$this->rawEntries = array();
$this->currentEntry = $this->createNewEntryAsArray();
$this->state = null;
$this->justNewEntry = false;
$handle = $this->openFile($filePath);
while (!feof($handle)) {
$line = trim(fgets($handle));
$this->processLine($line);
}
fclose($handle);
$this->addFinalEntry();
$this->prepareResults();
return $this->entriesAsArrays;
} | php | public function read($filePath)
{
$this->rawEntries = array();
$this->currentEntry = $this->createNewEntryAsArray();
$this->state = null;
$this->justNewEntry = false;
$handle = $this->openFile($filePath);
while (!feof($handle)) {
$line = trim(fgets($handle));
$this->processLine($line);
}
fclose($handle);
$this->addFinalEntry();
$this->prepareResults();
return $this->entriesAsArrays;
} | [
"public",
"function",
"read",
"(",
"$",
"filePath",
")",
"{",
"$",
"this",
"->",
"rawEntries",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"currentEntry",
"=",
"$",
"this",
"->",
"createNewEntryAsArray",
"(",
")",
";",
"$",
"this",
"->",
"state",
... | Reads and parses strings in a .po file.
return An array of entries located in the file:
Format: array(
'msgid' => <string> ID of the message.
'msgctxt' => <string> Message context.
'msgstr' => <string> Message translation.
'tcomment' => <string> Comment from translator.
'ccomment' => <string> Extracted comments from code.
'references' => <array> Location of string in code.
'obsolete' => <bool> Is the message obsolete?
'fuzzy' => <bool> Is the message "fuzzy"?
'flags' => <array> Flags of the entry. Internal usage.
)
#~ (old entry)
# @ default
#, fuzzy
#~ msgid "Editar datos"
#~ msgstr "editar dades"
@param string $filePath
@throws \Exception
@return array|bool | [
"Reads",
"and",
"parses",
"strings",
"in",
"a",
".",
"po",
"file",
"."
] | f229850f73edc681f71f5527bf10945f7bf2f994 | https://github.com/MAXakaWIZARD/PoParser/blob/f229850f73edc681f71f5527bf10945f7bf2f994/src/Parser.php#L84-L102 | train |
MAXakaWIZARD/PoParser | src/Parser.php | Parser.prepareResults | protected function prepareResults()
{
$this->entriesAsArrays = array();
$this->entries = array();
$this->headers = array();
$counter = 0;
foreach ($this->rawEntries as $entry) {
$entry = $this->prepareEntry($entry, $counter);
$id = $this->getMsgId($entry);
$this->entriesAsArrays[$id] = $entry;
$this->entries[$id] = new Entry($entry);
$counter++;
}
return true;
} | php | protected function prepareResults()
{
$this->entriesAsArrays = array();
$this->entries = array();
$this->headers = array();
$counter = 0;
foreach ($this->rawEntries as $entry) {
$entry = $this->prepareEntry($entry, $counter);
$id = $this->getMsgId($entry);
$this->entriesAsArrays[$id] = $entry;
$this->entries[$id] = new Entry($entry);
$counter++;
}
return true;
} | [
"protected",
"function",
"prepareResults",
"(",
")",
"{",
"$",
"this",
"->",
"entriesAsArrays",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"entries",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"headers",
"=",
"array",
"(",
")",
";",
"$",
... | Cleanup data, merge multiline entries, reindex hash for ksort
@return bool | [
"Cleanup",
"data",
"merge",
"multiline",
"entries",
"reindex",
"hash",
"for",
"ksort"
] | f229850f73edc681f71f5527bf10945f7bf2f994 | https://github.com/MAXakaWIZARD/PoParser/blob/f229850f73edc681f71f5527bf10945f7bf2f994/src/Parser.php#L309-L328 | train |
MAXakaWIZARD/PoParser | src/Parser.php | Parser.removeFuzzyFlagForMsgId | protected function removeFuzzyFlagForMsgId($msgid)
{
if (!isset($this->entriesAsArrays[$msgid])) {
throw new \Exception('Entry does not exist');
}
if ($this->entriesAsArrays[$msgid]['fuzzy']) {
$flags = $this->entriesAsArrays[$msgid]['flags'];
unset($flags[array_search('fuzzy', $flags, true)]);
$this->entriesAsArrays[$msgid]['flags'] = $flags;
$this->entriesAsArrays[$msgid]['fuzzy'] = false;
}
} | php | protected function removeFuzzyFlagForMsgId($msgid)
{
if (!isset($this->entriesAsArrays[$msgid])) {
throw new \Exception('Entry does not exist');
}
if ($this->entriesAsArrays[$msgid]['fuzzy']) {
$flags = $this->entriesAsArrays[$msgid]['flags'];
unset($flags[array_search('fuzzy', $flags, true)]);
$this->entriesAsArrays[$msgid]['flags'] = $flags;
$this->entriesAsArrays[$msgid]['fuzzy'] = false;
}
} | [
"protected",
"function",
"removeFuzzyFlagForMsgId",
"(",
"$",
"msgid",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"entriesAsArrays",
"[",
"$",
"msgid",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Entry does not exist'",
")... | Helper for the update-functions by deleting the fuzzy flag
@param $msgid string msgid of entry
@throws \Exception | [
"Helper",
"for",
"the",
"update",
"-",
"functions",
"by",
"deleting",
"the",
"fuzzy",
"flag"
] | f229850f73edc681f71f5527bf10945f7bf2f994 | https://github.com/MAXakaWIZARD/PoParser/blob/f229850f73edc681f71f5527bf10945f7bf2f994/src/Parser.php#L448-L459 | train |
MAXakaWIZARD/PoParser | src/Parser.php | Parser.updateEntries | public function updateEntries($msgid, $translation)
{
if (
!isset($this->entriesAsArrays[$msgid])
|| !is_array($translation)
|| sizeof($translation) != sizeof($this->entriesAsArrays[$msgid]['msgstr'])
) {
throw new \Exception('Cannot update entry translation');
}
$this->removeFuzzyFlagForMsgId($msgid);
$this->entriesAsArrays[$msgid]['msgstr'] = $translation;
} | php | public function updateEntries($msgid, $translation)
{
if (
!isset($this->entriesAsArrays[$msgid])
|| !is_array($translation)
|| sizeof($translation) != sizeof($this->entriesAsArrays[$msgid]['msgstr'])
) {
throw new \Exception('Cannot update entry translation');
}
$this->removeFuzzyFlagForMsgId($msgid);
$this->entriesAsArrays[$msgid]['msgstr'] = $translation;
} | [
"public",
"function",
"updateEntries",
"(",
"$",
"msgid",
",",
"$",
"translation",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"entriesAsArrays",
"[",
"$",
"msgid",
"]",
")",
"||",
"!",
"is_array",
"(",
"$",
"translation",
")",
"||",
"... | Allows modification of all translations of an entry
@param $msgid string msgid of the entry which should be updated
@param $translation array of strings new Translation for all msgstr by msgid
@throws \Exception | [
"Allows",
"modification",
"of",
"all",
"translations",
"of",
"an",
"entry"
] | f229850f73edc681f71f5527bf10945f7bf2f994 | https://github.com/MAXakaWIZARD/PoParser/blob/f229850f73edc681f71f5527bf10945f7bf2f994/src/Parser.php#L469-L480 | train |
MAXakaWIZARD/PoParser | src/Parser.php | Parser.updateEntry | public function updateEntry($msgid, $translation, $positionMsgstr = 0)
{
if (
!isset($this->entriesAsArrays[$msgid])
|| !is_string($translation)
|| !isset($this->entriesAsArrays[$msgid]['msgstr'][$positionMsgstr])
) {
throw new \Exception('Cannot update entry translation');
}
$this->removeFuzzyFlagForMsgId($msgid);
$this->entriesAsArrays[$msgid]['msgstr'][$positionMsgstr] = $translation;
} | php | public function updateEntry($msgid, $translation, $positionMsgstr = 0)
{
if (
!isset($this->entriesAsArrays[$msgid])
|| !is_string($translation)
|| !isset($this->entriesAsArrays[$msgid]['msgstr'][$positionMsgstr])
) {
throw new \Exception('Cannot update entry translation');
}
$this->removeFuzzyFlagForMsgId($msgid);
$this->entriesAsArrays[$msgid]['msgstr'][$positionMsgstr] = $translation;
} | [
"public",
"function",
"updateEntry",
"(",
"$",
"msgid",
",",
"$",
"translation",
",",
"$",
"positionMsgstr",
"=",
"0",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"entriesAsArrays",
"[",
"$",
"msgid",
"]",
")",
"||",
"!",
"is_string",
... | Allows modification of a single translation of an entry
@param $msgid string msgid of the entry which should be updated
@param $translation string new translation for an msgstr by msgid
@param $positionMsgstr integer spezification which of the msgstr
should be changed
@throws \Exception | [
"Allows",
"modification",
"of",
"a",
"single",
"translation",
"of",
"an",
"entry"
] | f229850f73edc681f71f5527bf10945f7bf2f994 | https://github.com/MAXakaWIZARD/PoParser/blob/f229850f73edc681f71f5527bf10945f7bf2f994/src/Parser.php#L492-L503 | train |
wikiworldorder/survloop | src/Controllers/Admin/AdminDatabaseInstall.php | AdminDatabaseInstall.manualMySql | public function manualMySql(Request $request)
{
$this->admControlInit($request, '/dashboard/db/all');
if ($this->v["uID"] == 1) { // && in_array($_SERVER["REMOTE_ADDR"], ['192.168.10.1'])) {
$this->v["manualMySql"] = 'Connected successfully<br />';
$db = mysqli_connect(env('DB_HOST', 'localhost'), env('DB_USERNAME', 'homestead'),
env('DB_PASSWORD', 'secret'), env('DB_DATABASE', 'homestead'));
if ($db->connect_error) {
$this->v["manualMySql"] = "Connection failed: " . $db->connect_error . '<br />';
}
$this->v["lastSql"] = '';
$this->v["lastResults"] = [];
if ($request->has('mys') && trim($request->mys) != '') {
$this->v["lastSql"] = trim($request->mys);
$this->v["manualMySql"] .= '<b>Statements submitted...</b><br />';
$statements = $GLOBALS["SL"]->mexplode(';', $request->mys);
foreach ($statements as $sql) {
$cnt = 0;
if (trim($sql) != '') {
ob_start();
$res = mysqli_query($db, $sql);
$errorCatch = ob_get_contents();
ob_end_clean();
$this->v["lastResults"][$cnt][0] = $sql;
$this->v["lastResults"][$cnt][1] = $errorCatch;
if ($res->isNotEmpty()) {
ob_start();
print_r($res);
$this->v["lastResults"][$cnt][2] = ob_get_contents();
ob_end_clean();
}
$cnt++;
}
}
}
mysqli_close($db);
return view('vendor.survloop.admin.db.manualMySql', $this->v);
}
return $this->redir('/dashboard/db/export');
} | php | public function manualMySql(Request $request)
{
$this->admControlInit($request, '/dashboard/db/all');
if ($this->v["uID"] == 1) { // && in_array($_SERVER["REMOTE_ADDR"], ['192.168.10.1'])) {
$this->v["manualMySql"] = 'Connected successfully<br />';
$db = mysqli_connect(env('DB_HOST', 'localhost'), env('DB_USERNAME', 'homestead'),
env('DB_PASSWORD', 'secret'), env('DB_DATABASE', 'homestead'));
if ($db->connect_error) {
$this->v["manualMySql"] = "Connection failed: " . $db->connect_error . '<br />';
}
$this->v["lastSql"] = '';
$this->v["lastResults"] = [];
if ($request->has('mys') && trim($request->mys) != '') {
$this->v["lastSql"] = trim($request->mys);
$this->v["manualMySql"] .= '<b>Statements submitted...</b><br />';
$statements = $GLOBALS["SL"]->mexplode(';', $request->mys);
foreach ($statements as $sql) {
$cnt = 0;
if (trim($sql) != '') {
ob_start();
$res = mysqli_query($db, $sql);
$errorCatch = ob_get_contents();
ob_end_clean();
$this->v["lastResults"][$cnt][0] = $sql;
$this->v["lastResults"][$cnt][1] = $errorCatch;
if ($res->isNotEmpty()) {
ob_start();
print_r($res);
$this->v["lastResults"][$cnt][2] = ob_get_contents();
ob_end_clean();
}
$cnt++;
}
}
}
mysqli_close($db);
return view('vendor.survloop.admin.db.manualMySql', $this->v);
}
return $this->redir('/dashboard/db/export');
} | [
"public",
"function",
"manualMySql",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"this",
"->",
"admControlInit",
"(",
"$",
"request",
",",
"'/dashboard/db/all'",
")",
";",
"if",
"(",
"$",
"this",
"->",
"v",
"[",
"\"uID\"",
"]",
"==",
"1",
")",
"{",
... | for emergency cases with questionable database access, this should only be temporarily included | [
"for",
"emergency",
"cases",
"with",
"questionable",
"database",
"access",
"this",
"should",
"only",
"be",
"temporarily",
"included"
] | 7fbd61a453e2ea8c3e55bbdd6b0bed1c859c8f4a | https://github.com/wikiworldorder/survloop/blob/7fbd61a453e2ea8c3e55bbdd6b0bed1c859c8f4a/src/Controllers/Admin/AdminDatabaseInstall.php#L504-L543 | train |
orchestral/model | src/Concerns/Metable.php | Metable.getOriginalMetaData | public function getOriginalMetaData(string $key, $default = null)
{
$meta = $this->accessMetableAttribute($this->getOriginal('meta'));
return $meta->get($key, $default);
} | php | public function getOriginalMetaData(string $key, $default = null)
{
$meta = $this->accessMetableAttribute($this->getOriginal('meta'));
return $meta->get($key, $default);
} | [
"public",
"function",
"getOriginalMetaData",
"(",
"string",
"$",
"key",
",",
"$",
"default",
"=",
"null",
")",
"{",
"$",
"meta",
"=",
"$",
"this",
"->",
"accessMetableAttribute",
"(",
"$",
"this",
"->",
"getOriginal",
"(",
"'meta'",
")",
")",
";",
"retur... | Get original meta data.
@param string $key
@param mixed $default
@return mixed | [
"Get",
"original",
"meta",
"data",
"."
] | 59eb60a022afb3caa0ac5824d6faac85f3255c0d | https://github.com/orchestral/model/blob/59eb60a022afb3caa0ac5824d6faac85f3255c0d/src/Concerns/Metable.php#L42-L47 | train |
orchestral/model | src/Concerns/Metable.php | Metable.getMetaData | public function getMetaData(string $key, $default = null)
{
$meta = $this->getAttribute('meta');
return $meta->get($key, $default);
} | php | public function getMetaData(string $key, $default = null)
{
$meta = $this->getAttribute('meta');
return $meta->get($key, $default);
} | [
"public",
"function",
"getMetaData",
"(",
"string",
"$",
"key",
",",
"$",
"default",
"=",
"null",
")",
"{",
"$",
"meta",
"=",
"$",
"this",
"->",
"getAttribute",
"(",
"'meta'",
")",
";",
"return",
"$",
"meta",
"->",
"get",
"(",
"$",
"key",
",",
"$",... | Get meta data.
@param string $key
@param mixed $default
@return mixed | [
"Get",
"meta",
"data",
"."
] | 59eb60a022afb3caa0ac5824d6faac85f3255c0d | https://github.com/orchestral/model/blob/59eb60a022afb3caa0ac5824d6faac85f3255c0d/src/Concerns/Metable.php#L57-L62 | train |
orchestral/model | src/Concerns/Metable.php | Metable.putMetaData | public function putMetaData($key, $value = null): void
{
$meta = $this->getAttribute('meta');
if (\is_array($key)) {
foreach ($key as $name => $value) {
$meta->put($name, $value);
}
} else {
$meta->put($key, $value);
}
$this->setMetaAttribute($meta);
} | php | public function putMetaData($key, $value = null): void
{
$meta = $this->getAttribute('meta');
if (\is_array($key)) {
foreach ($key as $name => $value) {
$meta->put($name, $value);
}
} else {
$meta->put($key, $value);
}
$this->setMetaAttribute($meta);
} | [
"public",
"function",
"putMetaData",
"(",
"$",
"key",
",",
"$",
"value",
"=",
"null",
")",
":",
"void",
"{",
"$",
"meta",
"=",
"$",
"this",
"->",
"getAttribute",
"(",
"'meta'",
")",
";",
"if",
"(",
"\\",
"is_array",
"(",
"$",
"key",
")",
")",
"{"... | Put meta data.
@param string|array $key
@param mixed $value
@return void | [
"Put",
"meta",
"data",
"."
] | 59eb60a022afb3caa0ac5824d6faac85f3255c0d | https://github.com/orchestral/model/blob/59eb60a022afb3caa0ac5824d6faac85f3255c0d/src/Concerns/Metable.php#L72-L85 | train |
orchestral/model | src/Concerns/Metable.php | Metable.forgetMetaData | public function forgetMetaData($key): void
{
$meta = $this->getAttribute('meta');
if (\is_array($key)) {
foreach ($key as $name) {
$meta->forget($name);
}
} else {
$meta->forget($key);
}
$this->setMetaAttribute($meta);
} | php | public function forgetMetaData($key): void
{
$meta = $this->getAttribute('meta');
if (\is_array($key)) {
foreach ($key as $name) {
$meta->forget($name);
}
} else {
$meta->forget($key);
}
$this->setMetaAttribute($meta);
} | [
"public",
"function",
"forgetMetaData",
"(",
"$",
"key",
")",
":",
"void",
"{",
"$",
"meta",
"=",
"$",
"this",
"->",
"getAttribute",
"(",
"'meta'",
")",
";",
"if",
"(",
"\\",
"is_array",
"(",
"$",
"key",
")",
")",
"{",
"foreach",
"(",
"$",
"key",
... | Forget meta data.
@param string|array $key
@return void | [
"Forget",
"meta",
"data",
"."
] | 59eb60a022afb3caa0ac5824d6faac85f3255c0d | https://github.com/orchestral/model/blob/59eb60a022afb3caa0ac5824d6faac85f3255c0d/src/Concerns/Metable.php#L94-L107 | train |
orchestral/model | src/Concerns/Metable.php | Metable.accessMetableAttribute | protected function accessMetableAttribute($value): Meta
{
$meta = [];
if ($value instanceof Meta) {
return $value;
} elseif (! \is_null($value)) {
$meta = $this->fromJson($value);
}
return new Meta($meta);
} | php | protected function accessMetableAttribute($value): Meta
{
$meta = [];
if ($value instanceof Meta) {
return $value;
} elseif (! \is_null($value)) {
$meta = $this->fromJson($value);
}
return new Meta($meta);
} | [
"protected",
"function",
"accessMetableAttribute",
"(",
"$",
"value",
")",
":",
"Meta",
"{",
"$",
"meta",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"value",
"instanceof",
"Meta",
")",
"{",
"return",
"$",
"value",
";",
"}",
"elseif",
"(",
"!",
"\\",
"is_nul... | Access meta attribute.
@param mixed $value
@return \Orchestra\Model\Value\Meta | [
"Access",
"meta",
"attribute",
"."
] | 59eb60a022afb3caa0ac5824d6faac85f3255c0d | https://github.com/orchestral/model/blob/59eb60a022afb3caa0ac5824d6faac85f3255c0d/src/Concerns/Metable.php#L116-L127 | train |
wikiworldorder/survloop | src/Controllers/Tree/TreeSurvNodeEdit.php | TreeSurvNodeEdit.updateTreeOpts | public function updateTreeOpts($treeID = -3)
{
$treeRow = $GLOBALS["SL"]->treeRow;
if ($treeID <= 0) {
$treeID = $GLOBALS["SL"]->treeID;
} else {
$treeRow = SLTree::find($treeID);
}
if ($treeRow->TreeType == 'Page') {
/* // auto-setting
$skipConds = [];
$testCond = SLConditions::where('CondTag', '#TestLink')
->where('CondDatabase', $treeRow->TreeDatabase)
->first();
if (!$testCond || !isset($testCond->CondID)) {
$testCond = SLConditions::where('CondTag', '#TestLink')
->first();
}
if ($testCond && isset($testCond->CondID)) $skipConds[] = $testCond->CondID;
$chk = DB::select( DB::raw( "SELECT c.`CondNodeCondID`, n.`NodeID` FROM `SL_ConditionsNodes` c
LEFT OUTER JOIN `SL_Node` n ON c.`CondNodeNodeID` LIKE n.`NodeID`
WHERE n.`NodeTree` LIKE '" . $treeID . "'" . ((sizeof($skipConds) > 0)
? " AND c.`CondNodeCondID` NOT IN ('" . implode("', '", $skipConds) . "')" : "") ) );
if ($chk && sizeof($chk)) {
if ($treeRow->TreeOpts%29 > 0) $treeRow->TreeOpts *= 29;
} else {
if ($treeRow->TreeOpts%29 == 0) $treeRow->TreeOpts = $treeRow->TreeOpts/29;
}
$treeRow->save();
*/
}
return true;
} | php | public function updateTreeOpts($treeID = -3)
{
$treeRow = $GLOBALS["SL"]->treeRow;
if ($treeID <= 0) {
$treeID = $GLOBALS["SL"]->treeID;
} else {
$treeRow = SLTree::find($treeID);
}
if ($treeRow->TreeType == 'Page') {
/* // auto-setting
$skipConds = [];
$testCond = SLConditions::where('CondTag', '#TestLink')
->where('CondDatabase', $treeRow->TreeDatabase)
->first();
if (!$testCond || !isset($testCond->CondID)) {
$testCond = SLConditions::where('CondTag', '#TestLink')
->first();
}
if ($testCond && isset($testCond->CondID)) $skipConds[] = $testCond->CondID;
$chk = DB::select( DB::raw( "SELECT c.`CondNodeCondID`, n.`NodeID` FROM `SL_ConditionsNodes` c
LEFT OUTER JOIN `SL_Node` n ON c.`CondNodeNodeID` LIKE n.`NodeID`
WHERE n.`NodeTree` LIKE '" . $treeID . "'" . ((sizeof($skipConds) > 0)
? " AND c.`CondNodeCondID` NOT IN ('" . implode("', '", $skipConds) . "')" : "") ) );
if ($chk && sizeof($chk)) {
if ($treeRow->TreeOpts%29 > 0) $treeRow->TreeOpts *= 29;
} else {
if ($treeRow->TreeOpts%29 == 0) $treeRow->TreeOpts = $treeRow->TreeOpts/29;
}
$treeRow->save();
*/
}
return true;
} | [
"public",
"function",
"updateTreeOpts",
"(",
"$",
"treeID",
"=",
"-",
"3",
")",
"{",
"$",
"treeRow",
"=",
"$",
"GLOBALS",
"[",
"\"SL\"",
"]",
"->",
"treeRow",
";",
"if",
"(",
"$",
"treeID",
"<=",
"0",
")",
"{",
"$",
"treeID",
"=",
"$",
"GLOBALS",
... | If none of this tree's nodes have conditions, this tree's cache is the most basic | [
"If",
"none",
"of",
"this",
"tree",
"s",
"nodes",
"have",
"conditions",
"this",
"tree",
"s",
"cache",
"is",
"the",
"most",
"basic"
] | 7fbd61a453e2ea8c3e55bbdd6b0bed1c859c8f4a | https://github.com/wikiworldorder/survloop/blob/7fbd61a453e2ea8c3e55bbdd6b0bed1c859c8f4a/src/Controllers/Tree/TreeSurvNodeEdit.php#L709-L741 | train |
crysalead/chaos-orm | src/Model.php | Model.shard | static function shard($collector = null) {
if (func_num_args()) {
if ($collector) {
static::$_shards[static::class] = $collector;
} else {
unset(static::$_shards[static::class]);
}
return;
}
if (!isset(static::$_shards[static::class])) {
static::$_shards[static::class] = new Map();
}
return static::$_shards[static::class];
} | php | static function shard($collector = null) {
if (func_num_args()) {
if ($collector) {
static::$_shards[static::class] = $collector;
} else {
unset(static::$_shards[static::class]);
}
return;
}
if (!isset(static::$_shards[static::class])) {
static::$_shards[static::class] = new Map();
}
return static::$_shards[static::class];
} | [
"static",
"function",
"shard",
"(",
"$",
"collector",
"=",
"null",
")",
"{",
"if",
"(",
"func_num_args",
"(",
")",
")",
"{",
"if",
"(",
"$",
"collector",
")",
"{",
"static",
"::",
"$",
"_shards",
"[",
"static",
"::",
"class",
"]",
"=",
"$",
"collec... | Get the shard attached to the model.
@param Map $collector The collector instance to set or none to get it.
@return Map The collector instance on get and `this` on set. | [
"Get",
"the",
"shard",
"attached",
"to",
"the",
"model",
"."
] | 835f891311bb30c9178910df7223d1cdfd269560 | https://github.com/crysalead/chaos-orm/blob/835f891311bb30c9178910df7223d1cdfd269560/src/Model.php#L115-L128 | train |
crysalead/chaos-orm | src/Model.php | Model.find | public static function find($options = [])
{
$options = Set::extend(static::query(), $options);
$schema = static::definition();
return $schema->query(['query' => $options] + ['finders' => static::finders()]);
} | php | public static function find($options = [])
{
$options = Set::extend(static::query(), $options);
$schema = static::definition();
return $schema->query(['query' => $options] + ['finders' => static::finders()]);
} | [
"public",
"static",
"function",
"find",
"(",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"options",
"=",
"Set",
"::",
"extend",
"(",
"static",
"::",
"query",
"(",
")",
",",
"$",
"options",
")",
";",
"$",
"schema",
"=",
"static",
"::",
"definition... | Finds a record by its primary key.
@param array $options Options for the query.
-`'conditions'` : The conditions array.
- other options depend on the ones supported by the query instance.
@return object An instance of `Query`. | [
"Finds",
"a",
"record",
"by",
"its",
"primary",
"key",
"."
] | 835f891311bb30c9178910df7223d1cdfd269560 | https://github.com/crysalead/chaos-orm/blob/835f891311bb30c9178910df7223d1cdfd269560/src/Model.php#L217-L222 | train |
crysalead/chaos-orm | src/Model.php | Model.load | public static function load($id, $options = [], $fetchOptions = [])
{
$options = ['conditions' => [static::definition()->key() => $id]] + $options;
return static::find($options)->first($fetchOptions);
} | php | public static function load($id, $options = [], $fetchOptions = [])
{
$options = ['conditions' => [static::definition()->key() => $id]] + $options;
return static::find($options)->first($fetchOptions);
} | [
"public",
"static",
"function",
"load",
"(",
"$",
"id",
",",
"$",
"options",
"=",
"[",
"]",
",",
"$",
"fetchOptions",
"=",
"[",
"]",
")",
"{",
"$",
"options",
"=",
"[",
"'conditions'",
"=>",
"[",
"static",
"::",
"definition",
"(",
")",
"->",
"key",... | Finds a record by its ID.
@param mixed $id The id to retreive.
@param array $fetchOptions The fecthing options.
@return mixed The result. | [
"Finds",
"a",
"record",
"by",
"its",
"ID",
"."
] | 835f891311bb30c9178910df7223d1cdfd269560 | https://github.com/crysalead/chaos-orm/blob/835f891311bb30c9178910df7223d1cdfd269560/src/Model.php#L255-L259 | train |
crysalead/chaos-orm | src/Model.php | Model.reset | public static function reset()
{
unset(static::$_dependencies[static::class]);
static::conventions(null);
static::connection(null);
static::definition(null);
static::validator(null);
static::query([]);
unset(static::$_unicities[static::class]);
unset(static::$_definitions[static::class]);
unset(static::$_shards[static::class]);
} | php | public static function reset()
{
unset(static::$_dependencies[static::class]);
static::conventions(null);
static::connection(null);
static::definition(null);
static::validator(null);
static::query([]);
unset(static::$_unicities[static::class]);
unset(static::$_definitions[static::class]);
unset(static::$_shards[static::class]);
} | [
"public",
"static",
"function",
"reset",
"(",
")",
"{",
"unset",
"(",
"static",
"::",
"$",
"_dependencies",
"[",
"static",
"::",
"class",
"]",
")",
";",
"static",
"::",
"conventions",
"(",
"null",
")",
";",
"static",
"::",
"connection",
"(",
"null",
")... | Reset the Model class. | [
"Reset",
"the",
"Model",
"class",
"."
] | 835f891311bb30c9178910df7223d1cdfd269560 | https://github.com/crysalead/chaos-orm/blob/835f891311bb30c9178910df7223d1cdfd269560/src/Model.php#L338-L349 | train |
crysalead/chaos-orm | src/Model.php | Model.fetch | public function fetch($name)
{
return $this->get($name, function($instance, $name) {
$collection = [$instance];
$this->schema()->embed($collection, $name);
return isset($this->_data[$name]) ? $this->_data[$name] : null;
});
} | php | public function fetch($name)
{
return $this->get($name, function($instance, $name) {
$collection = [$instance];
$this->schema()->embed($collection, $name);
return isset($this->_data[$name]) ? $this->_data[$name] : null;
});
} | [
"public",
"function",
"fetch",
"(",
"$",
"name",
")",
"{",
"return",
"$",
"this",
"->",
"get",
"(",
"$",
"name",
",",
"function",
"(",
"$",
"instance",
",",
"$",
"name",
")",
"{",
"$",
"collection",
"=",
"[",
"$",
"instance",
"]",
";",
"$",
"this... | Lazy load a relation and return its data.
@param string name The name of the relation to load.
@return mixed. | [
"Lazy",
"load",
"a",
"relation",
"and",
"return",
"its",
"data",
"."
] | 835f891311bb30c9178910df7223d1cdfd269560 | https://github.com/crysalead/chaos-orm/blob/835f891311bb30c9178910df7223d1cdfd269560/src/Model.php#L450-L457 | train |
crysalead/chaos-orm | src/Model.php | Model.sync | public function sync($data = false)
{
if ($this->_exists !== null) {
return;
}
$id = $this->id();
if ($id !== null) {
$persisted = static::load($id);
if ($persisted && $data) {
$this->amend($persisted->data(), ['exists' => true]);
} else {
$this->_exists = !!$persisted;
}
} else {
$this->_exists = false;
}
} | php | public function sync($data = false)
{
if ($this->_exists !== null) {
return;
}
$id = $this->id();
if ($id !== null) {
$persisted = static::load($id);
if ($persisted && $data) {
$this->amend($persisted->data(), ['exists' => true]);
} else {
$this->_exists = !!$persisted;
}
} else {
$this->_exists = false;
}
} | [
"public",
"function",
"sync",
"(",
"$",
"data",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_exists",
"!==",
"null",
")",
"{",
"return",
";",
"}",
"$",
"id",
"=",
"$",
"this",
"->",
"id",
"(",
")",
";",
"if",
"(",
"$",
"id",
"!==",... | Sync the entity existence from the database.
@param boolean $data Indicate whether the data need to by synced or not. | [
"Sync",
"the",
"entity",
"existence",
"from",
"the",
"database",
"."
] | 835f891311bb30c9178910df7223d1cdfd269560 | https://github.com/crysalead/chaos-orm/blob/835f891311bb30c9178910df7223d1cdfd269560/src/Model.php#L553-L569 | train |
crysalead/chaos-orm | src/Model.php | Model.validates | public function validates($options = [])
{
$this->sync();
$exists = $this->exists();
$defaults = [
'events' => $exists ? 'update' : 'create',
'required' => $exists ? false : true,
'entity' => $this,
'embed' => true
];
$options += $defaults;
$validator = static::validator();
$valid = $this->_validates(['embed' => $options['embed']]);
$success = $validator->validates($this->get(), $options);
$this->_errors = [];
$this->invalidate($validator->errors());
return $success && $valid;
} | php | public function validates($options = [])
{
$this->sync();
$exists = $this->exists();
$defaults = [
'events' => $exists ? 'update' : 'create',
'required' => $exists ? false : true,
'entity' => $this,
'embed' => true
];
$options += $defaults;
$validator = static::validator();
$valid = $this->_validates(['embed' => $options['embed']]);
$success = $validator->validates($this->get(), $options);
$this->_errors = [];
$this->invalidate($validator->errors());
return $success && $valid;
} | [
"public",
"function",
"validates",
"(",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"sync",
"(",
")",
";",
"$",
"exists",
"=",
"$",
"this",
"->",
"exists",
"(",
")",
";",
"$",
"defaults",
"=",
"[",
"'events'",
"=>",
"$",
"exists",... | Validates the entity data.
@param array $options Available options:
- `'events'` _mixed_ : A string or array defining one or more validation
events. Events are different contexts in which data events can occur, and
correspond to the optional `'on'` key in validation rules. For example, by
default, `'events'` is set to either `'create'` or `'update'`, depending on
whether the entity already exists. Then, individual rules can specify
`'on' => 'create'` or `'on' => 'update'` to only be applied at certain times.
You can also set up custom events in your rules as well, such as `'on' => 'login'`.
Note that when defining validation rules, the `'on'` key can also be an array of
multiple events.
- `'required'` _boolean_ : Sets the validation rules `'required'` default value.
- `'embed'` _array_ : List of relations to validate.
@return boolean Returns `true` if all validation rules on all fields succeed, otherwise
`false`. After validation, the messages for any validation failures are assigned
to the entity, and accessible through the `errors()` method of the entity object. | [
"Validates",
"the",
"entity",
"data",
"."
] | 835f891311bb30c9178910df7223d1cdfd269560 | https://github.com/crysalead/chaos-orm/blob/835f891311bb30c9178910df7223d1cdfd269560/src/Model.php#L602-L621 | train |
crysalead/chaos-orm | src/Model.php | Model._validates | protected function _validates($options)
{
$defaults = ['embed' => true];
$options += $defaults;
if ($options['embed'] === true) {
$options['embed'] = $this->hierarchy();
}
$schema = $this->schema();
$tree = $schema->treeify($options['embed']);
$success = true;
foreach ($tree as $field => $value) {
if (isset($this->{$field})) {
$rel = $schema->relation($field);
$success = $success && $rel->validates($this, $value ? $value + $options : $options);
}
}
return $success;
} | php | protected function _validates($options)
{
$defaults = ['embed' => true];
$options += $defaults;
if ($options['embed'] === true) {
$options['embed'] = $this->hierarchy();
}
$schema = $this->schema();
$tree = $schema->treeify($options['embed']);
$success = true;
foreach ($tree as $field => $value) {
if (isset($this->{$field})) {
$rel = $schema->relation($field);
$success = $success && $rel->validates($this, $value ? $value + $options : $options);
}
}
return $success;
} | [
"protected",
"function",
"_validates",
"(",
"$",
"options",
")",
"{",
"$",
"defaults",
"=",
"[",
"'embed'",
"=>",
"true",
"]",
";",
"$",
"options",
"+=",
"$",
"defaults",
";",
"if",
"(",
"$",
"options",
"[",
"'embed'",
"]",
"===",
"true",
")",
"{",
... | Check if nested relations are valid.
@param array $options Available options:
- `'embed'` _array_ : List of relations to validate.
@return boolean Returns `true` if all validation rules on all fields succeed, `false` otherwise. | [
"Check",
"if",
"nested",
"relations",
"are",
"valid",
"."
] | 835f891311bb30c9178910df7223d1cdfd269560 | https://github.com/crysalead/chaos-orm/blob/835f891311bb30c9178910df7223d1cdfd269560/src/Model.php#L630-L650 | train |
crysalead/chaos-orm | src/Model.php | Model.invalidate | public function invalidate($field, $errors = [])
{
$schema = $this->schema();
if (func_num_args() === 1) {
foreach ($field as $key => $value) {
if ($schema->hasRelation($key) && $this->has($key)) {
$this->{$key}->invalidate($value);
} else {
$this->invalidate($key, $value);
}
}
return $this;
}
if ($errors) {
$this->_errors[$field] = (array) $errors;
}
return $this;
} | php | public function invalidate($field, $errors = [])
{
$schema = $this->schema();
if (func_num_args() === 1) {
foreach ($field as $key => $value) {
if ($schema->hasRelation($key) && $this->has($key)) {
$this->{$key}->invalidate($value);
} else {
$this->invalidate($key, $value);
}
}
return $this;
}
if ($errors) {
$this->_errors[$field] = (array) $errors;
}
return $this;
} | [
"public",
"function",
"invalidate",
"(",
"$",
"field",
",",
"$",
"errors",
"=",
"[",
"]",
")",
"{",
"$",
"schema",
"=",
"$",
"this",
"->",
"schema",
"(",
")",
";",
"if",
"(",
"func_num_args",
"(",
")",
"===",
"1",
")",
"{",
"foreach",
"(",
"$",
... | Invalidate a field or an array of fields.
@param string|array $field The field to invalidate of an array of fields with associated errors.
@param string|array $errors The associated error message(s).
@return self | [
"Invalidate",
"a",
"field",
"or",
"an",
"array",
"of",
"fields",
"."
] | 835f891311bb30c9178910df7223d1cdfd269560 | https://github.com/crysalead/chaos-orm/blob/835f891311bb30c9178910df7223d1cdfd269560/src/Model.php#L659-L677 | train |
crysalead/chaos-orm | src/Model.php | Model.error | public function error($field, $all = false)
{
if (!empty($this->_errors[$field])) {
return $all ? $this->_errors[$field] : reset($this->_errors[$field]);
}
return '';
} | php | public function error($field, $all = false)
{
if (!empty($this->_errors[$field])) {
return $all ? $this->_errors[$field] : reset($this->_errors[$field]);
}
return '';
} | [
"public",
"function",
"error",
"(",
"$",
"field",
",",
"$",
"all",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"_errors",
"[",
"$",
"field",
"]",
")",
")",
"{",
"return",
"$",
"all",
"?",
"$",
"this",
"->",
"_errors... | Return an indivitual error
@param string $field The field name.
@param string|array $all Indicate whether all errors or simply the first one need to be returned.
@return string Return an array of error messages or the first one (depending on `$all`) or
an empty string for no error. | [
"Return",
"an",
"indivitual",
"error"
] | 835f891311bb30c9178910df7223d1cdfd269560 | https://github.com/crysalead/chaos-orm/blob/835f891311bb30c9178910df7223d1cdfd269560/src/Model.php#L687-L693 | train |
crysalead/chaos-orm | src/Model.php | Model.errored | public function errored($field = null)
{
if (!func_num_args()) {
return !!$this->_errors;
}
return isset($this->_errors[$field]);
} | php | public function errored($field = null)
{
if (!func_num_args()) {
return !!$this->_errors;
}
return isset($this->_errors[$field]);
} | [
"public",
"function",
"errored",
"(",
"$",
"field",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"func_num_args",
"(",
")",
")",
"{",
"return",
"!",
"!",
"$",
"this",
"->",
"_errors",
";",
"}",
"return",
"isset",
"(",
"$",
"this",
"->",
"_errors",
"[",
... | Check if the entity or a specific field errored
@param string $field The field to check.
@return boolean | [
"Check",
"if",
"the",
"entity",
"or",
"a",
"specific",
"field",
"errored"
] | 835f891311bb30c9178910df7223d1cdfd269560 | https://github.com/crysalead/chaos-orm/blob/835f891311bb30c9178910df7223d1cdfd269560/src/Model.php#L731-L737 | train |
neutrinobg/yii2-oci2pdo | OciPdoStatementAdapter.php | OciPdoStatementAdapter.bindColumn | public function bindColumn($column, &$param, $type = PDO::PARAM_STR, $maxlen = -1, $driverdata = null) {
$type = $this->removeBitFlag($$type, PDO::PARAM_INPUT_OUTPUT);
$ociParamType = $this->pdo2OciParamConst($type);
// LOBs
if ($lob_desc = $this->oci_lob_desc($ociParamType)) {
$this->_lobs[$this->_lobsCount]['type'] = $ociParamType;
$this->_lobs[$this->_lobsCount]['lob'] = @oci_new_descriptor($this->ociPdoAdapter->getOciConnection(), $lob_desc);
$res = $this->_lobs[$this->_lobsCount]['lob'];
$this->checkError($res);
$res = @oci_define_by_name($this->stmt, $column, $this->_lobs[$this->_lobsCount]['lob'], $ociParamType);
$this->checkError($res);
$this->_lobs[$this->_lobsCount]['var'] = $param;
$this->_lobs[$this->_lobsCount]['input'] = false;
$this->_lobsCount++;
}
else {
$res = @oci_define_by_name($this->stmt, $column, $param, $ociParamType);
$this->checkError($res);
}
return $res;
} | php | public function bindColumn($column, &$param, $type = PDO::PARAM_STR, $maxlen = -1, $driverdata = null) {
$type = $this->removeBitFlag($$type, PDO::PARAM_INPUT_OUTPUT);
$ociParamType = $this->pdo2OciParamConst($type);
// LOBs
if ($lob_desc = $this->oci_lob_desc($ociParamType)) {
$this->_lobs[$this->_lobsCount]['type'] = $ociParamType;
$this->_lobs[$this->_lobsCount]['lob'] = @oci_new_descriptor($this->ociPdoAdapter->getOciConnection(), $lob_desc);
$res = $this->_lobs[$this->_lobsCount]['lob'];
$this->checkError($res);
$res = @oci_define_by_name($this->stmt, $column, $this->_lobs[$this->_lobsCount]['lob'], $ociParamType);
$this->checkError($res);
$this->_lobs[$this->_lobsCount]['var'] = $param;
$this->_lobs[$this->_lobsCount]['input'] = false;
$this->_lobsCount++;
}
else {
$res = @oci_define_by_name($this->stmt, $column, $param, $ociParamType);
$this->checkError($res);
}
return $res;
} | [
"public",
"function",
"bindColumn",
"(",
"$",
"column",
",",
"&",
"$",
"param",
",",
"$",
"type",
"=",
"PDO",
"::",
"PARAM_STR",
",",
"$",
"maxlen",
"=",
"-",
"1",
",",
"$",
"driverdata",
"=",
"null",
")",
"{",
"$",
"type",
"=",
"$",
"this",
"->"... | Binds a column to a PHP variable
@param mixed $column The number of the column or name of the column
@param mixed $param The PHP variable to which the column should be bound
@param int $type
@param int $maxLength
@param mixed $options
@return bool | [
"Binds",
"a",
"column",
"to",
"a",
"PHP",
"variable"
] | d0170a2722c72521c510f8dddf8028185506e465 | https://github.com/neutrinobg/yii2-oci2pdo/blob/d0170a2722c72521c510f8dddf8028185506e465/OciPdoStatementAdapter.php#L124-L146 | train |
neutrinobg/yii2-oci2pdo | OciPdoStatementAdapter.php | OciPdoStatementAdapter.fetchObject | public function fetchObject($class_name = 'stdClass', array $ctor_args = array()) {
$obj = $this->fetch(PDO::FETCH_OBJ);
if($class_name == 'stdClass') {
$res = $obj;
}
else {
$res = $this->populateObject($obj, $class_name, $ctor_args);
}
return $res;
} | php | public function fetchObject($class_name = 'stdClass', array $ctor_args = array()) {
$obj = $this->fetch(PDO::FETCH_OBJ);
if($class_name == 'stdClass') {
$res = $obj;
}
else {
$res = $this->populateObject($obj, $class_name, $ctor_args);
}
return $res;
} | [
"public",
"function",
"fetchObject",
"(",
"$",
"class_name",
"=",
"'stdClass'",
",",
"array",
"$",
"ctor_args",
"=",
"array",
"(",
")",
")",
"{",
"$",
"obj",
"=",
"$",
"this",
"->",
"fetch",
"(",
"PDO",
"::",
"FETCH_OBJ",
")",
";",
"if",
"(",
"$",
... | Fetches the next row and returns it as an object
@param string $className
@param array $ctor_args
@return mixed | [
"Fetches",
"the",
"next",
"row",
"and",
"returns",
"it",
"as",
"an",
"object"
] | d0170a2722c72521c510f8dddf8028185506e465 | https://github.com/neutrinobg/yii2-oci2pdo/blob/d0170a2722c72521c510f8dddf8028185506e465/OciPdoStatementAdapter.php#L584-L594 | train |
neutrinobg/yii2-oci2pdo | OciPdoStatementAdapter.php | OciPdoStatementAdapter.getError | protected function getError() {
if ($this->_error === false) {
if (is_resource($this->stmt)) {
$this->_error = @oci_error($this->stmt);
}
else {
$this->_error = @oci_error();
}
}
return $this->_error;
} | php | protected function getError() {
if ($this->_error === false) {
if (is_resource($this->stmt)) {
$this->_error = @oci_error($this->stmt);
}
else {
$this->_error = @oci_error();
}
}
return $this->_error;
} | [
"protected",
"function",
"getError",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_error",
"===",
"false",
")",
"{",
"if",
"(",
"is_resource",
"(",
"$",
"this",
"->",
"stmt",
")",
")",
"{",
"$",
"this",
"->",
"_error",
"=",
"@",
"oci_error",
"(",
... | Retrieve OCI error of the statement | [
"Retrieve",
"OCI",
"error",
"of",
"the",
"statement"
] | d0170a2722c72521c510f8dddf8028185506e465 | https://github.com/neutrinobg/yii2-oci2pdo/blob/d0170a2722c72521c510f8dddf8028185506e465/OciPdoStatementAdapter.php#L763-L774 | train |
neutrinobg/yii2-oci2pdo | OciPdoStatementAdapter.php | OciPdoStatementAdapter.oci_lob_desc | public function oci_lob_desc($type) {
switch ($type) {
case OCI_B_BFILE: $result = OCI_D_FILE; break;
case OCI_B_CFILEE: $result = OCI_D_FILE; break;
case OCI_B_CLOB:
case SQLT_CLOB:
case OCI_B_BLOB:
case SQLT_BLOB: $result = OCI_D_LOB; break;
case OCI_B_ROWID: $result = OCI_D_ROWID; break;
default: $result = false; break;
}
return $result;
} | php | public function oci_lob_desc($type) {
switch ($type) {
case OCI_B_BFILE: $result = OCI_D_FILE; break;
case OCI_B_CFILEE: $result = OCI_D_FILE; break;
case OCI_B_CLOB:
case SQLT_CLOB:
case OCI_B_BLOB:
case SQLT_BLOB: $result = OCI_D_LOB; break;
case OCI_B_ROWID: $result = OCI_D_ROWID; break;
default: $result = false; break;
}
return $result;
} | [
"public",
"function",
"oci_lob_desc",
"(",
"$",
"type",
")",
"{",
"switch",
"(",
"$",
"type",
")",
"{",
"case",
"OCI_B_BFILE",
":",
"$",
"result",
"=",
"OCI_D_FILE",
";",
"break",
";",
"case",
"OCI_B_CFILEE",
":",
"$",
"result",
"=",
"OCI_D_FILE",
";",
... | Define the LOB descriptor type for the given type
@param int $type LOB data type
@return int|false Descriptor | [
"Define",
"the",
"LOB",
"descriptor",
"type",
"for",
"the",
"given",
"type"
] | d0170a2722c72521c510f8dddf8028185506e465 | https://github.com/neutrinobg/yii2-oci2pdo/blob/d0170a2722c72521c510f8dddf8028185506e465/OciPdoStatementAdapter.php#L781-L794 | train |
neutrinobg/yii2-oci2pdo | OciPdoStatementAdapter.php | OciPdoStatementAdapter.lobToStream | protected function lobToStream(&$lob) {
if (is_null($lob)) {
return null;
}
if (is_object($lob) && get_class($lob) == 'OCI-Lob') {
return fopen('ocipdolob://', 'r', false, OciPdoLobStreamWrapper::getContext($lob));
}
else {
return String2Stream::create($lob);
}
} | php | protected function lobToStream(&$lob) {
if (is_null($lob)) {
return null;
}
if (is_object($lob) && get_class($lob) == 'OCI-Lob') {
return fopen('ocipdolob://', 'r', false, OciPdoLobStreamWrapper::getContext($lob));
}
else {
return String2Stream::create($lob);
}
} | [
"protected",
"function",
"lobToStream",
"(",
"&",
"$",
"lob",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"lob",
")",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"is_object",
"(",
"$",
"lob",
")",
"&&",
"get_class",
"(",
"$",
"lob",
")",
"==",... | Convert string or OCI LOB to stream
@param string|OCI-Lob $lob
@return resource | [
"Convert",
"string",
"or",
"OCI",
"LOB",
"to",
"stream"
] | d0170a2722c72521c510f8dddf8028185506e465 | https://github.com/neutrinobg/yii2-oci2pdo/blob/d0170a2722c72521c510f8dddf8028185506e465/OciPdoStatementAdapter.php#L801-L811 | train |
apioo/psx-framework | src/Util/Annotation.php | Annotation.parse | public static function parse($doc)
{
$block = new DocBlock();
$lines = explode("\n", $doc);
// remove first line
unset($lines[0]);
foreach ($lines as $line) {
$line = trim($line);
$line = substr($line, 2);
if (isset($line[0]) && $line[0] == '@') {
$line = substr($line, 1);
$sp = strpos($line, ' ');
$bp = strpos($line, '(');
if ($sp !== false || $bp !== false) {
if ($sp !== false && $bp === false) {
$pos = $sp;
} elseif ($sp === false && $bp !== false) {
$pos = $bp;
} else {
$pos = $sp < $bp ? $sp : $bp;
}
$key = substr($line, 0, $pos);
$value = substr($line, $pos);
} else {
$key = $line;
$value = null;
}
$key = trim($key);
$value = trim($value);
if (!empty($key)) {
// if key contains backslashes its a namespace use only the
// short name
$pos = strrpos($key, '\\');
if ($pos !== false) {
$key = substr($key, $pos + 1);
}
$block->addAnnotation($key, $value);
}
}
}
return $block;
} | php | public static function parse($doc)
{
$block = new DocBlock();
$lines = explode("\n", $doc);
// remove first line
unset($lines[0]);
foreach ($lines as $line) {
$line = trim($line);
$line = substr($line, 2);
if (isset($line[0]) && $line[0] == '@') {
$line = substr($line, 1);
$sp = strpos($line, ' ');
$bp = strpos($line, '(');
if ($sp !== false || $bp !== false) {
if ($sp !== false && $bp === false) {
$pos = $sp;
} elseif ($sp === false && $bp !== false) {
$pos = $bp;
} else {
$pos = $sp < $bp ? $sp : $bp;
}
$key = substr($line, 0, $pos);
$value = substr($line, $pos);
} else {
$key = $line;
$value = null;
}
$key = trim($key);
$value = trim($value);
if (!empty($key)) {
// if key contains backslashes its a namespace use only the
// short name
$pos = strrpos($key, '\\');
if ($pos !== false) {
$key = substr($key, $pos + 1);
}
$block->addAnnotation($key, $value);
}
}
}
return $block;
} | [
"public",
"static",
"function",
"parse",
"(",
"$",
"doc",
")",
"{",
"$",
"block",
"=",
"new",
"DocBlock",
"(",
")",
";",
"$",
"lines",
"=",
"explode",
"(",
"\"\\n\"",
",",
"$",
"doc",
")",
";",
"// remove first line",
"unset",
"(",
"$",
"lines",
"[",... | Parses the annotations from the given doc block
@param string $doc
@return \PSX\Framework\Util\Annotation\DocBlock | [
"Parses",
"the",
"annotations",
"from",
"the",
"given",
"doc",
"block"
] | e8e550a1a87dae49b615b42a05583395088c1efb | https://github.com/apioo/psx-framework/blob/e8e550a1a87dae49b615b42a05583395088c1efb/src/Util/Annotation.php#L40-L90 | train |
apioo/psx-framework | src/Util/Annotation.php | Annotation.parseAttributes | public static function parseAttributes($values)
{
$result = array();
$values = trim($values, " \t\n\r\0\x0B()");
$parts = explode(',', $values);
foreach ($parts as $part) {
$kv = explode('=', $part, 2);
$key = trim($kv[0]);
$value = isset($kv[1]) ? $kv[1] : '';
$value = trim($value, " \t\n\r\0\x0B\"");
if (!empty($key)) {
$result[$key] = $value;
}
}
return $result;
} | php | public static function parseAttributes($values)
{
$result = array();
$values = trim($values, " \t\n\r\0\x0B()");
$parts = explode(',', $values);
foreach ($parts as $part) {
$kv = explode('=', $part, 2);
$key = trim($kv[0]);
$value = isset($kv[1]) ? $kv[1] : '';
$value = trim($value, " \t\n\r\0\x0B\"");
if (!empty($key)) {
$result[$key] = $value;
}
}
return $result;
} | [
"public",
"static",
"function",
"parseAttributes",
"(",
"$",
"values",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"$",
"values",
"=",
"trim",
"(",
"$",
"values",
",",
"\" \\t\\n\\r\\0\\x0B()\"",
")",
";",
"$",
"parts",
"=",
"explode",
"(",
"... | Parses the constructor values from an doctrine annotation
@param string $values
@return array | [
"Parses",
"the",
"constructor",
"values",
"from",
"an",
"doctrine",
"annotation"
] | e8e550a1a87dae49b615b42a05583395088c1efb | https://github.com/apioo/psx-framework/blob/e8e550a1a87dae49b615b42a05583395088c1efb/src/Util/Annotation.php#L98-L116 | train |
wikiworldorder/survloop | src/Controllers/Stats/SurvStatsCore.php | SurvStatsCore.loadMapRow | protected function loadMapRow()
{
$ret = [
"cnt" => 0,
"rec" => [],
"dat" => []
];
if (sizeof($this->datMap) > 0) {
foreach ($this->datMap as $let => $d) {
$ret["dat"][$let] = [
"sum" => 0,
"avg" => 0,
"ids" => []
];
}
}
return $ret;
} | php | protected function loadMapRow()
{
$ret = [
"cnt" => 0,
"rec" => [],
"dat" => []
];
if (sizeof($this->datMap) > 0) {
foreach ($this->datMap as $let => $d) {
$ret["dat"][$let] = [
"sum" => 0,
"avg" => 0,
"ids" => []
];
}
}
return $ret;
} | [
"protected",
"function",
"loadMapRow",
"(",
")",
"{",
"$",
"ret",
"=",
"[",
"\"cnt\"",
"=>",
"0",
",",
"\"rec\"",
"=>",
"[",
"]",
",",
"\"dat\"",
"=>",
"[",
"]",
"]",
";",
"if",
"(",
"sizeof",
"(",
"$",
"this",
"->",
"datMap",
")",
">",
"0",
")... | raw data array, filters on each raw data point, data sum, data average, unique record count | [
"raw",
"data",
"array",
"filters",
"on",
"each",
"raw",
"data",
"point",
"data",
"sum",
"data",
"average",
"unique",
"record",
"count"
] | 7fbd61a453e2ea8c3e55bbdd6b0bed1c859c8f4a | https://github.com/wikiworldorder/survloop/blob/7fbd61a453e2ea8c3e55bbdd6b0bed1c859c8f4a/src/Controllers/Stats/SurvStatsCore.php#L104-L121 | train |
crysalead/chaos-orm | src/Collection/Through.php | Through._merge | protected function _merge($data, $exists)
{
if (!$data) {
$this->_parent->get($this->_through)->clear();
return;
}
$pivot = $this->_parent->{$this->_through};
$relThrough = $this->_parent->schema()->relation($this->_through);
$through = $relThrough->to();
$schema = $through::definition();
$rel = $schema->relation($this->_using);
$fromKey = $rel->keys('from');
$toKey = $rel->keys('to');
$i = 0;
while ($i < $pivot->count()) {
$found = false;
$entity = $pivot->get($i);
$id1 = $entity->get($fromKey);
if ($id1 === null) {
$pivot->splice($i, 1);
continue;
}
foreach ($data as $key => $item) {
$isDocument = $item instanceof Document;
$id2 = $isDocument ? $item->get($toKey) : (isset($item[$toKey]) ?$item[$toKey] : null);
if ((string) $id1 === (string) $id2) {
if ($isDocument) {
$entity->set($this->_using, $item);
} else {
$entity->get($this->_using)->amend($item);
}
unset($data[$key]);
$i++;
$found = true;
break;
}
}
if (!$found) {
$pivot->splice($i, 1);
}
}
foreach ($data as $entity) {
$this[] = $entity;
}
} | php | protected function _merge($data, $exists)
{
if (!$data) {
$this->_parent->get($this->_through)->clear();
return;
}
$pivot = $this->_parent->{$this->_through};
$relThrough = $this->_parent->schema()->relation($this->_through);
$through = $relThrough->to();
$schema = $through::definition();
$rel = $schema->relation($this->_using);
$fromKey = $rel->keys('from');
$toKey = $rel->keys('to');
$i = 0;
while ($i < $pivot->count()) {
$found = false;
$entity = $pivot->get($i);
$id1 = $entity->get($fromKey);
if ($id1 === null) {
$pivot->splice($i, 1);
continue;
}
foreach ($data as $key => $item) {
$isDocument = $item instanceof Document;
$id2 = $isDocument ? $item->get($toKey) : (isset($item[$toKey]) ?$item[$toKey] : null);
if ((string) $id1 === (string) $id2) {
if ($isDocument) {
$entity->set($this->_using, $item);
} else {
$entity->get($this->_using)->amend($item);
}
unset($data[$key]);
$i++;
$found = true;
break;
}
}
if (!$found) {
$pivot->splice($i, 1);
}
}
foreach ($data as $entity) {
$this[] = $entity;
}
} | [
"protected",
"function",
"_merge",
"(",
"$",
"data",
",",
"$",
"exists",
")",
"{",
"if",
"(",
"!",
"$",
"data",
")",
"{",
"$",
"this",
"->",
"_parent",
"->",
"get",
"(",
"$",
"this",
"->",
"_through",
")",
"->",
"clear",
"(",
")",
";",
"return",
... | Merge pivot data based on entities ids
@param array $data The pivot data.
@param boolean $exists The existance value. | [
"Merge",
"pivot",
"data",
"based",
"on",
"entities",
"ids"
] | 835f891311bb30c9178910df7223d1cdfd269560 | https://github.com/crysalead/chaos-orm/blob/835f891311bb30c9178910df7223d1cdfd269560/src/Collection/Through.php#L104-L154 | train |
crysalead/chaos-orm | src/Collection/Through.php | Through.set | public function set($offset = null, $data = [])
{
$name = $this->_through;
$this->_parent->{$name}->set($offset, $this->_item($data));
return $this;
} | php | public function set($offset = null, $data = [])
{
$name = $this->_through;
$this->_parent->{$name}->set($offset, $this->_item($data));
return $this;
} | [
"public",
"function",
"set",
"(",
"$",
"offset",
"=",
"null",
",",
"$",
"data",
"=",
"[",
"]",
")",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"_through",
";",
"$",
"this",
"->",
"_parent",
"->",
"{",
"$",
"name",
"}",
"->",
"set",
"(",
"$",
"... | Sets data to a specified offset and wraps all data array in its appropriate object type.
@param mixed $offset The offset. If offset is `null` data is simply appended to the set.
@param mixed $data An array or an entity instance to set.
@return self Return `this`. | [
"Sets",
"data",
"to",
"a",
"specified",
"offset",
"and",
"wraps",
"all",
"data",
"array",
"in",
"its",
"appropriate",
"object",
"type",
"."
] | 835f891311bb30c9178910df7223d1cdfd269560 | https://github.com/crysalead/chaos-orm/blob/835f891311bb30c9178910df7223d1cdfd269560/src/Collection/Through.php#L284-L289 | train |
crysalead/chaos-orm | src/Collection/Through.php | Through.push | public function push($data = [])
{
$name = $this->_through;
$this->_parent->{$name}->push($offset, $this->_item($data));
return $this;
} | php | public function push($data = [])
{
$name = $this->_through;
$this->_parent->{$name}->push($offset, $this->_item($data));
return $this;
} | [
"public",
"function",
"push",
"(",
"$",
"data",
"=",
"[",
"]",
")",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"_through",
";",
"$",
"this",
"->",
"_parent",
"->",
"{",
"$",
"name",
"}",
"->",
"push",
"(",
"$",
"offset",
",",
"$",
"this",
"->",
... | Adds data into the `Collection` instance.
@param mixed $data An array or an entity instance to set.
@return self Return `this`. | [
"Adds",
"data",
"into",
"the",
"Collection",
"instance",
"."
] | 835f891311bb30c9178910df7223d1cdfd269560 | https://github.com/crysalead/chaos-orm/blob/835f891311bb30c9178910df7223d1cdfd269560/src/Collection/Through.php#L313-L318 | train |
crysalead/chaos-orm | src/Collection/Through.php | Through._item | protected function _item($data, $options = [])
{
$name = $this->_through;
$parent = $this->_parent;
$relThrough = $parent->schema()->relation($name);
$through = $relThrough->to();
$id = $this->_parent->id();
$item = $through::create($id !== null ? $relThrough->match($this->_parent) : [], $options);
$item->setAt($this->_using, $data, $options);
return $item;
} | php | protected function _item($data, $options = [])
{
$name = $this->_through;
$parent = $this->_parent;
$relThrough = $parent->schema()->relation($name);
$through = $relThrough->to();
$id = $this->_parent->id();
$item = $through::create($id !== null ? $relThrough->match($this->_parent) : [], $options);
$item->setAt($this->_using, $data, $options);
return $item;
} | [
"protected",
"function",
"_item",
"(",
"$",
"data",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"_through",
";",
"$",
"parent",
"=",
"$",
"this",
"->",
"_parent",
";",
"$",
"relThrough",
"=",
"$",
"parent",
... | Create a pivot instance.
@param mixed $data The data.
@param array $options Method options:
- `'exists'` _boolean_: Determines whether or not this entity exists
@return mixed The pivot instance. | [
"Create",
"a",
"pivot",
"instance",
"."
] | 835f891311bb30c9178910df7223d1cdfd269560 | https://github.com/crysalead/chaos-orm/blob/835f891311bb30c9178910df7223d1cdfd269560/src/Collection/Through.php#L328-L338 | train |
crysalead/chaos-orm | src/Collection/Through.php | Through.prev | public function prev()
{
$entity = $this->_parent->{$this->_through}->prev();
if ($entity) {
return $entity->{$this->_using};
}
} | php | public function prev()
{
$entity = $this->_parent->{$this->_through}->prev();
if ($entity) {
return $entity->{$this->_using};
}
} | [
"public",
"function",
"prev",
"(",
")",
"{",
"$",
"entity",
"=",
"$",
"this",
"->",
"_parent",
"->",
"{",
"$",
"this",
"->",
"_through",
"}",
"->",
"prev",
"(",
")",
";",
"if",
"(",
"$",
"entity",
")",
"{",
"return",
"$",
"entity",
"->",
"{",
"... | Moves backward to the previous item. If already at the first item,
moves to the last one.
@return mixed The current item after moving or the last item on failure. | [
"Moves",
"backward",
"to",
"the",
"previous",
"item",
".",
"If",
"already",
"at",
"the",
"first",
"item",
"moves",
"to",
"the",
"last",
"one",
"."
] | 835f891311bb30c9178910df7223d1cdfd269560 | https://github.com/crysalead/chaos-orm/blob/835f891311bb30c9178910df7223d1cdfd269560/src/Collection/Through.php#L494-L500 | train |
crysalead/chaos-orm | src/Collection/Through.php | Through.map | public function map($closure)
{
$data = [];
foreach ($this as $val) {
$data[] = $closure($val);
}
return new Collection(compact('data'));
} | php | public function map($closure)
{
$data = [];
foreach ($this as $val) {
$data[] = $closure($val);
}
return new Collection(compact('data'));
} | [
"public",
"function",
"map",
"(",
"$",
"closure",
")",
"{",
"$",
"data",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"as",
"$",
"val",
")",
"{",
"$",
"data",
"[",
"]",
"=",
"$",
"closure",
"(",
"$",
"val",
")",
";",
"}",
"return",
"new",... | Applies a closure to a copy of all data in the collection
and returns the result.
@param Closure $closure The closure to apply.
@return mixed Returns the set of filtered values inside a `Collection`. | [
"Applies",
"a",
"closure",
"to",
"a",
"copy",
"of",
"all",
"data",
"in",
"the",
"collection",
"and",
"returns",
"the",
"result",
"."
] | 835f891311bb30c9178910df7223d1cdfd269560 | https://github.com/crysalead/chaos-orm/blob/835f891311bb30c9178910df7223d1cdfd269560/src/Collection/Through.php#L697-L704 | train |
crysalead/chaos-orm | src/Collection/Through.php | Through.reduce | public function reduce($closure, $initial = false)
{
$result = $initial;
foreach ($this as $val) {
$result = $closure($result, $val);
}
return $result;
} | php | public function reduce($closure, $initial = false)
{
$result = $initial;
foreach ($this as $val) {
$result = $closure($result, $val);
}
return $result;
} | [
"public",
"function",
"reduce",
"(",
"$",
"closure",
",",
"$",
"initial",
"=",
"false",
")",
"{",
"$",
"result",
"=",
"$",
"initial",
";",
"foreach",
"(",
"$",
"this",
"as",
"$",
"val",
")",
"{",
"$",
"result",
"=",
"$",
"closure",
"(",
"$",
"res... | Reduces, or folds, a collection down to a single value
@param Closure $closure The filter to apply.
@param mixed $initial Initial value.
@return mixed The reduced value. | [
"Reduces",
"or",
"folds",
"a",
"collection",
"down",
"to",
"a",
"single",
"value"
] | 835f891311bb30c9178910df7223d1cdfd269560 | https://github.com/crysalead/chaos-orm/blob/835f891311bb30c9178910df7223d1cdfd269560/src/Collection/Through.php#L713-L720 | train |
crysalead/chaos-orm | src/Collection/Through.php | Through.validates | public function validates($options = [])
{
$success = true;
foreach ($this as $entity) {
if (!$entity->validates($options)) {
$success = false;
}
}
return $success;
} | php | public function validates($options = [])
{
$success = true;
foreach ($this as $entity) {
if (!$entity->validates($options)) {
$success = false;
}
}
return $success;
} | [
"public",
"function",
"validates",
"(",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"success",
"=",
"true",
";",
"foreach",
"(",
"$",
"this",
"as",
"$",
"entity",
")",
"{",
"if",
"(",
"!",
"$",
"entity",
"->",
"validates",
"(",
"$",
"options",
... | Validates the collection.
@param array $options Validates option.
@return boolean | [
"Validates",
"the",
"collection",
"."
] | 835f891311bb30c9178910df7223d1cdfd269560 | https://github.com/crysalead/chaos-orm/blob/835f891311bb30c9178910df7223d1cdfd269560/src/Collection/Through.php#L789-L798 | train |
pear/Console_Color2 | Console/Color2.php | Console_Color2.color | public function color($color = null, $style = null, $background = null) // {{{
{
$colors = $this->getColorCodes();
if (is_array($color)) {
$style = isset($color['style']) ? $color['style'] : null;
$background = isset($color['background']) ? $color['background'] : null;
$color = isset($color['color']) ? $color['color'] : null;
}
if ($color == 'reset') {
return "\033[0m";
}
$code = array();
if (isset($style)) {
$code[] = $colors['style'][$style];
}
if (isset($color)) {
$code[] = $colors['color'][$color];
}
if (isset($background)) {
$code[] = $colors['background'][$background];
}
if (empty($code)) {
$code[] = 0;
}
$code = implode(';', $code);
return "\033[{$code}m";
} | php | public function color($color = null, $style = null, $background = null) // {{{
{
$colors = $this->getColorCodes();
if (is_array($color)) {
$style = isset($color['style']) ? $color['style'] : null;
$background = isset($color['background']) ? $color['background'] : null;
$color = isset($color['color']) ? $color['color'] : null;
}
if ($color == 'reset') {
return "\033[0m";
}
$code = array();
if (isset($style)) {
$code[] = $colors['style'][$style];
}
if (isset($color)) {
$code[] = $colors['color'][$color];
}
if (isset($background)) {
$code[] = $colors['background'][$background];
}
if (empty($code)) {
$code[] = 0;
}
$code = implode(';', $code);
return "\033[{$code}m";
} | [
"public",
"function",
"color",
"(",
"$",
"color",
"=",
"null",
",",
"$",
"style",
"=",
"null",
",",
"$",
"background",
"=",
"null",
")",
"// {{{",
"{",
"$",
"colors",
"=",
"$",
"this",
"->",
"getColorCodes",
"(",
")",
";",
"if",
"(",
"is_array",
"(... | Returns an ANSI-Controlcode
Takes 1 to 3 Arguments: either 1 to 3 strings containing the name of the
FG Color, style and BG color, or one array with the indices color, style
or background.
@param mixed $color Optional.
Either a string with the name of the foreground
color, or an array with the indices 'color',
'style', 'background' and corresponding names as
values.
@param string $style Optional name of the style
@param string $background Optional name of the background color
@return string | [
"Returns",
"an",
"ANSI",
"-",
"Controlcode"
] | e7cc88dc38253d7e7441bb58e0418ff5e5ff65b7 | https://github.com/pear/Console_Color2/blob/e7cc88dc38253d7e7441bb58e0418ff5e5ff65b7/Console/Color2.php#L120-L152 | train |
cyril-barragan/kujira-phpunit-printer | src/Printer.php | Printer.formatExceptionMsg | protected function formatExceptionMsg($exceptionMessage)
{
$exceptionMessage = str_replace("+++ Actual\n", '', $exceptionMessage);
$exceptionMessage = str_replace("--- Expected\n", '', $exceptionMessage);
$exceptionMessage = str_replace("@@ @@\n", '', $exceptionMessage);
$exceptionMessage = preg_replace("/(Failed.*)$/m", " \033[01;31m$1\033[0m", $exceptionMessage);
$exceptionMessage = preg_replace("/\-+(.*)$/m", "\n \033[01;32m$1\033[0m", $exceptionMessage);
return preg_replace("/\++(.*)$/m", " \033[01;31m$1\033[0m", $exceptionMessage);
} | php | protected function formatExceptionMsg($exceptionMessage)
{
$exceptionMessage = str_replace("+++ Actual\n", '', $exceptionMessage);
$exceptionMessage = str_replace("--- Expected\n", '', $exceptionMessage);
$exceptionMessage = str_replace("@@ @@\n", '', $exceptionMessage);
$exceptionMessage = preg_replace("/(Failed.*)$/m", " \033[01;31m$1\033[0m", $exceptionMessage);
$exceptionMessage = preg_replace("/\-+(.*)$/m", "\n \033[01;32m$1\033[0m", $exceptionMessage);
return preg_replace("/\++(.*)$/m", " \033[01;31m$1\033[0m", $exceptionMessage);
} | [
"protected",
"function",
"formatExceptionMsg",
"(",
"$",
"exceptionMessage",
")",
"{",
"$",
"exceptionMessage",
"=",
"str_replace",
"(",
"\"+++ Actual\\n\"",
",",
"''",
",",
"$",
"exceptionMessage",
")",
";",
"$",
"exceptionMessage",
"=",
"str_replace",
"(",
"\"--... | Add colors and removes superfluous informations
@param string $exceptionMessage
@return string | [
"Add",
"colors",
"and",
"removes",
"superfluous",
"informations"
] | ffe513b48c2938cc9fd9d1117430dc2a4710b93b | https://github.com/cyril-barragan/kujira-phpunit-printer/blob/ffe513b48c2938cc9fd9d1117430dc2a4710b93b/src/Printer.php#L128-L136 | train |
orchestral/model | src/Concerns/CheckRoles.php | CheckRoles.attachRoles | public function attachRoles($roles)
{
if ($roles instanceof Role) {
$roles = [$roles->getKey()];
}
$this->roles()->sync($roles, false);
unset($this->relations['roles']);
return $this;
} | php | public function attachRoles($roles)
{
if ($roles instanceof Role) {
$roles = [$roles->getKey()];
}
$this->roles()->sync($roles, false);
unset($this->relations['roles']);
return $this;
} | [
"public",
"function",
"attachRoles",
"(",
"$",
"roles",
")",
"{",
"if",
"(",
"$",
"roles",
"instanceof",
"Role",
")",
"{",
"$",
"roles",
"=",
"[",
"$",
"roles",
"->",
"getKey",
"(",
")",
"]",
";",
"}",
"$",
"this",
"->",
"roles",
"(",
")",
"->",
... | Assign roles to user.
@param \Orchestra\Model\Role|int|array $roles
@return $this | [
"Assign",
"roles",
"to",
"user",
"."
] | 59eb60a022afb3caa0ac5824d6faac85f3255c0d | https://github.com/orchestral/model/blob/59eb60a022afb3caa0ac5824d6faac85f3255c0d/src/Concerns/CheckRoles.php#L60-L71 | train |
orchestral/model | src/Concerns/CheckRoles.php | CheckRoles.detachRoles | public function detachRoles($roles)
{
if ($roles instanceof Role) {
$roles = [$roles->getKey()];
}
$this->roles()->detach($roles);
unset($this->relations['roles']);
return $this;
} | php | public function detachRoles($roles)
{
if ($roles instanceof Role) {
$roles = [$roles->getKey()];
}
$this->roles()->detach($roles);
unset($this->relations['roles']);
return $this;
} | [
"public",
"function",
"detachRoles",
"(",
"$",
"roles",
")",
"{",
"if",
"(",
"$",
"roles",
"instanceof",
"Role",
")",
"{",
"$",
"roles",
"=",
"[",
"$",
"roles",
"->",
"getKey",
"(",
")",
"]",
";",
"}",
"$",
"this",
"->",
"roles",
"(",
")",
"->",
... | Un-assign roles from user.
@param \Orchestra\Model\Role|int|array $roles
@return $this | [
"Un",
"-",
"assign",
"roles",
"from",
"user",
"."
] | 59eb60a022afb3caa0ac5824d6faac85f3255c0d | https://github.com/orchestral/model/blob/59eb60a022afb3caa0ac5824d6faac85f3255c0d/src/Concerns/CheckRoles.php#L80-L91 | train |
cleaniquecoders/laravel-observers | src/Services/Hashids.php | Hashids.make | public static function make(?string $salt, ?int $length, ?string $alphabet)
{
$salt = is_null($salt) ? config('hashids.salt') : config('hashids.salt') . $salt;
$length = $length ?? config('hashids.length');
$alphabet = $alphabet ?? config('hashids.alphabet');
$salt = \Illuminate\Support\Facades\Hash::make($salt);
return new self($salt, $length, $alphabet);
} | php | public static function make(?string $salt, ?int $length, ?string $alphabet)
{
$salt = is_null($salt) ? config('hashids.salt') : config('hashids.salt') . $salt;
$length = $length ?? config('hashids.length');
$alphabet = $alphabet ?? config('hashids.alphabet');
$salt = \Illuminate\Support\Facades\Hash::make($salt);
return new self($salt, $length, $alphabet);
} | [
"public",
"static",
"function",
"make",
"(",
"?",
"string",
"$",
"salt",
",",
"?",
"int",
"$",
"length",
",",
"?",
"string",
"$",
"alphabet",
")",
"{",
"$",
"salt",
"=",
"is_null",
"(",
"$",
"salt",
")",
"?",
"config",
"(",
"'hashids.salt'",
")",
"... | Create an instance of Hashids.
@return static | [
"Create",
"an",
"instance",
"of",
"Hashids",
"."
] | ec6f9f0de7a1277a29c0956bd881f972f5a1847c | https://github.com/cleaniquecoders/laravel-observers/blob/ec6f9f0de7a1277a29c0956bd881f972f5a1847c/src/Services/Hashids.php#L29-L37 | train |
hostnet/phpcs-tool | src/Hostnet/Component/CodeSniffer/Installer.php | Installer.configureAsRoot | public static function configureAsRoot(): void
{
$filesystem = new Filesystem();
$vendor_dir = Path::VENDOR_DIR . '/hostnet/phpcs-tool/src';
if ($filesystem->exists($vendor_dir)) {
return;
}
self::configure();
$filesystem->mkdir($vendor_dir . '/Hostnet');
$filesystem->symlink(__DIR__ . '/../../Sniffs', $vendor_dir . '/Hostnet/Sniffs');
$filesystem->copy(__DIR__ . '/../../ruleset.xml', $vendor_dir . '/Hostnet/ruleset.xml');
$filesystem->mkdir($vendor_dir . '/HostnetPaths');
$filesystem->copy(__DIR__ . '/../../../HostnetPaths/ruleset.xml', $vendor_dir . '/HostnetPaths/ruleset.xml');
} | php | public static function configureAsRoot(): void
{
$filesystem = new Filesystem();
$vendor_dir = Path::VENDOR_DIR . '/hostnet/phpcs-tool/src';
if ($filesystem->exists($vendor_dir)) {
return;
}
self::configure();
$filesystem->mkdir($vendor_dir . '/Hostnet');
$filesystem->symlink(__DIR__ . '/../../Sniffs', $vendor_dir . '/Hostnet/Sniffs');
$filesystem->copy(__DIR__ . '/../../ruleset.xml', $vendor_dir . '/Hostnet/ruleset.xml');
$filesystem->mkdir($vendor_dir . '/HostnetPaths');
$filesystem->copy(__DIR__ . '/../../../HostnetPaths/ruleset.xml', $vendor_dir . '/HostnetPaths/ruleset.xml');
} | [
"public",
"static",
"function",
"configureAsRoot",
"(",
")",
":",
"void",
"{",
"$",
"filesystem",
"=",
"new",
"Filesystem",
"(",
")",
";",
"$",
"vendor_dir",
"=",
"Path",
"::",
"VENDOR_DIR",
".",
"'/hostnet/phpcs-tool/src'",
";",
"if",
"(",
"$",
"filesystem"... | Configuration for standalone use in a system wide installation scenario | [
"Configuration",
"for",
"standalone",
"use",
"in",
"a",
"system",
"wide",
"installation",
"scenario"
] | 0d50d253493f7b596faeccf47898fecabfbb2c88 | https://github.com/hostnet/phpcs-tool/blob/0d50d253493f7b596faeccf47898fecabfbb2c88/src/Hostnet/Component/CodeSniffer/Installer.php#L39-L55 | train |
hostnet/phpcs-tool | src/Hostnet/Component/CodeSniffer/Installer.php | Installer.execute | public function execute(): void
{
self::configure();
if (false === $this->io->isVerbose()) {
return;
}
$this->io->write('<info>Configured phpcs to use Hostnet standard</info>');
} | php | public function execute(): void
{
self::configure();
if (false === $this->io->isVerbose()) {
return;
}
$this->io->write('<info>Configured phpcs to use Hostnet standard</info>');
} | [
"public",
"function",
"execute",
"(",
")",
":",
"void",
"{",
"self",
"::",
"configure",
"(",
")",
";",
"if",
"(",
"false",
"===",
"$",
"this",
"->",
"io",
"->",
"isVerbose",
"(",
")",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"io",
"->",
... | The 'logical'-operation of this Installer.
PHPCS does not define constants for the config options,
doing so ourselves would only lead to outdated intel.
@see https://github.com/squizlabs/PHP_CodeSniffer/wiki/Configuration-Options | [
"The",
"logical",
"-",
"operation",
"of",
"this",
"Installer",
".",
"PHPCS",
"does",
"not",
"define",
"constants",
"for",
"the",
"config",
"options",
"doing",
"so",
"ourselves",
"would",
"only",
"lead",
"to",
"outdated",
"intel",
"."
] | 0d50d253493f7b596faeccf47898fecabfbb2c88 | https://github.com/hostnet/phpcs-tool/blob/0d50d253493f7b596faeccf47898fecabfbb2c88/src/Hostnet/Component/CodeSniffer/Installer.php#L72-L80 | train |
hostnet/phpcs-tool | src/Hostnet/Component/CodeSniffer/Installer.php | Installer.configure | public static function configure(): void
{
$filesystem = new Filesystem();
$config = [
'colors' => '1',
'installed_paths' => implode(',', [
Path::VENDOR_DIR . '/hostnet/phpcs-tool/src/',
Path::VENDOR_DIR . '/slevomat/coding-standard/SlevomatCodingStandard',
]),
];
if (!$filesystem->exists(['phpcs.xml', 'phpcs.xml.dist'])) {
$config['default_standard'] = 'Hostnet';
}
$filesystem->dumpFile(
Path::VENDOR_DIR . '/squizlabs/php_codesniffer/CodeSniffer.conf',
sprintf('<?php $phpCodeSnifferConfig = %s;', var_export($config, true))
);
$filesystem->dumpFile(__DIR__ . '/../../../HostnetPaths/ruleset.xml', self::generateHostnetPathsXml());
} | php | public static function configure(): void
{
$filesystem = new Filesystem();
$config = [
'colors' => '1',
'installed_paths' => implode(',', [
Path::VENDOR_DIR . '/hostnet/phpcs-tool/src/',
Path::VENDOR_DIR . '/slevomat/coding-standard/SlevomatCodingStandard',
]),
];
if (!$filesystem->exists(['phpcs.xml', 'phpcs.xml.dist'])) {
$config['default_standard'] = 'Hostnet';
}
$filesystem->dumpFile(
Path::VENDOR_DIR . '/squizlabs/php_codesniffer/CodeSniffer.conf',
sprintf('<?php $phpCodeSnifferConfig = %s;', var_export($config, true))
);
$filesystem->dumpFile(__DIR__ . '/../../../HostnetPaths/ruleset.xml', self::generateHostnetPathsXml());
} | [
"public",
"static",
"function",
"configure",
"(",
")",
":",
"void",
"{",
"$",
"filesystem",
"=",
"new",
"Filesystem",
"(",
")",
";",
"$",
"config",
"=",
"[",
"'colors'",
"=>",
"'1'",
",",
"'installed_paths'",
"=>",
"implode",
"(",
"','",
",",
"[",
"Pat... | Configure the Hostnet code style | [
"Configure",
"the",
"Hostnet",
"code",
"style"
] | 0d50d253493f7b596faeccf47898fecabfbb2c88 | https://github.com/hostnet/phpcs-tool/blob/0d50d253493f7b596faeccf47898fecabfbb2c88/src/Hostnet/Component/CodeSniffer/Installer.php#L85-L106 | train |
yangjian102621/herosphp | src/image/VerifyCode.php | VerifyCode.configure | public function configure($_array = NULL) {
if ( $_array != NULL ) {
if ( isset( $_array['x'] ) ) $this->_config['x'] = $_array['x'];
if ( isset( $_array['y'] ) ) $this->_config['y'] = $_array['y'];
if ( isset( $_array['w'] ) ) $this->_config['w'] = $_array['w'];
if ( isset( $_array['h'] ) ) $this->_config['h'] = $_array['h'];
if ( isset( $_array['f'] ) ) $this->_config['f'] = $_array['f'];
}
return self::$_instance;
} | php | public function configure($_array = NULL) {
if ( $_array != NULL ) {
if ( isset( $_array['x'] ) ) $this->_config['x'] = $_array['x'];
if ( isset( $_array['y'] ) ) $this->_config['y'] = $_array['y'];
if ( isset( $_array['w'] ) ) $this->_config['w'] = $_array['w'];
if ( isset( $_array['h'] ) ) $this->_config['h'] = $_array['h'];
if ( isset( $_array['f'] ) ) $this->_config['f'] = $_array['f'];
}
return self::$_instance;
} | [
"public",
"function",
"configure",
"(",
"$",
"_array",
"=",
"NULL",
")",
"{",
"if",
"(",
"$",
"_array",
"!=",
"NULL",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"_array",
"[",
"'x'",
"]",
")",
")",
"$",
"this",
"->",
"_config",
"[",
"'x'",
"]",
"=... | configure the attribute of the Verify code.
@param null $_array
@return VerifyCode | [
"configure",
"the",
"attribute",
"of",
"the",
"Verify",
"code",
"."
] | dc0a7b1c73b005098fd627977cd787eb0ab4a4e2 | https://github.com/yangjian102621/herosphp/blob/dc0a7b1c73b005098fd627977cd787eb0ab4a4e2/src/image/VerifyCode.php#L51-L60 | train |
matteosister/GitElephantBundle | Command/MergeCommand.php | MergeCommand.execute | protected function execute(InputInterface $input, OutputInterface $output)
{
// Welcome
$output->writeln(
'<info>Welcome to the Cypress GitElephantBundle merge command.</info>'
);
if ($input->getOption('no-push')) {
$output->writeln(
'<comment>--no-push option enabled (this option disable push destination branch to remotes)</comment>'
);
}
/** @var GitElephantRepositoryCollection $rc */
$rc = $this->getContainer()->get('git_repositories');
if ($rc->count() == 0) {
throw new \Exception('Must have at least one Git repository. See https://github.com/matteosister/GitElephantBundle#how-to-use');
}
/** @var Repository $repository */
foreach ($rc as $key => $repository) {
if ($key == 0 || $key > 0 && $input->getOption('all')) {
/** @var Branch $source */
$source = $repository->getBranch($input->getArgument('source'));
if (is_null($source)) {
throw new \Exception('Source branch ' . $input->getArgument('source') . ' doesn\'t exists');
}
/** @var Branch $destination */
$destination = $repository->getBranch($input->getArgument('destination'));
if (is_null($destination)) {
throw new \Exception('Destination branch ' . $input->getArgument('destination') . ' doesn\'t exists');
}
$repository->checkout($destination->getName());
$repository->merge($source, '', (!$input->getOption('fast-forward') ? 'no-ff' : 'ff-only'));
if (!$input->getOption('no-push')) {
/** @var Remote $remote */
foreach ($repository->getRemotes() as $remote) {
$repository->push($remote->getName(), $repository->getMainBranch()->getName()); // Push destination branch to all remotes
}
}
$repository->checkout($input->getArgument('source'));
$output->writeln('Merge from ' . $input->getArgument('source') . ' branch to ' . $input->getArgument('destination') . ' done' . (!$input->getOption('no-push') ? ' and pushed to all remotes.' : ''));
}
}
} | php | protected function execute(InputInterface $input, OutputInterface $output)
{
// Welcome
$output->writeln(
'<info>Welcome to the Cypress GitElephantBundle merge command.</info>'
);
if ($input->getOption('no-push')) {
$output->writeln(
'<comment>--no-push option enabled (this option disable push destination branch to remotes)</comment>'
);
}
/** @var GitElephantRepositoryCollection $rc */
$rc = $this->getContainer()->get('git_repositories');
if ($rc->count() == 0) {
throw new \Exception('Must have at least one Git repository. See https://github.com/matteosister/GitElephantBundle#how-to-use');
}
/** @var Repository $repository */
foreach ($rc as $key => $repository) {
if ($key == 0 || $key > 0 && $input->getOption('all')) {
/** @var Branch $source */
$source = $repository->getBranch($input->getArgument('source'));
if (is_null($source)) {
throw new \Exception('Source branch ' . $input->getArgument('source') . ' doesn\'t exists');
}
/** @var Branch $destination */
$destination = $repository->getBranch($input->getArgument('destination'));
if (is_null($destination)) {
throw new \Exception('Destination branch ' . $input->getArgument('destination') . ' doesn\'t exists');
}
$repository->checkout($destination->getName());
$repository->merge($source, '', (!$input->getOption('fast-forward') ? 'no-ff' : 'ff-only'));
if (!$input->getOption('no-push')) {
/** @var Remote $remote */
foreach ($repository->getRemotes() as $remote) {
$repository->push($remote->getName(), $repository->getMainBranch()->getName()); // Push destination branch to all remotes
}
}
$repository->checkout($input->getArgument('source'));
$output->writeln('Merge from ' . $input->getArgument('source') . ' branch to ' . $input->getArgument('destination') . ' done' . (!$input->getOption('no-push') ? ' and pushed to all remotes.' : ''));
}
}
} | [
"protected",
"function",
"execute",
"(",
"InputInterface",
"$",
"input",
",",
"OutputInterface",
"$",
"output",
")",
"{",
"// Welcome",
"$",
"output",
"->",
"writeln",
"(",
"'<info>Welcome to the Cypress GitElephantBundle merge command.</info>'",
")",
";",
"if",
"(",
... | Execute merge command
@param InputInterface $input
@param OutputInterface $output
@throws \Exception
@return int|null|void | [
"Execute",
"merge",
"command"
] | 8235b9ed91a62bb6acf685f6b71cce3db73de6ef | https://github.com/matteosister/GitElephantBundle/blob/8235b9ed91a62bb6acf685f6b71cce3db73de6ef/Command/MergeCommand.php#L82-L126 | train |
orchestral/model | src/User.php | User.getSearchableRules | public function getSearchableRules(): array
{
return [
'roles:[]' => function (Builder $query, array $roles) {
return $query->whereHas('roles', function (Builder $query) use ($roles) {
return $query->whereIn(Role::column('name'), $roles);
});
},
];
} | php | public function getSearchableRules(): array
{
return [
'roles:[]' => function (Builder $query, array $roles) {
return $query->whereHas('roles', function (Builder $query) use ($roles) {
return $query->whereIn(Role::column('name'), $roles);
});
},
];
} | [
"public",
"function",
"getSearchableRules",
"(",
")",
":",
"array",
"{",
"return",
"[",
"'roles:[]'",
"=>",
"function",
"(",
"Builder",
"$",
"query",
",",
"array",
"$",
"roles",
")",
"{",
"return",
"$",
"query",
"->",
"whereHas",
"(",
"'roles'",
",",
"fu... | Get searchable rules.
@return array | [
"Get",
"searchable",
"rules",
"."
] | 59eb60a022afb3caa0ac5824d6faac85f3255c0d | https://github.com/orchestral/model/blob/59eb60a022afb3caa0ac5824d6faac85f3255c0d/src/User.php#L60-L69 | train |
orchestral/model | src/User.php | User.scopeHasRoles | public function scopeHasRoles(Builder $query, array $roles = []): Builder
{
$query->with('roles')->whereNotNull('users.id');
if (! empty($roles)) {
$query->whereHas('roles', function ($query) use ($roles) {
$query->whereIn(Role::column('name'), $roles);
});
}
return $query;
} | php | public function scopeHasRoles(Builder $query, array $roles = []): Builder
{
$query->with('roles')->whereNotNull('users.id');
if (! empty($roles)) {
$query->whereHas('roles', function ($query) use ($roles) {
$query->whereIn(Role::column('name'), $roles);
});
}
return $query;
} | [
"public",
"function",
"scopeHasRoles",
"(",
"Builder",
"$",
"query",
",",
"array",
"$",
"roles",
"=",
"[",
"]",
")",
":",
"Builder",
"{",
"$",
"query",
"->",
"with",
"(",
"'roles'",
")",
"->",
"whereNotNull",
"(",
"'users.id'",
")",
";",
"if",
"(",
"... | Search user based on keyword as roles.
@param \Illuminate\Database\Eloquent\Builder $query
@param array $roles
@return \Illuminate\Database\Eloquent\Builder | [
"Search",
"user",
"based",
"on",
"keyword",
"as",
"roles",
"."
] | 59eb60a022afb3caa0ac5824d6faac85f3255c0d | https://github.com/orchestral/model/blob/59eb60a022afb3caa0ac5824d6faac85f3255c0d/src/User.php#L79-L90 | train |
orchestral/model | src/User.php | User.scopeHasRolesId | public function scopeHasRolesId(Builder $query, array $rolesId = []): Builder
{
$query->with('roles')->whereNotNull('users.id');
if (! empty($rolesId)) {
$query->whereHas('roles', function ($query) use ($rolesId) {
$query->whereIn(Role::column('id'), $rolesId);
});
}
return $query;
} | php | public function scopeHasRolesId(Builder $query, array $rolesId = []): Builder
{
$query->with('roles')->whereNotNull('users.id');
if (! empty($rolesId)) {
$query->whereHas('roles', function ($query) use ($rolesId) {
$query->whereIn(Role::column('id'), $rolesId);
});
}
return $query;
} | [
"public",
"function",
"scopeHasRolesId",
"(",
"Builder",
"$",
"query",
",",
"array",
"$",
"rolesId",
"=",
"[",
"]",
")",
":",
"Builder",
"{",
"$",
"query",
"->",
"with",
"(",
"'roles'",
")",
"->",
"whereNotNull",
"(",
"'users.id'",
")",
";",
"if",
"(",... | Search user based on keyword as roles id.
@param \Illuminate\Database\Eloquent\Builder $query
@param array $rolesId
@return \Illuminate\Database\Eloquent\Builder | [
"Search",
"user",
"based",
"on",
"keyword",
"as",
"roles",
"id",
"."
] | 59eb60a022afb3caa0ac5824d6faac85f3255c0d | https://github.com/orchestral/model/blob/59eb60a022afb3caa0ac5824d6faac85f3255c0d/src/User.php#L100-L111 | train |
orchestral/model | src/User.php | User.setPasswordAttribute | public function setPasswordAttribute(string $value): void
{
if (Hash::needsRehash($value)) {
$value = Hash::make($value);
}
$this->attributes['password'] = $value;
} | php | public function setPasswordAttribute(string $value): void
{
if (Hash::needsRehash($value)) {
$value = Hash::make($value);
}
$this->attributes['password'] = $value;
} | [
"public",
"function",
"setPasswordAttribute",
"(",
"string",
"$",
"value",
")",
":",
"void",
"{",
"if",
"(",
"Hash",
"::",
"needsRehash",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"Hash",
"::",
"make",
"(",
"$",
"value",
")",
";",
"}",
"... | Set `password` mutator.
@param string $value
@return void | [
"Set",
"password",
"mutator",
"."
] | 59eb60a022afb3caa0ac5824d6faac85f3255c0d | https://github.com/orchestral/model/blob/59eb60a022afb3caa0ac5824d6faac85f3255c0d/src/User.php#L130-L137 | train |
orchestral/model | src/Concerns/OwnedBy.php | OwnedBy.scopeOwnedBy | public function scopeOwnedBy(Builder $query, Model $related, ?string $key = null): Builder
{
if (\is_null($key)) {
$key = $related->getForeignKey();
}
return $query->where($key, $related->getKey());
} | php | public function scopeOwnedBy(Builder $query, Model $related, ?string $key = null): Builder
{
if (\is_null($key)) {
$key = $related->getForeignKey();
}
return $query->where($key, $related->getKey());
} | [
"public",
"function",
"scopeOwnedBy",
"(",
"Builder",
"$",
"query",
",",
"Model",
"$",
"related",
",",
"?",
"string",
"$",
"key",
"=",
"null",
")",
":",
"Builder",
"{",
"if",
"(",
"\\",
"is_null",
"(",
"$",
"key",
")",
")",
"{",
"$",
"key",
"=",
... | Scope query to get model which are owned by the specified model.
@param \Illuminate\Database\Eloquent\Builder $query
@param \Illuminate\Database\Eloquent\Model $related
@param string|null $key
@return \Illuminate\Database\Eloquent\Builder | [
"Scope",
"query",
"to",
"get",
"model",
"which",
"are",
"owned",
"by",
"the",
"specified",
"model",
"."
] | 59eb60a022afb3caa0ac5824d6faac85f3255c0d | https://github.com/orchestral/model/blob/59eb60a022afb3caa0ac5824d6faac85f3255c0d/src/Concerns/OwnedBy.php#L19-L26 | train |
duncan3dc/bom-string | src/Handler.php | Handler.getEncoding | private function getEncoding(string &$string): string
{
# Check for the UTF-8 byte order mark
if (substr($string, 0, 3) === self::UTF8) {
$string = substr($string, 3);
return self::UTF8;
}
# Check for the UTF-16 big endian byte order mark
if (substr($string, 0, 2) === self::UTF16BE) {
$string = substr($string, 2);
return self::UTF16BE;
}
# Check for the UTF-16 little endian byte order mark
if (substr($string, 0, 2) === self::UTF16LE) {
$string = substr($string, 2);
return self::UTF16LE;
}
return self::UNKNOWN;
} | php | private function getEncoding(string &$string): string
{
# Check for the UTF-8 byte order mark
if (substr($string, 0, 3) === self::UTF8) {
$string = substr($string, 3);
return self::UTF8;
}
# Check for the UTF-16 big endian byte order mark
if (substr($string, 0, 2) === self::UTF16BE) {
$string = substr($string, 2);
return self::UTF16BE;
}
# Check for the UTF-16 little endian byte order mark
if (substr($string, 0, 2) === self::UTF16LE) {
$string = substr($string, 2);
return self::UTF16LE;
}
return self::UNKNOWN;
} | [
"private",
"function",
"getEncoding",
"(",
"string",
"&",
"$",
"string",
")",
":",
"string",
"{",
"# Check for the UTF-8 byte order mark",
"if",
"(",
"substr",
"(",
"$",
"string",
",",
"0",
",",
"3",
")",
"===",
"self",
"::",
"UTF8",
")",
"{",
"$",
"stri... | Get the encoding of a BOM declared string, and remove the bom.
@param string $string The data to examine
@return string The encoding of the string | [
"Get",
"the",
"encoding",
"of",
"a",
"BOM",
"declared",
"string",
"and",
"remove",
"the",
"bom",
"."
] | 0dd75e228f5524b64c23e5734faed909d9ff5281 | https://github.com/duncan3dc/bom-string/blob/0dd75e228f5524b64c23e5734faed909d9ff5281/src/Handler.php#L28-L49 | train |
duncan3dc/bom-string | src/Handler.php | Handler.convert | public function convert(string $string): string
{
if ($this->encoding === null) {
$this->encoding = $this->getEncoding($string);
}
if ($this->encoding === self::UTF16BE) {
$string = mb_convert_encoding($string, "UTF-8", "UTF-16BE");
}
if ($this->encoding === self::UTF16LE) {
$string = mb_convert_encoding($string, "UTF-8", "UTF-16LE");
}
return $string;
} | php | public function convert(string $string): string
{
if ($this->encoding === null) {
$this->encoding = $this->getEncoding($string);
}
if ($this->encoding === self::UTF16BE) {
$string = mb_convert_encoding($string, "UTF-8", "UTF-16BE");
}
if ($this->encoding === self::UTF16LE) {
$string = mb_convert_encoding($string, "UTF-8", "UTF-16LE");
}
return $string;
} | [
"public",
"function",
"convert",
"(",
"string",
"$",
"string",
")",
":",
"string",
"{",
"if",
"(",
"$",
"this",
"->",
"encoding",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"encoding",
"=",
"$",
"this",
"->",
"getEncoding",
"(",
"$",
"string",
")",
... | Read some data, remove any BOM found, and convert to UTF-8.
@param string $string The data to read/convert
@return string | [
"Read",
"some",
"data",
"remove",
"any",
"BOM",
"found",
"and",
"convert",
"to",
"UTF",
"-",
"8",
"."
] | 0dd75e228f5524b64c23e5734faed909d9ff5281 | https://github.com/duncan3dc/bom-string/blob/0dd75e228f5524b64c23e5734faed909d9ff5281/src/Handler.php#L59-L74 | train |
crysalead/chaos-orm | src/Map.php | Map.set | public function set($value, $data)
{
$id = is_object($value) ? spl_object_hash($value) : $value;
$this->_keys[$id] = $value;
$this->_data[$id] = $data;
return $this;
} | php | public function set($value, $data)
{
$id = is_object($value) ? spl_object_hash($value) : $value;
$this->_keys[$id] = $value;
$this->_data[$id] = $data;
return $this;
} | [
"public",
"function",
"set",
"(",
"$",
"value",
",",
"$",
"data",
")",
"{",
"$",
"id",
"=",
"is_object",
"(",
"$",
"value",
")",
"?",
"spl_object_hash",
"(",
"$",
"value",
")",
":",
"$",
"value",
";",
"$",
"this",
"->",
"_keys",
"[",
"$",
"id",
... | Collects an object.
@param mixed $value A value.
@param mixed $data The data to map to the value.
@return self Return `$this`. | [
"Collects",
"an",
"object",
"."
] | 835f891311bb30c9178910df7223d1cdfd269560 | https://github.com/crysalead/chaos-orm/blob/835f891311bb30c9178910df7223d1cdfd269560/src/Map.php#L30-L36 | train |
crysalead/chaos-orm | src/Map.php | Map.get | public function get($value)
{
$id = is_object($value) ? spl_object_hash($value) : $value;
if (isset($this->_data[$id])) {
return $this->_data[$id];
}
throw new ORMException("No collected data associated to the key.");
} | php | public function get($value)
{
$id = is_object($value) ? spl_object_hash($value) : $value;
if (isset($this->_data[$id])) {
return $this->_data[$id];
}
throw new ORMException("No collected data associated to the key.");
} | [
"public",
"function",
"get",
"(",
"$",
"value",
")",
"{",
"$",
"id",
"=",
"is_object",
"(",
"$",
"value",
")",
"?",
"spl_object_hash",
"(",
"$",
"value",
")",
":",
"$",
"value",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_data",
"[",
"$",
... | Gets a collected object.
@param mixed $value A value.
@return mixed The collected data. | [
"Gets",
"a",
"collected",
"object",
"."
] | 835f891311bb30c9178910df7223d1cdfd269560 | https://github.com/crysalead/chaos-orm/blob/835f891311bb30c9178910df7223d1cdfd269560/src/Map.php#L44-L51 | train |
crysalead/chaos-orm | src/Map.php | Map.delete | public function delete($value)
{
$id = is_object($value) ? spl_object_hash($value) : $value;
unset($this->_keys[$id]);
unset($this->_data[$id]);
return $this;
} | php | public function delete($value)
{
$id = is_object($value) ? spl_object_hash($value) : $value;
unset($this->_keys[$id]);
unset($this->_data[$id]);
return $this;
} | [
"public",
"function",
"delete",
"(",
"$",
"value",
")",
"{",
"$",
"id",
"=",
"is_object",
"(",
"$",
"value",
")",
"?",
"spl_object_hash",
"(",
"$",
"value",
")",
":",
"$",
"value",
";",
"unset",
"(",
"$",
"this",
"->",
"_keys",
"[",
"$",
"id",
"]... | Uncollects an object.
@param mixed $value A value.
@return self Return `$this`. | [
"Uncollects",
"an",
"object",
"."
] | 835f891311bb30c9178910df7223d1cdfd269560 | https://github.com/crysalead/chaos-orm/blob/835f891311bb30c9178910df7223d1cdfd269560/src/Map.php#L59-L65 | train |
crysalead/chaos-orm | src/Map.php | Map.has | public function has($value)
{
$id = is_object($value) ? spl_object_hash($value) : $value;
return isset($this->_data[$id]);
} | php | public function has($value)
{
$id = is_object($value) ? spl_object_hash($value) : $value;
return isset($this->_data[$id]);
} | [
"public",
"function",
"has",
"(",
"$",
"value",
")",
"{",
"$",
"id",
"=",
"is_object",
"(",
"$",
"value",
")",
"?",
"spl_object_hash",
"(",
"$",
"value",
")",
":",
"$",
"value",
";",
"return",
"isset",
"(",
"$",
"this",
"->",
"_data",
"[",
"$",
"... | Checks if an object with a specific ID has already been collected.
@param mixed $value A value.
@return boolean Returns `true` if exists, `false` otherwise. | [
"Checks",
"if",
"an",
"object",
"with",
"a",
"specific",
"ID",
"has",
"already",
"been",
"collected",
"."
] | 835f891311bb30c9178910df7223d1cdfd269560 | https://github.com/crysalead/chaos-orm/blob/835f891311bb30c9178910df7223d1cdfd269560/src/Map.php#L73-L77 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.