id int32 0 241k | repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1 value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 |
|---|---|---|---|---|---|---|---|---|---|---|---|
39,400 | cmsgears/module-core | common/models/resources/ModelMeta.php | ModelMeta.updateByNameType | public static function updateByNameType( $parentId, $parentType, $name, $type, $value, $config = [] ) {
$meta = self::findByNameType( $parentId, $parentType, $name, $type, $value, $config );
if( isset( $meta ) ) {
$meta->value = $value;
return $meta->update();
}
return false;
} | php | public static function updateByNameType( $parentId, $parentType, $name, $type, $value, $config = [] ) {
$meta = self::findByNameType( $parentId, $parentType, $name, $type, $value, $config );
if( isset( $meta ) ) {
$meta->value = $value;
return $meta->update();
}
return false;
} | [
"public",
"static",
"function",
"updateByNameType",
"(",
"$",
"parentId",
",",
"$",
"parentType",
",",
"$",
"name",
",",
"$",
"type",
",",
"$",
"value",
",",
"$",
"config",
"=",
"[",
"]",
")",
"{",
"$",
"meta",
"=",
"self",
"::",
"findByNameType",
"(... | Update the meta value for given parent id, parent type, name and type.
@param integer $parentId
@param string $parentType
@param string $name
@param string $type
@param type $value
@return int|false either 1 or false if meta not found or validation fails. | [
"Update",
"the",
"meta",
"value",
"for",
"given",
"parent",
"id",
"parent",
"type",
"name",
"and",
"type",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/resources/ModelMeta.php#L299-L311 |
39,401 | phPoirot/Std | src/Environment/EnvBase.php | EnvBase.apply | final function apply($settings = null, $throwException = false)
{
if ($settings !== null)
$this->import($settings);
# initialize specific environment
$this->initApply();
# do apply by current options value
foreach($this as $prop => $value) {
$method = 'do'.StdString::of($prop)->camelCase();
if (! method_exists($this, $method) && $throwException)
throw new \Exception(sprintf(
'Unknown instruction (%s).'
, $method
));
$this->{$method}($value);
}
} | php | final function apply($settings = null, $throwException = false)
{
if ($settings !== null)
$this->import($settings);
# initialize specific environment
$this->initApply();
# do apply by current options value
foreach($this as $prop => $value) {
$method = 'do'.StdString::of($prop)->camelCase();
if (! method_exists($this, $method) && $throwException)
throw new \Exception(sprintf(
'Unknown instruction (%s).'
, $method
));
$this->{$method}($value);
}
} | [
"final",
"function",
"apply",
"(",
"$",
"settings",
"=",
"null",
",",
"$",
"throwException",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"settings",
"!==",
"null",
")",
"$",
"this",
"->",
"import",
"(",
"$",
"settings",
")",
";",
"# initialize specific envir... | Setup Php Environment
EnvBase|array|\Traversable $settings Will override default environment values
bool $throwException Safe load
@param $settings
@param bool $throwException
@throws \Exception | [
"Setup",
"Php",
"Environment"
] | 67883b1b1dd2cea80fec3d98a199c403b8a23b4d | https://github.com/phPoirot/Std/blob/67883b1b1dd2cea80fec3d98a199c403b8a23b4d/src/Environment/EnvBase.php#L38-L58 |
39,402 | nails/module-form-builder | src/Service/FieldType.php | FieldType.getAll | public function getAll($bOnlySelectable = false)
{
$aOut = [];
foreach ($this->aAvailable as $oType) {
$sClassName = $oType->slug;
if (!$bOnlySelectable || $sClassName::IS_SELECTABLE) {
$aOut[] = $oType;
}
}
return $aOut;
} | php | public function getAll($bOnlySelectable = false)
{
$aOut = [];
foreach ($this->aAvailable as $oType) {
$sClassName = $oType->slug;
if (!$bOnlySelectable || $sClassName::IS_SELECTABLE) {
$aOut[] = $oType;
}
}
return $aOut;
} | [
"public",
"function",
"getAll",
"(",
"$",
"bOnlySelectable",
"=",
"false",
")",
"{",
"$",
"aOut",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"aAvailable",
"as",
"$",
"oType",
")",
"{",
"$",
"sClassName",
"=",
"$",
"oType",
"->",
"slug",
... | Returns all available Field definitions
@param boolean $bOnlySelectable Filter out field types which are not selectable by the user
@return array | [
"Returns",
"all",
"available",
"Field",
"definitions"
] | a961a8791a75d01884f46f8e2b492d1cca07fb5b | https://github.com/nails/module-form-builder/blob/a961a8791a75d01884f46f8e2b492d1cca07fb5b/src/Service/FieldType.php#L101-L113 |
39,403 | nails/module-form-builder | src/Service/FieldType.php | FieldType.getAllFlat | public function getAllFlat($bOnlySelectable = false)
{
$aAvailable = $this->getAll($bOnlySelectable);
$aOut = [];
foreach ($aAvailable as $oType) {
$aOut[$oType->slug] = $oType->label;
}
return $aOut;
} | php | public function getAllFlat($bOnlySelectable = false)
{
$aAvailable = $this->getAll($bOnlySelectable);
$aOut = [];
foreach ($aAvailable as $oType) {
$aOut[$oType->slug] = $oType->label;
}
return $aOut;
} | [
"public",
"function",
"getAllFlat",
"(",
"$",
"bOnlySelectable",
"=",
"false",
")",
"{",
"$",
"aAvailable",
"=",
"$",
"this",
"->",
"getAll",
"(",
"$",
"bOnlySelectable",
")",
";",
"$",
"aOut",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"aAvailable",
"as... | Return all the available types of field which can be created as a flat array
@param boolean $bOnlySelectable Filter out field types which are not selectable by the user
@return array | [
"Return",
"all",
"the",
"available",
"types",
"of",
"field",
"which",
"can",
"be",
"created",
"as",
"a",
"flat",
"array"
] | a961a8791a75d01884f46f8e2b492d1cca07fb5b | https://github.com/nails/module-form-builder/blob/a961a8791a75d01884f46f8e2b492d1cca07fb5b/src/Service/FieldType.php#L124-L134 |
39,404 | nails/module-form-builder | src/Service/FieldType.php | FieldType.getAllWithOptions | public function getAllWithOptions($bOnlySelectable = false)
{
$aAvailable = $this->getAll($bOnlySelectable);
$aOut = [];
foreach ($aAvailable as $oType) {
$sClassName = $oType->slug;
if ($sClassName::SUPPORTS_OPTIONS) {
$aOut[] = $oType;
}
}
return $aOut;
} | php | public function getAllWithOptions($bOnlySelectable = false)
{
$aAvailable = $this->getAll($bOnlySelectable);
$aOut = [];
foreach ($aAvailable as $oType) {
$sClassName = $oType->slug;
if ($sClassName::SUPPORTS_OPTIONS) {
$aOut[] = $oType;
}
}
return $aOut;
} | [
"public",
"function",
"getAllWithOptions",
"(",
"$",
"bOnlySelectable",
"=",
"false",
")",
"{",
"$",
"aAvailable",
"=",
"$",
"this",
"->",
"getAll",
"(",
"$",
"bOnlySelectable",
")",
";",
"$",
"aOut",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"aAvailable"... | Returns the types which support defining multiple options
@param boolean $bOnlySelectable Filter out field types which are not selectable by the user
@return array | [
"Returns",
"the",
"types",
"which",
"support",
"defining",
"multiple",
"options"
] | a961a8791a75d01884f46f8e2b492d1cca07fb5b | https://github.com/nails/module-form-builder/blob/a961a8791a75d01884f46f8e2b492d1cca07fb5b/src/Service/FieldType.php#L145-L158 |
39,405 | nails/module-form-builder | src/Service/FieldType.php | FieldType.getAllWithDefaultValue | public function getAllWithDefaultValue($bOnlySelectable = false)
{
$aAvailable = $this->getAll($bOnlySelectable);
$aOut = [];
foreach ($aAvailable as $oType) {
$sClassName = $oType->slug;
if ($sClassName::SUPPORTS_DEFAULTS) {
$aOut[] = $oType;
}
}
return $aOut;
} | php | public function getAllWithDefaultValue($bOnlySelectable = false)
{
$aAvailable = $this->getAll($bOnlySelectable);
$aOut = [];
foreach ($aAvailable as $oType) {
$sClassName = $oType->slug;
if ($sClassName::SUPPORTS_DEFAULTS) {
$aOut[] = $oType;
}
}
return $aOut;
} | [
"public",
"function",
"getAllWithDefaultValue",
"(",
"$",
"bOnlySelectable",
"=",
"false",
")",
"{",
"$",
"aAvailable",
"=",
"$",
"this",
"->",
"getAll",
"(",
"$",
"bOnlySelectable",
")",
";",
"$",
"aOut",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"aAvail... | Returns the types which support a default value
@param boolean $bOnlySelectable Filter out field types which are not selectable by the user
@return array | [
"Returns",
"the",
"types",
"which",
"support",
"a",
"default",
"value"
] | a961a8791a75d01884f46f8e2b492d1cca07fb5b | https://github.com/nails/module-form-builder/blob/a961a8791a75d01884f46f8e2b492d1cca07fb5b/src/Service/FieldType.php#L169-L182 |
39,406 | nails/module-form-builder | src/Service/FieldType.php | FieldType.getBySlug | public function getBySlug($sSlug, $bOnlySelectable = false)
{
$aAvailable = $this->getAll($bOnlySelectable);
foreach ($aAvailable as $oType) {
if ($oType->slug == $sSlug) {
if (!isset($oType->instance)) {
$oType->instance = Factory::factory(
$oType->component,
$oType->provider
);
}
return $oType->instance;
}
}
return null;
} | php | public function getBySlug($sSlug, $bOnlySelectable = false)
{
$aAvailable = $this->getAll($bOnlySelectable);
foreach ($aAvailable as $oType) {
if ($oType->slug == $sSlug) {
if (!isset($oType->instance)) {
$oType->instance = Factory::factory(
$oType->component,
$oType->provider
);
}
return $oType->instance;
}
}
return null;
} | [
"public",
"function",
"getBySlug",
"(",
"$",
"sSlug",
",",
"$",
"bOnlySelectable",
"=",
"false",
")",
"{",
"$",
"aAvailable",
"=",
"$",
"this",
"->",
"getAll",
"(",
"$",
"bOnlySelectable",
")",
";",
"foreach",
"(",
"$",
"aAvailable",
"as",
"$",
"oType",
... | Get an individual field type instance by it's slug
@param string $sSlug The Field Type's slug
@param boolean $bOnlySelectable Filter out field types which are not selectable by the user
@return object | [
"Get",
"an",
"individual",
"field",
"type",
"instance",
"by",
"it",
"s",
"slug"
] | a961a8791a75d01884f46f8e2b492d1cca07fb5b | https://github.com/nails/module-form-builder/blob/a961a8791a75d01884f46f8e2b492d1cca07fb5b/src/Service/FieldType.php#L194-L214 |
39,407 | cmsgears/module-core | common/models/forms/Register.php | Register.validateEmail | public function validateEmail( $attribute, $params ) {
if( !$this->hasErrors() ) {
if( $this->userService->isExistByEmail( $this->email ) ) {
$this->addError( $attribute, Yii::$app->coreMessage->getMessage( CoreGlobal::ERROR_EMAIL_EXIST ) );
}
}
} | php | public function validateEmail( $attribute, $params ) {
if( !$this->hasErrors() ) {
if( $this->userService->isExistByEmail( $this->email ) ) {
$this->addError( $attribute, Yii::$app->coreMessage->getMessage( CoreGlobal::ERROR_EMAIL_EXIST ) );
}
}
} | [
"public",
"function",
"validateEmail",
"(",
"$",
"attribute",
",",
"$",
"params",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasErrors",
"(",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"userService",
"->",
"isExistByEmail",
"(",
"$",
"this",
"->... | Check whether the email is available.
@param string $attribute
@param array $params | [
"Check",
"whether",
"the",
"email",
"is",
"available",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/forms/Register.php#L206-L215 |
39,408 | cmsgears/module-core | common/models/forms/Register.php | Register.validateUsername | public function validateUsername( $attribute, $params ) {
if( !$this->hasErrors() ) {
if( $this->userService->isExistByUsername( $this->username ) ) {
$this->addError( $attribute, Yii::$app->coreMessage->getMessage( CoreGlobal::ERROR_USERNAME_EXIST ) );
}
}
} | php | public function validateUsername( $attribute, $params ) {
if( !$this->hasErrors() ) {
if( $this->userService->isExistByUsername( $this->username ) ) {
$this->addError( $attribute, Yii::$app->coreMessage->getMessage( CoreGlobal::ERROR_USERNAME_EXIST ) );
}
}
} | [
"public",
"function",
"validateUsername",
"(",
"$",
"attribute",
",",
"$",
"params",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasErrors",
"(",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"userService",
"->",
"isExistByUsername",
"(",
"$",
"this",... | Check whether the username is available.
@param string $attribute
@param array $params | [
"Check",
"whether",
"the",
"username",
"is",
"available",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/forms/Register.php#L223-L232 |
39,409 | cmsgears/module-core | common/models/forms/Register.php | Register.termsValidator | public function termsValidator( $attribute, $params ) {
if( $this->terms === 'on' ) {
return;
}
if( !isset( $this->terms ) || $this->terms <= 0 ) {
$this->addError( $attribute, Yii::$app->coreMessage->getMessage( CoreGlobal::ERROR_TERMS ) );
}
} | php | public function termsValidator( $attribute, $params ) {
if( $this->terms === 'on' ) {
return;
}
if( !isset( $this->terms ) || $this->terms <= 0 ) {
$this->addError( $attribute, Yii::$app->coreMessage->getMessage( CoreGlobal::ERROR_TERMS ) );
}
} | [
"public",
"function",
"termsValidator",
"(",
"$",
"attribute",
",",
"$",
"params",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"terms",
"===",
"'on'",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"terms",
")",
"||",
... | Check whether user agreed to terms and conditions.
@param string $attribute
@param array $params | [
"Check",
"whether",
"user",
"agreed",
"to",
"terms",
"and",
"conditions",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/forms/Register.php#L240-L251 |
39,410 | phPoirot/Std | src/Type/fixes/NSplEnum.php | NSplEnum.getConstList | function getConstList($include_default = false)
{
if (isset($this->_c__consts))
return $this->_c__consts;
$reflection = new ReflectionClass($this);
$consts = $reflection->getConstants();
if ((bool)$include_default === false)
unset($consts['__default']);
return $this->_c__consts = $consts;
} | php | function getConstList($include_default = false)
{
if (isset($this->_c__consts))
return $this->_c__consts;
$reflection = new ReflectionClass($this);
$consts = $reflection->getConstants();
if ((bool)$include_default === false)
unset($consts['__default']);
return $this->_c__consts = $consts;
} | [
"function",
"getConstList",
"(",
"$",
"include_default",
"=",
"false",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_c__consts",
")",
")",
"return",
"$",
"this",
"->",
"_c__consts",
";",
"$",
"reflection",
"=",
"new",
"ReflectionClass",
"(",
"$... | Get Constant Lists
@param bool $include_default
@return array | [
"Get",
"Constant",
"Lists"
] | 67883b1b1dd2cea80fec3d98a199c403b8a23b4d | https://github.com/phPoirot/Std/blob/67883b1b1dd2cea80fec3d98a199c403b8a23b4d/src/Type/fixes/NSplEnum.php#L46-L57 |
39,411 | mcaskill/charcoal-support | src/Model/ManufacturableModelLoaderTrait.php | ManufacturableModelLoaderTrait.modelLoader | protected function modelLoader($objType, $objKey = null)
{
if (!is_string($objType)) {
throw new InvalidArgumentException(sprintf(
'The object type must be a string, received %s',
get_var_type($objType)
));
}
$key = $objKey;
if ($key === null) {
$key = '_';
} elseif (!is_string($key)) {
throw new InvalidArgumentException(sprintf(
'The object property key must be a string, received %s',
get_var_type($key)
));
}
if (isset(self::$modelLoaders[$objType][$key])) {
return self::$modelLoaders[$objType][$key];
}
$builder = $this->modelLoaderBuilder();
self::$modelLoaders[$objType][$key] = $builder($objType, $objKey);
return self::$modelLoaders[$objType][$key];
} | php | protected function modelLoader($objType, $objKey = null)
{
if (!is_string($objType)) {
throw new InvalidArgumentException(sprintf(
'The object type must be a string, received %s',
get_var_type($objType)
));
}
$key = $objKey;
if ($key === null) {
$key = '_';
} elseif (!is_string($key)) {
throw new InvalidArgumentException(sprintf(
'The object property key must be a string, received %s',
get_var_type($key)
));
}
if (isset(self::$modelLoaders[$objType][$key])) {
return self::$modelLoaders[$objType][$key];
}
$builder = $this->modelLoaderBuilder();
self::$modelLoaders[$objType][$key] = $builder($objType, $objKey);
return self::$modelLoaders[$objType][$key];
} | [
"protected",
"function",
"modelLoader",
"(",
"$",
"objType",
",",
"$",
"objKey",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"objType",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'The object type must b... | Retrieve the object laoder for the given model.
@param string $objType The target model.
@param string|null $objKey The target model's key to load by.
@throws InvalidArgumentException If the $objType or $objKey are invalid.
@return ModelLoader | [
"Retrieve",
"the",
"object",
"laoder",
"for",
"the",
"given",
"model",
"."
] | 2138a34463ca6865bf3a60635aa11381a9ae73c5 | https://github.com/mcaskill/charcoal-support/blob/2138a34463ca6865bf3a60635aa11381a9ae73c5/src/Model/ManufacturableModelLoaderTrait.php#L67-L95 |
39,412 | phPoirot/Std | src/MutexLock.php | MutexLock.acquire | function acquire()
{
if ( $this->isLocked() )
// resource is locked
return false;
$lockRes = static::_getLocksDir("{$this->realm}.lockfile");
if (false === $this->file = $file = fopen($lockRes, 'w+') )
throw new \RuntimeException(sprintf(
'Failed To Open Resource (%s).'
, $lockRes
));
if (! flock($file, LOCK_EX | LOCK_NB, $wouldBlock) ) {
if ($wouldBlock)
// another process holds the lock
return false;
throw new \RuntimeException(sprintf(
'FAILED to acquire lock[%s] on resource (%s).'
, $this->realm
, $lockRes
));
}
ftruncate($file, 0);
fwrite($file, sprintf("(%s): Locked Accrued. \n", date('Y-m-d H:i:s')));
fflush($file);
return true;
} | php | function acquire()
{
if ( $this->isLocked() )
// resource is locked
return false;
$lockRes = static::_getLocksDir("{$this->realm}.lockfile");
if (false === $this->file = $file = fopen($lockRes, 'w+') )
throw new \RuntimeException(sprintf(
'Failed To Open Resource (%s).'
, $lockRes
));
if (! flock($file, LOCK_EX | LOCK_NB, $wouldBlock) ) {
if ($wouldBlock)
// another process holds the lock
return false;
throw new \RuntimeException(sprintf(
'FAILED to acquire lock[%s] on resource (%s).'
, $this->realm
, $lockRes
));
}
ftruncate($file, 0);
fwrite($file, sprintf("(%s): Locked Accrued. \n", date('Y-m-d H:i:s')));
fflush($file);
return true;
} | [
"function",
"acquire",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isLocked",
"(",
")",
")",
"// resource is locked",
"return",
"false",
";",
"$",
"lockRes",
"=",
"static",
"::",
"_getLocksDir",
"(",
"\"{$this->realm}.lockfile\"",
")",
";",
"if",
"(",
"f... | Put Lock On Resource
@return bool | [
"Put",
"Lock",
"On",
"Resource"
] | 67883b1b1dd2cea80fec3d98a199c403b8a23b4d | https://github.com/phPoirot/Std/blob/67883b1b1dd2cea80fec3d98a199c403b8a23b4d/src/MutexLock.php#L34-L67 |
39,413 | phPoirot/Std | src/MutexLock.php | MutexLock.release | function release()
{
$lockRes = static::_getLocksDir("{$this->realm}.lockfile");
if ( null === $file = $this->file )
if (false === $file = fopen($lockRes, 'w+') )
throw new \RuntimeException(sprintf(
'Failed To Open Resource (%s).'
, $lockRes
));
## Release Lock Res.
#
$this->file = null;
if (! flock($file, LOCK_UN) )
throw new \RuntimeException(sprintf(
'FAILED to release lock[%s] on resource (%s).'
, $this->realm
, $lockRes
));
fclose($file);
unlink($lockRes);
return true;
} | php | function release()
{
$lockRes = static::_getLocksDir("{$this->realm}.lockfile");
if ( null === $file = $this->file )
if (false === $file = fopen($lockRes, 'w+') )
throw new \RuntimeException(sprintf(
'Failed To Open Resource (%s).'
, $lockRes
));
## Release Lock Res.
#
$this->file = null;
if (! flock($file, LOCK_UN) )
throw new \RuntimeException(sprintf(
'FAILED to release lock[%s] on resource (%s).'
, $this->realm
, $lockRes
));
fclose($file);
unlink($lockRes);
return true;
} | [
"function",
"release",
"(",
")",
"{",
"$",
"lockRes",
"=",
"static",
"::",
"_getLocksDir",
"(",
"\"{$this->realm}.lockfile\"",
")",
";",
"if",
"(",
"null",
"===",
"$",
"file",
"=",
"$",
"this",
"->",
"file",
")",
"if",
"(",
"false",
"===",
"$",
"file",... | Unlock Resource Locked
@return bool | [
"Unlock",
"Resource",
"Locked"
] | 67883b1b1dd2cea80fec3d98a199c403b8a23b4d | https://github.com/phPoirot/Std/blob/67883b1b1dd2cea80fec3d98a199c403b8a23b4d/src/MutexLock.php#L84-L112 |
39,414 | phPoirot/Std | src/MutexLock.php | MutexLock.giveDefaultLocksDir | static function giveDefaultLocksDir($dirPath)
{
if ( isset(static::$defLockDirectory) )
throw new exImmutable(sprintf(
'Default Lock Directory Has Value: (%s).'
, static::$defLockDirectory
));
$dirPath = (string) $dirPath;
if (! (is_dir($dirPath) && is_writable($dirPath)) )
throw new \RuntimeException(sprintf(
'Lock Folder (%s) Is Not A Writable Directory Or Not Exists.'
, $dirPath
));
static::$defLockDirectory = $dirPath;
} | php | static function giveDefaultLocksDir($dirPath)
{
if ( isset(static::$defLockDirectory) )
throw new exImmutable(sprintf(
'Default Lock Directory Has Value: (%s).'
, static::$defLockDirectory
));
$dirPath = (string) $dirPath;
if (! (is_dir($dirPath) && is_writable($dirPath)) )
throw new \RuntimeException(sprintf(
'Lock Folder (%s) Is Not A Writable Directory Or Not Exists.'
, $dirPath
));
static::$defLockDirectory = $dirPath;
} | [
"static",
"function",
"giveDefaultLocksDir",
"(",
"$",
"dirPath",
")",
"{",
"if",
"(",
"isset",
"(",
"static",
"::",
"$",
"defLockDirectory",
")",
")",
"throw",
"new",
"exImmutable",
"(",
"sprintf",
"(",
"'Default Lock Directory Has Value: (%s).'",
",",
"static",
... | Set Default Locks Directory
@param string $dirPath | [
"Set",
"Default",
"Locks",
"Directory"
] | 67883b1b1dd2cea80fec3d98a199c403b8a23b4d | https://github.com/phPoirot/Std/blob/67883b1b1dd2cea80fec3d98a199c403b8a23b4d/src/MutexLock.php#L123-L141 |
39,415 | cmsgears/module-core | frontend/controllers/UserController.php | UserController.actionProfile | public function actionProfile() {
// Find Model
$user = Yii::$app->core->getUser();
// Avatar
$avatar = File::loadFile( $user->avatar, 'Avatar' );
// Scenario
$user->setScenario( 'profile' );
if( $user->load( Yii::$app->request->post(), $user->getClassName() ) && $user->validate() ) {
// Update User
$this->modelService->update( $user, [ 'avatar' => $avatar ] );
// Refresh Page
return $this->refresh();
}
$genderMap = $this->optionService->getIdNameMapByCategorySlug( CoreGlobal::CATEGORY_GENDER, [ 'prepend' => [ [ 'id' => '0', 'name' => 'Choose Gender' ] ] ] );
return $this->render( CoreGlobalWeb::PAGE_PROFILE, [
'user' => $user,
'avatar' => $avatar,
'genderMap' => $genderMap
]);
} | php | public function actionProfile() {
// Find Model
$user = Yii::$app->core->getUser();
// Avatar
$avatar = File::loadFile( $user->avatar, 'Avatar' );
// Scenario
$user->setScenario( 'profile' );
if( $user->load( Yii::$app->request->post(), $user->getClassName() ) && $user->validate() ) {
// Update User
$this->modelService->update( $user, [ 'avatar' => $avatar ] );
// Refresh Page
return $this->refresh();
}
$genderMap = $this->optionService->getIdNameMapByCategorySlug( CoreGlobal::CATEGORY_GENDER, [ 'prepend' => [ [ 'id' => '0', 'name' => 'Choose Gender' ] ] ] );
return $this->render( CoreGlobalWeb::PAGE_PROFILE, [
'user' => $user,
'avatar' => $avatar,
'genderMap' => $genderMap
]);
} | [
"public",
"function",
"actionProfile",
"(",
")",
"{",
"// Find Model",
"$",
"user",
"=",
"Yii",
"::",
"$",
"app",
"->",
"core",
"->",
"getUser",
"(",
")",
";",
"// Avatar",
"$",
"avatar",
"=",
"File",
"::",
"loadFile",
"(",
"$",
"user",
"->",
"avatar",... | The action profile allows users to update their profile.
@return string | [
"The",
"action",
"profile",
"allows",
"users",
"to",
"update",
"their",
"profile",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/frontend/controllers/UserController.php#L139-L166 |
39,416 | cmsgears/module-core | frontend/controllers/UserController.php | UserController.actionAccount | public function actionAccount() {
// Find Model
$user = Yii::$app->core->getUser();
$model = new ResetPassword();
// Configure Model
$model->email = $user->email;
// Old password required if it was already set
if( !empty( $user->passwordHash ) ) {
$model->setScenario( 'oldPassword' );
}
if( $model->load( Yii::$app->request->post(), $model->getClassName() ) && $model->validate() ) {
// Update User
$this->modelService->resetPassword( $user, $model, false );
return $this->refresh();
}
return $this->render( CoreGlobalWeb::PAGE_ACCOUNT, [
'user' => $user,
'model' => $model
]);
} | php | public function actionAccount() {
// Find Model
$user = Yii::$app->core->getUser();
$model = new ResetPassword();
// Configure Model
$model->email = $user->email;
// Old password required if it was already set
if( !empty( $user->passwordHash ) ) {
$model->setScenario( 'oldPassword' );
}
if( $model->load( Yii::$app->request->post(), $model->getClassName() ) && $model->validate() ) {
// Update User
$this->modelService->resetPassword( $user, $model, false );
return $this->refresh();
}
return $this->render( CoreGlobalWeb::PAGE_ACCOUNT, [
'user' => $user,
'model' => $model
]);
} | [
"public",
"function",
"actionAccount",
"(",
")",
"{",
"// Find Model",
"$",
"user",
"=",
"Yii",
"::",
"$",
"app",
"->",
"core",
"->",
"getUser",
"(",
")",
";",
"$",
"model",
"=",
"new",
"ResetPassword",
"(",
")",
";",
"// Configure Model",
"$",
"model",
... | The account action allows user to change password.
@return string | [
"The",
"account",
"action",
"allows",
"user",
"to",
"change",
"password",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/frontend/controllers/UserController.php#L173-L200 |
39,417 | cmsgears/module-core | frontend/controllers/UserController.php | UserController.actionAddress | public function actionAddress( $ctype ) {
$user = Yii::$app->core->getUser();
$address = null;
// Accept only selected type for a user
if( !in_array( $ctype, [ Address::TYPE_PRIMARY, Address::TYPE_BILLING, Address::TYPE_MAILING, Address::TYPE_SHIPPING ] ) ) {
throw new InvalidArgumentException( 'Address type not allowed.' );
}
switch( $ctype ) {
case Address::TYPE_PRIMARY: {
$address = $user->primaryAddress;
break;
}
case Address::TYPE_BILLING: {
$address = $user->billingAddress;
break;
}
case Address::TYPE_MAILING: {
$address = $user->mailingAddress;
break;
}
case Address::TYPE_SHIPPING: {
$address = $user->shippingAddress;
break;
}
}
if( empty( $address ) ) {
$address = $this->addressService->getModelObject();
}
if( $address->load( Yii::$app->request->post(), $address->getClassName() ) && $address->validate() ) {
// Create/Update Address
$address = $this->addressService->createOrUpdate( $address );
// Create Mapping
$modelAddress = $this->modelAddressService->activateByModelId( $user->id, CoreGlobal::TYPE_USER, $address->id, $ctype );
return $this->refresh();
}
$countryMap = Yii::$app->factory->get( 'countryService' )->getIdNameMap();
$countryId = isset( $address->country ) ? $address->country->id : array_keys( $countryMap )[ 0 ];
$provinceMap = Yii::$app->factory->get( 'provinceService' )->getMapByCountryId( $countryId, [ 'default' => true, 'defaultValue' => Yii::$app->core->provinceLabel ] );
$provinceId = isset( $address->province ) ? $address->province->id : array_keys( $provinceMap )[ 0 ];
$regionMap = Yii::$app->factory->get( 'regionService' )->getMapByProvinceId( $provinceId, [ 'default' => true, 'defaultValue' => Yii::$app->core->regionLabel ] );
return $this->render( 'address', [
'user' => $user,
'address' => $address,
'countryMap' => $countryMap,
'provinceMap' => $provinceMap,
'regionMap' => $regionMap
]);
} | php | public function actionAddress( $ctype ) {
$user = Yii::$app->core->getUser();
$address = null;
// Accept only selected type for a user
if( !in_array( $ctype, [ Address::TYPE_PRIMARY, Address::TYPE_BILLING, Address::TYPE_MAILING, Address::TYPE_SHIPPING ] ) ) {
throw new InvalidArgumentException( 'Address type not allowed.' );
}
switch( $ctype ) {
case Address::TYPE_PRIMARY: {
$address = $user->primaryAddress;
break;
}
case Address::TYPE_BILLING: {
$address = $user->billingAddress;
break;
}
case Address::TYPE_MAILING: {
$address = $user->mailingAddress;
break;
}
case Address::TYPE_SHIPPING: {
$address = $user->shippingAddress;
break;
}
}
if( empty( $address ) ) {
$address = $this->addressService->getModelObject();
}
if( $address->load( Yii::$app->request->post(), $address->getClassName() ) && $address->validate() ) {
// Create/Update Address
$address = $this->addressService->createOrUpdate( $address );
// Create Mapping
$modelAddress = $this->modelAddressService->activateByModelId( $user->id, CoreGlobal::TYPE_USER, $address->id, $ctype );
return $this->refresh();
}
$countryMap = Yii::$app->factory->get( 'countryService' )->getIdNameMap();
$countryId = isset( $address->country ) ? $address->country->id : array_keys( $countryMap )[ 0 ];
$provinceMap = Yii::$app->factory->get( 'provinceService' )->getMapByCountryId( $countryId, [ 'default' => true, 'defaultValue' => Yii::$app->core->provinceLabel ] );
$provinceId = isset( $address->province ) ? $address->province->id : array_keys( $provinceMap )[ 0 ];
$regionMap = Yii::$app->factory->get( 'regionService' )->getMapByProvinceId( $provinceId, [ 'default' => true, 'defaultValue' => Yii::$app->core->regionLabel ] );
return $this->render( 'address', [
'user' => $user,
'address' => $address,
'countryMap' => $countryMap,
'provinceMap' => $provinceMap,
'regionMap' => $regionMap
]);
} | [
"public",
"function",
"actionAddress",
"(",
"$",
"ctype",
")",
"{",
"$",
"user",
"=",
"Yii",
"::",
"$",
"app",
"->",
"core",
"->",
"getUser",
"(",
")",
";",
"$",
"address",
"=",
"null",
";",
"// Accept only selected type for a user",
"if",
"(",
"!",
"in_... | The address action allows user to update primary address using form submit. Use the
corresponding Ajax Action to handle multiple user address.
In case we need multiple address using form submit, this action can be overridden by
child classes to load multiple address.
@return string | [
"The",
"address",
"action",
"allows",
"user",
"to",
"update",
"primary",
"address",
"using",
"form",
"submit",
".",
"Use",
"the",
"corresponding",
"Ajax",
"Action",
"to",
"handle",
"multiple",
"user",
"address",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/frontend/controllers/UserController.php#L211-L279 |
39,418 | froq/froq | src/Autoload.php | Autoload.getObjectFile | public function getObjectFile(string $objectName): ?string
{
// user service objects
if (0 === strpos($objectName, self::NAMESPACE_APP_SERVICE)) {
$objectBase = $this->getObjectBase($objectName);
if ($objectBase == self::SERVICE_NAME_MAIN || $objectBase == self::SERVICE_NAME_FAIL) {
$objectFile = sprintf('%s/app/service/_default/%s/%s.php',
$this->appDir, $objectBase, $objectBase);
} else {
$objectFile = sprintf('%s/app/service/%s/%s.php',
$this->appDir, $objectBase, $objectBase);
}
return $this->fixSlashes($objectFile);
}
// user model objects
if (0 === strpos($objectName, self::NAMESPACE_APP_DATABASE) && 'Model' === substr($objectName, -5)) {
$objectBase = $this->getObjectBase(substr($objectName, 0, -5 /* strlen('Model') */) . 'Service');
if ($objectBase == self::SERVICE_NAME_MAIN || $objectBase == self::SERVICE_NAME_FAIL) {
$objectFile = sprintf('%s/app/service/_default/%s/model/model.php',
$this->appDir, $objectBase);
} else {
$objectFile = sprintf('%s/app/service/%s/model/model.php',
$this->appDir, $objectBase);
}
return $this->fixSlashes($objectFile);
}
// user library objects
if (0 === strpos($objectName, self::NAMESPACE_APP_LIBRARY)) {
return $this->fixSlashes(sprintf('%s/app/library/%s.php',
$this->appDir, $this->getObjectBase($objectName, false)));
}
return null;
} | php | public function getObjectFile(string $objectName): ?string
{
// user service objects
if (0 === strpos($objectName, self::NAMESPACE_APP_SERVICE)) {
$objectBase = $this->getObjectBase($objectName);
if ($objectBase == self::SERVICE_NAME_MAIN || $objectBase == self::SERVICE_NAME_FAIL) {
$objectFile = sprintf('%s/app/service/_default/%s/%s.php',
$this->appDir, $objectBase, $objectBase);
} else {
$objectFile = sprintf('%s/app/service/%s/%s.php',
$this->appDir, $objectBase, $objectBase);
}
return $this->fixSlashes($objectFile);
}
// user model objects
if (0 === strpos($objectName, self::NAMESPACE_APP_DATABASE) && 'Model' === substr($objectName, -5)) {
$objectBase = $this->getObjectBase(substr($objectName, 0, -5 /* strlen('Model') */) . 'Service');
if ($objectBase == self::SERVICE_NAME_MAIN || $objectBase == self::SERVICE_NAME_FAIL) {
$objectFile = sprintf('%s/app/service/_default/%s/model/model.php',
$this->appDir, $objectBase);
} else {
$objectFile = sprintf('%s/app/service/%s/model/model.php',
$this->appDir, $objectBase);
}
return $this->fixSlashes($objectFile);
}
// user library objects
if (0 === strpos($objectName, self::NAMESPACE_APP_LIBRARY)) {
return $this->fixSlashes(sprintf('%s/app/library/%s.php',
$this->appDir, $this->getObjectBase($objectName, false)));
}
return null;
} | [
"public",
"function",
"getObjectFile",
"(",
"string",
"$",
"objectName",
")",
":",
"?",
"string",
"{",
"// user service objects",
"if",
"(",
"0",
"===",
"strpos",
"(",
"$",
"objectName",
",",
"self",
"::",
"NAMESPACE_APP_SERVICE",
")",
")",
"{",
"$",
"object... | Get object file.
@param string $objectName
@return ?string | [
"Get",
"object",
"file",
"."
] | bc153ccec05585f66301cd632ff46bad91915029 | https://github.com/froq/froq/blob/bc153ccec05585f66301cd632ff46bad91915029/src/Autoload.php#L155-L192 |
39,419 | froq/froq | src/Autoload.php | Autoload.getObjectBase | public function getObjectBase(string $objectName, bool $endOnly = true): string
{
$tmp = explode('\\', $objectName);
$end = array_pop($tmp);
if ($endOnly) {
return $end;
}
// eg: froq\app\library\entity\UserEntity => app/library/entity/UserEntity
$path = join('\\', array_slice($tmp, 3));
return $path .'\\'. $end;
} | php | public function getObjectBase(string $objectName, bool $endOnly = true): string
{
$tmp = explode('\\', $objectName);
$end = array_pop($tmp);
if ($endOnly) {
return $end;
}
// eg: froq\app\library\entity\UserEntity => app/library/entity/UserEntity
$path = join('\\', array_slice($tmp, 3));
return $path .'\\'. $end;
} | [
"public",
"function",
"getObjectBase",
"(",
"string",
"$",
"objectName",
",",
"bool",
"$",
"endOnly",
"=",
"true",
")",
":",
"string",
"{",
"$",
"tmp",
"=",
"explode",
"(",
"'\\\\'",
",",
"$",
"objectName",
")",
";",
"$",
"end",
"=",
"array_pop",
"(",
... | Get object base.
@param string $objectName
@param bool $endOnly
@return string | [
"Get",
"object",
"base",
"."
] | bc153ccec05585f66301cd632ff46bad91915029 | https://github.com/froq/froq/blob/bc153ccec05585f66301cd632ff46bad91915029/src/Autoload.php#L200-L213 |
39,420 | phPoirot/Std | src/Glob.php | Glob.fallbackGlob | protected static function fallbackGlob($pattern, $flags)
{
if (! $flags & self::GLOB_BRACE) {
return static::systemGlob($pattern, $flags);
}
$flags &= ~self::GLOB_BRACE;
$length = strlen($pattern);
$paths = [];
if ($flags & self::GLOB_NOESCAPE) {
$begin = strpos($pattern, '{');
} else {
$begin = 0;
while (true) {
if ($begin === $length) {
$begin = false;
break;
} elseif ($pattern[$begin] === '\\' && ($begin + 1) < $length) {
$begin++;
} elseif ($pattern[$begin] === '{') {
break;
}
$begin++;
}
}
if ($begin === false) {
return static::systemGlob($pattern, $flags);
}
$next = static::nextBraceSub($pattern, $begin + 1, $flags);
if ($next === null) {
return static::systemGlob($pattern, $flags);
}
$rest = $next;
while ($pattern[$rest] !== '}') {
$rest = static::nextBraceSub($pattern, $rest + 1, $flags);
if ($rest === null) {
return static::systemGlob($pattern, $flags);
}
}
$p = $begin + 1;
while (true) {
$subPattern = substr($pattern, 0, $begin)
. substr($pattern, $p, $next - $p)
. substr($pattern, $rest + 1);
$result = static::fallbackGlob($subPattern, $flags | self::GLOB_BRACE);
if ($result) {
$paths = array_merge($paths, $result);
}
if ($pattern[$next] === '}') {
break;
}
$p = $next + 1;
$next = static::nextBraceSub($pattern, $p, $flags);
}
return array_unique($paths);
} | php | protected static function fallbackGlob($pattern, $flags)
{
if (! $flags & self::GLOB_BRACE) {
return static::systemGlob($pattern, $flags);
}
$flags &= ~self::GLOB_BRACE;
$length = strlen($pattern);
$paths = [];
if ($flags & self::GLOB_NOESCAPE) {
$begin = strpos($pattern, '{');
} else {
$begin = 0;
while (true) {
if ($begin === $length) {
$begin = false;
break;
} elseif ($pattern[$begin] === '\\' && ($begin + 1) < $length) {
$begin++;
} elseif ($pattern[$begin] === '{') {
break;
}
$begin++;
}
}
if ($begin === false) {
return static::systemGlob($pattern, $flags);
}
$next = static::nextBraceSub($pattern, $begin + 1, $flags);
if ($next === null) {
return static::systemGlob($pattern, $flags);
}
$rest = $next;
while ($pattern[$rest] !== '}') {
$rest = static::nextBraceSub($pattern, $rest + 1, $flags);
if ($rest === null) {
return static::systemGlob($pattern, $flags);
}
}
$p = $begin + 1;
while (true) {
$subPattern = substr($pattern, 0, $begin)
. substr($pattern, $p, $next - $p)
. substr($pattern, $rest + 1);
$result = static::fallbackGlob($subPattern, $flags | self::GLOB_BRACE);
if ($result) {
$paths = array_merge($paths, $result);
}
if ($pattern[$next] === '}') {
break;
}
$p = $next + 1;
$next = static::nextBraceSub($pattern, $p, $flags);
}
return array_unique($paths);
} | [
"protected",
"static",
"function",
"fallbackGlob",
"(",
"$",
"pattern",
",",
"$",
"flags",
")",
"{",
"if",
"(",
"!",
"$",
"flags",
"&",
"self",
"::",
"GLOB_BRACE",
")",
"{",
"return",
"static",
"::",
"systemGlob",
"(",
"$",
"pattern",
",",
"$",
"flags"... | Expand braces manually, then use the system glob.
@param string $pattern
@param int $flags
@return array
@throws \RuntimeException | [
"Expand",
"braces",
"manually",
"then",
"use",
"the",
"system",
"glob",
"."
] | 67883b1b1dd2cea80fec3d98a199c403b8a23b4d | https://github.com/phPoirot/Std/blob/67883b1b1dd2cea80fec3d98a199c403b8a23b4d/src/Glob.php#L76-L130 |
39,421 | phPoirot/Std | src/Glob.php | Glob.nextBraceSub | protected static function nextBraceSub($pattern, $begin, $flags)
{
$length = strlen($pattern);
$depth = 0;
$current = $begin;
while ($current < $length) {
if (! $flags & self::GLOB_NOESCAPE && $pattern[$current] === '\\') {
if (++$current === $length) {
break;
}
$current++;
} else {
if (($pattern[$current] === '}' && $depth-- === 0) || ($pattern[$current] === ',' && $depth === 0)) {
break;
} elseif ($pattern[$current++] === '{') {
$depth++;
}
}
}
return ($current < $length ? $current : null);
} | php | protected static function nextBraceSub($pattern, $begin, $flags)
{
$length = strlen($pattern);
$depth = 0;
$current = $begin;
while ($current < $length) {
if (! $flags & self::GLOB_NOESCAPE && $pattern[$current] === '\\') {
if (++$current === $length) {
break;
}
$current++;
} else {
if (($pattern[$current] === '}' && $depth-- === 0) || ($pattern[$current] === ',' && $depth === 0)) {
break;
} elseif ($pattern[$current++] === '{') {
$depth++;
}
}
}
return ($current < $length ? $current : null);
} | [
"protected",
"static",
"function",
"nextBraceSub",
"(",
"$",
"pattern",
",",
"$",
"begin",
",",
"$",
"flags",
")",
"{",
"$",
"length",
"=",
"strlen",
"(",
"$",
"pattern",
")",
";",
"$",
"depth",
"=",
"0",
";",
"$",
"current",
"=",
"$",
"begin",
";"... | Find the end of the sub-pattern in a brace expression.
@param string $pattern
@param int $begin
@param int $flags
@return int|null | [
"Find",
"the",
"end",
"of",
"the",
"sub",
"-",
"pattern",
"in",
"a",
"brace",
"expression",
"."
] | 67883b1b1dd2cea80fec3d98a199c403b8a23b4d | https://github.com/phPoirot/Std/blob/67883b1b1dd2cea80fec3d98a199c403b8a23b4d/src/Glob.php#L139-L159 |
39,422 | nails/module-form-builder | src/FieldType/Base.php | Base.getStatsTextData | public function getStatsTextData($aResponses)
{
$aOut = [];
$aStrings = [];
foreach ($aResponses as $oResponse) {
if (!empty($oResponse->text)) {
if (!array_key_exists($oResponse->text, $aStrings)) {
$aStrings[$oResponse->text] = 0;
}
$aStrings[$oResponse->text]++;
}
}
foreach ($aStrings as $sString => $iCount) {
if ($iCount > 1) {
$sString .= ' <span class="count" title="This item repeats ' . $iCount . ' times">' . $iCount . '</span>';
}
$aOut[] = $sString;
}
return $aOut;
} | php | public function getStatsTextData($aResponses)
{
$aOut = [];
$aStrings = [];
foreach ($aResponses as $oResponse) {
if (!empty($oResponse->text)) {
if (!array_key_exists($oResponse->text, $aStrings)) {
$aStrings[$oResponse->text] = 0;
}
$aStrings[$oResponse->text]++;
}
}
foreach ($aStrings as $sString => $iCount) {
if ($iCount > 1) {
$sString .= ' <span class="count" title="This item repeats ' . $iCount . ' times">' . $iCount . '</span>';
}
$aOut[] = $sString;
}
return $aOut;
} | [
"public",
"function",
"getStatsTextData",
"(",
"$",
"aResponses",
")",
"{",
"$",
"aOut",
"=",
"[",
"]",
";",
"$",
"aStrings",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"aResponses",
"as",
"$",
"oResponse",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$"... | Takes responses for this field type and extracts all the text components
@param array $aResponses The array of responses from ResponseAnswer
@return array | [
"Takes",
"responses",
"for",
"this",
"field",
"type",
"and",
"extracts",
"all",
"the",
"text",
"components"
] | a961a8791a75d01884f46f8e2b492d1cca07fb5b | https://github.com/nails/module-form-builder/blob/a961a8791a75d01884f46f8e2b492d1cca07fb5b/src/FieldType/Base.php#L230-L252 |
39,423 | tyam/bamboo | src/Renderer.php | Renderer.render | public function render(string $template, array $variables = null): string
{
list($path__, $env__) = call_user_func($this->resolve, $template, $variables);
$renderer = $this;
unset($template, $variables);
extract($env__);
ob_start();
require($path__);
$output = ob_get_clean();
if ($this->next) {
// wrapper has been specified. Then continue wrapper with current output.
list($template, $variables) = $this->next;
$next = new Renderer($this->resolve, $this->sections, $output);
return $next->render($template, $variables);
} else {
return $output;
}
} | php | public function render(string $template, array $variables = null): string
{
list($path__, $env__) = call_user_func($this->resolve, $template, $variables);
$renderer = $this;
unset($template, $variables);
extract($env__);
ob_start();
require($path__);
$output = ob_get_clean();
if ($this->next) {
// wrapper has been specified. Then continue wrapper with current output.
list($template, $variables) = $this->next;
$next = new Renderer($this->resolve, $this->sections, $output);
return $next->render($template, $variables);
} else {
return $output;
}
} | [
"public",
"function",
"render",
"(",
"string",
"$",
"template",
",",
"array",
"$",
"variables",
"=",
"null",
")",
":",
"string",
"{",
"list",
"(",
"$",
"path__",
",",
"$",
"env__",
")",
"=",
"call_user_func",
"(",
"$",
"this",
"->",
"resolve",
",",
"... | renders a specified template and returns output string.
If the template inherits/includes other templates, then instantiate the new renderer objects
and renders them all.
@param string $template path to the template to be rendered
@param array|null $variables template variables
@return string rendered content | [
"renders",
"a",
"specified",
"template",
"and",
"returns",
"output",
"string",
"."
] | cd2745cebb6376fe5e36072e265ef66ead5e6ccf | https://github.com/tyam/bamboo/blob/cd2745cebb6376fe5e36072e265ef66ead5e6ccf/src/Renderer.php#L48-L67 |
39,424 | tyam/bamboo | src/Renderer.php | Renderer.endsection | public function endsection(string $name = null): void
{
// You can specify the section name for sanity-check purpose.
if (! is_null($name) && $this->sectionStack[0] != $name) {
throw new \LogicException('unmatched end-section: ' . $name . ', expects: ' . $this->sectionStack[0]);
}
$output = ob_get_clean();
$name = array_shift($this->sectionStack);
$this->sections[$name] = $output;
} | php | public function endsection(string $name = null): void
{
// You can specify the section name for sanity-check purpose.
if (! is_null($name) && $this->sectionStack[0] != $name) {
throw new \LogicException('unmatched end-section: ' . $name . ', expects: ' . $this->sectionStack[0]);
}
$output = ob_get_clean();
$name = array_shift($this->sectionStack);
$this->sections[$name] = $output;
} | [
"public",
"function",
"endsection",
"(",
"string",
"$",
"name",
"=",
"null",
")",
":",
"void",
"{",
"// You can specify the section name for sanity-check purpose.",
"if",
"(",
"!",
"is_null",
"(",
"$",
"name",
")",
"&&",
"$",
"this",
"->",
"sectionStack",
"[",
... | End section.
The `$name` parameter, if passed, is used to check section sanity.
When the passed name is different from the current section, then renderer throws runtime exception.
@param string|null $name the section name
@return void | [
"End",
"section",
"."
] | cd2745cebb6376fe5e36072e265ef66ead5e6ccf | https://github.com/tyam/bamboo/blob/cd2745cebb6376fe5e36072e265ef66ead5e6ccf/src/Renderer.php#L116-L127 |
39,425 | tyam/bamboo | src/Renderer.php | Renderer.yield | public function yield(string $name): void
{
if (empty($this->sections[$name])) {
// do nothing
} else {
echo $this->sections[$name];
}
} | php | public function yield(string $name): void
{
if (empty($this->sections[$name])) {
// do nothing
} else {
echo $this->sections[$name];
}
} | [
"public",
"function",
"yield",
"(",
"string",
"$",
"name",
")",
":",
"void",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"sections",
"[",
"$",
"name",
"]",
")",
")",
"{",
"// do nothing",
"}",
"else",
"{",
"echo",
"$",
"this",
"->",
"sections"... | Outputs the block captured by section+endsection.
@param string $name section name to be output | [
"Outputs",
"the",
"block",
"captured",
"by",
"section",
"+",
"endsection",
"."
] | cd2745cebb6376fe5e36072e265ef66ead5e6ccf | https://github.com/tyam/bamboo/blob/cd2745cebb6376fe5e36072e265ef66ead5e6ccf/src/Renderer.php#L134-L141 |
39,426 | tyam/bamboo | src/Renderer.php | Renderer.include | public function include(string $template, array $variables = null): void
{
$renderer = new Renderer($this->resolve, $this->sections);
echo $renderer->render($template, $variables);
} | php | public function include(string $template, array $variables = null): void
{
$renderer = new Renderer($this->resolve, $this->sections);
echo $renderer->render($template, $variables);
} | [
"public",
"function",
"include",
"(",
"string",
"$",
"template",
",",
"array",
"$",
"variables",
"=",
"null",
")",
":",
"void",
"{",
"$",
"renderer",
"=",
"new",
"Renderer",
"(",
"$",
"this",
"->",
"resolve",
",",
"$",
"this",
"->",
"sections",
")",
... | Outputs another template.
@param string $template path to the template
@param array|null $variables template variables | [
"Outputs",
"another",
"template",
"."
] | cd2745cebb6376fe5e36072e265ef66ead5e6ccf | https://github.com/tyam/bamboo/blob/cd2745cebb6376fe5e36072e265ef66ead5e6ccf/src/Renderer.php#L149-L153 |
39,427 | ethical-jobs/ethical-jobs-foundation-php | src/Laravel/ElasticsearchServiceProvider.php | ElasticsearchServiceProvider.registerConnectionSingleton | public function registerConnectionSingleton()
{
$this->app->singleton(Client::class, function () {
$defaultConfig = [
'logPath' => storage_path().'/logs/elasticsearch-'.php_sapi_name().'.log',
];
$config = array_merge($defaultConfig, config('elasticsearch'));
$connection = array_get($config, 'connections.'.$config['defaultConnection']);
$client = ClientBuilder::create()->setHosts($connection['hosts']);
if ($connection['logging']) {
$logger = ClientBuilder::defaultLogger($connection['logPath']);
$client->setLogger($logger);
}
return $client->build();
});
} | php | public function registerConnectionSingleton()
{
$this->app->singleton(Client::class, function () {
$defaultConfig = [
'logPath' => storage_path().'/logs/elasticsearch-'.php_sapi_name().'.log',
];
$config = array_merge($defaultConfig, config('elasticsearch'));
$connection = array_get($config, 'connections.'.$config['defaultConnection']);
$client = ClientBuilder::create()->setHosts($connection['hosts']);
if ($connection['logging']) {
$logger = ClientBuilder::defaultLogger($connection['logPath']);
$client->setLogger($logger);
}
return $client->build();
});
} | [
"public",
"function",
"registerConnectionSingleton",
"(",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"singleton",
"(",
"Client",
"::",
"class",
",",
"function",
"(",
")",
"{",
"$",
"defaultConfig",
"=",
"[",
"'logPath'",
"=>",
"storage_path",
"(",
")",
".",... | Register connection instance
@return void | [
"Register",
"connection",
"instance"
] | 35dafc2172dc8ba44c0ace4a58a7c0a9b63455a8 | https://github.com/ethical-jobs/ethical-jobs-foundation-php/blob/35dafc2172dc8ba44c0ace4a58a7c0a9b63455a8/src/Laravel/ElasticsearchServiceProvider.php#L62-L83 |
39,428 | ethical-jobs/ethical-jobs-foundation-php | src/Laravel/ElasticsearchServiceProvider.php | ElasticsearchServiceProvider.registerIndexSingleton | public function registerIndexSingleton()
{
$this->app->singleton(Index::class, function ($app) {
$settings = new IndexSettings(
config('elasticsearch.index'),
config('elasticsearch.settings'),
config('elasticsearch.mappings')
);
$settings->setIndexables(config('elasticsearch.indexables'));
return new Index($app[Client::class], $settings);
});
} | php | public function registerIndexSingleton()
{
$this->app->singleton(Index::class, function ($app) {
$settings = new IndexSettings(
config('elasticsearch.index'),
config('elasticsearch.settings'),
config('elasticsearch.mappings')
);
$settings->setIndexables(config('elasticsearch.indexables'));
return new Index($app[Client::class], $settings);
});
} | [
"public",
"function",
"registerIndexSingleton",
"(",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"singleton",
"(",
"Index",
"::",
"class",
",",
"function",
"(",
"$",
"app",
")",
"{",
"$",
"settings",
"=",
"new",
"IndexSettings",
"(",
"config",
"(",
"'elast... | Register index instance
@return void | [
"Register",
"index",
"instance"
] | 35dafc2172dc8ba44c0ace4a58a7c0a9b63455a8 | https://github.com/ethical-jobs/ethical-jobs-foundation-php/blob/35dafc2172dc8ba44c0ace4a58a7c0a9b63455a8/src/Laravel/ElasticsearchServiceProvider.php#L90-L104 |
39,429 | rodrigoiii/skeleton-core | src/classes/Utilities/Session.php | Session.allExcept | public static function allExcept(array $keys)
{
$sessions = static::all();
if (!empty($keys))
{
foreach ($keys as $key) {
unset($sessions[$key]);
}
}
return $sessions;
} | php | public static function allExcept(array $keys)
{
$sessions = static::all();
if (!empty($keys))
{
foreach ($keys as $key) {
unset($sessions[$key]);
}
}
return $sessions;
} | [
"public",
"static",
"function",
"allExcept",
"(",
"array",
"$",
"keys",
")",
"{",
"$",
"sessions",
"=",
"static",
"::",
"all",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"keys",
")",
")",
"{",
"foreach",
"(",
"$",
"keys",
"as",
"$",
"key",... | Return all data except the provided keys.
@param array $keys
@return array | [
"Return",
"all",
"data",
"except",
"the",
"provided",
"keys",
"."
] | 5dab0637b9cd0f55a64b1f5926d7ba6bb3f93df0 | https://github.com/rodrigoiii/skeleton-core/blob/5dab0637b9cd0f55a64b1f5926d7ba6bb3f93df0/src/classes/Utilities/Session.php#L88-L100 |
39,430 | eclipxe13/XmlResourceRetriever | src/XmlResourceRetriever/Utils.php | Utils.relativePath | public static function relativePath(string $sourceFile, string $destinationFile): string
{
$source = static::simplifyPath($sourceFile);
$destination = static::simplifyPath($destinationFile);
if ($source[0] !== '' && $destination[0] === '') {
return implode('/', $destination);
}
// remove the common path
foreach ($source as $depth => $dir) {
if (isset($destination[$depth])) {
if ($dir === $destination[$depth]) {
unset($destination[$depth]);
unset($source[$depth]);
} else {
break;
}
}
}
// add '..' to the beginning of the source as required by the count of from
$fromCount = count($source);
for ($i = 0; $i < $fromCount - 1; $i++) {
array_unshift($destination, '..');
}
return implode('/', $destination);
} | php | public static function relativePath(string $sourceFile, string $destinationFile): string
{
$source = static::simplifyPath($sourceFile);
$destination = static::simplifyPath($destinationFile);
if ($source[0] !== '' && $destination[0] === '') {
return implode('/', $destination);
}
// remove the common path
foreach ($source as $depth => $dir) {
if (isset($destination[$depth])) {
if ($dir === $destination[$depth]) {
unset($destination[$depth]);
unset($source[$depth]);
} else {
break;
}
}
}
// add '..' to the beginning of the source as required by the count of from
$fromCount = count($source);
for ($i = 0; $i < $fromCount - 1; $i++) {
array_unshift($destination, '..');
}
return implode('/', $destination);
} | [
"public",
"static",
"function",
"relativePath",
"(",
"string",
"$",
"sourceFile",
",",
"string",
"$",
"destinationFile",
")",
":",
"string",
"{",
"$",
"source",
"=",
"static",
"::",
"simplifyPath",
"(",
"$",
"sourceFile",
")",
";",
"$",
"destination",
"=",
... | Return the relative path from one location to other
@param string $sourceFile
@param string $destinationFile
@return string | [
"Return",
"the",
"relative",
"path",
"from",
"one",
"location",
"to",
"other"
] | 38354825dbbf0f705fe2dd70ca6bdf00438ea63c | https://github.com/eclipxe13/XmlResourceRetriever/blob/38354825dbbf0f705fe2dd70ca6bdf00438ea63c/src/XmlResourceRetriever/Utils.php#L15-L39 |
39,431 | eclipxe13/XmlResourceRetriever | src/XmlResourceRetriever/Utils.php | Utils.simplifyPath | public static function simplifyPath(string $path): array
{
$parts = explode('/', str_replace('//', '/./', $path));
$count = count($parts);
for ($i = 0; $i < $count; $i = $i + 1) {
// is .. and previous is not ..
if ($i > 0 && '..' === $parts[$i] && '..' !== $parts[$i - 1]) {
unset($parts[$i - 1]);
unset($parts[$i]);
return static::simplifyPath(implode('/', $parts));
}
// is inner '.'
if ('.' == $parts[$i]) {
unset($parts[$i]);
return static::simplifyPath(implode('/', $parts));
}
}
return array_values($parts);
} | php | public static function simplifyPath(string $path): array
{
$parts = explode('/', str_replace('//', '/./', $path));
$count = count($parts);
for ($i = 0; $i < $count; $i = $i + 1) {
// is .. and previous is not ..
if ($i > 0 && '..' === $parts[$i] && '..' !== $parts[$i - 1]) {
unset($parts[$i - 1]);
unset($parts[$i]);
return static::simplifyPath(implode('/', $parts));
}
// is inner '.'
if ('.' == $parts[$i]) {
unset($parts[$i]);
return static::simplifyPath(implode('/', $parts));
}
}
return array_values($parts);
} | [
"public",
"static",
"function",
"simplifyPath",
"(",
"string",
"$",
"path",
")",
":",
"array",
"{",
"$",
"parts",
"=",
"explode",
"(",
"'/'",
",",
"str_replace",
"(",
"'//'",
",",
"'/./'",
",",
"$",
"path",
")",
")",
";",
"$",
"count",
"=",
"count",
... | Simplify a path and return its parts as an array
@param string $path
@return array | [
"Simplify",
"a",
"path",
"and",
"return",
"its",
"parts",
"as",
"an",
"array"
] | 38354825dbbf0f705fe2dd70ca6bdf00438ea63c | https://github.com/eclipxe13/XmlResourceRetriever/blob/38354825dbbf0f705fe2dd70ca6bdf00438ea63c/src/XmlResourceRetriever/Utils.php#L47-L65 |
39,432 | 975L/IncludeLibraryBundle | Twig/IncludeLibraryCode.php | IncludeLibraryCode.Code | public function Code(Environment $environment, $name, $type, $version = 'latest', $params = null)
{
$type = strtolower($type);
//Gets type for local file
$local = false;
if ('local' == $type) {
$local = true;
$type = strtolower(substr($name, strrpos($name, '.') + 1));
}
//Defines fragment to use
$fragment = null;
if ('css' == $type) {
$fragment = '@c975LIncludeLibrary/fragments/css.html.twig';
} elseif ('js' == $type || 'javascript' == $type || 'jscript' == $type || 'script' == $type) {
$fragment = '@c975LIncludeLibrary/fragments/javascript.html.twig';
$type = 'javascript';
}
//Gets data for local file
if ($local) {
$data = 'css' == $type ? array('href' => $name) : array('src' => $name);
//Gets data for external library
} else {
$data = $this->includeLibraryService->getData($name, $type, $version);
}
//Returns xhtml code
if (null != $fragment && null != $data) {
$render = $environment->render($fragment, array(
'data' => $data,
'params' => $params,
));
return str_replace(array("\n", ' ', ' ', ' ', ' ', ' '), ' ', $render);
}
//Throws an error if not found
throw new Error('The Library "' . $name . ' (' . $type . ') version ' . $version . '" requested via "inc_lib()" was not found. Please check name and supported library/versions.');
} | php | public function Code(Environment $environment, $name, $type, $version = 'latest', $params = null)
{
$type = strtolower($type);
//Gets type for local file
$local = false;
if ('local' == $type) {
$local = true;
$type = strtolower(substr($name, strrpos($name, '.') + 1));
}
//Defines fragment to use
$fragment = null;
if ('css' == $type) {
$fragment = '@c975LIncludeLibrary/fragments/css.html.twig';
} elseif ('js' == $type || 'javascript' == $type || 'jscript' == $type || 'script' == $type) {
$fragment = '@c975LIncludeLibrary/fragments/javascript.html.twig';
$type = 'javascript';
}
//Gets data for local file
if ($local) {
$data = 'css' == $type ? array('href' => $name) : array('src' => $name);
//Gets data for external library
} else {
$data = $this->includeLibraryService->getData($name, $type, $version);
}
//Returns xhtml code
if (null != $fragment && null != $data) {
$render = $environment->render($fragment, array(
'data' => $data,
'params' => $params,
));
return str_replace(array("\n", ' ', ' ', ' ', ' ', ' '), ' ', $render);
}
//Throws an error if not found
throw new Error('The Library "' . $name . ' (' . $type . ') version ' . $version . '" requested via "inc_lib()" was not found. Please check name and supported library/versions.');
} | [
"public",
"function",
"Code",
"(",
"Environment",
"$",
"environment",
",",
"$",
"name",
",",
"$",
"type",
",",
"$",
"version",
"=",
"'latest'",
",",
"$",
"params",
"=",
"null",
")",
"{",
"$",
"type",
"=",
"strtolower",
"(",
"$",
"type",
")",
";",
"... | Returns the xhtml code to be included
@return string
@throws Error | [
"Returns",
"the",
"xhtml",
"code",
"to",
"be",
"included"
] | 74f9140551d6f20c1308213c4c142f7fff43eb52 | https://github.com/975L/IncludeLibraryBundle/blob/74f9140551d6f20c1308213c4c142f7fff43eb52/Twig/IncludeLibraryCode.php#L55-L95 |
39,433 | locomotivemtl/charcoal-property | src/Charcoal/Property/StringProperty.php | StringProperty.setMaxLength | public function setMaxLength($maxLength)
{
if (!is_integer($maxLength)) {
throw new InvalidArgumentException(
'Max length must be an integer.'
);
}
if ($maxLength < 0) {
throw new InvalidArgumentException(
'Max length must be a positive integer (>=0).'
);
}
$this->maxLength = $maxLength;
return $this;
} | php | public function setMaxLength($maxLength)
{
if (!is_integer($maxLength)) {
throw new InvalidArgumentException(
'Max length must be an integer.'
);
}
if ($maxLength < 0) {
throw new InvalidArgumentException(
'Max length must be a positive integer (>=0).'
);
}
$this->maxLength = $maxLength;
return $this;
} | [
"public",
"function",
"setMaxLength",
"(",
"$",
"maxLength",
")",
"{",
"if",
"(",
"!",
"is_integer",
"(",
"$",
"maxLength",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Max length must be an integer.'",
")",
";",
"}",
"if",
"(",
"$",
"ma... | Set the maximum number of characters allowed.
@param integer $maxLength The max length allowed.
@throws InvalidArgumentException If the parameter is not an integer or < 0.
@return self | [
"Set",
"the",
"maximum",
"number",
"of",
"characters",
"allowed",
"."
] | 5ff339a0edb78a909537a9d2bb7f9b783255316b | https://github.com/locomotivemtl/charcoal-property/blob/5ff339a0edb78a909537a9d2bb7f9b783255316b/src/Charcoal/Property/StringProperty.php#L127-L144 |
39,434 | locomotivemtl/charcoal-property | src/Charcoal/Property/StringProperty.php | StringProperty.maxLength | public function maxLength()
{
if ($this->maxLength === null) {
$this->maxLength = $this->defaultMaxLength();
}
return $this->maxLength;
} | php | public function maxLength()
{
if ($this->maxLength === null) {
$this->maxLength = $this->defaultMaxLength();
}
return $this->maxLength;
} | [
"public",
"function",
"maxLength",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"maxLength",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"maxLength",
"=",
"$",
"this",
"->",
"defaultMaxLength",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"maxLen... | Retrieve the maximum number of characters allowed.
@return integer | [
"Retrieve",
"the",
"maximum",
"number",
"of",
"characters",
"allowed",
"."
] | 5ff339a0edb78a909537a9d2bb7f9b783255316b | https://github.com/locomotivemtl/charcoal-property/blob/5ff339a0edb78a909537a9d2bb7f9b783255316b/src/Charcoal/Property/StringProperty.php#L151-L158 |
39,435 | locomotivemtl/charcoal-property | src/Charcoal/Property/StringProperty.php | StringProperty.setMinLength | public function setMinLength($minLength)
{
if (!is_integer($minLength)) {
throw new InvalidArgumentException(
'Min length must be an integer.'
);
}
if ($minLength < 0) {
throw new InvalidArgumentException(
'Min length must be a positive integer (>=0).'
);
}
$this->minLength = $minLength;
return $this;
} | php | public function setMinLength($minLength)
{
if (!is_integer($minLength)) {
throw new InvalidArgumentException(
'Min length must be an integer.'
);
}
if ($minLength < 0) {
throw new InvalidArgumentException(
'Min length must be a positive integer (>=0).'
);
}
$this->minLength = $minLength;
return $this;
} | [
"public",
"function",
"setMinLength",
"(",
"$",
"minLength",
")",
"{",
"if",
"(",
"!",
"is_integer",
"(",
"$",
"minLength",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Min length must be an integer.'",
")",
";",
"}",
"if",
"(",
"$",
"mi... | Set the minimum number of characters allowed.
@param integer $minLength The minimum length allowed.
@throws InvalidArgumentException If the parameter is not an integer or < 0.
@return self | [
"Set",
"the",
"minimum",
"number",
"of",
"characters",
"allowed",
"."
] | 5ff339a0edb78a909537a9d2bb7f9b783255316b | https://github.com/locomotivemtl/charcoal-property/blob/5ff339a0edb78a909537a9d2bb7f9b783255316b/src/Charcoal/Property/StringProperty.php#L177-L194 |
39,436 | locomotivemtl/charcoal-property | src/Charcoal/Property/StringProperty.php | StringProperty.minLength | public function minLength()
{
if ($this->minLength === null) {
$this->minLength = $this->defaultMinLength();
}
return $this->minLength;
} | php | public function minLength()
{
if ($this->minLength === null) {
$this->minLength = $this->defaultMinLength();
}
return $this->minLength;
} | [
"public",
"function",
"minLength",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"minLength",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"minLength",
"=",
"$",
"this",
"->",
"defaultMinLength",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"minLen... | Retrieve the minimum number of characters allowed.
@return integer | [
"Retrieve",
"the",
"minimum",
"number",
"of",
"characters",
"allowed",
"."
] | 5ff339a0edb78a909537a9d2bb7f9b783255316b | https://github.com/locomotivemtl/charcoal-property/blob/5ff339a0edb78a909537a9d2bb7f9b783255316b/src/Charcoal/Property/StringProperty.php#L201-L208 |
39,437 | locomotivemtl/charcoal-property | src/Charcoal/Property/StringProperty.php | StringProperty.regexp | public function regexp()
{
if ($this->regexp === null) {
$this->regexp = self::DEFAULT_REGEXP;
}
return $this->regexp;
} | php | public function regexp()
{
if ($this->regexp === null) {
$this->regexp = self::DEFAULT_REGEXP;
}
return $this->regexp;
} | [
"public",
"function",
"regexp",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"regexp",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"regexp",
"=",
"self",
"::",
"DEFAULT_REGEXP",
";",
"}",
"return",
"$",
"this",
"->",
"regexp",
";",
"}"
] | Retrieve the regular expression to check the value against.
@return string | [
"Retrieve",
"the",
"regular",
"expression",
"to",
"check",
"the",
"value",
"against",
"."
] | 5ff339a0edb78a909537a9d2bb7f9b783255316b | https://github.com/locomotivemtl/charcoal-property/blob/5ff339a0edb78a909537a9d2bb7f9b783255316b/src/Charcoal/Property/StringProperty.php#L245-L252 |
39,438 | locomotivemtl/charcoal-property | src/Charcoal/Property/StringProperty.php | StringProperty.validateMaxLength | public function validateMaxLength()
{
$val = $this->val();
if ($val === null && $this->allowNull()) {
return true;
}
$maxLength = $this->maxLength();
if ($maxLength == 0) {
return true;
}
if (is_string($val)) {
$valid = (mb_strlen($val) <= $maxLength);
if (!$valid) {
$this->validator()->error('Maximum length error', 'maxLength');
}
} else {
$valid = true;
foreach ($val as $v) {
$valid = (mb_strlen($v) <= $maxLength);
if (!$valid) {
$this->validator()->error('Maximum length error', 'maxLength');
return $valid;
}
}
}
return $valid;
} | php | public function validateMaxLength()
{
$val = $this->val();
if ($val === null && $this->allowNull()) {
return true;
}
$maxLength = $this->maxLength();
if ($maxLength == 0) {
return true;
}
if (is_string($val)) {
$valid = (mb_strlen($val) <= $maxLength);
if (!$valid) {
$this->validator()->error('Maximum length error', 'maxLength');
}
} else {
$valid = true;
foreach ($val as $v) {
$valid = (mb_strlen($v) <= $maxLength);
if (!$valid) {
$this->validator()->error('Maximum length error', 'maxLength');
return $valid;
}
}
}
return $valid;
} | [
"public",
"function",
"validateMaxLength",
"(",
")",
"{",
"$",
"val",
"=",
"$",
"this",
"->",
"val",
"(",
")",
";",
"if",
"(",
"$",
"val",
"===",
"null",
"&&",
"$",
"this",
"->",
"allowNull",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"$",
... | Validate if the property's value exceeds the maximum length.
@todo Support `multiple` / `l10n`
@return boolean | [
"Validate",
"if",
"the",
"property",
"s",
"value",
"exceeds",
"the",
"maximum",
"length",
"."
] | 5ff339a0edb78a909537a9d2bb7f9b783255316b | https://github.com/locomotivemtl/charcoal-property/blob/5ff339a0edb78a909537a9d2bb7f9b783255316b/src/Charcoal/Property/StringProperty.php#L338-L368 |
39,439 | locomotivemtl/charcoal-property | src/Charcoal/Property/StringProperty.php | StringProperty.validateMinLength | public function validateMinLength()
{
$val = $this->val();
if ($val === null) {
return $this->allowNull();
}
$minLength = $this->minLength();
if ($minLength == 0) {
return true;
}
if ($val === '' && $this->allowEmpty()) {
// Don't check empty string if they are allowed
return true;
}
if (is_string($val)) {
$valid = (mb_strlen($val) >= $minLength);
if (!$valid) {
$this->validator()->error('Minimum length error', 'minLength');
}
} else {
$valid = true;
foreach ($val as $v) {
$valid = (mb_strlen($v) >= $minLength);
if (!$valid) {
$this->validator()->error('Minimum length error', 'minLength');
return $valid;
}
}
}
return $valid;
} | php | public function validateMinLength()
{
$val = $this->val();
if ($val === null) {
return $this->allowNull();
}
$minLength = $this->minLength();
if ($minLength == 0) {
return true;
}
if ($val === '' && $this->allowEmpty()) {
// Don't check empty string if they are allowed
return true;
}
if (is_string($val)) {
$valid = (mb_strlen($val) >= $minLength);
if (!$valid) {
$this->validator()->error('Minimum length error', 'minLength');
}
} else {
$valid = true;
foreach ($val as $v) {
$valid = (mb_strlen($v) >= $minLength);
if (!$valid) {
$this->validator()->error('Minimum length error', 'minLength');
return $valid;
}
}
}
return $valid;
} | [
"public",
"function",
"validateMinLength",
"(",
")",
"{",
"$",
"val",
"=",
"$",
"this",
"->",
"val",
"(",
")",
";",
"if",
"(",
"$",
"val",
"===",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"allowNull",
"(",
")",
";",
"}",
"$",
"minLength",
"=... | Validate if the property's value satisfies the minimum length.
@todo Support `multiple` / `l10n`
@return boolean | [
"Validate",
"if",
"the",
"property",
"s",
"value",
"satisfies",
"the",
"minimum",
"length",
"."
] | 5ff339a0edb78a909537a9d2bb7f9b783255316b | https://github.com/locomotivemtl/charcoal-property/blob/5ff339a0edb78a909537a9d2bb7f9b783255316b/src/Charcoal/Property/StringProperty.php#L376-L411 |
39,440 | locomotivemtl/charcoal-property | src/Charcoal/Property/StringProperty.php | StringProperty.validateRegexp | public function validateRegexp()
{
$val = $this->val();
$regexp = $this->regexp();
if ($regexp == '') {
return true;
}
$valid = !!preg_match($regexp, $val);
if (!$valid) {
$this->validator()->error('Regexp error', 'regexp');
}
return $valid;
} | php | public function validateRegexp()
{
$val = $this->val();
$regexp = $this->regexp();
if ($regexp == '') {
return true;
}
$valid = !!preg_match($regexp, $val);
if (!$valid) {
$this->validator()->error('Regexp error', 'regexp');
}
return $valid;
} | [
"public",
"function",
"validateRegexp",
"(",
")",
"{",
"$",
"val",
"=",
"$",
"this",
"->",
"val",
"(",
")",
";",
"$",
"regexp",
"=",
"$",
"this",
"->",
"regexp",
"(",
")",
";",
"if",
"(",
"$",
"regexp",
"==",
"''",
")",
"{",
"return",
"true",
"... | Validate if the property's value matches the regular expression.
@return boolean | [
"Validate",
"if",
"the",
"property",
"s",
"value",
"matches",
"the",
"regular",
"expression",
"."
] | 5ff339a0edb78a909537a9d2bb7f9b783255316b | https://github.com/locomotivemtl/charcoal-property/blob/5ff339a0edb78a909537a9d2bb7f9b783255316b/src/Charcoal/Property/StringProperty.php#L418-L433 |
39,441 | locomotivemtl/charcoal-property | src/Charcoal/Property/StringProperty.php | StringProperty.validateAllowEmpty | public function validateAllowEmpty()
{
$val = $this->val();
if (($val === null || $val === '') && !$this->allowEmpty()) {
return false;
} else {
return true;
}
} | php | public function validateAllowEmpty()
{
$val = $this->val();
if (($val === null || $val === '') && !$this->allowEmpty()) {
return false;
} else {
return true;
}
} | [
"public",
"function",
"validateAllowEmpty",
"(",
")",
"{",
"$",
"val",
"=",
"$",
"this",
"->",
"val",
"(",
")",
";",
"if",
"(",
"(",
"$",
"val",
"===",
"null",
"||",
"$",
"val",
"===",
"''",
")",
"&&",
"!",
"$",
"this",
"->",
"allowEmpty",
"(",
... | Validate if the property's value is allowed to be empty.
@return boolean | [
"Validate",
"if",
"the",
"property",
"s",
"value",
"is",
"allowed",
"to",
"be",
"empty",
"."
] | 5ff339a0edb78a909537a9d2bb7f9b783255316b | https://github.com/locomotivemtl/charcoal-property/blob/5ff339a0edb78a909537a9d2bb7f9b783255316b/src/Charcoal/Property/StringProperty.php#L440-L449 |
39,442 | locomotivemtl/charcoal-property | src/Charcoal/Property/StringProperty.php | StringProperty.valLabel | protected function valLabel($val, $lang = null)
{
if (is_string($val) && $this->hasChoice($val)) {
$choice = $this->choice($val);
return $this->l10nVal($choice['label'], $lang);
} else {
return $val;
}
} | php | protected function valLabel($val, $lang = null)
{
if (is_string($val) && $this->hasChoice($val)) {
$choice = $this->choice($val);
return $this->l10nVal($choice['label'], $lang);
} else {
return $val;
}
} | [
"protected",
"function",
"valLabel",
"(",
"$",
"val",
",",
"$",
"lang",
"=",
"null",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"val",
")",
"&&",
"$",
"this",
"->",
"hasChoice",
"(",
"$",
"val",
")",
")",
"{",
"$",
"choice",
"=",
"$",
"this",
... | Attempts to return the label for a given choice.
@param string $val The value to retrieve the label of.
@param mixed $lang The language to return the label in.
@return string Returns the label. Otherwise, returns the raw value. | [
"Attempts",
"to",
"return",
"the",
"label",
"for",
"a",
"given",
"choice",
"."
] | 5ff339a0edb78a909537a9d2bb7f9b783255316b | https://github.com/locomotivemtl/charcoal-property/blob/5ff339a0edb78a909537a9d2bb7f9b783255316b/src/Charcoal/Property/StringProperty.php#L511-L519 |
39,443 | ethical-jobs/ethical-jobs-foundation-php | src/Utils/Arrays.php | Arrays.expandDotNotationKeys | public static function expandDotNotationKeys(Array $array)
{
$result = [];
foreach ($array as $key => $value) {
array_set($result, $key, $value);
}
return $result;
} | php | public static function expandDotNotationKeys(Array $array)
{
$result = [];
foreach ($array as $key => $value) {
array_set($result, $key, $value);
}
return $result;
} | [
"public",
"static",
"function",
"expandDotNotationKeys",
"(",
"Array",
"$",
"array",
")",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"array",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"array_set",
"(",
"$",
"result",
",",
"$",... | Expands arrays with keys that have dot notation
@param Array $array
@return Array | [
"Expands",
"arrays",
"with",
"keys",
"that",
"have",
"dot",
"notation"
] | 35dafc2172dc8ba44c0ace4a58a7c0a9b63455a8 | https://github.com/ethical-jobs/ethical-jobs-foundation-php/blob/35dafc2172dc8ba44c0ace4a58a7c0a9b63455a8/src/Utils/Arrays.php#L20-L29 |
39,444 | 975L/IncludeLibraryBundle | Twig/IncludeLibraryLink.php | IncludeLibraryLink.Link | public function Link($name, $type, $version = 'latest')
{
$type = strtolower($type);
//Gets data
$data = $this->includeLibraryService->getData($name, $type, $version);
//Returns the href or src part
if (null !== $data) {
return 'css' == $type ? $data['href'] : $data['src'];
}
//Throws an error if not found
throw new Error('The Library "' . $name . ' (' . $type . ') version ' . $version . '" requested via "inc_link()" was not found. Please check name and supported library/versions.');
} | php | public function Link($name, $type, $version = 'latest')
{
$type = strtolower($type);
//Gets data
$data = $this->includeLibraryService->getData($name, $type, $version);
//Returns the href or src part
if (null !== $data) {
return 'css' == $type ? $data['href'] : $data['src'];
}
//Throws an error if not found
throw new Error('The Library "' . $name . ' (' . $type . ') version ' . $version . '" requested via "inc_link()" was not found. Please check name and supported library/versions.');
} | [
"public",
"function",
"Link",
"(",
"$",
"name",
",",
"$",
"type",
",",
"$",
"version",
"=",
"'latest'",
")",
"{",
"$",
"type",
"=",
"strtolower",
"(",
"$",
"type",
")",
";",
"//Gets data",
"$",
"data",
"=",
"$",
"this",
"->",
"includeLibraryService",
... | Returns the link of the requested library
@return string
@throws Error | [
"Returns",
"the",
"link",
"of",
"the",
"requested",
"library"
] | 74f9140551d6f20c1308213c4c142f7fff43eb52 | https://github.com/975L/IncludeLibraryBundle/blob/74f9140551d6f20c1308213c4c142f7fff43eb52/Twig/IncludeLibraryLink.php#L50-L64 |
39,445 | cmsgears/module-core | common/config/CoreProperties.php | CoreProperties.getRootUrl | public function getRootUrl( $admin = false ) {
if( $admin ) {
return $this->properties[ self::PROP_ADMIN_URL ] . \Yii::getAlias( '@web' ) ;
}
return $this->properties[ self::PROP_SITE_URL ] . \Yii::getAlias( '@web' ) ;
} | php | public function getRootUrl( $admin = false ) {
if( $admin ) {
return $this->properties[ self::PROP_ADMIN_URL ] . \Yii::getAlias( '@web' ) ;
}
return $this->properties[ self::PROP_SITE_URL ] . \Yii::getAlias( '@web' ) ;
} | [
"public",
"function",
"getRootUrl",
"(",
"$",
"admin",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"admin",
")",
"{",
"return",
"$",
"this",
"->",
"properties",
"[",
"self",
"::",
"PROP_ADMIN_URL",
"]",
".",
"\\",
"Yii",
"::",
"getAlias",
"(",
"'@web'",
... | Returns the root URL for the app | [
"Returns",
"the",
"root",
"URL",
"for",
"the",
"app"
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/config/CoreProperties.php#L290-L298 |
39,446 | phPoirot/Std | src/Type/StdString.php | StdString.stripPrefix | function stripPrefix($prefix)
{
$key = (string) $this;
if (substr($key, 0, strlen($prefix)) == $prefix)
$key = substr($key, strlen($prefix));
return new self($key);
} | php | function stripPrefix($prefix)
{
$key = (string) $this;
if (substr($key, 0, strlen($prefix)) == $prefix)
$key = substr($key, strlen($prefix));
return new self($key);
} | [
"function",
"stripPrefix",
"(",
"$",
"prefix",
")",
"{",
"$",
"key",
"=",
"(",
"string",
")",
"$",
"this",
";",
"if",
"(",
"substr",
"(",
"$",
"key",
",",
"0",
",",
"strlen",
"(",
"$",
"prefix",
")",
")",
"==",
"$",
"prefix",
")",
"$",
"key",
... | Remove a prefix string from the beginning of a string
@param string $prefix
@return StdString | [
"Remove",
"a",
"prefix",
"string",
"from",
"the",
"beginning",
"of",
"a",
"string"
] | 67883b1b1dd2cea80fec3d98a199c403b8a23b4d | https://github.com/phPoirot/Std/blob/67883b1b1dd2cea80fec3d98a199c403b8a23b4d/src/Type/StdString.php#L122-L130 |
39,447 | phPoirot/Std | src/Type/StdString.php | StdString.slugify | function slugify()
{
$text = (string) $this;
// replace non letter or digits by -
$text = preg_replace('~[^\pL\d]+~u', '-', $text);
// transliterate
$text = iconv('utf-8', 'us-ascii//TRANSLIT', $text);
// remove unwanted characters
$text = preg_replace('~[^-\w]+~', '', $text);
// trim
$text = trim($text, '-');
// remove duplicate -
$text = preg_replace('~-+~', '-', $text);
// lowercase
$text = strtolower($text);
if (empty($text))
return 'n-a';
return new self($text);
} | php | function slugify()
{
$text = (string) $this;
// replace non letter or digits by -
$text = preg_replace('~[^\pL\d]+~u', '-', $text);
// transliterate
$text = iconv('utf-8', 'us-ascii//TRANSLIT', $text);
// remove unwanted characters
$text = preg_replace('~[^-\w]+~', '', $text);
// trim
$text = trim($text, '-');
// remove duplicate -
$text = preg_replace('~-+~', '-', $text);
// lowercase
$text = strtolower($text);
if (empty($text))
return 'n-a';
return new self($text);
} | [
"function",
"slugify",
"(",
")",
"{",
"$",
"text",
"=",
"(",
"string",
")",
"$",
"this",
";",
"// replace non letter or digits by -",
"$",
"text",
"=",
"preg_replace",
"(",
"'~[^\\pL\\d]+~u'",
",",
"'-'",
",",
"$",
"text",
")",
";",
"// transliterate",
"$",
... | Slugify Input Text
@return StdString | [
"Slugify",
"Input",
"Text"
] | 67883b1b1dd2cea80fec3d98a199c403b8a23b4d | https://github.com/phPoirot/Std/blob/67883b1b1dd2cea80fec3d98a199c403b8a23b4d/src/Type/StdString.php#L137-L163 |
39,448 | phPoirot/Std | src/Type/StdString.php | StdString.PascalCase | function PascalCase()
{
$key = (string) $this;
## prefix and postfix __ remains; like: __this__
$pos = 'prefix';
$prefix = '';
$posfix = '';
for ($i = 0; $i <= strlen($key)-1; $i++) {
if ($key[$i] == '_')
$$pos.='_';
else {
$posfix = ''; // reset posix, _ may found within string
$pos = 'posfix';
}
}
$r = str_replace(' ', '', ucwords(str_replace('_', ' ', $key)));
$r = $prefix.$r.$posfix;
return new self($r);
} | php | function PascalCase()
{
$key = (string) $this;
## prefix and postfix __ remains; like: __this__
$pos = 'prefix';
$prefix = '';
$posfix = '';
for ($i = 0; $i <= strlen($key)-1; $i++) {
if ($key[$i] == '_')
$$pos.='_';
else {
$posfix = ''; // reset posix, _ may found within string
$pos = 'posfix';
}
}
$r = str_replace(' ', '', ucwords(str_replace('_', ' ', $key)));
$r = $prefix.$r.$posfix;
return new self($r);
} | [
"function",
"PascalCase",
"(",
")",
"{",
"$",
"key",
"=",
"(",
"string",
")",
"$",
"this",
";",
"## prefix and postfix __ remains; like: __this__",
"$",
"pos",
"=",
"'prefix'",
";",
"$",
"prefix",
"=",
"''",
";",
"$",
"posfix",
"=",
"''",
";",
"for",
"("... | Sanitize Underscore To Camelcase
@return StdString | [
"Sanitize",
"Underscore",
"To",
"Camelcase"
] | 67883b1b1dd2cea80fec3d98a199c403b8a23b4d | https://github.com/phPoirot/Std/blob/67883b1b1dd2cea80fec3d98a199c403b8a23b4d/src/Type/StdString.php#L181-L202 |
39,449 | phPoirot/Std | src/Type/StdString.php | StdString.under_score | function under_score()
{
$key = (string) $this;
$output = strtolower(preg_replace(array('/([a-z\d])([A-Z])/', '/([^_])([A-Z][a-z])/'), '$1_$2', $key));
return new self($output);
} | php | function under_score()
{
$key = (string) $this;
$output = strtolower(preg_replace(array('/([a-z\d])([A-Z])/', '/([^_])([A-Z][a-z])/'), '$1_$2', $key));
return new self($output);
} | [
"function",
"under_score",
"(",
")",
"{",
"$",
"key",
"=",
"(",
"string",
")",
"$",
"this",
";",
"$",
"output",
"=",
"strtolower",
"(",
"preg_replace",
"(",
"array",
"(",
"'/([a-z\\d])([A-Z])/'",
",",
"'/([^_])([A-Z][a-z])/'",
")",
",",
"'$1_$2'",
",",
"$"... | Sanitize CamelCase To under_score
@return StdString | [
"Sanitize",
"CamelCase",
"To",
"under_score"
] | 67883b1b1dd2cea80fec3d98a199c403b8a23b4d | https://github.com/phPoirot/Std/blob/67883b1b1dd2cea80fec3d98a199c403b8a23b4d/src/Type/StdString.php#L209-L216 |
39,450 | phPoirot/Std | src/Type/StdString.php | StdString.isUTF8 | function isUTF8()
{
$string = (string) $this;
if (function_exists('utf8_decode'))
$decodedStr = strlen(utf8_decode($string));
elseif (function_exists('mb_convert_encoding'))
$decodedStr = strlen(utf8_decode($string));
else
$decodedStr = $string;
return strlen($string) != strlen($decodedStr);
} | php | function isUTF8()
{
$string = (string) $this;
if (function_exists('utf8_decode'))
$decodedStr = strlen(utf8_decode($string));
elseif (function_exists('mb_convert_encoding'))
$decodedStr = strlen(utf8_decode($string));
else
$decodedStr = $string;
return strlen($string) != strlen($decodedStr);
} | [
"function",
"isUTF8",
"(",
")",
"{",
"$",
"string",
"=",
"(",
"string",
")",
"$",
"this",
";",
"if",
"(",
"function_exists",
"(",
"'utf8_decode'",
")",
")",
"$",
"decodedStr",
"=",
"strlen",
"(",
"utf8_decode",
"(",
"$",
"string",
")",
")",
";",
"els... | Is Contain UTF-8 Encoding?
@return bool | [
"Is",
"Contain",
"UTF",
"-",
"8",
"Encoding?"
] | 67883b1b1dd2cea80fec3d98a199c403b8a23b4d | https://github.com/phPoirot/Std/blob/67883b1b1dd2cea80fec3d98a199c403b8a23b4d/src/Type/StdString.php#L223-L235 |
39,451 | locomotivemtl/charcoal-cache | src/Charcoal/Cache/Middleware/CacheMiddleware.php | CacheMiddleware.cacheKeyFromRequest | private function cacheKeyFromRequest(RequestInterface $request)
{
$uri = $request->getUri();
$queryStr = $uri->getQuery();
if (!empty($queryStr)) {
$queryArr = [];
parse_str($queryStr, $queryArr);
$queryArr = $this->parseIgnoredParams($queryArr);
$queryStr = http_build_query($queryArr);
$uri = $uri->withQuery($queryStr);
}
$cacheKey = 'request/' . $request->getMethod() . '/' . md5((string)$uri);
return $cacheKey;
} | php | private function cacheKeyFromRequest(RequestInterface $request)
{
$uri = $request->getUri();
$queryStr = $uri->getQuery();
if (!empty($queryStr)) {
$queryArr = [];
parse_str($queryStr, $queryArr);
$queryArr = $this->parseIgnoredParams($queryArr);
$queryStr = http_build_query($queryArr);
$uri = $uri->withQuery($queryStr);
}
$cacheKey = 'request/' . $request->getMethod() . '/' . md5((string)$uri);
return $cacheKey;
} | [
"private",
"function",
"cacheKeyFromRequest",
"(",
"RequestInterface",
"$",
"request",
")",
"{",
"$",
"uri",
"=",
"$",
"request",
"->",
"getUri",
"(",
")",
";",
"$",
"queryStr",
"=",
"$",
"uri",
"->",
"getQuery",
"(",
")",
";",
"if",
"(",
"!",
"empty",... | Generate the cache key from the HTTP request.
@param RequestInterface $request The PSR-7 HTTP request.
@return string | [
"Generate",
"the",
"cache",
"key",
"from",
"the",
"HTTP",
"request",
"."
] | 38d04f6f21c6a826c28e08a5ac48b02c37e8da85 | https://github.com/locomotivemtl/charcoal-cache/blob/38d04f6f21c6a826c28e08a5ac48b02c37e8da85/src/Charcoal/Cache/Middleware/CacheMiddleware.php#L251-L269 |
39,452 | locomotivemtl/charcoal-cache | src/Charcoal/Cache/Middleware/CacheMiddleware.php | CacheMiddleware.isSkipCache | private function isSkipCache(RequestInterface $request)
{
if (isset($this->skipCache['session_vars'])) {
$skip = $this->skipCache['session_vars'];
if (!empty($skip)) {
if (!session_id()) {
session_cache_limiter(false);
session_start();
}
if (array_intersect_key($_SESSION, array_flip($skip))) {
return true;
}
}
}
return false;
} | php | private function isSkipCache(RequestInterface $request)
{
if (isset($this->skipCache['session_vars'])) {
$skip = $this->skipCache['session_vars'];
if (!empty($skip)) {
if (!session_id()) {
session_cache_limiter(false);
session_start();
}
if (array_intersect_key($_SESSION, array_flip($skip))) {
return true;
}
}
}
return false;
} | [
"private",
"function",
"isSkipCache",
"(",
"RequestInterface",
"$",
"request",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"skipCache",
"[",
"'session_vars'",
"]",
")",
")",
"{",
"$",
"skip",
"=",
"$",
"this",
"->",
"skipCache",
"[",
"'session_... | Determine if the HTTP request method matches the accepted choices.
@param RequestInterface $request The PSR-7 HTTP request.
@return boolean | [
"Determine",
"if",
"the",
"HTTP",
"request",
"method",
"matches",
"the",
"accepted",
"choices",
"."
] | 38d04f6f21c6a826c28e08a5ac48b02c37e8da85 | https://github.com/locomotivemtl/charcoal-cache/blob/38d04f6f21c6a826c28e08a5ac48b02c37e8da85/src/Charcoal/Cache/Middleware/CacheMiddleware.php#L288-L306 |
39,453 | locomotivemtl/charcoal-cache | src/Charcoal/Cache/Middleware/CacheMiddleware.php | CacheMiddleware.isPathIncluded | private function isPathIncluded($path)
{
if ($this->includedPath === '*') {
return true;
}
if (empty($this->includedPath) && !is_numeric($this->includedPath)) {
return false;
}
foreach ((array)$this->includedPath as $included) {
if (preg_match('@' . $included . '@', $path)) {
return true;
}
}
return false;
} | php | private function isPathIncluded($path)
{
if ($this->includedPath === '*') {
return true;
}
if (empty($this->includedPath) && !is_numeric($this->includedPath)) {
return false;
}
foreach ((array)$this->includedPath as $included) {
if (preg_match('@' . $included . '@', $path)) {
return true;
}
}
return false;
} | [
"private",
"function",
"isPathIncluded",
"(",
"$",
"path",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"includedPath",
"===",
"'*'",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"includedPath",
")",
"&&",
"!",
"is_num... | Determine if the request should be cached based on the URI path.
@param string $path The request path (route) to verify.
@return boolean | [
"Determine",
"if",
"the",
"request",
"should",
"be",
"cached",
"based",
"on",
"the",
"URI",
"path",
"."
] | 38d04f6f21c6a826c28e08a5ac48b02c37e8da85 | https://github.com/locomotivemtl/charcoal-cache/blob/38d04f6f21c6a826c28e08a5ac48b02c37e8da85/src/Charcoal/Cache/Middleware/CacheMiddleware.php#L325-L342 |
39,454 | locomotivemtl/charcoal-cache | src/Charcoal/Cache/Middleware/CacheMiddleware.php | CacheMiddleware.isPathExcluded | private function isPathExcluded($path)
{
if ($this->excludedPath === '*') {
return true;
}
if (empty($this->excludedPath) && !is_numeric($this->excludedPath)) {
return false;
}
foreach ((array)$this->excludedPath as $excluded) {
if (preg_match('@' . $excluded . '@', $path)) {
return true;
}
}
return false;
} | php | private function isPathExcluded($path)
{
if ($this->excludedPath === '*') {
return true;
}
if (empty($this->excludedPath) && !is_numeric($this->excludedPath)) {
return false;
}
foreach ((array)$this->excludedPath as $excluded) {
if (preg_match('@' . $excluded . '@', $path)) {
return true;
}
}
return false;
} | [
"private",
"function",
"isPathExcluded",
"(",
"$",
"path",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"excludedPath",
"===",
"'*'",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"excludedPath",
")",
"&&",
"!",
"is_num... | Determine if the request should NOT be cached based on the URI path.
@param string $path The request path (route) to verify.
@return boolean | [
"Determine",
"if",
"the",
"request",
"should",
"NOT",
"be",
"cached",
"based",
"on",
"the",
"URI",
"path",
"."
] | 38d04f6f21c6a826c28e08a5ac48b02c37e8da85 | https://github.com/locomotivemtl/charcoal-cache/blob/38d04f6f21c6a826c28e08a5ac48b02c37e8da85/src/Charcoal/Cache/Middleware/CacheMiddleware.php#L350-L367 |
39,455 | locomotivemtl/charcoal-cache | src/Charcoal/Cache/Middleware/CacheMiddleware.php | CacheMiddleware.isQueryIncluded | private function isQueryIncluded(array $queryParams)
{
if (empty($queryParams)) {
return true;
}
if ($this->includedQuery === '*') {
return true;
}
if (empty($this->includedQuery) && !is_numeric($this->includedQuery)) {
return false;
}
$includedParams = array_intersect_key($queryParams, array_flip((array)$this->includedQuery));
return (count($includedParams) > 0);
} | php | private function isQueryIncluded(array $queryParams)
{
if (empty($queryParams)) {
return true;
}
if ($this->includedQuery === '*') {
return true;
}
if (empty($this->includedQuery) && !is_numeric($this->includedQuery)) {
return false;
}
$includedParams = array_intersect_key($queryParams, array_flip((array)$this->includedQuery));
return (count($includedParams) > 0);
} | [
"private",
"function",
"isQueryIncluded",
"(",
"array",
"$",
"queryParams",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"queryParams",
")",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"includedQuery",
"===",
"'*'",
")",
"{",
"return... | Determine if the request should be cached based on the URI query.
@param array $queryParams The query parameters to verify.
@return boolean | [
"Determine",
"if",
"the",
"request",
"should",
"be",
"cached",
"based",
"on",
"the",
"URI",
"query",
"."
] | 38d04f6f21c6a826c28e08a5ac48b02c37e8da85 | https://github.com/locomotivemtl/charcoal-cache/blob/38d04f6f21c6a826c28e08a5ac48b02c37e8da85/src/Charcoal/Cache/Middleware/CacheMiddleware.php#L375-L391 |
39,456 | locomotivemtl/charcoal-cache | src/Charcoal/Cache/Middleware/CacheMiddleware.php | CacheMiddleware.isQueryExcluded | private function isQueryExcluded(array $queryParams)
{
if (empty($queryParams)) {
return false;
}
if ($this->excludedQuery === '*') {
return true;
}
if (empty($this->excludedQuery) && !is_numeric($this->excludedQuery)) {
return false;
}
$excludedParams = array_intersect_key($queryParams, array_flip((array)$this->excludedQuery));
return (count($excludedParams) > 0);
} | php | private function isQueryExcluded(array $queryParams)
{
if (empty($queryParams)) {
return false;
}
if ($this->excludedQuery === '*') {
return true;
}
if (empty($this->excludedQuery) && !is_numeric($this->excludedQuery)) {
return false;
}
$excludedParams = array_intersect_key($queryParams, array_flip((array)$this->excludedQuery));
return (count($excludedParams) > 0);
} | [
"private",
"function",
"isQueryExcluded",
"(",
"array",
"$",
"queryParams",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"queryParams",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"excludedQuery",
"===",
"'*'",
")",
"{",
"retur... | Determine if the request should NOT be cached based on the URI query.
@param array $queryParams The query parameters to verify.
@return boolean | [
"Determine",
"if",
"the",
"request",
"should",
"NOT",
"be",
"cached",
"based",
"on",
"the",
"URI",
"query",
"."
] | 38d04f6f21c6a826c28e08a5ac48b02c37e8da85 | https://github.com/locomotivemtl/charcoal-cache/blob/38d04f6f21c6a826c28e08a5ac48b02c37e8da85/src/Charcoal/Cache/Middleware/CacheMiddleware.php#L399-L415 |
39,457 | locomotivemtl/charcoal-cache | src/Charcoal/Cache/Middleware/CacheMiddleware.php | CacheMiddleware.parseIgnoredParams | private function parseIgnoredParams(array $queryParams)
{
if (empty($queryParams)) {
return $queryParams;
}
if ($this->ignoredQuery === '*') {
if ($this->includedQuery === '*') {
return $queryParams;
}
if (empty($this->includedQuery) && !is_numeric($this->includedQuery)) {
return [];
}
return array_intersect_key($queryParams, array_flip((array)$this->includedQuery));
}
if (empty($this->ignoredQuery) && !is_numeric($this->ignoredQuery)) {
return $queryParams;
}
return array_diff_key($queryParams, array_flip((array)$this->ignoredQuery));
} | php | private function parseIgnoredParams(array $queryParams)
{
if (empty($queryParams)) {
return $queryParams;
}
if ($this->ignoredQuery === '*') {
if ($this->includedQuery === '*') {
return $queryParams;
}
if (empty($this->includedQuery) && !is_numeric($this->includedQuery)) {
return [];
}
return array_intersect_key($queryParams, array_flip((array)$this->includedQuery));
}
if (empty($this->ignoredQuery) && !is_numeric($this->ignoredQuery)) {
return $queryParams;
}
return array_diff_key($queryParams, array_flip((array)$this->ignoredQuery));
} | [
"private",
"function",
"parseIgnoredParams",
"(",
"array",
"$",
"queryParams",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"queryParams",
")",
")",
"{",
"return",
"$",
"queryParams",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"ignoredQuery",
"===",
"'*'",
")",
... | Returns the query parameters that are NOT ignored.
@param array $queryParams The query parameters to filter.
@return array | [
"Returns",
"the",
"query",
"parameters",
"that",
"are",
"NOT",
"ignored",
"."
] | 38d04f6f21c6a826c28e08a5ac48b02c37e8da85 | https://github.com/locomotivemtl/charcoal-cache/blob/38d04f6f21c6a826c28e08a5ac48b02c37e8da85/src/Charcoal/Cache/Middleware/CacheMiddleware.php#L423-L446 |
39,458 | phPoirot/Std | src/ErrorStack.php | ErrorStack.hasErrorAccrued | static function hasErrorAccrued()
{
if (!self::hasHandling())
return false;
$stack = self::$_STACK[self::getStackNum()-1];
return $stack['has_handled_error'];
} | php | static function hasErrorAccrued()
{
if (!self::hasHandling())
return false;
$stack = self::$_STACK[self::getStackNum()-1];
return $stack['has_handled_error'];
} | [
"static",
"function",
"hasErrorAccrued",
"(",
")",
"{",
"if",
"(",
"!",
"self",
"::",
"hasHandling",
"(",
")",
")",
"return",
"false",
";",
"$",
"stack",
"=",
"self",
"::",
"$",
"_STACK",
"[",
"self",
"::",
"getStackNum",
"(",
")",
"-",
"1",
"]",
"... | Get Current Accrued Error If Has
@return false|\Exception|\ErrorException | [
"Get",
"Current",
"Accrued",
"Error",
"If",
"Has"
] | 67883b1b1dd2cea80fec3d98a199c403b8a23b4d | https://github.com/phPoirot/Std/blob/67883b1b1dd2cea80fec3d98a199c403b8a23b4d/src/ErrorStack.php#L174-L181 |
39,459 | phPoirot/Std | src/ErrorStack.php | ErrorStack.handleDone | static function handleDone()
{
$return = null;
if (!self::hasHandling())
## there is no error
return $return;
$stack = array_pop(self::$_STACK);
if ($stack['has_handled_error'])
$return = $stack['has_handled_error'];
# restore error handler
(($stack['error_type']) === self::ERR_TYP_ERROR)
? restore_error_handler()
: restore_exception_handler()
;
return $return;
} | php | static function handleDone()
{
$return = null;
if (!self::hasHandling())
## there is no error
return $return;
$stack = array_pop(self::$_STACK);
if ($stack['has_handled_error'])
$return = $stack['has_handled_error'];
# restore error handler
(($stack['error_type']) === self::ERR_TYP_ERROR)
? restore_error_handler()
: restore_exception_handler()
;
return $return;
} | [
"static",
"function",
"handleDone",
"(",
")",
"{",
"$",
"return",
"=",
"null",
";",
"if",
"(",
"!",
"self",
"::",
"hasHandling",
"(",
")",
")",
"## there is no error",
"return",
"$",
"return",
";",
"$",
"stack",
"=",
"array_pop",
"(",
"self",
"::",
"$"... | Stopping The Error Handling Stack
!! It can using only for error not exceptions
@return null|ErrorException Last error if has | [
"Stopping",
"The",
"Error",
"Handling",
"Stack"
] | 67883b1b1dd2cea80fec3d98a199c403b8a23b4d | https://github.com/phPoirot/Std/blob/67883b1b1dd2cea80fec3d98a199c403b8a23b4d/src/ErrorStack.php#L190-L209 |
39,460 | paulbunyannet/bandolier | src/Bandolier/Type/Paths.php | Paths.curlPath | public static function curlPath($toPath, $paths = null, $dockerEnv = "")
{
if (!$paths) {
$paths = new Paths();
}
if (!$dockerEnv) {
$dockerEnv = self::CURL_CHECK_FILE;
}
$serverName = self::serverName();
if ($paths->domainNameIsWeb($serverName)
|| ($paths->domainNameIsLocalHost($serverName) && $paths->checkForEnvironmentFile($dockerEnv))
) {
$serverName = $paths->getDomainNameWeb();
}
return self::httpProtocol() . '://' . $serverName . DIRECTORY_SEPARATOR . ltrim($toPath, DIRECTORY_SEPARATOR);
} | php | public static function curlPath($toPath, $paths = null, $dockerEnv = "")
{
if (!$paths) {
$paths = new Paths();
}
if (!$dockerEnv) {
$dockerEnv = self::CURL_CHECK_FILE;
}
$serverName = self::serverName();
if ($paths->domainNameIsWeb($serverName)
|| ($paths->domainNameIsLocalHost($serverName) && $paths->checkForEnvironmentFile($dockerEnv))
) {
$serverName = $paths->getDomainNameWeb();
}
return self::httpProtocol() . '://' . $serverName . DIRECTORY_SEPARATOR . ltrim($toPath, DIRECTORY_SEPARATOR);
} | [
"public",
"static",
"function",
"curlPath",
"(",
"$",
"toPath",
",",
"$",
"paths",
"=",
"null",
",",
"$",
"dockerEnv",
"=",
"\"\"",
")",
"{",
"if",
"(",
"!",
"$",
"paths",
")",
"{",
"$",
"paths",
"=",
"new",
"Paths",
"(",
")",
";",
"}",
"if",
"... | Check to see what curl path should be used. If running in
localhost or currently run inside a container use web,
otherwise use the current SERVER_NAME
@param string $toPath Path to start from
@param Paths $paths Instance of Path (or mock)
@param string $dockerEnv Path to environment file that should exist if we're in a docker container
@return string | [
"Check",
"to",
"see",
"what",
"curl",
"path",
"should",
"be",
"used",
".",
"If",
"running",
"in",
"localhost",
"or",
"currently",
"run",
"inside",
"a",
"container",
"use",
"web",
"otherwise",
"use",
"the",
"current",
"SERVER_NAME"
] | a98cb30bf63a18a7e3fc81418bf561ac36e9cd84 | https://github.com/paulbunyannet/bandolier/blob/a98cb30bf63a18a7e3fc81418bf561ac36e9cd84/src/Bandolier/Type/Paths.php#L74-L92 |
39,461 | paulbunyannet/bandolier | src/Bandolier/Type/Paths.php | Paths.fileGetContents | public static function fileGetContents(array $params = [])
{
/** @var string $toPath Path to get request from */
/** @var array $clientParams parameters passed into client */
/** @var \GuzzleHttp\Client $client */
/** @var string $request_type request type */
/** @var array $requestParams parameters to pass into request */
/** @var string $request type of request */
$parameters = new Collection();
$parameters->addItems((array)Arrays::defaultAttributes([
"toPath" => self::httpProtocol() . '://' . self::serverName() . '/',
"clientParams" => [],
"client" => "\\GuzzleHttp\\Client",
"request" => "GET",
"requestParams" => [],
], $params));
$parameters->addItem(parse_url($parameters->getItem('toPath'), PHP_URL_SCHEME) . "://" . parse_url($parameters->getItem('toPath'), PHP_URL_HOST), 'base_uri');
$parameters->setItem(array_merge($parameters->getItem('clientParams'), array('base_uri' => $parameters->getItem('base_uri'))), 'clientParams');
if (is_string($parameters->getItem('client'))) {
$client = $parameters->getItem('client');
$parameters->setItem(new $client($parameters->getItem('clientParams')), 'client');
}
$path = substr($parameters->getItem('toPath'), strlen($parameters->getItem('base_uri')), strlen($parameters->getItem('toPath')));
if (method_exists($parameters->getItem('client'), 'request')) {
// For GuzzleHttp 6
return $parameters->getItem('client')
->request($parameters->getItem('request'), $path, $parameters->getItem('requestParams'))
->getBody()
->getContents();
} elseif (method_exists($parameters->getItem('client'), 'createRequest')) {
// for GuzzleHttp 5.3
$request = $parameters->getItem('client')
->createRequest($parameters->getItem('request'), $path, $parameters->getItem('requestParams'));
return $parameters->getItem('client')->send($request)->getBody();
} else {
throw new FileGetContentsException('The client must be an instance of \\GuzzleHttp\\Client');
}
} | php | public static function fileGetContents(array $params = [])
{
/** @var string $toPath Path to get request from */
/** @var array $clientParams parameters passed into client */
/** @var \GuzzleHttp\Client $client */
/** @var string $request_type request type */
/** @var array $requestParams parameters to pass into request */
/** @var string $request type of request */
$parameters = new Collection();
$parameters->addItems((array)Arrays::defaultAttributes([
"toPath" => self::httpProtocol() . '://' . self::serverName() . '/',
"clientParams" => [],
"client" => "\\GuzzleHttp\\Client",
"request" => "GET",
"requestParams" => [],
], $params));
$parameters->addItem(parse_url($parameters->getItem('toPath'), PHP_URL_SCHEME) . "://" . parse_url($parameters->getItem('toPath'), PHP_URL_HOST), 'base_uri');
$parameters->setItem(array_merge($parameters->getItem('clientParams'), array('base_uri' => $parameters->getItem('base_uri'))), 'clientParams');
if (is_string($parameters->getItem('client'))) {
$client = $parameters->getItem('client');
$parameters->setItem(new $client($parameters->getItem('clientParams')), 'client');
}
$path = substr($parameters->getItem('toPath'), strlen($parameters->getItem('base_uri')), strlen($parameters->getItem('toPath')));
if (method_exists($parameters->getItem('client'), 'request')) {
// For GuzzleHttp 6
return $parameters->getItem('client')
->request($parameters->getItem('request'), $path, $parameters->getItem('requestParams'))
->getBody()
->getContents();
} elseif (method_exists($parameters->getItem('client'), 'createRequest')) {
// for GuzzleHttp 5.3
$request = $parameters->getItem('client')
->createRequest($parameters->getItem('request'), $path, $parameters->getItem('requestParams'));
return $parameters->getItem('client')->send($request)->getBody();
} else {
throw new FileGetContentsException('The client must be an instance of \\GuzzleHttp\\Client');
}
} | [
"public",
"static",
"function",
"fileGetContents",
"(",
"array",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"/** @var string $toPath Path to get request from */",
"/** @var array $clientParams parameters passed into client */",
"/** @var \\GuzzleHttp\\Client $client */",
"/** @var strin... | Get content from a path
@param array $params parameters
@return string
@throws \Exception | [
"Get",
"content",
"from",
"a",
"path"
] | a98cb30bf63a18a7e3fc81418bf561ac36e9cd84 | https://github.com/paulbunyannet/bandolier/blob/a98cb30bf63a18a7e3fc81418bf561ac36e9cd84/src/Bandolier/Type/Paths.php#L166-L205 |
39,462 | paulbunyannet/bandolier | src/Bandolier/Type/Paths.php | Paths.filePutContents | public static function filePutContents($filePath, $content = null)
{
// https://stackoverflow.com/a/282140/405758
if (!file_exists(dirname($filePath))) {
mkdir(dirname($filePath), 0775, true);
}
return file_put_contents($filePath, $content);
} | php | public static function filePutContents($filePath, $content = null)
{
// https://stackoverflow.com/a/282140/405758
if (!file_exists(dirname($filePath))) {
mkdir(dirname($filePath), 0775, true);
}
return file_put_contents($filePath, $content);
} | [
"public",
"static",
"function",
"filePutContents",
"(",
"$",
"filePath",
",",
"$",
"content",
"=",
"null",
")",
"{",
"// https://stackoverflow.com/a/282140/405758",
"if",
"(",
"!",
"file_exists",
"(",
"dirname",
"(",
"$",
"filePath",
")",
")",
")",
"{",
"mkdir... | Traverse path to make file
@param string $filePath path to file to check if it exists
@param string|null $content content of file to be written
@return bool|int | [
"Traverse",
"path",
"to",
"make",
"file"
] | a98cb30bf63a18a7e3fc81418bf561ac36e9cd84 | https://github.com/paulbunyannet/bandolier/blob/a98cb30bf63a18a7e3fc81418bf561ac36e9cd84/src/Bandolier/Type/Paths.php#L253-L260 |
39,463 | froq/froq | src/App.php | App.configValue | public function configValue(string $key, $valueDefault = null)
{
return $this->config->get($key, $valueDefault);
} | php | public function configValue(string $key, $valueDefault = null)
{
return $this->config->get($key, $valueDefault);
} | [
"public",
"function",
"configValue",
"(",
"string",
"$",
"key",
",",
"$",
"valueDefault",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"$",
"key",
",",
"$",
"valueDefault",
")",
";",
"}"
] | Config value.
@param string $key
@param any $valueDefault
@return any | [
"Config",
"value",
"."
] | bc153ccec05585f66301cd632ff46bad91915029 | https://github.com/froq/froq/blob/bc153ccec05585f66301cd632ff46bad91915029/src/App.php#L243-L246 |
39,464 | froq/froq | src/App.php | App.loadTime | public function loadTime(bool $totalStringOnly = true)
{
$start = APP_START_TIME; $end = microtime(true);
$total = $end - $start;
$totalString = sprintf('%.5f', $total);
if ($totalStringOnly) {
return $totalString;
}
return [$start, $end, $total, $totalString];
} | php | public function loadTime(bool $totalStringOnly = true)
{
$start = APP_START_TIME; $end = microtime(true);
$total = $end - $start;
$totalString = sprintf('%.5f', $total);
if ($totalStringOnly) {
return $totalString;
}
return [$start, $end, $total, $totalString];
} | [
"public",
"function",
"loadTime",
"(",
"bool",
"$",
"totalStringOnly",
"=",
"true",
")",
"{",
"$",
"start",
"=",
"APP_START_TIME",
";",
"$",
"end",
"=",
"microtime",
"(",
"true",
")",
";",
"$",
"total",
"=",
"$",
"end",
"-",
"$",
"start",
";",
"$",
... | Load time.
@param bool $totalStringOnly
@return array|string | [
"Load",
"time",
"."
] | bc153ccec05585f66301cd632ff46bad91915029 | https://github.com/froq/froq/blob/bc153ccec05585f66301cd632ff46bad91915029/src/App.php#L395-L406 |
39,465 | froq/froq | src/App.php | App.setServiceMethod | public function setServiceMethod(string $method): void
{
$this->service && $this->service->setMethod($method);
} | php | public function setServiceMethod(string $method): void
{
$this->service && $this->service->setMethod($method);
} | [
"public",
"function",
"setServiceMethod",
"(",
"string",
"$",
"method",
")",
":",
"void",
"{",
"$",
"this",
"->",
"service",
"&&",
"$",
"this",
"->",
"service",
"->",
"setMethod",
"(",
"$",
"method",
")",
";",
"}"
] | Set service method.
@param string $method
@return void | [
"Set",
"service",
"method",
"."
] | bc153ccec05585f66301cd632ff46bad91915029 | https://github.com/froq/froq/blob/bc153ccec05585f66301cd632ff46bad91915029/src/App.php#L423-L426 |
39,466 | froq/froq | src/App.php | App.applyConfig | private function applyConfig(array $config): void
{
// override
if ($this->config != null) {
$config = Config::merge($config, $this->config->getData());
}
$this->config = new Config($config);
// set/reset logger options
$loggerOptions = $this->config->get('logger');
if ($loggerOptions != null) {
isset($loggerOptions['level']) && $this->logger->setLevel($loggerOptions['level']);
isset($loggerOptions['directory']) && $this->logger->setDirectory($loggerOptions['directory']);
}
} | php | private function applyConfig(array $config): void
{
// override
if ($this->config != null) {
$config = Config::merge($config, $this->config->getData());
}
$this->config = new Config($config);
// set/reset logger options
$loggerOptions = $this->config->get('logger');
if ($loggerOptions != null) {
isset($loggerOptions['level']) && $this->logger->setLevel($loggerOptions['level']);
isset($loggerOptions['directory']) && $this->logger->setDirectory($loggerOptions['directory']);
}
} | [
"private",
"function",
"applyConfig",
"(",
"array",
"$",
"config",
")",
":",
"void",
"{",
"// override",
"if",
"(",
"$",
"this",
"->",
"config",
"!=",
"null",
")",
"{",
"$",
"config",
"=",
"Config",
"::",
"merge",
"(",
"$",
"config",
",",
"$",
"this"... | Apply config.
@param array $config
@return void | [
"Apply",
"config",
"."
] | bc153ccec05585f66301cd632ff46bad91915029 | https://github.com/froq/froq/blob/bc153ccec05585f66301cd632ff46bad91915029/src/App.php#L479-L493 |
39,467 | froq/froq | src/App.php | App.applyDefaults | private function applyDefaults(): void
{
$timezone = $this->config->get('timezone');
if ($timezone != null) {
date_default_timezone_set($timezone);
}
$encoding = $this->config->get('encoding');
if ($encoding != null) {
mb_internal_encoding($encoding);
ini_set('default_charset', $encoding);
}
$locales = $this->config->get('locales');
if ($locales != null) {
foreach ((array) $locales as $category => $locale) {
setlocale($category, $locale);
}
}
} | php | private function applyDefaults(): void
{
$timezone = $this->config->get('timezone');
if ($timezone != null) {
date_default_timezone_set($timezone);
}
$encoding = $this->config->get('encoding');
if ($encoding != null) {
mb_internal_encoding($encoding);
ini_set('default_charset', $encoding);
}
$locales = $this->config->get('locales');
if ($locales != null) {
foreach ((array) $locales as $category => $locale) {
setlocale($category, $locale);
}
}
} | [
"private",
"function",
"applyDefaults",
"(",
")",
":",
"void",
"{",
"$",
"timezone",
"=",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'timezone'",
")",
";",
"if",
"(",
"$",
"timezone",
"!=",
"null",
")",
"{",
"date_default_timezone_set",
"(",
"$",
... | Apply defaults.
@return void | [
"Apply",
"defaults",
"."
] | bc153ccec05585f66301cd632ff46bad91915029 | https://github.com/froq/froq/blob/bc153ccec05585f66301cd632ff46bad91915029/src/App.php#L499-L518 |
39,468 | froq/froq | src/App.php | App.endOutputBuffer | private function endOutputBuffer($output = null): void
{
// handle redirections
$statusCode = $this->response->status()->getCode();
if ($statusCode >= 300 && $statusCode <= 399) {
// clean & turn off output buffering
while (ob_get_level()) {
ob_end_clean();
}
$this->response->body()->setContentType('none');
}
// handle outputs
else {
// echo'd or print'ed service methods return 'null'
if ($output === null) {
$output = '';
while (ob_get_level()) {
$output .= ob_get_clean();
}
}
// call user output handler if provided
if ($this->events->has('app.output')) {
$output = $this->events->fire('app.output', $output);
}
$this->response->setBody($output);
}
$this->response->end();
} | php | private function endOutputBuffer($output = null): void
{
// handle redirections
$statusCode = $this->response->status()->getCode();
if ($statusCode >= 300 && $statusCode <= 399) {
// clean & turn off output buffering
while (ob_get_level()) {
ob_end_clean();
}
$this->response->body()->setContentType('none');
}
// handle outputs
else {
// echo'd or print'ed service methods return 'null'
if ($output === null) {
$output = '';
while (ob_get_level()) {
$output .= ob_get_clean();
}
}
// call user output handler if provided
if ($this->events->has('app.output')) {
$output = $this->events->fire('app.output', $output);
}
$this->response->setBody($output);
}
$this->response->end();
} | [
"private",
"function",
"endOutputBuffer",
"(",
"$",
"output",
"=",
"null",
")",
":",
"void",
"{",
"// handle redirections",
"$",
"statusCode",
"=",
"$",
"this",
"->",
"response",
"->",
"status",
"(",
")",
"->",
"getCode",
"(",
")",
";",
"if",
"(",
"$",
... | End output buffer.
@param any $output
@return void | [
"End",
"output",
"buffer",
"."
] | bc153ccec05585f66301cd632ff46bad91915029 | https://github.com/froq/froq/blob/bc153ccec05585f66301cd632ff46bad91915029/src/App.php#L536-L566 |
39,469 | donatj/mddoc | src/Runner/ConfigParser.php | ConfigParser.parse | public function parse( $filename ) {
if( !is_readable($filename) ) {
throw new ConfigException("Config file '{$filename}' not readable");
}
$dom = new \DOMDocument();
if( @$dom->load($filename) === false ) {
throw new ConfigException("Error parsing {$filename}");
}
$root = $dom->firstChild;
if( !$root instanceof \DOMElement ) {
throw new \RuntimeException('Needs a DOM element');
}
$docRoot = new Documentation\DocRoot([], []);
if( $root->nodeName == 'mddoc' ) {
$this->loadChildren($root, $docRoot);
} else {
if( $root->nodeName ) {
throw new ConfigException("XML Root element `{$root->nodeName}` is invalid.");
}
throw new ConfigException("Error parsing {$filename}");
}
return $docRoot;
} | php | public function parse( $filename ) {
if( !is_readable($filename) ) {
throw new ConfigException("Config file '{$filename}' not readable");
}
$dom = new \DOMDocument();
if( @$dom->load($filename) === false ) {
throw new ConfigException("Error parsing {$filename}");
}
$root = $dom->firstChild;
if( !$root instanceof \DOMElement ) {
throw new \RuntimeException('Needs a DOM element');
}
$docRoot = new Documentation\DocRoot([], []);
if( $root->nodeName == 'mddoc' ) {
$this->loadChildren($root, $docRoot);
} else {
if( $root->nodeName ) {
throw new ConfigException("XML Root element `{$root->nodeName}` is invalid.");
}
throw new ConfigException("Error parsing {$filename}");
}
return $docRoot;
} | [
"public",
"function",
"parse",
"(",
"$",
"filename",
")",
"{",
"if",
"(",
"!",
"is_readable",
"(",
"$",
"filename",
")",
")",
"{",
"throw",
"new",
"ConfigException",
"(",
"\"Config file '{$filename}' not readable\"",
")",
";",
"}",
"$",
"dom",
"=",
"new",
... | Parse a config file
@param string $filename
@return \donatj\MDDoc\Documentation\DocRoot
@throws \donatj\MDDoc\Exceptions\ConfigException | [
"Parse",
"a",
"config",
"file"
] | 3db2c0980dc54dbc46748fe8650242ead344ba82 | https://github.com/donatj/mddoc/blob/3db2c0980dc54dbc46748fe8650242ead344ba82/src/Runner/ConfigParser.php#L140-L167 |
39,470 | phPoirot/Std | src/Type/StdTravers.php | StdTravers.toArray | function toArray(\Closure $filter = null, $recursive = false)
{
$arr = array();
foreach($this->getIterator() as $key => $val)
{
if ($recursive && ( $val instanceof \Traversable || is_array($val) ) ) {
// (A) At the end value can be empty by filter
## deep convert
$val = StdTravers::of($val)->toArray($filter, $recursive);
}
// (B) So Filter Check Placed After Recursive Calls
$flag = false;
if ($filter !== null)
$flag = $filter($val, $key);
if ($flag) continue;
if (! \Poirot\Std\isStringify($key) )
## some poirot Traversable is able to handle objects as key
$key = \Poirot\Std\flatten($key);
$arr[(string) $key] = $val;
}
return $arr;
} | php | function toArray(\Closure $filter = null, $recursive = false)
{
$arr = array();
foreach($this->getIterator() as $key => $val)
{
if ($recursive && ( $val instanceof \Traversable || is_array($val) ) ) {
// (A) At the end value can be empty by filter
## deep convert
$val = StdTravers::of($val)->toArray($filter, $recursive);
}
// (B) So Filter Check Placed After Recursive Calls
$flag = false;
if ($filter !== null)
$flag = $filter($val, $key);
if ($flag) continue;
if (! \Poirot\Std\isStringify($key) )
## some poirot Traversable is able to handle objects as key
$key = \Poirot\Std\flatten($key);
$arr[(string) $key] = $val;
}
return $arr;
} | [
"function",
"toArray",
"(",
"\\",
"Closure",
"$",
"filter",
"=",
"null",
",",
"$",
"recursive",
"=",
"false",
")",
"{",
"$",
"arr",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getIterator",
"(",
")",
"as",
"$",
"key",
"=>",
"... | Convert Iterator To An Array
filter:
// return true mean not present to output array
bool function(&$val, &$key = null);
@param \Closure|null $filter
@param bool $recursive Recursively convert values that can be iterated
@return array | [
"Convert",
"Iterator",
"To",
"An",
"Array"
] | 67883b1b1dd2cea80fec3d98a199c403b8a23b4d | https://github.com/phPoirot/Std/blob/67883b1b1dd2cea80fec3d98a199c403b8a23b4d/src/Type/StdTravers.php#L70-L97 |
39,471 | phPoirot/Std | src/Type/StdTravers.php | StdTravers.chain | function chain(\Closure $func, $default = null)
{
$i = 0;
$prev = $default;
foreach ($this->getIterator() as $key => $val) {
if ($i++ !== 0)
$prev = $func($val, $key, $prev);
else
// use default value of argument of given closure
$prev = $func($val, $key);
}
return $prev;
} | php | function chain(\Closure $func, $default = null)
{
$i = 0;
$prev = $default;
foreach ($this->getIterator() as $key => $val) {
if ($i++ !== 0)
$prev = $func($val, $key, $prev);
else
// use default value of argument of given closure
$prev = $func($val, $key);
}
return $prev;
} | [
"function",
"chain",
"(",
"\\",
"Closure",
"$",
"func",
",",
"$",
"default",
"=",
"null",
")",
"{",
"$",
"i",
"=",
"0",
";",
"$",
"prev",
"=",
"$",
"default",
";",
"foreach",
"(",
"$",
"this",
"->",
"getIterator",
"(",
")",
"as",
"$",
"key",
"=... | With Each Item
$prev is previous value that func return
@param \Closure $func fun($val, $key, $prev)
@return mixed | [
"With",
"Each",
"Item"
] | 67883b1b1dd2cea80fec3d98a199c403b8a23b4d | https://github.com/phPoirot/Std/blob/67883b1b1dd2cea80fec3d98a199c403b8a23b4d/src/Type/StdTravers.php#L107-L121 |
39,472 | paulbunyannet/bandolier | src/Bandolier/Type/Strings.php | Strings.titleCase | public static function titleCase(
$value,
$delimiters = [" ", "-", ".", "'", "O'", "Mc"],
$exceptions = ["and", "to", "of", "das", "dos", "I", "II", "III", "IV", "V", "VI"]
) {
// if value passed as empty or is not a string then return false
if (!$value) {
return false;
}
/** @var string $cache Cache Value */
$cache = self::cacheString($value, $delimiters, $exceptions);
// check for cache
if (isset(static::$titleCaseCache[$cache])) {
return static::$titleCaseCache[$cache];
}
/*
* Exceptions in lower case are words you don't want converted
* Exceptions all in upper case are any words you don't want converted to title case
* but should be converted to upper case, e.g.:
* king henry viii or king henry Viii should be King Henry VIII
*/
$value = mb_convert_case($value, MB_CASE_TITLE, "UTF-8");
foreach ($delimiters as $delimiter) {
$words = explode($delimiter, $value);
$newWords = [];
foreach ($words as $word) {
if (in_array(mb_strtoupper($word, "UTF-8"), $exceptions)) {
// check exceptions list for any words that should be in upper case
$word = mb_strtoupper($word, "UTF-8");
} elseif (in_array(mb_strtolower($word, "UTF-8"), $exceptions)) {
// check exceptions list for any words that should be in upper case
$word = mb_strtolower($word, "UTF-8");
} elseif (!in_array($word, $exceptions)) {
// convert to uppercase (non-utf8 only)
$word = ucfirst($word);
}
array_push($newWords, $word);
}
$value = join($delimiter, $newWords);
}
return static::$formatForTitleCache[$cache] = $value;
} | php | public static function titleCase(
$value,
$delimiters = [" ", "-", ".", "'", "O'", "Mc"],
$exceptions = ["and", "to", "of", "das", "dos", "I", "II", "III", "IV", "V", "VI"]
) {
// if value passed as empty or is not a string then return false
if (!$value) {
return false;
}
/** @var string $cache Cache Value */
$cache = self::cacheString($value, $delimiters, $exceptions);
// check for cache
if (isset(static::$titleCaseCache[$cache])) {
return static::$titleCaseCache[$cache];
}
/*
* Exceptions in lower case are words you don't want converted
* Exceptions all in upper case are any words you don't want converted to title case
* but should be converted to upper case, e.g.:
* king henry viii or king henry Viii should be King Henry VIII
*/
$value = mb_convert_case($value, MB_CASE_TITLE, "UTF-8");
foreach ($delimiters as $delimiter) {
$words = explode($delimiter, $value);
$newWords = [];
foreach ($words as $word) {
if (in_array(mb_strtoupper($word, "UTF-8"), $exceptions)) {
// check exceptions list for any words that should be in upper case
$word = mb_strtoupper($word, "UTF-8");
} elseif (in_array(mb_strtolower($word, "UTF-8"), $exceptions)) {
// check exceptions list for any words that should be in upper case
$word = mb_strtolower($word, "UTF-8");
} elseif (!in_array($word, $exceptions)) {
// convert to uppercase (non-utf8 only)
$word = ucfirst($word);
}
array_push($newWords, $word);
}
$value = join($delimiter, $newWords);
}
return static::$formatForTitleCache[$cache] = $value;
} | [
"public",
"static",
"function",
"titleCase",
"(",
"$",
"value",
",",
"$",
"delimiters",
"=",
"[",
"\" \"",
",",
"\"-\"",
",",
"\".\"",
",",
"\"'\"",
",",
"\"O'\"",
",",
"\"Mc\"",
"]",
",",
"$",
"exceptions",
"=",
"[",
"\"and\"",
",",
"\"to\"",
",",
"... | Convert a string to Title Case
@param string $value String to convert
@param array $delimiters Delimiters to break into apart words
@param array $exceptions strings to skip when capitalizing
@return string|bool | [
"Convert",
"a",
"string",
"to",
"Title",
"Case"
] | a98cb30bf63a18a7e3fc81418bf561ac36e9cd84 | https://github.com/paulbunyannet/bandolier/blob/a98cb30bf63a18a7e3fc81418bf561ac36e9cd84/src/Bandolier/Type/Strings.php#L217-L261 |
39,473 | paulbunyannet/bandolier | src/Bandolier/Type/Strings.php | Strings.stripOuterQuotes | public static function stripOuterQuotes($value = "")
{
// if value passed as empty or is not a string then return false
if (!$value) {
return false;
}
/** @var string $cache Cache Value */
$cache = self::cacheString($value);
// check for cache
if (isset(static::$stripOuterQuotesCache[$cache])) {
return static::$stripOuterQuotesCache[$cache];
}
$start = (strlen($value) > 1 && self::startsWith($value, '"'))
|| (strlen($value) > 1 && self::startsWith($value, '\''));
$end = (strlen($value) > 1 && self::endsWith($value, '"'))
|| (strlen($value) > 1 && self::endsWith($value, '\''));
if ($start && $end) {
return static::$stripOuterQuotesCache[$cache] = substr($value, 1, -1);
}
return static::$stripOuterQuotesCache[$cache] = $value;
} | php | public static function stripOuterQuotes($value = "")
{
// if value passed as empty or is not a string then return false
if (!$value) {
return false;
}
/** @var string $cache Cache Value */
$cache = self::cacheString($value);
// check for cache
if (isset(static::$stripOuterQuotesCache[$cache])) {
return static::$stripOuterQuotesCache[$cache];
}
$start = (strlen($value) > 1 && self::startsWith($value, '"'))
|| (strlen($value) > 1 && self::startsWith($value, '\''));
$end = (strlen($value) > 1 && self::endsWith($value, '"'))
|| (strlen($value) > 1 && self::endsWith($value, '\''));
if ($start && $end) {
return static::$stripOuterQuotesCache[$cache] = substr($value, 1, -1);
}
return static::$stripOuterQuotesCache[$cache] = $value;
} | [
"public",
"static",
"function",
"stripOuterQuotes",
"(",
"$",
"value",
"=",
"\"\"",
")",
"{",
"// if value passed as empty or is not a string then return false",
"if",
"(",
"!",
"$",
"value",
")",
"{",
"return",
"false",
";",
"}",
"/** @var string $cache Cache Value */"... | Strip outer quotes from a string
@param string $value
@return bool|string
@throws \Exception | [
"Strip",
"outer",
"quotes",
"from",
"a",
"string"
] | a98cb30bf63a18a7e3fc81418bf561ac36e9cd84 | https://github.com/paulbunyannet/bandolier/blob/a98cb30bf63a18a7e3fc81418bf561ac36e9cd84/src/Bandolier/Type/Strings.php#L328-L353 |
39,474 | paulbunyannet/bandolier | src/Bandolier/Type/Strings.php | Strings.cacheString | protected static function cacheString()
{
$string = "";
foreach (func_get_args() as $functionArgument) {
$string .= md5(serialize($functionArgument));
}
return $string;
} | php | protected static function cacheString()
{
$string = "";
foreach (func_get_args() as $functionArgument) {
$string .= md5(serialize($functionArgument));
}
return $string;
} | [
"protected",
"static",
"function",
"cacheString",
"(",
")",
"{",
"$",
"string",
"=",
"\"\"",
";",
"foreach",
"(",
"func_get_args",
"(",
")",
"as",
"$",
"functionArgument",
")",
"{",
"$",
"string",
".=",
"md5",
"(",
"serialize",
"(",
"$",
"functionArgument"... | Create a cache string from function attributes
@return null|string | [
"Create",
"a",
"cache",
"string",
"from",
"function",
"attributes"
] | a98cb30bf63a18a7e3fc81418bf561ac36e9cd84 | https://github.com/paulbunyannet/bandolier/blob/a98cb30bf63a18a7e3fc81418bf561ac36e9cd84/src/Bandolier/Type/Strings.php#L433-L441 |
39,475 | mcaskill/charcoal-support | src/Email/ManufacturableEmailTrait.php | ManufacturableEmailTrait.emailFactory | protected function emailFactory()
{
if (!isset($this->emailFactory)) {
throw new RuntimeException(sprintf(
'Email Factory is not defined for [%s]',
get_class($this)
));
}
return $this->emailFactory;
} | php | protected function emailFactory()
{
if (!isset($this->emailFactory)) {
throw new RuntimeException(sprintf(
'Email Factory is not defined for [%s]',
get_class($this)
));
}
return $this->emailFactory;
} | [
"protected",
"function",
"emailFactory",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"emailFactory",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"sprintf",
"(",
"'Email Factory is not defined for [%s]'",
",",
"get_class",
"(",
"... | Retrieve the email model factory.
@throws RuntimeException If the model factory is missing.
@return FactoryInterface | [
"Retrieve",
"the",
"email",
"model",
"factory",
"."
] | 2138a34463ca6865bf3a60635aa11381a9ae73c5 | https://github.com/mcaskill/charcoal-support/blob/2138a34463ca6865bf3a60635aa11381a9ae73c5/src/Email/ManufacturableEmailTrait.php#L39-L49 |
39,476 | phPoirot/Std | src/Struct/fixes/DataEntity.php | DataEntity.del | function del($key)
{
if ($key !== $hash = $this->_normalizeKey($key))
$key = $hash;
$properties = &$this->_referDataArrayReference();
if (array_key_exists($key, $properties)) {
unset($properties[$key]);
unset($this->__mapedPropObjects[$hash]);
}
return $this;
} | php | function del($key)
{
if ($key !== $hash = $this->_normalizeKey($key))
$key = $hash;
$properties = &$this->_referDataArrayReference();
if (array_key_exists($key, $properties)) {
unset($properties[$key]);
unset($this->__mapedPropObjects[$hash]);
}
return $this;
} | [
"function",
"del",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"$",
"key",
"!==",
"$",
"hash",
"=",
"$",
"this",
"->",
"_normalizeKey",
"(",
"$",
"key",
")",
")",
"$",
"key",
"=",
"$",
"hash",
";",
"$",
"properties",
"=",
"&",
"$",
"this",
"->",
"_... | Delete a property
@param string $key Property
@return $this | [
"Delete",
"a",
"property"
] | 67883b1b1dd2cea80fec3d98a199c403b8a23b4d | https://github.com/phPoirot/Std/blob/67883b1b1dd2cea80fec3d98a199c403b8a23b4d/src/Struct/fixes/DataEntity.php#L121-L134 |
39,477 | phPoirot/Std | src/Struct/fixes/DataEntity.php | DataEntity._normalizeKey | protected function _normalizeKey($key)
{
if (!is_string($key) && !is_numeric($key))
$key = md5(Std\flatten($key));
return $key;
} | php | protected function _normalizeKey($key)
{
if (!is_string($key) && !is_numeric($key))
$key = md5(Std\flatten($key));
return $key;
} | [
"protected",
"function",
"_normalizeKey",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"key",
")",
"&&",
"!",
"is_numeric",
"(",
"$",
"key",
")",
")",
"$",
"key",
"=",
"md5",
"(",
"Std",
"\\",
"flatten",
"(",
"$",
"key",
")",... | Make hash string for none scalars
@param string|mixed $key
@return string | [
"Make",
"hash",
"string",
"for",
"none",
"scalars"
] | 67883b1b1dd2cea80fec3d98a199c403b8a23b4d | https://github.com/phPoirot/Std/blob/67883b1b1dd2cea80fec3d98a199c403b8a23b4d/src/Struct/fixes/DataEntity.php#L144-L150 |
39,478 | apioo/psx-http | src/Stream/FileStream.php | FileStream.move | public function move($toFile)
{
if ($this->error == UPLOAD_ERR_OK) {
return move_uploaded_file($this->tmpName, $toFile);
} else {
return false;
}
} | php | public function move($toFile)
{
if ($this->error == UPLOAD_ERR_OK) {
return move_uploaded_file($this->tmpName, $toFile);
} else {
return false;
}
} | [
"public",
"function",
"move",
"(",
"$",
"toFile",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"error",
"==",
"UPLOAD_ERR_OK",
")",
"{",
"return",
"move_uploaded_file",
"(",
"$",
"this",
"->",
"tmpName",
",",
"$",
"toFile",
")",
";",
"}",
"else",
"{",
"re... | Moves the uploaded file to a new location
@param string $toFile
@return boolean | [
"Moves",
"the",
"uploaded",
"file",
"to",
"a",
"new",
"location"
] | c54d7212cfb513df84f810429aa34c6ac9942c01 | https://github.com/apioo/psx-http/blob/c54d7212cfb513df84f810429aa34c6ac9942c01/src/Stream/FileStream.php#L125-L132 |
39,479 | nails/module-email | src/Factory/Email.php | Email.addRecipient | protected function addRecipient($mUserIdOrEmail, $bAppend, &$aArray)
{
if (!$bAppend) {
$aArray = [];
}
if (strpos($mUserIdOrEmail, ',') !== false) {
$mUserIdOrEmail = array_map('trim', explode(',', $mUserIdOrEmail));
}
if (is_array($mUserIdOrEmail)) {
foreach ($mUserIdOrEmail as $sUserIdOrEmail) {
$this->addRecipient($sUserIdOrEmail, true, $aArray);
}
} else {
$this->validateEmail($mUserIdOrEmail);
$aArray[] = $mUserIdOrEmail;
}
return $this;
} | php | protected function addRecipient($mUserIdOrEmail, $bAppend, &$aArray)
{
if (!$bAppend) {
$aArray = [];
}
if (strpos($mUserIdOrEmail, ',') !== false) {
$mUserIdOrEmail = array_map('trim', explode(',', $mUserIdOrEmail));
}
if (is_array($mUserIdOrEmail)) {
foreach ($mUserIdOrEmail as $sUserIdOrEmail) {
$this->addRecipient($sUserIdOrEmail, true, $aArray);
}
} else {
$this->validateEmail($mUserIdOrEmail);
$aArray[] = $mUserIdOrEmail;
}
return $this;
} | [
"protected",
"function",
"addRecipient",
"(",
"$",
"mUserIdOrEmail",
",",
"$",
"bAppend",
",",
"&",
"$",
"aArray",
")",
"{",
"if",
"(",
"!",
"$",
"bAppend",
")",
"{",
"$",
"aArray",
"=",
"[",
"]",
";",
"}",
"if",
"(",
"strpos",
"(",
"$",
"mUserIdOr... | Adds a recipient
@param integer|string $mUserIdOrEmail The user ID to send to, or an email address
@param bool $bAppend Whether to add to the list of recipients or not
@param array $aArray The array to add the recipient to
@return $this | [
"Adds",
"a",
"recipient"
] | 42183b33a0465ab302f66a7b4f881410275eb6a4 | https://github.com/nails/module-email/blob/42183b33a0465ab302f66a7b4f881410275eb6a4/src/Factory/Email.php#L164-L184 |
39,480 | nails/module-email | src/Factory/Email.php | Email.data | public function data($mKey, $mValue = null)
{
if (is_array($mKey)) {
foreach ($mKey as $sKey => $mValue) {
$this->data($sKey, $mValue);
}
} else {
$this->aData[$mKey] = $mValue;
}
return $this;
} | php | public function data($mKey, $mValue = null)
{
if (is_array($mKey)) {
foreach ($mKey as $sKey => $mValue) {
$this->data($sKey, $mValue);
}
} else {
$this->aData[$mKey] = $mValue;
}
return $this;
} | [
"public",
"function",
"data",
"(",
"$",
"mKey",
",",
"$",
"mValue",
"=",
"null",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"mKey",
")",
")",
"{",
"foreach",
"(",
"$",
"mKey",
"as",
"$",
"sKey",
"=>",
"$",
"mValue",
")",
"{",
"$",
"this",
"->",... | Set email payload data
@param array|string $mKey An array of key value pairs, or the key if supplying the second parameter
@param mixed $mValue The value
@return $this | [
"Set",
"email",
"payload",
"data"
] | 42183b33a0465ab302f66a7b4f881410275eb6a4 | https://github.com/nails/module-email/blob/42183b33a0465ab302f66a7b4f881410275eb6a4/src/Factory/Email.php#L232-L243 |
39,481 | phPoirot/Std | src/Type/fixes/StdArray.php | StdArray.& | function &select($query)
{
/**
* @param $query
* @param $stackArr
* @return array|null
*/
$_f__select = function & ($query, &$stackArr) use (&$_f__select)
{
$queryOrig = $query;
if (strpos($query, '/') === 0)
## ignore first slash from instructions
## it cause an empty unwanted item on command stacks(exploded instructions)
## (withespace instruction has meaningful command "//item_on_any_depth")
$query = substr($query, 1);
if (!is_array($stackArr) && $query !== '') {
// notice: only variable by reference must return
$z = null;
return $x = &$z;
}
if ($query === '')
return $stackArr;
$instructions = explode('/', $query);
$ins = array_shift($instructions);
$remainQuery = implode('/', $instructions);
## match find(//):
if ($ins === '') {
### looking for any array elements to match query
$return = array();
foreach($stackArr as &$v) {
$r = &$_f__select($remainQuery, $v);
if ($r !== null)
$return[] = &$r;
if (is_array($v)) {
#### continue with deeper data
$r = &$_f__select($queryOrig, $v);
if ($r !== null) {
$return = array_merge($return, $r);
}
}
}
if (empty($return)) {
// notice: only variable by reference must return
$z = null;
return @$x = &$z;
}
return $return;
}
## match wildcard:
if ($ins === '*') {
$return = array();
foreach($stackArr as &$v)
$return[] = &$_f__select($remainQuery, $v);
return $return;
}
## match data item against current query instruct:
if (array_key_exists($ins, $stackArr))
### looking for exact match of an item:
### /*/[query/to/match/item]
return $_f__select($remainQuery, $stackArr[$ins]);
else {
## nothing match query
// notice: only variable by reference must return
$z = null;
return $x = &$z;
}
};
return $_f__select($query, $this->value);
} | php | function &select($query)
{
/**
* @param $query
* @param $stackArr
* @return array|null
*/
$_f__select = function & ($query, &$stackArr) use (&$_f__select)
{
$queryOrig = $query;
if (strpos($query, '/') === 0)
## ignore first slash from instructions
## it cause an empty unwanted item on command stacks(exploded instructions)
## (withespace instruction has meaningful command "//item_on_any_depth")
$query = substr($query, 1);
if (!is_array($stackArr) && $query !== '') {
// notice: only variable by reference must return
$z = null;
return $x = &$z;
}
if ($query === '')
return $stackArr;
$instructions = explode('/', $query);
$ins = array_shift($instructions);
$remainQuery = implode('/', $instructions);
## match find(//):
if ($ins === '') {
### looking for any array elements to match query
$return = array();
foreach($stackArr as &$v) {
$r = &$_f__select($remainQuery, $v);
if ($r !== null)
$return[] = &$r;
if (is_array($v)) {
#### continue with deeper data
$r = &$_f__select($queryOrig, $v);
if ($r !== null) {
$return = array_merge($return, $r);
}
}
}
if (empty($return)) {
// notice: only variable by reference must return
$z = null;
return @$x = &$z;
}
return $return;
}
## match wildcard:
if ($ins === '*') {
$return = array();
foreach($stackArr as &$v)
$return[] = &$_f__select($remainQuery, $v);
return $return;
}
## match data item against current query instruct:
if (array_key_exists($ins, $stackArr))
### looking for exact match of an item:
### /*/[query/to/match/item]
return $_f__select($remainQuery, $stackArr[$ins]);
else {
## nothing match query
// notice: only variable by reference must return
$z = null;
return $x = &$z;
}
};
return $_f__select($query, $this->value);
} | [
"function",
"&",
"select",
"(",
"$",
"query",
")",
"{",
"/**\n * @param $query\n * @param $stackArr\n * @return array|null\n */",
"$",
"_f__select",
"=",
"function",
"&",
"(",
"$",
"query",
",",
"&",
"$",
"stackArr",
")",
"use",
"(",
"&... | Select Bunch Of Items Regard To Given Query
!! for reference return must call with reference
&$stdArr->select('/1/Passenger/Credentials');
$result->select('/* /Passengers');
mean from root-any key presentation - that contains Passenger
$result->select('/insurance|hotels/Passengers');
mean from root-insurance|hotels-that contains Passenger
@param string $query
@return &mixed | [
"Select",
"Bunch",
"Of",
"Items",
"Regard",
"To",
"Given",
"Query"
] | 67883b1b1dd2cea80fec3d98a199c403b8a23b4d | https://github.com/phPoirot/Std/blob/67883b1b1dd2cea80fec3d98a199c403b8a23b4d/src/Type/fixes/StdArray.php#L97-L177 |
39,482 | phpgithook/hello-world | src/Hooks/PrepareCommitMsg.php | PrepareCommitMsg.prepareCommitMsg | public function prepareCommitMsg(
string &$message,
InputInterface $input,
OutputInterface $output,
ParameterBagInterface $configuration,
?string $type = null,
?string $sha = null
): bool {
// Lets add some sweet text to the commit message
$message = 'sweet text '.$message;
// And return true, because the message is good
return true;
} | php | public function prepareCommitMsg(
string &$message,
InputInterface $input,
OutputInterface $output,
ParameterBagInterface $configuration,
?string $type = null,
?string $sha = null
): bool {
// Lets add some sweet text to the commit message
$message = 'sweet text '.$message;
// And return true, because the message is good
return true;
} | [
"public",
"function",
"prepareCommitMsg",
"(",
"string",
"&",
"$",
"message",
",",
"InputInterface",
"$",
"input",
",",
"OutputInterface",
"$",
"output",
",",
"ParameterBagInterface",
"$",
"configuration",
",",
"?",
"string",
"$",
"type",
"=",
"null",
",",
"?"... | Called after receiving the default commit message, just prior to firing up the commit message editor.
Returning false aborts the commit.
This is used to edit the message in a way that cannot be suppressed.
@param string $message Commit message
@param InputInterface $input
@param OutputInterface $output
@param ParameterBagInterface $configuration
@param string|null $type Type of commit message (message, template, merge, squash, or commit)
@param string|null $sha SHA-1 of the commit (only available if working on a existing commit)
@return bool | [
"Called",
"after",
"receiving",
"the",
"default",
"commit",
"message",
"just",
"prior",
"to",
"firing",
"up",
"the",
"commit",
"message",
"editor",
"."
] | c01e5d57b24f5b4823c4007127d8fdf401f2f7da | https://github.com/phpgithook/hello-world/blob/c01e5d57b24f5b4823c4007127d8fdf401f2f7da/src/Hooks/PrepareCommitMsg.php#L28-L41 |
39,483 | rodrigoiii/skeleton-core | src/classes/Console/Commands/MakeTransformerCommand.php | MakeTransformerCommand.makeTemplate | private function makeTemplate($transformer, $model, $template)
{
$template = !empty($template) ? "-{$template}" : "";
$file = __DIR__ . "/../templates/transformer/transformer{$template}.php.dist";
if (file_exists($file))
{
$template = strtr(file_get_contents($file), [
'{{namespace}}' => get_app_namespace(),
'{{transformer}}' => $transformer,
'{{model}}' => $model,
'{{model_small}}' => strtolower($model),
]);
if (!file_exists(app_path("Transformers")))
{
mkdir(app_path("Transformers"), 0755, true);
}
$file_path = app_path("Transformers/{$transformer}.php");
$file = fopen($file_path, "w");
fwrite($file, $template);
fclose($file);
return file_exists($file_path);
}
return false;
} | php | private function makeTemplate($transformer, $model, $template)
{
$template = !empty($template) ? "-{$template}" : "";
$file = __DIR__ . "/../templates/transformer/transformer{$template}.php.dist";
if (file_exists($file))
{
$template = strtr(file_get_contents($file), [
'{{namespace}}' => get_app_namespace(),
'{{transformer}}' => $transformer,
'{{model}}' => $model,
'{{model_small}}' => strtolower($model),
]);
if (!file_exists(app_path("Transformers")))
{
mkdir(app_path("Transformers"), 0755, true);
}
$file_path = app_path("Transformers/{$transformer}.php");
$file = fopen($file_path, "w");
fwrite($file, $template);
fclose($file);
return file_exists($file_path);
}
return false;
} | [
"private",
"function",
"makeTemplate",
"(",
"$",
"transformer",
",",
"$",
"model",
",",
"$",
"template",
")",
"{",
"$",
"template",
"=",
"!",
"empty",
"(",
"$",
"template",
")",
"?",
"\"-{$template}\"",
":",
"\"\"",
";",
"$",
"file",
"=",
"__DIR__",
".... | Create the transformer template.
@depends handle
@param string $transformer
@param string $model
@param boolean $template
@return boolean | [
"Create",
"the",
"transformer",
"template",
"."
] | 5dab0637b9cd0f55a64b1f5926d7ba6bb3f93df0 | https://github.com/rodrigoiii/skeleton-core/blob/5dab0637b9cd0f55a64b1f5926d7ba6bb3f93df0/src/classes/Console/Commands/MakeTransformerCommand.php#L72-L101 |
39,484 | cmsgears/module-core | common/models/resources/Stats.php | Stats.getRowCount | public static function getRowCount( $table, $type = 'row' ) {
$stat = self::find()->where( '`table`=:table AND type=:type', [ ':table' => $table, ':type' => $type ] )->one();
if( isset( $stat ) ) {
return $stat->count;
}
return 0;
} | php | public static function getRowCount( $table, $type = 'row' ) {
$stat = self::find()->where( '`table`=:table AND type=:type', [ ':table' => $table, ':type' => $type ] )->one();
if( isset( $stat ) ) {
return $stat->count;
}
return 0;
} | [
"public",
"static",
"function",
"getRowCount",
"(",
"$",
"table",
",",
"$",
"type",
"=",
"'row'",
")",
"{",
"$",
"stat",
"=",
"self",
"::",
"find",
"(",
")",
"->",
"where",
"(",
"'`table`=:table AND type=:type'",
",",
"[",
"':table'",
"=>",
"$",
"table",... | Returns row count for given table and type.
@param string $table
@param string $type
@return integer | [
"Returns",
"row",
"count",
"for",
"given",
"table",
"and",
"type",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/resources/Stats.php#L135-L145 |
39,485 | cmsgears/module-core | common/utilities/DataUtil.php | DataUtil.sortObjectArrayByNumber | public static function sortObjectArrayByNumber( $array, $attribute, $asc = true ) {
uasort( $array, function( $item1, $item2 ) use ( $attribute, $asc ) {
if( $asc ) {
return $item1->$attribute > $item2->$attribute;
}
else {
return $item1->$attribute < $item2->$attribute;
}
});
return $array;
} | php | public static function sortObjectArrayByNumber( $array, $attribute, $asc = true ) {
uasort( $array, function( $item1, $item2 ) use ( $attribute, $asc ) {
if( $asc ) {
return $item1->$attribute > $item2->$attribute;
}
else {
return $item1->$attribute < $item2->$attribute;
}
});
return $array;
} | [
"public",
"static",
"function",
"sortObjectArrayByNumber",
"(",
"$",
"array",
",",
"$",
"attribute",
",",
"$",
"asc",
"=",
"true",
")",
"{",
"uasort",
"(",
"$",
"array",
",",
"function",
"(",
"$",
"item1",
",",
"$",
"item2",
")",
"use",
"(",
"$",
"at... | The method sort give object array using the attribute having number value. The array objects will be sorted in ascending order by default.
It expects that all the array elements must have the given attribute. | [
"The",
"method",
"sort",
"give",
"object",
"array",
"using",
"the",
"attribute",
"having",
"number",
"value",
".",
"The",
"array",
"objects",
"will",
"be",
"sorted",
"in",
"ascending",
"order",
"by",
"default",
".",
"It",
"expects",
"that",
"all",
"the",
"... | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/utilities/DataUtil.php#L32-L47 |
39,486 | nails/module-email | email/controllers/Verify.php | Verify.index | public function index()
{
$oUri = Factory::service('Uri');
$oInput = Factory::service('Input');
$oSession = Factory::service('Session', 'nails/module-auth');
$oUserModel = Factory::model('User', 'nails/module-auth');
$iId = $oUri->segment(3);
$sCode = $oUri->segment(4);
$sStatus = '';
$sMessage = '';
$oUser = $oUserModel->getById($iId);
if ($oUser && !$oUser->email_is_verified && $sCode) {
try {
if (!$oUserModel->emailVerify($oUser->id, $sCode)) {
throw new NailsException($oUserModel->lastError());
}
// Reward referrer (if any)
if (!empty($oUser->referred_by)) {
$oUserModel->rewardReferral($oUser->id, $oUser->referred_by);
}
$sStatus = 'success';
$sMessage = 'Success! Email verified successfully, thanks!';
} catch (\Exception $e) {
$sStatus = 'error';
$sMessage = 'Sorry, we couldn\'t verify your email address. ' . $e->getMessage();
}
}
// --------------------------------------------------------------------------
if ($oInput->get('return_to')) {
$sRedirect = $oInput->get('return_to');
} elseif (!isLoggedIn() && $oUser) {
if ($oUser->temp_pw) {
$sRedirect = 'auth/password/reset/' . $oUser->id . '/' . md5($oUser->salt);
} else {
$oUserModel->setLoginData($oUser->id);
$sRedirect = $oUser->group_homepage;
}
} elseif ($oUser) {
$sRedirect = $oUser->group_homepage;
} else {
$sRedirect = '/';
}
if (!empty($sStatus)) {
$oSession->setFlashData(
$sStatus,
$sMessage
);
}
redirect($sRedirect);
} | php | public function index()
{
$oUri = Factory::service('Uri');
$oInput = Factory::service('Input');
$oSession = Factory::service('Session', 'nails/module-auth');
$oUserModel = Factory::model('User', 'nails/module-auth');
$iId = $oUri->segment(3);
$sCode = $oUri->segment(4);
$sStatus = '';
$sMessage = '';
$oUser = $oUserModel->getById($iId);
if ($oUser && !$oUser->email_is_verified && $sCode) {
try {
if (!$oUserModel->emailVerify($oUser->id, $sCode)) {
throw new NailsException($oUserModel->lastError());
}
// Reward referrer (if any)
if (!empty($oUser->referred_by)) {
$oUserModel->rewardReferral($oUser->id, $oUser->referred_by);
}
$sStatus = 'success';
$sMessage = 'Success! Email verified successfully, thanks!';
} catch (\Exception $e) {
$sStatus = 'error';
$sMessage = 'Sorry, we couldn\'t verify your email address. ' . $e->getMessage();
}
}
// --------------------------------------------------------------------------
if ($oInput->get('return_to')) {
$sRedirect = $oInput->get('return_to');
} elseif (!isLoggedIn() && $oUser) {
if ($oUser->temp_pw) {
$sRedirect = 'auth/password/reset/' . $oUser->id . '/' . md5($oUser->salt);
} else {
$oUserModel->setLoginData($oUser->id);
$sRedirect = $oUser->group_homepage;
}
} elseif ($oUser) {
$sRedirect = $oUser->group_homepage;
} else {
$sRedirect = '/';
}
if (!empty($sStatus)) {
$oSession->setFlashData(
$sStatus,
$sMessage
);
}
redirect($sRedirect);
} | [
"public",
"function",
"index",
"(",
")",
"{",
"$",
"oUri",
"=",
"Factory",
"::",
"service",
"(",
"'Uri'",
")",
";",
"$",
"oInput",
"=",
"Factory",
"::",
"service",
"(",
"'Input'",
")",
";",
"$",
"oSession",
"=",
"Factory",
"::",
"service",
"(",
"'Ses... | Attempt to validate the user's activation code | [
"Attempt",
"to",
"validate",
"the",
"user",
"s",
"activation",
"code"
] | 42183b33a0465ab302f66a7b4f881410275eb6a4 | https://github.com/nails/module-email/blob/42183b33a0465ab302f66a7b4f881410275eb6a4/email/controllers/Verify.php#L22-L81 |
39,487 | apioo/psx-http | src/Response.php | Response.setStatus | public function setStatus($code, $reasonPhrase = null)
{
$this->code = (int) $code;
if ($reasonPhrase !== null) {
$this->reasonPhrase = $reasonPhrase;
} elseif (isset(Http::$codes[$this->code])) {
$this->reasonPhrase = Http::$codes[$this->code];
}
} | php | public function setStatus($code, $reasonPhrase = null)
{
$this->code = (int) $code;
if ($reasonPhrase !== null) {
$this->reasonPhrase = $reasonPhrase;
} elseif (isset(Http::$codes[$this->code])) {
$this->reasonPhrase = Http::$codes[$this->code];
}
} | [
"public",
"function",
"setStatus",
"(",
"$",
"code",
",",
"$",
"reasonPhrase",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"code",
"=",
"(",
"int",
")",
"$",
"code",
";",
"if",
"(",
"$",
"reasonPhrase",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"... | Sets the status code and reason phrase. If no reason phrase is provided
the standard message according to the status code is used
@param integer $code
@param integer $reasonPhrase | [
"Sets",
"the",
"status",
"code",
"and",
"reason",
"phrase",
".",
"If",
"no",
"reason",
"phrase",
"is",
"provided",
"the",
"standard",
"message",
"according",
"to",
"the",
"status",
"code",
"is",
"used"
] | c54d7212cfb513df84f810429aa34c6ac9942c01 | https://github.com/apioo/psx-http/blob/c54d7212cfb513df84f810429aa34c6ac9942c01/src/Response.php#L82-L91 |
39,488 | apioo/psx-http | src/Response.php | Response.toString | public function toString()
{
$response = Parser\ResponseParser::buildStatusLine($this) . Http::NEW_LINE;
$headers = Parser\ResponseParser::buildHeaderFromMessage($this);
foreach ($headers as $header) {
$response.= $header . Http::NEW_LINE;
}
$response.= Http::NEW_LINE;
$response.= (string) $this->getBody();
return $response;
} | php | public function toString()
{
$response = Parser\ResponseParser::buildStatusLine($this) . Http::NEW_LINE;
$headers = Parser\ResponseParser::buildHeaderFromMessage($this);
foreach ($headers as $header) {
$response.= $header . Http::NEW_LINE;
}
$response.= Http::NEW_LINE;
$response.= (string) $this->getBody();
return $response;
} | [
"public",
"function",
"toString",
"(",
")",
"{",
"$",
"response",
"=",
"Parser",
"\\",
"ResponseParser",
"::",
"buildStatusLine",
"(",
"$",
"this",
")",
".",
"Http",
"::",
"NEW_LINE",
";",
"$",
"headers",
"=",
"Parser",
"\\",
"ResponseParser",
"::",
"build... | Converts the response object to an http response string
@return string | [
"Converts",
"the",
"response",
"object",
"to",
"an",
"http",
"response",
"string"
] | c54d7212cfb513df84f810429aa34c6ac9942c01 | https://github.com/apioo/psx-http/blob/c54d7212cfb513df84f810429aa34c6ac9942c01/src/Response.php#L98-L111 |
39,489 | cmsgears/module-core | common/models/resources/Category.php | Category.getRoot | public function getRoot() {
$parentTable = CoreTables::getTableName( CoreTables::TABLE_CATEGORY );
return $this->hasOne( Category::class, [ 'id' => 'rootId' ] )->from( "$parentTable as root" );
} | php | public function getRoot() {
$parentTable = CoreTables::getTableName( CoreTables::TABLE_CATEGORY );
return $this->hasOne( Category::class, [ 'id' => 'rootId' ] )->from( "$parentTable as root" );
} | [
"public",
"function",
"getRoot",
"(",
")",
"{",
"$",
"parentTable",
"=",
"CoreTables",
"::",
"getTableName",
"(",
"CoreTables",
"::",
"TABLE_CATEGORY",
")",
";",
"return",
"$",
"this",
"->",
"hasOne",
"(",
"Category",
"::",
"class",
",",
"[",
"'id'",
"=>",... | Return the root parent of the category.
@return Category | [
"Return",
"the",
"root",
"parent",
"of",
"the",
"category",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/resources/Category.php#L223-L228 |
39,490 | cmsgears/module-core | common/models/resources/Category.php | Category.findByParentId | public static function findByParentId( $parentId, $config = [] ) {
$limit = $config['limit'] ?? null;
return self::find()->where( 'parentId=:id', [ ':id' => $parentId ] )->limit($limit)->all();
} | php | public static function findByParentId( $parentId, $config = [] ) {
$limit = $config['limit'] ?? null;
return self::find()->where( 'parentId=:id', [ ':id' => $parentId ] )->limit($limit)->all();
} | [
"public",
"static",
"function",
"findByParentId",
"(",
"$",
"parentId",
",",
"$",
"config",
"=",
"[",
"]",
")",
"{",
"$",
"limit",
"=",
"$",
"config",
"[",
"'limit'",
"]",
"??",
"null",
";",
"return",
"self",
"::",
"find",
"(",
")",
"->",
"where",
... | Find and return the categories having given parent id.
@param string $parentId
@param array $config
@return Category[] | [
"Find",
"and",
"return",
"the",
"categories",
"having",
"given",
"parent",
"id",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/resources/Category.php#L317-L321 |
39,491 | cmsgears/module-core | common/models/resources/Category.php | Category.findFeaturedByType | public static function findFeaturedByType( $type, $config = [] ) {
$ignoreSite = isset( $config[ 'ignoreSite' ] ) ? $config[ 'ignoreSite' ] : false;
$order = isset( $config[ 'order' ] ) ? $config[ 'order' ] : [ 'name' => SORT_ASC ];
$limit = $config['limit'] ?? null;
if( static::isMultiSite() && !$ignoreSite ) {
$siteId = isset( $config[ 'siteId' ] ) ? $config[ 'siteId' ] : Yii::$app->core->siteId;
return static::find()->where( 'type=:type AND siteId=:siteId AND featured=1', [ ':type' => $type, ':siteId' => $siteId ] )->orderBy( $order )->limit($limit)->all();
}
else {
return static::find()->where( 'type=:type AND featured=1', [ ':type' => $type ] )->orderBy( $order )->limit( $limit )->all();
}
} | php | public static function findFeaturedByType( $type, $config = [] ) {
$ignoreSite = isset( $config[ 'ignoreSite' ] ) ? $config[ 'ignoreSite' ] : false;
$order = isset( $config[ 'order' ] ) ? $config[ 'order' ] : [ 'name' => SORT_ASC ];
$limit = $config['limit'] ?? null;
if( static::isMultiSite() && !$ignoreSite ) {
$siteId = isset( $config[ 'siteId' ] ) ? $config[ 'siteId' ] : Yii::$app->core->siteId;
return static::find()->where( 'type=:type AND siteId=:siteId AND featured=1', [ ':type' => $type, ':siteId' => $siteId ] )->orderBy( $order )->limit($limit)->all();
}
else {
return static::find()->where( 'type=:type AND featured=1', [ ':type' => $type ] )->orderBy( $order )->limit( $limit )->all();
}
} | [
"public",
"static",
"function",
"findFeaturedByType",
"(",
"$",
"type",
",",
"$",
"config",
"=",
"[",
"]",
")",
"{",
"$",
"ignoreSite",
"=",
"isset",
"(",
"$",
"config",
"[",
"'ignoreSite'",
"]",
")",
"?",
"$",
"config",
"[",
"'ignoreSite'",
"]",
":",
... | Find and return the featured categories for given type.
@param string $type
@param array $config
@return Category | [
"Find",
"and",
"return",
"the",
"featured",
"categories",
"for",
"given",
"type",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/resources/Category.php#L330-L346 |
39,492 | rodrigoiii/skeleton-core | src/classes/Console/Commands/MakeRuleCommand.php | MakeRuleCommand.ruleTemplate | private function ruleTemplate($rule)
{
$file = __DIR__ . "/../templates/validator/rule.php.dist";
if (file_exists($file))
{
$template = strtr(file_get_contents($file), [
'{{namespace}}' => get_app_namespace(),
'{{rule}}' => $rule
]);
if (!file_exists(app_path("Validation/Rules")))
{
mkdir(app_path("Validation/Rules"), 0755, true);
}
$file_path = app_path("Validation/Rules/{$rule}.php");
$file = fopen($file_path, "w");
fwrite($file, $template);
fclose($file);
return file_exists($file_path);
}
return false;
} | php | private function ruleTemplate($rule)
{
$file = __DIR__ . "/../templates/validator/rule.php.dist";
if (file_exists($file))
{
$template = strtr(file_get_contents($file), [
'{{namespace}}' => get_app_namespace(),
'{{rule}}' => $rule
]);
if (!file_exists(app_path("Validation/Rules")))
{
mkdir(app_path("Validation/Rules"), 0755, true);
}
$file_path = app_path("Validation/Rules/{$rule}.php");
$file = fopen($file_path, "w");
fwrite($file, $template);
fclose($file);
return file_exists($file_path);
}
return false;
} | [
"private",
"function",
"ruleTemplate",
"(",
"$",
"rule",
")",
"{",
"$",
"file",
"=",
"__DIR__",
".",
"\"/../templates/validator/rule.php.dist\"",
";",
"if",
"(",
"file_exists",
"(",
"$",
"file",
")",
")",
"{",
"$",
"template",
"=",
"strtr",
"(",
"file_get_co... | Create the rule template.
@param string $rule
@return boolean | [
"Create",
"the",
"rule",
"template",
"."
] | 5dab0637b9cd0f55a64b1f5926d7ba6bb3f93df0 | https://github.com/rodrigoiii/skeleton-core/blob/5dab0637b9cd0f55a64b1f5926d7ba6bb3f93df0/src/classes/Console/Commands/MakeRuleCommand.php#L67-L93 |
39,493 | Finesse/MicroDB | src/Connection.php | Connection.create | public static function create(
string $dsn,
string $username = null,
string $passwd = null,
array $options = null
): self {
$defaultOptions = [
\PDO::ATTR_STRINGIFY_FETCHES => false
];
try {
return new static(new \PDO($dsn, $username, $passwd, array_replace($defaultOptions, $options ?? [])));
} catch (\Throwable $exception) {
throw static::wrapException($exception);
}
} | php | public static function create(
string $dsn,
string $username = null,
string $passwd = null,
array $options = null
): self {
$defaultOptions = [
\PDO::ATTR_STRINGIFY_FETCHES => false
];
try {
return new static(new \PDO($dsn, $username, $passwd, array_replace($defaultOptions, $options ?? [])));
} catch (\Throwable $exception) {
throw static::wrapException($exception);
}
} | [
"public",
"static",
"function",
"create",
"(",
"string",
"$",
"dsn",
",",
"string",
"$",
"username",
"=",
"null",
",",
"string",
"$",
"passwd",
"=",
"null",
",",
"array",
"$",
"options",
"=",
"null",
")",
":",
"self",
"{",
"$",
"defaultOptions",
"=",
... | Creates a self instance. All the arguments are the arguments for the PDO constructor.
@param string $dsn
@param string|null $username
@param string|null $passwd
@param array|null $options
@return static
@throws PDOException
@see http://php.net/manual/en/pdo.construct.php Arguments reference | [
"Creates",
"a",
"self",
"instance",
".",
"All",
"the",
"arguments",
"are",
"the",
"arguments",
"for",
"the",
"PDO",
"constructor",
"."
] | 839ee9b2bbf7bf9811f946325ae7a0eb03d0c063 | https://github.com/Finesse/MicroDB/blob/839ee9b2bbf7bf9811f946325ae7a0eb03d0c063/src/Connection.php#L50-L65 |
39,494 | Finesse/MicroDB | src/Connection.php | Connection.selectFirst | public function selectFirst(string $query, array $values = [])
{
try {
$row = $this->executeStatement($query, $values)->fetch();
return $row === false ? null : $row;
} catch (\Throwable $exception) {
throw static::wrapException($exception, $query, $values);
}
} | php | public function selectFirst(string $query, array $values = [])
{
try {
$row = $this->executeStatement($query, $values)->fetch();
return $row === false ? null : $row;
} catch (\Throwable $exception) {
throw static::wrapException($exception, $query, $values);
}
} | [
"public",
"function",
"selectFirst",
"(",
"string",
"$",
"query",
",",
"array",
"$",
"values",
"=",
"[",
"]",
")",
"{",
"try",
"{",
"$",
"row",
"=",
"$",
"this",
"->",
"executeStatement",
"(",
"$",
"query",
",",
"$",
"values",
")",
"->",
"fetch",
"... | Performs a select query and returns the first query result.
@param string $query Full SQL query
@param array $values Values to bind. The indexes are the names or numbers of the values.
@return array|null An array indexed by columns. Null if nothing is found.
@throws InvalidArgumentException
@throws PDOException | [
"Performs",
"a",
"select",
"query",
"and",
"returns",
"the",
"first",
"query",
"result",
"."
] | 839ee9b2bbf7bf9811f946325ae7a0eb03d0c063 | https://github.com/Finesse/MicroDB/blob/839ee9b2bbf7bf9811f946325ae7a0eb03d0c063/src/Connection.php#L94-L102 |
39,495 | Finesse/MicroDB | src/Connection.php | Connection.insert | public function insert(string $query, array $values = []): int
{
try {
return $this->executeStatement($query, $values)->rowCount();
} catch (\Throwable $exception) {
throw static::wrapException($exception, $query, $values);
}
} | php | public function insert(string $query, array $values = []): int
{
try {
return $this->executeStatement($query, $values)->rowCount();
} catch (\Throwable $exception) {
throw static::wrapException($exception, $query, $values);
}
} | [
"public",
"function",
"insert",
"(",
"string",
"$",
"query",
",",
"array",
"$",
"values",
"=",
"[",
"]",
")",
":",
"int",
"{",
"try",
"{",
"return",
"$",
"this",
"->",
"executeStatement",
"(",
"$",
"query",
",",
"$",
"values",
")",
"->",
"rowCount",
... | Performs an insert query and returns the number of inserted rows.
@param string $query Full SQL query
@param array $values Values to bind. The indexes are the names or numbers of the values.
@return int
@throws InvalidArgumentException
@throws PDOException | [
"Performs",
"an",
"insert",
"query",
"and",
"returns",
"the",
"number",
"of",
"inserted",
"rows",
"."
] | 839ee9b2bbf7bf9811f946325ae7a0eb03d0c063 | https://github.com/Finesse/MicroDB/blob/839ee9b2bbf7bf9811f946325ae7a0eb03d0c063/src/Connection.php#L113-L120 |
39,496 | Finesse/MicroDB | src/Connection.php | Connection.insertGetId | public function insertGetId(string $query, array $values = [], string $sequence = null)
{
try {
$this->executeStatement($query, $values);
$id = $this->pdo->lastInsertId($sequence);
return is_numeric($id) ? (int)$id : $id;
} catch (\Throwable $exception) {
throw static::wrapException($exception, $query, $values);
}
} | php | public function insertGetId(string $query, array $values = [], string $sequence = null)
{
try {
$this->executeStatement($query, $values);
$id = $this->pdo->lastInsertId($sequence);
return is_numeric($id) ? (int)$id : $id;
} catch (\Throwable $exception) {
throw static::wrapException($exception, $query, $values);
}
} | [
"public",
"function",
"insertGetId",
"(",
"string",
"$",
"query",
",",
"array",
"$",
"values",
"=",
"[",
"]",
",",
"string",
"$",
"sequence",
"=",
"null",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"executeStatement",
"(",
"$",
"query",
",",
"$",
"valu... | Performs an insert query and returns the identifier of the last inserted row.
@param string $query Full SQL query
@param array $values Values to bind. The indexes are the names or numbers of the values.
@param string|null $sequence Name of the sequence object from which the ID should be returned
@return int|string
@throws InvalidArgumentException
@throws PDOException | [
"Performs",
"an",
"insert",
"query",
"and",
"returns",
"the",
"identifier",
"of",
"the",
"last",
"inserted",
"row",
"."
] | 839ee9b2bbf7bf9811f946325ae7a0eb03d0c063 | https://github.com/Finesse/MicroDB/blob/839ee9b2bbf7bf9811f946325ae7a0eb03d0c063/src/Connection.php#L132-L141 |
39,497 | Finesse/MicroDB | src/Connection.php | Connection.statement | public function statement(string $query, array $values = [])
{
try {
$this->executeStatement($query, $values);
} catch (\Throwable $exception) {
throw static::wrapException($exception, $query, $values);
}
} | php | public function statement(string $query, array $values = [])
{
try {
$this->executeStatement($query, $values);
} catch (\Throwable $exception) {
throw static::wrapException($exception, $query, $values);
}
} | [
"public",
"function",
"statement",
"(",
"string",
"$",
"query",
",",
"array",
"$",
"values",
"=",
"[",
"]",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"executeStatement",
"(",
"$",
"query",
",",
"$",
"values",
")",
";",
"}",
"catch",
"(",
"\\",
"Thro... | Performs a general query. If the query contains multiple statements separated by a semicolon, only the first
statement will be executed.
@param string $query Full SQL query
@param array $values Values to bind. The indexes are the names or numbers of the values.
@throws InvalidArgumentException
@throws PDOException | [
"Performs",
"a",
"general",
"query",
".",
"If",
"the",
"query",
"contains",
"multiple",
"statements",
"separated",
"by",
"a",
"semicolon",
"only",
"the",
"first",
"statement",
"will",
"be",
"executed",
"."
] | 839ee9b2bbf7bf9811f946325ae7a0eb03d0c063 | https://github.com/Finesse/MicroDB/blob/839ee9b2bbf7bf9811f946325ae7a0eb03d0c063/src/Connection.php#L188-L195 |
39,498 | Finesse/MicroDB | src/Connection.php | Connection.executeStatement | protected function executeStatement(string $query, array $values = []): \PDOStatement
{
$statement = $this->pdo->prepare($query);
$this->bindValues($statement, $values);
$statement->execute();
return $statement;
} | php | protected function executeStatement(string $query, array $values = []): \PDOStatement
{
$statement = $this->pdo->prepare($query);
$this->bindValues($statement, $values);
$statement->execute();
return $statement;
} | [
"protected",
"function",
"executeStatement",
"(",
"string",
"$",
"query",
",",
"array",
"$",
"values",
"=",
"[",
"]",
")",
":",
"\\",
"PDOStatement",
"{",
"$",
"statement",
"=",
"$",
"this",
"->",
"pdo",
"->",
"prepare",
"(",
"$",
"query",
")",
";",
... | Executes a single SQL statement and returns the corresponding PDO statement.
@param string $query Full SQL query
@param array $values Values to bind. The indexes are the names or numbers of the values.
@return \PDOStatement
@throws InvalidArgumentException
@throws BasePDOException | [
"Executes",
"a",
"single",
"SQL",
"statement",
"and",
"returns",
"the",
"corresponding",
"PDO",
"statement",
"."
] | 839ee9b2bbf7bf9811f946325ae7a0eb03d0c063 | https://github.com/Finesse/MicroDB/blob/839ee9b2bbf7bf9811f946325ae7a0eb03d0c063/src/Connection.php#L260-L266 |
39,499 | Finesse/MicroDB | src/Connection.php | Connection.bindValues | protected function bindValues(\PDOStatement $statement, array $values)
{
$number = 1;
foreach ($values as $name => $value) {
$this->bindValue($statement, is_string($name) ? $name : $number, $value);
$number += 1;
}
} | php | protected function bindValues(\PDOStatement $statement, array $values)
{
$number = 1;
foreach ($values as $name => $value) {
$this->bindValue($statement, is_string($name) ? $name : $number, $value);
$number += 1;
}
} | [
"protected",
"function",
"bindValues",
"(",
"\\",
"PDOStatement",
"$",
"statement",
",",
"array",
"$",
"values",
")",
"{",
"$",
"number",
"=",
"1",
";",
"foreach",
"(",
"$",
"values",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->"... | Binds parameters to a PDO statement.
@param \PDOStatement $statement PDO statement
@param array $values Parameters. The indexes are the names or numbers of the values.
@throws InvalidArgumentException
@throws BasePDOException | [
"Binds",
"parameters",
"to",
"a",
"PDO",
"statement",
"."
] | 839ee9b2bbf7bf9811f946325ae7a0eb03d0c063 | https://github.com/Finesse/MicroDB/blob/839ee9b2bbf7bf9811f946325ae7a0eb03d0c063/src/Connection.php#L276-L284 |
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.