repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1 value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 | partition stringclasses 1 value |
|---|---|---|---|---|---|---|---|---|---|---|---|
maximebf/ConsoleKit | src/ConsoleKit/Colors.php | Colors.extractColorAndOptions | private static function extractColorAndOptions($colorCode)
{
$options = array();
foreach (self::$options as $name => $bit) {
if (($colorCode & $bit) === $bit) {
$options[] = self::$codes[$bit];
$colorCode = $colorCode & ~$bit;
}
}
if (!isset(self::$codes[$colorCode])) {
throw new ConsoleException("Cannot parse color code");
}
return array(self::$codes[$colorCode], $options);
} | php | private static function extractColorAndOptions($colorCode)
{
$options = array();
foreach (self::$options as $name => $bit) {
if (($colorCode & $bit) === $bit) {
$options[] = self::$codes[$bit];
$colorCode = $colorCode & ~$bit;
}
}
if (!isset(self::$codes[$colorCode])) {
throw new ConsoleException("Cannot parse color code");
}
return array(self::$codes[$colorCode], $options);
} | [
"private",
"static",
"function",
"extractColorAndOptions",
"(",
"$",
"colorCode",
")",
"{",
"$",
"options",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"self",
"::",
"$",
"options",
"as",
"$",
"name",
"=>",
"$",
"bit",
")",
"{",
"if",
"(",
"(",
"$",... | Extracts the options and the color from a color code
@param int $colorCode
@return array | [
"Extracts",
"the",
"options",
"and",
"the",
"color",
"from",
"a",
"color",
"code"
] | a05c0c5a4c48882599d59323314ac963a836d58f | https://github.com/maximebf/ConsoleKit/blob/a05c0c5a4c48882599d59323314ac963a836d58f/src/ConsoleKit/Colors.php#L185-L198 | train |
wangxian/ephp | src/Http/CookieSwoole.php | CookieSwoole.setSecret | public function setSecret($name, $value, $expire = 604800, $path = '/', $domain = '')
{
$value = \ePHP\Hash\Encrypt::encryptG($value, md5($_SERVER['HTTP_HOST'].APP_PATH.SERVER_MODE));
$this->set($name, $value, $expire, $path, $domain);
} | php | public function setSecret($name, $value, $expire = 604800, $path = '/', $domain = '')
{
$value = \ePHP\Hash\Encrypt::encryptG($value, md5($_SERVER['HTTP_HOST'].APP_PATH.SERVER_MODE));
$this->set($name, $value, $expire, $path, $domain);
} | [
"public",
"function",
"setSecret",
"(",
"$",
"name",
",",
"$",
"value",
",",
"$",
"expire",
"=",
"604800",
",",
"$",
"path",
"=",
"'/'",
",",
"$",
"domain",
"=",
"''",
")",
"{",
"$",
"value",
"=",
"\\",
"ePHP",
"\\",
"Hash",
"\\",
"Encrypt",
"::"... | Set Secret cookie
@param string $name cookie name
@param mixed $value
@param int $expire default 604800s(7days)
@param string $path default /
@param string $domain default empty
@return null | [
"Set",
"Secret",
"cookie"
] | 697248ab098d8dc352de31ab0c64ea0fee1d7132 | https://github.com/wangxian/ephp/blob/697248ab098d8dc352de31ab0c64ea0fee1d7132/src/Http/CookieSwoole.php#L39-L43 | train |
wangxian/ephp | src/Http/CookieSwoole.php | CookieSwoole.getSecret | public function getSecret($name)
{
$value = $this->get($name);
if (empty($value)) {
return false;
} else {
return \ePHP\Hash\Encrypt::decryptG($value, md5($_SERVER['HTTP_HOST'].APP_PATH.SERVER_MODE));
}
} | php | public function getSecret($name)
{
$value = $this->get($name);
if (empty($value)) {
return false;
} else {
return \ePHP\Hash\Encrypt::decryptG($value, md5($_SERVER['HTTP_HOST'].APP_PATH.SERVER_MODE));
}
} | [
"public",
"function",
"getSecret",
"(",
"$",
"name",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"get",
"(",
"$",
"name",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"value",
")",
")",
"{",
"return",
"false",
";",
"}",
"else",
"{",
"return",
"\... | Get Secret cookie
@param string $name
@return string | [
"Get",
"Secret",
"cookie"
] | 697248ab098d8dc352de31ab0c64ea0fee1d7132 | https://github.com/wangxian/ephp/blob/697248ab098d8dc352de31ab0c64ea0fee1d7132/src/Http/CookieSwoole.php#L62-L70 | train |
katsana/katsana-sdk-php | src/One/Vehicles.php | Vehicles.get | public function get(int $vehicleId, ?Query $query = null): Response
{
$this->requiresAccessToken();
return $this->send(
'GET', "vehicles/{$vehicleId}", $this->getApiHeaders(), $this->buildHttpQuery($query)
);
} | php | public function get(int $vehicleId, ?Query $query = null): Response
{
$this->requiresAccessToken();
return $this->send(
'GET', "vehicles/{$vehicleId}", $this->getApiHeaders(), $this->buildHttpQuery($query)
);
} | [
"public",
"function",
"get",
"(",
"int",
"$",
"vehicleId",
",",
"?",
"Query",
"$",
"query",
"=",
"null",
")",
":",
"Response",
"{",
"$",
"this",
"->",
"requiresAccessToken",
"(",
")",
";",
"return",
"$",
"this",
"->",
"send",
"(",
"'GET'",
",",
"\"ve... | Show single vehicle.
@param int $vehicleId
@param \Katsana\Sdk\Query|null $query
@return \Laravie\Codex\Contracts\Response | [
"Show",
"single",
"vehicle",
"."
] | 3266401639acd31c8f8cc0dea348085e3c59cb4d | https://github.com/katsana/katsana-sdk-php/blob/3266401639acd31c8f8cc0dea348085e3c59cb4d/src/One/Vehicles.php#L38-L45 | train |
katsana/katsana-sdk-php | src/One/Vehicles.php | Vehicles.update | public function update(int $vehicleId, array $payload): Response
{
$this->requiresAccessToken();
return $this->sendJson(
'PATCH', "vehicles/{$vehicleId}", $this->getApiHeaders(), $payload
);
} | php | public function update(int $vehicleId, array $payload): Response
{
$this->requiresAccessToken();
return $this->sendJson(
'PATCH', "vehicles/{$vehicleId}", $this->getApiHeaders(), $payload
);
} | [
"public",
"function",
"update",
"(",
"int",
"$",
"vehicleId",
",",
"array",
"$",
"payload",
")",
":",
"Response",
"{",
"$",
"this",
"->",
"requiresAccessToken",
"(",
")",
";",
"return",
"$",
"this",
"->",
"sendJson",
"(",
"'PATCH'",
",",
"\"vehicles/{$vehi... | Update vehicle information.
@param int $vehicleId
@param array $payload
@return \Laravie\Codex\Contracts\Response | [
"Update",
"vehicle",
"information",
"."
] | 3266401639acd31c8f8cc0dea348085e3c59cb4d | https://github.com/katsana/katsana-sdk-php/blob/3266401639acd31c8f8cc0dea348085e3c59cb4d/src/One/Vehicles.php#L72-L79 | train |
mikemirten/JsonApi | src/Mapper/Handler/DataTypeManager.php | DataTypeManager.registerDataTypeHandler | public function registerDataTypeHandler(DataTypeHandlerInterface $handler)
{
foreach ($handler->supports() as $name) {
$this->handlers[$name] = $handler;
}
} | php | public function registerDataTypeHandler(DataTypeHandlerInterface $handler)
{
foreach ($handler->supports() as $name) {
$this->handlers[$name] = $handler;
}
} | [
"public",
"function",
"registerDataTypeHandler",
"(",
"DataTypeHandlerInterface",
"$",
"handler",
")",
"{",
"foreach",
"(",
"$",
"handler",
"->",
"supports",
"(",
")",
"as",
"$",
"name",
")",
"{",
"$",
"this",
"->",
"handlers",
"[",
"$",
"name",
"]",
"=",
... | Register data-type handler
@param DataTypeHandlerInterface $handler | [
"Register",
"data",
"-",
"type",
"handler"
] | a3c1baf8f753c040f24e4522495b7d34565e6560 | https://github.com/mikemirten/JsonApi/blob/a3c1baf8f753c040f24e4522495b7d34565e6560/src/Mapper/Handler/DataTypeManager.php#L31-L36 | train |
mikemirten/JsonApi | src/Mapper/Handler/DataTypeManager.php | DataTypeManager.processHandlerToResource | protected function processHandlerToResource(Attribute $definition, $value)
{
$type = $definition->getType();
$handler = $this->handlers[$type];
$parameters = $definition->getTypeParameters();
if (! $definition->isMany()) {
return $handler->toResource($value, $type, $parameters);
}
if (! $value instanceof \Traversable && ! is_array($value)) {
throw new NotIterableAttribute($definition, $value);
}
$collection = [];
foreach ($value as $item) {
$collection[] = $handler->toResource($item, $type, $parameters);
}
return $collection;
} | php | protected function processHandlerToResource(Attribute $definition, $value)
{
$type = $definition->getType();
$handler = $this->handlers[$type];
$parameters = $definition->getTypeParameters();
if (! $definition->isMany()) {
return $handler->toResource($value, $type, $parameters);
}
if (! $value instanceof \Traversable && ! is_array($value)) {
throw new NotIterableAttribute($definition, $value);
}
$collection = [];
foreach ($value as $item) {
$collection[] = $handler->toResource($item, $type, $parameters);
}
return $collection;
} | [
"protected",
"function",
"processHandlerToResource",
"(",
"Attribute",
"$",
"definition",
",",
"$",
"value",
")",
"{",
"$",
"type",
"=",
"$",
"definition",
"->",
"getType",
"(",
")",
";",
"$",
"handler",
"=",
"$",
"this",
"->",
"handlers",
"[",
"$",
"typ... | Process value by registered data-type handler.
From object to resource.
@param Attribute $definition
@param mixed $value
@return mixed
@throws NotIterableAttribute | [
"Process",
"value",
"by",
"registered",
"data",
"-",
"type",
"handler",
".",
"From",
"object",
"to",
"resource",
"."
] | a3c1baf8f753c040f24e4522495b7d34565e6560 | https://github.com/mikemirten/JsonApi/blob/a3c1baf8f753c040f24e4522495b7d34565e6560/src/Mapper/Handler/DataTypeManager.php#L143-L164 | train |
mikemirten/JsonApi | src/Mapper/Handler/DataTypeManager.php | DataTypeManager.processHandlerFromResource | protected function processHandlerFromResource(Attribute $definition, $value)
{
$type = $definition->getType();
$handler = $this->handlers[$type];
$parameters = $definition->getTypeParameters();
if (! $definition->isMany()) {
return $handler->fromResource($value, $type, $parameters);
}
if (! $value instanceof \Traversable && ! is_array($value)) {
throw new NotIterableAttribute($definition, $value);
}
$collection = new \ArrayObject();
foreach ($value as $item) {
$collection[] = $handler->fromResource($item, $type, $parameters);
}
return $collection;
} | php | protected function processHandlerFromResource(Attribute $definition, $value)
{
$type = $definition->getType();
$handler = $this->handlers[$type];
$parameters = $definition->getTypeParameters();
if (! $definition->isMany()) {
return $handler->fromResource($value, $type, $parameters);
}
if (! $value instanceof \Traversable && ! is_array($value)) {
throw new NotIterableAttribute($definition, $value);
}
$collection = new \ArrayObject();
foreach ($value as $item) {
$collection[] = $handler->fromResource($item, $type, $parameters);
}
return $collection;
} | [
"protected",
"function",
"processHandlerFromResource",
"(",
"Attribute",
"$",
"definition",
",",
"$",
"value",
")",
"{",
"$",
"type",
"=",
"$",
"definition",
"->",
"getType",
"(",
")",
";",
"$",
"handler",
"=",
"$",
"this",
"->",
"handlers",
"[",
"$",
"t... | Process value by registered data-type handler.
From resource to object.
@param Attribute $definition
@param mixed $value
@return mixed
@throws NotIterableAttribute | [
"Process",
"value",
"by",
"registered",
"data",
"-",
"type",
"handler",
".",
"From",
"resource",
"to",
"object",
"."
] | a3c1baf8f753c040f24e4522495b7d34565e6560 | https://github.com/mikemirten/JsonApi/blob/a3c1baf8f753c040f24e4522495b7d34565e6560/src/Mapper/Handler/DataTypeManager.php#L175-L196 | train |
SplashSync/Php-Core | Models/Fields/FieldsManagerTrait.php | FieldsManagerTrait.filterFieldList | public static function filterFieldList($fieldsList, $filters = array())
{
$result = array();
foreach ($fieldsList as $field) {
if (in_array($field->id, $filters, true)) {
$result[] = $field;
}
}
return $result;
} | php | public static function filterFieldList($fieldsList, $filters = array())
{
$result = array();
foreach ($fieldsList as $field) {
if (in_array($field->id, $filters, true)) {
$result[] = $field;
}
}
return $result;
} | [
"public",
"static",
"function",
"filterFieldList",
"(",
"$",
"fieldsList",
",",
"$",
"filters",
"=",
"array",
"(",
")",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"fieldsList",
"as",
"$",
"field",
")",
"{",
"if",
"(",
... | Filter a Fields List to keap only given Fields Ids
@param array $fieldsList Object Field List
@param array $filters Array of Fields Ids
@return array | [
"Filter",
"a",
"Fields",
"List",
"to",
"keap",
"only",
"given",
"Fields",
"Ids"
] | f69724117b979e10eb38e72f7fe38611b5c3f830 | https://github.com/SplashSync/Php-Core/blob/f69724117b979e10eb38e72f7fe38611b5c3f830/Models/Fields/FieldsManagerTrait.php#L38-L49 | train |
SplashSync/Php-Core | Models/Fields/FieldsManagerTrait.php | FieldsManagerTrait.filterFieldListByTag | public static function filterFieldListByTag($fieldsList, $itemType, $itemProp)
{
$result = array();
$tag = md5($itemProp.IDSPLIT.$itemType);
foreach ($fieldsList as $field) {
if ($field->tag !== $tag) {
continue;
}
if (($field->itemtype !== $itemType) || ($field->itemprop !== $itemProp)) {
continue;
}
$result[] = $field;
}
return $result;
} | php | public static function filterFieldListByTag($fieldsList, $itemType, $itemProp)
{
$result = array();
$tag = md5($itemProp.IDSPLIT.$itemType);
foreach ($fieldsList as $field) {
if ($field->tag !== $tag) {
continue;
}
if (($field->itemtype !== $itemType) || ($field->itemprop !== $itemProp)) {
continue;
}
$result[] = $field;
}
return $result;
} | [
"public",
"static",
"function",
"filterFieldListByTag",
"(",
"$",
"fieldsList",
",",
"$",
"itemType",
",",
"$",
"itemProp",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"$",
"tag",
"=",
"md5",
"(",
"$",
"itemProp",
".",
"IDSPLIT",
".",
"$",
... | Filter a Fields List to keap only given Fields Tags
@param array $fieldsList Object Field List
@param string $itemType Field Microdata Type Url
@param string $itemProp Field Microdata Property Name
@return array | [
"Filter",
"a",
"Fields",
"List",
"to",
"keap",
"only",
"given",
"Fields",
"Tags"
] | f69724117b979e10eb38e72f7fe38611b5c3f830 | https://github.com/SplashSync/Php-Core/blob/f69724117b979e10eb38e72f7fe38611b5c3f830/Models/Fields/FieldsManagerTrait.php#L60-L76 | train |
SplashSync/Php-Core | Models/Fields/FieldsManagerTrait.php | FieldsManagerTrait.reduceFieldList | public static function reduceFieldList($fieldsList, $isRead = false, $isWrite = false)
{
$result = array();
foreach ($fieldsList as $field) {
//==============================================================================
// Filter Non-Readable Fields
if ($isRead && !$field->read) {
continue;
}
//==============================================================================
// Filter Non-Writable Fields
if ($isWrite && !$field->write) {
continue;
}
$result[] = $field->id;
}
return $result;
} | php | public static function reduceFieldList($fieldsList, $isRead = false, $isWrite = false)
{
$result = array();
foreach ($fieldsList as $field) {
//==============================================================================
// Filter Non-Readable Fields
if ($isRead && !$field->read) {
continue;
}
//==============================================================================
// Filter Non-Writable Fields
if ($isWrite && !$field->write) {
continue;
}
$result[] = $field->id;
}
return $result;
} | [
"public",
"static",
"function",
"reduceFieldList",
"(",
"$",
"fieldsList",
",",
"$",
"isRead",
"=",
"false",
",",
"$",
"isWrite",
"=",
"false",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"fieldsList",
"as",
"$",
"field",... | Redure a Fields List to an Array of Field Ids
@param array $fieldsList Object Field List
@param bool $isRead Filter non Readable Fields
@param bool $isWrite Filter non Writable Fields
@return string[] | [
"Redure",
"a",
"Fields",
"List",
"to",
"an",
"Array",
"of",
"Field",
"Ids"
] | f69724117b979e10eb38e72f7fe38611b5c3f830 | https://github.com/SplashSync/Php-Core/blob/f69724117b979e10eb38e72f7fe38611b5c3f830/Models/Fields/FieldsManagerTrait.php#L126-L145 | train |
SplashSync/Php-Core | Models/Fields/FieldsManagerTrait.php | FieldsManagerTrait.isListField | public static function isListField($fieldType)
{
//====================================================================//
// Safety Check
if (empty($fieldType)) {
return false;
}
//====================================================================//
// Detects Lists
$list = explode(LISTSPLIT, $fieldType);
if (is_array($list) && (2 == count($list))) {
//====================================================================//
// If List Detected, Prepare Field List Information Array
return array('fieldname' => $list[0], 'listname' => $list[1]);
}
return false;
} | php | public static function isListField($fieldType)
{
//====================================================================//
// Safety Check
if (empty($fieldType)) {
return false;
}
//====================================================================//
// Detects Lists
$list = explode(LISTSPLIT, $fieldType);
if (is_array($list) && (2 == count($list))) {
//====================================================================//
// If List Detected, Prepare Field List Information Array
return array('fieldname' => $list[0], 'listname' => $list[1]);
}
return false;
} | [
"public",
"static",
"function",
"isListField",
"(",
"$",
"fieldType",
")",
"{",
"//====================================================================//",
"// Safety Check",
"if",
"(",
"empty",
"(",
"$",
"fieldType",
")",
")",
"{",
"return",
"false",
";",
"}",
"//===... | Check if this id is a list identifier
@param string $fieldType Data Type Name String
@return array|false Exploded List field Array or False | [
"Check",
"if",
"this",
"id",
"is",
"a",
"list",
"identifier"
] | f69724117b979e10eb38e72f7fe38611b5c3f830 | https://github.com/SplashSync/Php-Core/blob/f69724117b979e10eb38e72f7fe38611b5c3f830/Models/Fields/FieldsManagerTrait.php#L158-L175 | train |
SplashSync/Php-Core | Models/Fields/FieldsManagerTrait.php | FieldsManagerTrait.fieldName | public static function fieldName($listFieldName)
{
//====================================================================//
// Decode
$result = self::isListField($listFieldName);
if (empty($result)) {
return false;
}
//====================================================================//
// Return Field Identifier
return $result['fieldname'];
} | php | public static function fieldName($listFieldName)
{
//====================================================================//
// Decode
$result = self::isListField($listFieldName);
if (empty($result)) {
return false;
}
//====================================================================//
// Return Field Identifier
return $result['fieldname'];
} | [
"public",
"static",
"function",
"fieldName",
"(",
"$",
"listFieldName",
")",
"{",
"//====================================================================//",
"// Decode",
"$",
"result",
"=",
"self",
"::",
"isListField",
"(",
"$",
"listFieldName",
")",
";",
"if",
"(",
... | Retrieve Field Identifier from an List Field String
@param string $listFieldName List Field Identifier String
@return false|string | [
"Retrieve",
"Field",
"Identifier",
"from",
"an",
"List",
"Field",
"String"
] | f69724117b979e10eb38e72f7fe38611b5c3f830 | https://github.com/SplashSync/Php-Core/blob/f69724117b979e10eb38e72f7fe38611b5c3f830/Models/Fields/FieldsManagerTrait.php#L184-L195 | train |
SplashSync/Php-Core | Models/Fields/FieldsManagerTrait.php | FieldsManagerTrait.listName | public static function listName($listFieldName)
{
//====================================================================//
// Decode
$result = self::isListField($listFieldName);
if (empty($result)) {
return false;
}
//====================================================================//
// Return List Name
return $result['listname'];
} | php | public static function listName($listFieldName)
{
//====================================================================//
// Decode
$result = self::isListField($listFieldName);
if (empty($result)) {
return false;
}
//====================================================================//
// Return List Name
return $result['listname'];
} | [
"public",
"static",
"function",
"listName",
"(",
"$",
"listFieldName",
")",
"{",
"//====================================================================//",
"// Decode",
"$",
"result",
"=",
"self",
"::",
"isListField",
"(",
"$",
"listFieldName",
")",
";",
"if",
"(",
"... | Retrieve List Name from an List Field String
@param string $listFieldName List Field Identifier String
@return false|string | [
"Retrieve",
"List",
"Name",
"from",
"an",
"List",
"Field",
"String"
] | f69724117b979e10eb38e72f7fe38611b5c3f830 | https://github.com/SplashSync/Php-Core/blob/f69724117b979e10eb38e72f7fe38611b5c3f830/Models/Fields/FieldsManagerTrait.php#L204-L215 | train |
SplashSync/Php-Core | Models/Fields/FieldsManagerTrait.php | FieldsManagerTrait.baseType | public static function baseType($fieldId)
{
//====================================================================//
// Detect List Id Fields
if (self::isListField($fieldId)) {
$fieldId = self::fieldName($fieldId);
}
//====================================================================//
// Detect Objects Id Fields
if (self::isIdField((string) $fieldId)) {
$fieldId = self::objectType((string) $fieldId);
}
return $fieldId;
} | php | public static function baseType($fieldId)
{
//====================================================================//
// Detect List Id Fields
if (self::isListField($fieldId)) {
$fieldId = self::fieldName($fieldId);
}
//====================================================================//
// Detect Objects Id Fields
if (self::isIdField((string) $fieldId)) {
$fieldId = self::objectType((string) $fieldId);
}
return $fieldId;
} | [
"public",
"static",
"function",
"baseType",
"(",
"$",
"fieldId",
")",
"{",
"//====================================================================//",
"// Detect List Id Fields",
"if",
"(",
"self",
"::",
"isListField",
"(",
"$",
"fieldId",
")",
")",
"{",
"$",
"fieldId",... | Retrieve Base Field Type from Field Type|Id String
@param string $fieldId List Field Identifier String
@return false|string | [
"Retrieve",
"Base",
"Field",
"Type",
"from",
"Field",
"Type|Id",
"String"
] | f69724117b979e10eb38e72f7fe38611b5c3f830 | https://github.com/SplashSync/Php-Core/blob/f69724117b979e10eb38e72f7fe38611b5c3f830/Models/Fields/FieldsManagerTrait.php#L224-L238 | train |
SplashSync/Php-Core | Models/Fields/FieldsManagerTrait.php | FieldsManagerTrait.isIdField | public static function isIdField($fieldId)
{
//====================================================================//
// Safety Check
if (empty($fieldId)) {
return false;
}
//====================================================================//
// Detects ObjectId
$list = explode(IDSPLIT, $fieldId);
if (is_array($list) && (2 == count($list))) {
//====================================================================//
// If List Detected, Prepare Field List Information Array
$result['ObjectId'] = $list[0];
$result['ObjectType'] = $list[1];
return $result;
}
return false;
} | php | public static function isIdField($fieldId)
{
//====================================================================//
// Safety Check
if (empty($fieldId)) {
return false;
}
//====================================================================//
// Detects ObjectId
$list = explode(IDSPLIT, $fieldId);
if (is_array($list) && (2 == count($list))) {
//====================================================================//
// If List Detected, Prepare Field List Information Array
$result['ObjectId'] = $list[0];
$result['ObjectType'] = $list[1];
return $result;
}
return false;
} | [
"public",
"static",
"function",
"isIdField",
"(",
"$",
"fieldId",
")",
"{",
"//====================================================================//",
"// Safety Check",
"if",
"(",
"empty",
"(",
"$",
"fieldId",
")",
")",
"{",
"return",
"false",
";",
"}",
"//=========... | Identify if field is Object Identifier Data & Decode Field
@param string $fieldId ObjectId Field String
@return array|false | [
"Identify",
"if",
"field",
"is",
"Object",
"Identifier",
"Data",
"&",
"Decode",
"Field"
] | f69724117b979e10eb38e72f7fe38611b5c3f830 | https://github.com/SplashSync/Php-Core/blob/f69724117b979e10eb38e72f7fe38611b5c3f830/Models/Fields/FieldsManagerTrait.php#L251-L271 | train |
SplashSync/Php-Core | Models/Fields/FieldsManagerTrait.php | FieldsManagerTrait.objectId | public static function objectId($fieldId)
{
//====================================================================//
// decode
$result = self::isIdField($fieldId);
if (empty($result)) {
return false;
}
//====================================================================//
// Return List Name
return $result['ObjectId'];
} | php | public static function objectId($fieldId)
{
//====================================================================//
// decode
$result = self::isIdField($fieldId);
if (empty($result)) {
return false;
}
//====================================================================//
// Return List Name
return $result['ObjectId'];
} | [
"public",
"static",
"function",
"objectId",
"(",
"$",
"fieldId",
")",
"{",
"//====================================================================//",
"// decode",
"$",
"result",
"=",
"self",
"::",
"isIdField",
"(",
"$",
"fieldId",
")",
";",
"if",
"(",
"empty",
"(",... | Retrieve Object Id Name from an Object Identifier String
@param string $fieldId Object Identifier String
@return false|string | [
"Retrieve",
"Object",
"Id",
"Name",
"from",
"an",
"Object",
"Identifier",
"String"
] | f69724117b979e10eb38e72f7fe38611b5c3f830 | https://github.com/SplashSync/Php-Core/blob/f69724117b979e10eb38e72f7fe38611b5c3f830/Models/Fields/FieldsManagerTrait.php#L280-L291 | train |
SplashSync/Php-Core | Models/Fields/FieldsManagerTrait.php | FieldsManagerTrait.objectType | public static function objectType($fieldId)
{
//====================================================================//
// decode
$result = self::isIdField($fieldId);
if (empty($result)) {
return false;
}
//====================================================================//
// Return Field Identifier
return $result['ObjectType'];
} | php | public static function objectType($fieldId)
{
//====================================================================//
// decode
$result = self::isIdField($fieldId);
if (empty($result)) {
return false;
}
//====================================================================//
// Return Field Identifier
return $result['ObjectType'];
} | [
"public",
"static",
"function",
"objectType",
"(",
"$",
"fieldId",
")",
"{",
"//====================================================================//",
"// decode",
"$",
"result",
"=",
"self",
"::",
"isIdField",
"(",
"$",
"fieldId",
")",
";",
"if",
"(",
"empty",
"(... | Retrieve Object Type Name from an Object Identifier String
@param string $fieldId Object Identifier String
@return false|string | [
"Retrieve",
"Object",
"Type",
"Name",
"from",
"an",
"Object",
"Identifier",
"String"
] | f69724117b979e10eb38e72f7fe38611b5c3f830 | https://github.com/SplashSync/Php-Core/blob/f69724117b979e10eb38e72f7fe38611b5c3f830/Models/Fields/FieldsManagerTrait.php#L300-L311 | train |
SplashSync/Php-Core | Models/Fields/FieldsManagerTrait.php | FieldsManagerTrait.extractRawData | public static function extractRawData($objectData, $filter)
{
$filteredData = self::filterData($objectData, array($filter));
//====================================================================//
// Explode List Field Id
$isList = self::isListField($filter);
//====================================================================//
// Simple Single Field
if (!$isList) {
if (isset($filteredData[$filter])) {
return $filteredData[$filter];
}
//====================================================================//
// List Field
} else {
//====================================================================//
// Check List Exists
if (!isset($filteredData[self::listName($filter)])) {
return null;
}
//====================================================================//
// Parse Raw List Data
$result = array();
foreach ($filteredData[self::listName($filter)] as $key => $item) {
$result[$key] = $item[self::fieldName($filter)];
}
return $result;
}
//====================================================================//
// Field Not Received or is Empty
return null;
} | php | public static function extractRawData($objectData, $filter)
{
$filteredData = self::filterData($objectData, array($filter));
//====================================================================//
// Explode List Field Id
$isList = self::isListField($filter);
//====================================================================//
// Simple Single Field
if (!$isList) {
if (isset($filteredData[$filter])) {
return $filteredData[$filter];
}
//====================================================================//
// List Field
} else {
//====================================================================//
// Check List Exists
if (!isset($filteredData[self::listName($filter)])) {
return null;
}
//====================================================================//
// Parse Raw List Data
$result = array();
foreach ($filteredData[self::listName($filter)] as $key => $item) {
$result[$key] = $item[self::fieldName($filter)];
}
return $result;
}
//====================================================================//
// Field Not Received or is Empty
return null;
} | [
"public",
"static",
"function",
"extractRawData",
"(",
"$",
"objectData",
",",
"$",
"filter",
")",
"{",
"$",
"filteredData",
"=",
"self",
"::",
"filterData",
"(",
"$",
"objectData",
",",
"array",
"(",
"$",
"filter",
")",
")",
";",
"//========================... | Extract Raw Field Data from an Object Data Block
@param array $objectData Object Data Block
@param string $filter Single Fields Id
@return null|array | [
"Extract",
"Raw",
"Field",
"Data",
"from",
"an",
"Object",
"Data",
"Block"
] | f69724117b979e10eb38e72f7fe38611b5c3f830 | https://github.com/SplashSync/Php-Core/blob/f69724117b979e10eb38e72f7fe38611b5c3f830/Models/Fields/FieldsManagerTrait.php#L325-L362 | train |
SplashSync/Php-Core | Models/Fields/FieldsManagerTrait.php | FieldsManagerTrait.filterData | public static function filterData($objectData, $filters = array())
{
$result = array();
$listFilters = array();
//====================================================================//
// Process All Single Fields Ids & Store Sorted List Fields Ids
foreach ($filters as $fieldId) {
//====================================================================//
// Explode List Field Id
$isList = self::isListField($fieldId);
//====================================================================//
// Single Field Data Type
if ((!$isList) && (array_key_exists($fieldId, $objectData))) {
$result[$fieldId] = $objectData[$fieldId];
} elseif (!$isList) {
continue;
}
//====================================================================//
// List Field Data Type
$listName = $isList['listname'];
$fieldName = $isList['fieldname'];
//====================================================================//
// Check List Data are Present in Block
if (!array_key_exists($listName, $objectData)) {
continue;
}
//====================================================================//
// Create List
if (!array_key_exists($listName, $listFilters)) {
$listFilters[$listName] = array();
}
$listFilters[$listName][] = $fieldName;
}
//====================================================================//
// Process All List Fields Ids Filters
foreach ($listFilters as $listName => $listFilters) {
$result[$listName] = self::filterListData($objectData[$listName], $listFilters);
}
return $result;
} | php | public static function filterData($objectData, $filters = array())
{
$result = array();
$listFilters = array();
//====================================================================//
// Process All Single Fields Ids & Store Sorted List Fields Ids
foreach ($filters as $fieldId) {
//====================================================================//
// Explode List Field Id
$isList = self::isListField($fieldId);
//====================================================================//
// Single Field Data Type
if ((!$isList) && (array_key_exists($fieldId, $objectData))) {
$result[$fieldId] = $objectData[$fieldId];
} elseif (!$isList) {
continue;
}
//====================================================================//
// List Field Data Type
$listName = $isList['listname'];
$fieldName = $isList['fieldname'];
//====================================================================//
// Check List Data are Present in Block
if (!array_key_exists($listName, $objectData)) {
continue;
}
//====================================================================//
// Create List
if (!array_key_exists($listName, $listFilters)) {
$listFilters[$listName] = array();
}
$listFilters[$listName][] = $fieldName;
}
//====================================================================//
// Process All List Fields Ids Filters
foreach ($listFilters as $listName => $listFilters) {
$result[$listName] = self::filterListData($objectData[$listName], $listFilters);
}
return $result;
} | [
"public",
"static",
"function",
"filterData",
"(",
"$",
"objectData",
",",
"$",
"filters",
"=",
"array",
"(",
")",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"$",
"listFilters",
"=",
"array",
"(",
")",
";",
"//===================================... | Filter a Object Data Block to keap only given Fields
@param array $objectData Object Data Block
@param array $filters Array of Fields Ids
@return null|array | [
"Filter",
"a",
"Object",
"Data",
"Block",
"to",
"keap",
"only",
"given",
"Fields"
] | f69724117b979e10eb38e72f7fe38611b5c3f830 | https://github.com/SplashSync/Php-Core/blob/f69724117b979e10eb38e72f7fe38611b5c3f830/Models/Fields/FieldsManagerTrait.php#L372-L414 | train |
SplashSync/Php-Core | Models/Fields/FieldsManagerTrait.php | FieldsManagerTrait.filterListData | public static function filterListData($objectData, $filters = array())
{
$result = array();
foreach ($objectData as $fieldData) {
$filteredItems = array();
//====================================================================//
// Ensure Item is An Array of Fields
if (!is_array($fieldData) && !($fieldData instanceof ArrayObject)) {
continue;
}
//====================================================================//
// Convert ArrayObjects to Array
if ($fieldData instanceof ArrayObject) {
$fieldData = $fieldData->getArrayCopy();
}
//====================================================================//
// Search for Field in Item Block
foreach ($filters as $fieldId) {
if (array_key_exists($fieldId, $fieldData)) {
$filteredItems[$fieldId] = $fieldData[$fieldId];
}
}
$result[] = $filteredItems;
}
return $result;
} | php | public static function filterListData($objectData, $filters = array())
{
$result = array();
foreach ($objectData as $fieldData) {
$filteredItems = array();
//====================================================================//
// Ensure Item is An Array of Fields
if (!is_array($fieldData) && !($fieldData instanceof ArrayObject)) {
continue;
}
//====================================================================//
// Convert ArrayObjects to Array
if ($fieldData instanceof ArrayObject) {
$fieldData = $fieldData->getArrayCopy();
}
//====================================================================//
// Search for Field in Item Block
foreach ($filters as $fieldId) {
if (array_key_exists($fieldId, $fieldData)) {
$filteredItems[$fieldId] = $fieldData[$fieldId];
}
}
$result[] = $filteredItems;
}
return $result;
} | [
"public",
"static",
"function",
"filterListData",
"(",
"$",
"objectData",
",",
"$",
"filters",
"=",
"array",
"(",
")",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"objectData",
"as",
"$",
"fieldData",
")",
"{",
"$",
"fi... | Filter a Object List Data Block to keap only given Fields
@param array $objectData Object Data Block
@param array $filters Array of Fields Ids
@return array | [
"Filter",
"a",
"Object",
"List",
"Data",
"Block",
"to",
"keap",
"only",
"given",
"Fields"
] | f69724117b979e10eb38e72f7fe38611b5c3f830 | https://github.com/SplashSync/Php-Core/blob/f69724117b979e10eb38e72f7fe38611b5c3f830/Models/Fields/FieldsManagerTrait.php#L424-L450 | train |
payneteasy/php-library-payneteasy-api | source/PaynetEasy/PaynetEasyApi/Transport/Response.php | Response.setNeededAction | public function setNeededAction($neededAction)
{
if (!in_array($neededAction, static::$allowedNeededActions))
{
throw new RuntimeException("Unknown needed action: '{$neededAction}'");
}
$this->neededAction = $neededAction;
return $this;
} | php | public function setNeededAction($neededAction)
{
if (!in_array($neededAction, static::$allowedNeededActions))
{
throw new RuntimeException("Unknown needed action: '{$neededAction}'");
}
$this->neededAction = $neededAction;
return $this;
} | [
"public",
"function",
"setNeededAction",
"(",
"$",
"neededAction",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"neededAction",
",",
"static",
"::",
"$",
"allowedNeededActions",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Unknown needed action:... | Set action needed after API method request ended
@param string $neededAction Action needed after API method request ended
@return self | [
"Set",
"action",
"needed",
"after",
"API",
"method",
"request",
"ended"
] | e3484aa37b6594231f59b1f43523603aa704f093 | https://github.com/payneteasy/php-library-payneteasy-api/blob/e3484aa37b6594231f59b1f43523603aa704f093/source/PaynetEasy/PaynetEasyApi/Transport/Response.php#L56-L66 | train |
payneteasy/php-library-payneteasy-api | source/PaynetEasy/PaynetEasyApi/Transport/Response.php | Response.getError | public function getError()
{
if($this->isError() || $this->isDeclined())
{
return new PaynetException($this->getErrorMessage(), $this->getErrorCode());
}
else
{
throw new RuntimeException('Response has no error');
}
} | php | public function getError()
{
if($this->isError() || $this->isDeclined())
{
return new PaynetException($this->getErrorMessage(), $this->getErrorCode());
}
else
{
throw new RuntimeException('Response has no error');
}
} | [
"public",
"function",
"getError",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isError",
"(",
")",
"||",
"$",
"this",
"->",
"isDeclined",
"(",
")",
")",
"{",
"return",
"new",
"PaynetException",
"(",
"$",
"this",
"->",
"getErrorMessage",
"(",
")",
",... | Get response error as Exception instance
@return \PaynetEasy\PaynetEasyApi\Exception\PaynetException Response error
@throws \RuntimeException Response has no error | [
"Get",
"response",
"error",
"as",
"Exception",
"instance"
] | e3484aa37b6594231f59b1f43523603aa704f093 | https://github.com/payneteasy/php-library-payneteasy-api/blob/e3484aa37b6594231f59b1f43523603aa704f093/source/PaynetEasy/PaynetEasyApi/Transport/Response.php#L282-L292 | train |
payneteasy/php-library-payneteasy-api | source/PaynetEasy/PaynetEasyApi/Transport/Response.php | Response.getAnyKey | protected function getAnyKey(array $keys)
{
foreach($keys as $key)
{
$value = $this->getValue($key);
if(!is_null($value))
{
return $value;
}
}
} | php | protected function getAnyKey(array $keys)
{
foreach($keys as $key)
{
$value = $this->getValue($key);
if(!is_null($value))
{
return $value;
}
}
} | [
"protected",
"function",
"getAnyKey",
"(",
"array",
"$",
"keys",
")",
"{",
"foreach",
"(",
"$",
"keys",
"as",
"$",
"key",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"getValue",
"(",
"$",
"key",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
... | Get value of first key that exists in Response
@param array $keys Given keys
@return string|integer|null Value of first found key or null if all keys does not exists | [
"Get",
"value",
"of",
"first",
"key",
"that",
"exists",
"in",
"Response"
] | e3484aa37b6594231f59b1f43523603aa704f093 | https://github.com/payneteasy/php-library-payneteasy-api/blob/e3484aa37b6594231f59b1f43523603aa704f093/source/PaynetEasy/PaynetEasyApi/Transport/Response.php#L301-L312 | train |
ClementIV/yii-rest-admin | auth/Jwt.php | Jwt.loadToken | public function loadToken($token, $validate = true, $verify = true)
{
$token = $this->getParser()->parse((string) $token);
if ($validate && !$this->validateToken($token)) {
return null;
}
if ($verify && !$this->verifyToken($token)) {
return null;
}
return $token;
} | php | public function loadToken($token, $validate = true, $verify = true)
{
$token = $this->getParser()->parse((string) $token);
if ($validate && !$this->validateToken($token)) {
return null;
}
if ($verify && !$this->verifyToken($token)) {
return null;
}
return $token;
} | [
"public",
"function",
"loadToken",
"(",
"$",
"token",
",",
"$",
"validate",
"=",
"true",
",",
"$",
"verify",
"=",
"true",
")",
"{",
"$",
"token",
"=",
"$",
"this",
"->",
"getParser",
"(",
")",
"->",
"parse",
"(",
"(",
"string",
")",
"$",
"token",
... | Parses the JWT and returns a token class
@param string $token JWT
@return Token|null | [
"Parses",
"the",
"JWT",
"and",
"returns",
"a",
"token",
"class"
] | 237409832883ba4429b633c3d68f8e81ca04e893 | https://github.com/ClementIV/yii-rest-admin/blob/237409832883ba4429b633c3d68f8e81ca04e893/auth/Jwt.php#L71-L83 | train |
wangxian/ephp | src/Misc/Xml.php | Xml._toArray | private static function _toArray($data, $recursion = false)
{
$tmp = array();
$data = (array) $data;
foreach ($data as $k => $v) {
$v = (array) $v;
if (isset($v[0]) && is_string($v[0])) {
$tmp[$k] = $v[0];
} else {
$tmp[$k] = self::_toArray($v, true);
}
}
return $tmp;
} | php | private static function _toArray($data, $recursion = false)
{
$tmp = array();
$data = (array) $data;
foreach ($data as $k => $v) {
$v = (array) $v;
if (isset($v[0]) && is_string($v[0])) {
$tmp[$k] = $v[0];
} else {
$tmp[$k] = self::_toArray($v, true);
}
}
return $tmp;
} | [
"private",
"static",
"function",
"_toArray",
"(",
"$",
"data",
",",
"$",
"recursion",
"=",
"false",
")",
"{",
"$",
"tmp",
"=",
"array",
"(",
")",
";",
"$",
"data",
"=",
"(",
"array",
")",
"$",
"data",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
... | SimpleXMLElement to array
@ignore | [
"SimpleXMLElement",
"to",
"array"
] | 697248ab098d8dc352de31ab0c64ea0fee1d7132 | https://github.com/wangxian/ephp/blob/697248ab098d8dc352de31ab0c64ea0fee1d7132/src/Misc/Xml.php#L76-L89 | train |
maximebf/ConsoleKit | src/ConsoleKit/Utils.php | Utils.find | public static function find($filename, $dirs = array())
{
if (empty($dirs)) {
if ($filename = realpath($filename)) {
return $filename;
}
} else {
foreach ((array) $dirs as $dir) {
$pathname = self::join($dir, $filename);
if ($pathname = realpath($pathname)) {
return $pathname;
}
}
}
return false;
} | php | public static function find($filename, $dirs = array())
{
if (empty($dirs)) {
if ($filename = realpath($filename)) {
return $filename;
}
} else {
foreach ((array) $dirs as $dir) {
$pathname = self::join($dir, $filename);
if ($pathname = realpath($pathname)) {
return $pathname;
}
}
}
return false;
} | [
"public",
"static",
"function",
"find",
"(",
"$",
"filename",
",",
"$",
"dirs",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"dirs",
")",
")",
"{",
"if",
"(",
"$",
"filename",
"=",
"realpath",
"(",
"$",
"filename",
")",
")",
... | Finds the first file that match the filename in any of
the specified directories.
@param string $filename
@param array $dirs
@return string | [
"Finds",
"the",
"first",
"file",
"that",
"match",
"the",
"filename",
"in",
"any",
"of",
"the",
"specified",
"directories",
"."
] | a05c0c5a4c48882599d59323314ac963a836d58f | https://github.com/maximebf/ConsoleKit/blob/a05c0c5a4c48882599d59323314ac963a836d58f/src/ConsoleKit/Utils.php#L41-L56 | train |
maximebf/ConsoleKit | src/ConsoleKit/Utils.php | Utils.filterFiles | public static function filterFiles($args, $allowWildcards = true)
{
$files = array();
foreach ($args as $arg) {
if (file_exists($arg)) {
$files[] = $arg;
} else if ($allowWildcards && strpos($arg, '*') !== false) {
$files = array_merge($files, glob($arg));
}
}
return $files;
} | php | public static function filterFiles($args, $allowWildcards = true)
{
$files = array();
foreach ($args as $arg) {
if (file_exists($arg)) {
$files[] = $arg;
} else if ($allowWildcards && strpos($arg, '*') !== false) {
$files = array_merge($files, glob($arg));
}
}
return $files;
} | [
"public",
"static",
"function",
"filterFiles",
"(",
"$",
"args",
",",
"$",
"allowWildcards",
"=",
"true",
")",
"{",
"$",
"files",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"args",
"as",
"$",
"arg",
")",
"{",
"if",
"(",
"file_exists",
"(",
"... | Extracts files from an array of args
@param array $args
@param bool $allowWildcards Whether wildcards are allowed
@return array | [
"Extracts",
"files",
"from",
"an",
"array",
"of",
"args"
] | a05c0c5a4c48882599d59323314ac963a836d58f | https://github.com/maximebf/ConsoleKit/blob/a05c0c5a4c48882599d59323314ac963a836d58f/src/ConsoleKit/Utils.php#L65-L76 | train |
maximebf/ConsoleKit | src/ConsoleKit/Utils.php | Utils.join | public static function join($path1, $path2) {
$ds = DIRECTORY_SEPARATOR;
return str_replace("$ds$ds", $ds, implode($ds, array_filter(func_get_args())));
} | php | public static function join($path1, $path2) {
$ds = DIRECTORY_SEPARATOR;
return str_replace("$ds$ds", $ds, implode($ds, array_filter(func_get_args())));
} | [
"public",
"static",
"function",
"join",
"(",
"$",
"path1",
",",
"$",
"path2",
")",
"{",
"$",
"ds",
"=",
"DIRECTORY_SEPARATOR",
";",
"return",
"str_replace",
"(",
"\"$ds$ds\"",
",",
"$",
"ds",
",",
"implode",
"(",
"$",
"ds",
",",
"array_filter",
"(",
"f... | Joins paths together
@param string $path1
@param string $path2
@param string ...
@return string | [
"Joins",
"paths",
"together"
] | a05c0c5a4c48882599d59323314ac963a836d58f | https://github.com/maximebf/ConsoleKit/blob/a05c0c5a4c48882599d59323314ac963a836d58f/src/ConsoleKit/Utils.php#L86-L89 | train |
maximebf/ConsoleKit | src/ConsoleKit/Utils.php | Utils.touch | public static function touch($filename, $content = '')
{
self::mkdir(dirname($filename));
file_put_contents($filename, $content);
} | php | public static function touch($filename, $content = '')
{
self::mkdir(dirname($filename));
file_put_contents($filename, $content);
} | [
"public",
"static",
"function",
"touch",
"(",
"$",
"filename",
",",
"$",
"content",
"=",
"''",
")",
"{",
"self",
"::",
"mkdir",
"(",
"dirname",
"(",
"$",
"filename",
")",
")",
";",
"file_put_contents",
"(",
"$",
"filename",
",",
"$",
"content",
")",
... | Creates a file and its directory
@param string $filename
@param string $content | [
"Creates",
"a",
"file",
"and",
"its",
"directory"
] | a05c0c5a4c48882599d59323314ac963a836d58f | https://github.com/maximebf/ConsoleKit/blob/a05c0c5a4c48882599d59323314ac963a836d58f/src/ConsoleKit/Utils.php#L110-L114 | train |
maximebf/ConsoleKit | src/ConsoleKit/Utils.php | Utils.computeFuncParams | public static function computeFuncParams(ReflectionFunctionAbstract $reflection, array $args, array $options, $needTagInDocComment = true)
{
if ($needTagInDocComment && !preg_match('/@compute-params/', $reflection->getDocComment())) {
return array($args, $options);
}
$nbRequiredParams = $reflection->getNumberOfRequiredParameters();
if (count($args) < $nbRequiredParams) {
throw new ConsoleException("Not enough parameters in '" . $reflection->getName() . "'");
}
$params = $args;
if (count($args) > $nbRequiredParams) {
$params = array_slice($args, 0, $nbRequiredParams);
$args = array_slice($args, $nbRequiredParams);
}
foreach ($reflection->getParameters() as $param) {
if ($param->isOptional() && substr($param->getName(), 0, 1) !== '_') {
if (array_key_exists($param->getName(), $options)) {
$params[] = $options[$param->getName()];
unset($options[$param->getName()]);
} else {
$params[] = $param->getDefaultValue();
}
}
}
$params[] = $args;
$params[] = $options;
return $params;
} | php | public static function computeFuncParams(ReflectionFunctionAbstract $reflection, array $args, array $options, $needTagInDocComment = true)
{
if ($needTagInDocComment && !preg_match('/@compute-params/', $reflection->getDocComment())) {
return array($args, $options);
}
$nbRequiredParams = $reflection->getNumberOfRequiredParameters();
if (count($args) < $nbRequiredParams) {
throw new ConsoleException("Not enough parameters in '" . $reflection->getName() . "'");
}
$params = $args;
if (count($args) > $nbRequiredParams) {
$params = array_slice($args, 0, $nbRequiredParams);
$args = array_slice($args, $nbRequiredParams);
}
foreach ($reflection->getParameters() as $param) {
if ($param->isOptional() && substr($param->getName(), 0, 1) !== '_') {
if (array_key_exists($param->getName(), $options)) {
$params[] = $options[$param->getName()];
unset($options[$param->getName()]);
} else {
$params[] = $param->getDefaultValue();
}
}
}
$params[] = $args;
$params[] = $options;
return $params;
} | [
"public",
"static",
"function",
"computeFuncParams",
"(",
"ReflectionFunctionAbstract",
"$",
"reflection",
",",
"array",
"$",
"args",
",",
"array",
"$",
"options",
",",
"$",
"needTagInDocComment",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"needTagInDocComment",
"&&... | Creates an array of parameters according to the function definition
@param ReflectionFunctionAbstract $reflection
@param array $args
@param array $options
@param bool $needTagInDocComment Whether the compute-params tag must be present in the doc comment
@return array | [
"Creates",
"an",
"array",
"of",
"parameters",
"according",
"to",
"the",
"function",
"definition"
] | a05c0c5a4c48882599d59323314ac963a836d58f | https://github.com/maximebf/ConsoleKit/blob/a05c0c5a4c48882599d59323314ac963a836d58f/src/ConsoleKit/Utils.php#L157-L188 | train |
PHP-DI/ZF2-Bridge | src/DI/ZendFramework2/Service/ControllerManager.php | ControllerManager.initialize | private function initialize(AbstractController $controller)
{
foreach ($this->initializers as $initializer) {
if ($initializer instanceof InitializerInterface) {
$initializer->initialize($controller, $this);
} else {
call_user_func($initializer, $controller, $this);
}
}
} | php | private function initialize(AbstractController $controller)
{
foreach ($this->initializers as $initializer) {
if ($initializer instanceof InitializerInterface) {
$initializer->initialize($controller, $this);
} else {
call_user_func($initializer, $controller, $this);
}
}
} | [
"private",
"function",
"initialize",
"(",
"AbstractController",
"$",
"controller",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"initializers",
"as",
"$",
"initializer",
")",
"{",
"if",
"(",
"$",
"initializer",
"instanceof",
"InitializerInterface",
")",
"{",
"... | injects Zend core services into the given controller
@param AbstractController $controller | [
"injects",
"Zend",
"core",
"services",
"into",
"the",
"given",
"controller"
] | 369dc7122251a262e133f05ccfcace20ccd5d00f | https://github.com/PHP-DI/ZF2-Bridge/blob/369dc7122251a262e133f05ccfcace20ccd5d00f/src/DI/ZendFramework2/Service/ControllerManager.php#L107-L116 | train |
sunrise-php/stream | src/Stream.php | Stream.tell | public function tell() : int
{
if (! \is_resource($this->resource))
{
throw new Exception\UntellableStreamException('Stream is not resourceable');
}
$result = \ftell($this->resource);
if (false === $result)
{
throw new Exception\UntellableStreamException('Unable to get the stream pointer position');
}
return $result;
} | php | public function tell() : int
{
if (! \is_resource($this->resource))
{
throw new Exception\UntellableStreamException('Stream is not resourceable');
}
$result = \ftell($this->resource);
if (false === $result)
{
throw new Exception\UntellableStreamException('Unable to get the stream pointer position');
}
return $result;
} | [
"public",
"function",
"tell",
"(",
")",
":",
"int",
"{",
"if",
"(",
"!",
"\\",
"is_resource",
"(",
"$",
"this",
"->",
"resource",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"UntellableStreamException",
"(",
"'Stream is not resourceable'",
")",
";",
... | Gets the stream pointer position
@return int
@throws Exception\UntellableStreamException
@link http://php.net/manual/en/function.ftell.php | [
"Gets",
"the",
"stream",
"pointer",
"position"
] | 43fb91e36375b792a8c11853c23aa6efbb71fdbe | https://github.com/sunrise-php/stream/blob/43fb91e36375b792a8c11853c23aa6efbb71fdbe/src/Stream.php#L112-L127 | train |
sunrise-php/stream | src/Stream.php | Stream.isSeekable | public function isSeekable() : bool
{
if (! \is_resource($this->resource))
{
return false;
}
$metadata = \stream_get_meta_data($this->resource);
return $metadata['seekable'];
} | php | public function isSeekable() : bool
{
if (! \is_resource($this->resource))
{
return false;
}
$metadata = \stream_get_meta_data($this->resource);
return $metadata['seekable'];
} | [
"public",
"function",
"isSeekable",
"(",
")",
":",
"bool",
"{",
"if",
"(",
"!",
"\\",
"is_resource",
"(",
"$",
"this",
"->",
"resource",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"metadata",
"=",
"\\",
"stream_get_meta_data",
"(",
"$",
"this",
... | Checks if the stream is seekable
@return bool | [
"Checks",
"if",
"the",
"stream",
"is",
"seekable"
] | 43fb91e36375b792a8c11853c23aa6efbb71fdbe | https://github.com/sunrise-php/stream/blob/43fb91e36375b792a8c11853c23aa6efbb71fdbe/src/Stream.php#L134-L144 | train |
sunrise-php/stream | src/Stream.php | Stream.rewind | public function rewind() : void
{
if (! \is_resource($this->resource))
{
throw new Exception\UnseekableStreamException('Stream is not resourceable');
}
if (! $this->isSeekable())
{
throw new Exception\UnseekableStreamException('Stream is not seekable');
}
$result = \fseek($this->resource, 0, \SEEK_SET);
if (! (0 === $result))
{
throw new Exception\UnseekableStreamException('Unable to move the stream pointer to beginning');
}
} | php | public function rewind() : void
{
if (! \is_resource($this->resource))
{
throw new Exception\UnseekableStreamException('Stream is not resourceable');
}
if (! $this->isSeekable())
{
throw new Exception\UnseekableStreamException('Stream is not seekable');
}
$result = \fseek($this->resource, 0, \SEEK_SET);
if (! (0 === $result))
{
throw new Exception\UnseekableStreamException('Unable to move the stream pointer to beginning');
}
} | [
"public",
"function",
"rewind",
"(",
")",
":",
"void",
"{",
"if",
"(",
"!",
"\\",
"is_resource",
"(",
"$",
"this",
"->",
"resource",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"UnseekableStreamException",
"(",
"'Stream is not resourceable'",
")",
";",... | Moves the stream pointer to begining
@return void
@throws Exception\UnseekableStreamException
@link http://php.net/manual/en/function.rewind.php | [
"Moves",
"the",
"stream",
"pointer",
"to",
"begining"
] | 43fb91e36375b792a8c11853c23aa6efbb71fdbe | https://github.com/sunrise-php/stream/blob/43fb91e36375b792a8c11853c23aa6efbb71fdbe/src/Stream.php#L155-L173 | train |
sunrise-php/stream | src/Stream.php | Stream.seek | public function seek($offset, $whence = \SEEK_SET) : void
{
if (! \is_resource($this->resource))
{
throw new Exception\UnseekableStreamException('Stream is not resourceable');
}
if (! $this->isSeekable())
{
throw new Exception\UnseekableStreamException('Stream is not seekable');
}
$result = \fseek($this->resource, $offset, $whence);
if (! (0 === $result))
{
throw new Exception\UnseekableStreamException('Unable to move the stream pointer to the given position');
}
} | php | public function seek($offset, $whence = \SEEK_SET) : void
{
if (! \is_resource($this->resource))
{
throw new Exception\UnseekableStreamException('Stream is not resourceable');
}
if (! $this->isSeekable())
{
throw new Exception\UnseekableStreamException('Stream is not seekable');
}
$result = \fseek($this->resource, $offset, $whence);
if (! (0 === $result))
{
throw new Exception\UnseekableStreamException('Unable to move the stream pointer to the given position');
}
} | [
"public",
"function",
"seek",
"(",
"$",
"offset",
",",
"$",
"whence",
"=",
"\\",
"SEEK_SET",
")",
":",
"void",
"{",
"if",
"(",
"!",
"\\",
"is_resource",
"(",
"$",
"this",
"->",
"resource",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"Unseekable... | Moves the stream pointer to the given position
@param int $offset
@param int $whence
@return void
@throws Exception\UnseekableStreamException
@link http://php.net/manual/en/function.fseek.php | [
"Moves",
"the",
"stream",
"pointer",
"to",
"the",
"given",
"position"
] | 43fb91e36375b792a8c11853c23aa6efbb71fdbe | https://github.com/sunrise-php/stream/blob/43fb91e36375b792a8c11853c23aa6efbb71fdbe/src/Stream.php#L187-L205 | train |
sunrise-php/stream | src/Stream.php | Stream.isWritable | public function isWritable() : bool
{
if (! \is_resource($this->resource))
{
return false;
}
$metadata = \stream_get_meta_data($this->resource);
return ! (false === \strpbrk($metadata['mode'], '+acwx'));
} | php | public function isWritable() : bool
{
if (! \is_resource($this->resource))
{
return false;
}
$metadata = \stream_get_meta_data($this->resource);
return ! (false === \strpbrk($metadata['mode'], '+acwx'));
} | [
"public",
"function",
"isWritable",
"(",
")",
":",
"bool",
"{",
"if",
"(",
"!",
"\\",
"is_resource",
"(",
"$",
"this",
"->",
"resource",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"metadata",
"=",
"\\",
"stream_get_meta_data",
"(",
"$",
"this",
... | Checks if the stream is writable
@return bool | [
"Checks",
"if",
"the",
"stream",
"is",
"writable"
] | 43fb91e36375b792a8c11853c23aa6efbb71fdbe | https://github.com/sunrise-php/stream/blob/43fb91e36375b792a8c11853c23aa6efbb71fdbe/src/Stream.php#L212-L222 | train |
sunrise-php/stream | src/Stream.php | Stream.write | public function write($string) : int
{
if (! \is_resource($this->resource))
{
throw new Exception\UnwritableStreamException('Stream is not resourceable');
}
if (! $this->isWritable())
{
throw new Exception\UnwritableStreamException('Stream is not writable');
}
$result = \fwrite($this->resource, $string);
if (false === $result)
{
throw new Exception\UnwritableStreamException('Unable to write to the stream');
}
return $result;
} | php | public function write($string) : int
{
if (! \is_resource($this->resource))
{
throw new Exception\UnwritableStreamException('Stream is not resourceable');
}
if (! $this->isWritable())
{
throw new Exception\UnwritableStreamException('Stream is not writable');
}
$result = \fwrite($this->resource, $string);
if (false === $result)
{
throw new Exception\UnwritableStreamException('Unable to write to the stream');
}
return $result;
} | [
"public",
"function",
"write",
"(",
"$",
"string",
")",
":",
"int",
"{",
"if",
"(",
"!",
"\\",
"is_resource",
"(",
"$",
"this",
"->",
"resource",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"UnwritableStreamException",
"(",
"'Stream is not resourceable... | Writes the given string to the stream
Returns the number of bytes written to the stream.
@param string $string
@return int
@throws Exception\UnwritableStreamException
@link http://php.net/manual/en/function.fwrite.php | [
"Writes",
"the",
"given",
"string",
"to",
"the",
"stream"
] | 43fb91e36375b792a8c11853c23aa6efbb71fdbe | https://github.com/sunrise-php/stream/blob/43fb91e36375b792a8c11853c23aa6efbb71fdbe/src/Stream.php#L237-L257 | train |
sunrise-php/stream | src/Stream.php | Stream.read | public function read($length) : string
{
if (! \is_resource($this->resource))
{
throw new Exception\UnreadableStreamException('Stream is not resourceable');
}
if (! $this->isReadable())
{
throw new Exception\UnreadableStreamException('Stream is not readable');
}
$result = \fread($this->resource, $length);
if (false === $result)
{
throw new Exception\UnreadableStreamException('Unable to read from the stream');
}
return $result;
} | php | public function read($length) : string
{
if (! \is_resource($this->resource))
{
throw new Exception\UnreadableStreamException('Stream is not resourceable');
}
if (! $this->isReadable())
{
throw new Exception\UnreadableStreamException('Stream is not readable');
}
$result = \fread($this->resource, $length);
if (false === $result)
{
throw new Exception\UnreadableStreamException('Unable to read from the stream');
}
return $result;
} | [
"public",
"function",
"read",
"(",
"$",
"length",
")",
":",
"string",
"{",
"if",
"(",
"!",
"\\",
"is_resource",
"(",
"$",
"this",
"->",
"resource",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"UnreadableStreamException",
"(",
"'Stream is not resourceab... | Reads the given number of bytes from the stream
@param int $length
@return string
@throws Exception\UnreadableStreamException
@link http://php.net/manual/en/function.fread.php | [
"Reads",
"the",
"given",
"number",
"of",
"bytes",
"from",
"the",
"stream"
] | 43fb91e36375b792a8c11853c23aa6efbb71fdbe | https://github.com/sunrise-php/stream/blob/43fb91e36375b792a8c11853c23aa6efbb71fdbe/src/Stream.php#L287-L307 | train |
sunrise-php/stream | src/Stream.php | Stream.getContents | public function getContents() : string
{
if (! \is_resource($this->resource))
{
throw new Exception\UnreadableStreamException('Stream is not resourceable');
}
if (! $this->isReadable())
{
throw new Exception\UnreadableStreamException('Stream is not readable');
}
$result = \stream_get_contents($this->resource);
if (false === $result)
{
throw new Exception\UnreadableStreamException('Unable to read remainder of the stream');
}
return $result;
} | php | public function getContents() : string
{
if (! \is_resource($this->resource))
{
throw new Exception\UnreadableStreamException('Stream is not resourceable');
}
if (! $this->isReadable())
{
throw new Exception\UnreadableStreamException('Stream is not readable');
}
$result = \stream_get_contents($this->resource);
if (false === $result)
{
throw new Exception\UnreadableStreamException('Unable to read remainder of the stream');
}
return $result;
} | [
"public",
"function",
"getContents",
"(",
")",
":",
"string",
"{",
"if",
"(",
"!",
"\\",
"is_resource",
"(",
"$",
"this",
"->",
"resource",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"UnreadableStreamException",
"(",
"'Stream is not resourceable'",
")",... | Reads remainder of the stream
@return string
@throws Exception\UnreadableStreamException
@link http://php.net/manual/en/function.stream-get-contents.php | [
"Reads",
"remainder",
"of",
"the",
"stream"
] | 43fb91e36375b792a8c11853c23aa6efbb71fdbe | https://github.com/sunrise-php/stream/blob/43fb91e36375b792a8c11853c23aa6efbb71fdbe/src/Stream.php#L318-L338 | train |
sunrise-php/stream | src/Stream.php | Stream.getMetadata | public function getMetadata($key = null)
{
if (! \is_resource($this->resource))
{
return null;
}
$metadata = \stream_get_meta_data($this->resource);
if (! (null === $key))
{
return $metadata[$key] ?? null;
}
return $metadata;
} | php | public function getMetadata($key = null)
{
if (! \is_resource($this->resource))
{
return null;
}
$metadata = \stream_get_meta_data($this->resource);
if (! (null === $key))
{
return $metadata[$key] ?? null;
}
return $metadata;
} | [
"public",
"function",
"getMetadata",
"(",
"$",
"key",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"\\",
"is_resource",
"(",
"$",
"this",
"->",
"resource",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"metadata",
"=",
"\\",
"stream_get_meta_data",
"(",
... | Gets the stream metadata
@param string $key
@return mixed
@link http://php.net/manual/en/function.stream-get-meta-data.php | [
"Gets",
"the",
"stream",
"metadata"
] | 43fb91e36375b792a8c11853c23aa6efbb71fdbe | https://github.com/sunrise-php/stream/blob/43fb91e36375b792a8c11853c23aa6efbb71fdbe/src/Stream.php#L349-L364 | train |
sunrise-php/stream | src/Stream.php | Stream.getSize | public function getSize() : ?int
{
if (! \is_resource($this->resource))
{
return null;
}
$stats = \fstat($this->resource);
if (false === $stats)
{
return null;
}
return $stats['size'];
} | php | public function getSize() : ?int
{
if (! \is_resource($this->resource))
{
return null;
}
$stats = \fstat($this->resource);
if (false === $stats)
{
return null;
}
return $stats['size'];
} | [
"public",
"function",
"getSize",
"(",
")",
":",
"?",
"int",
"{",
"if",
"(",
"!",
"\\",
"is_resource",
"(",
"$",
"this",
"->",
"resource",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"stats",
"=",
"\\",
"fstat",
"(",
"$",
"this",
"->",
"resour... | Gets the stream size
Returns NULL if the stream without a resource, or if the stream size cannot be determined.
@return null|int
@link http://php.net/manual/en/function.fstat.php | [
"Gets",
"the",
"stream",
"size"
] | 43fb91e36375b792a8c11853c23aa6efbb71fdbe | https://github.com/sunrise-php/stream/blob/43fb91e36375b792a8c11853c23aa6efbb71fdbe/src/Stream.php#L375-L390 | train |
maximebf/ConsoleKit | example.php | SayCommand.executeHello | public function executeHello(array $args, array $options = array())
{
$name = 'unknown';
if (empty($args)) {
$dialog = new Dialog($this->console);
$name = $dialog->ask('What is your name?', $name);
} else {
$name = $args[0];
}
$this->writeln(sprintf('hello %s!', $name));
} | php | public function executeHello(array $args, array $options = array())
{
$name = 'unknown';
if (empty($args)) {
$dialog = new Dialog($this->console);
$name = $dialog->ask('What is your name?', $name);
} else {
$name = $args[0];
}
$this->writeln(sprintf('hello %s!', $name));
} | [
"public",
"function",
"executeHello",
"(",
"array",
"$",
"args",
",",
"array",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"name",
"=",
"'unknown'",
";",
"if",
"(",
"empty",
"(",
"$",
"args",
")",
")",
"{",
"$",
"dialog",
"=",
"new",
"... | Says hello to someone
@arg name The name of the person to say hello to | [
"Says",
"hello",
"to",
"someone"
] | a05c0c5a4c48882599d59323314ac963a836d58f | https://github.com/maximebf/ConsoleKit/blob/a05c0c5a4c48882599d59323314ac963a836d58f/example.php#L49-L59 | train |
soosyze/framework | src/Components/Http/Uri.php | Uri.filterPort | protected function filterPort($port)
{
if (empty($port)) {
return null;
}
if (!self::validePort($port)) {
throw new \InvalidArgumentException('The port is not in the TCP/UDP port.');
}
return $this->scheme !== '' && !$this->validPortStandard($port)
? (int) $port
: null;
} | php | protected function filterPort($port)
{
if (empty($port)) {
return null;
}
if (!self::validePort($port)) {
throw new \InvalidArgumentException('The port is not in the TCP/UDP port.');
}
return $this->scheme !== '' && !$this->validPortStandard($port)
? (int) $port
: null;
} | [
"protected",
"function",
"filterPort",
"(",
"$",
"port",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"port",
")",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"!",
"self",
"::",
"validePort",
"(",
"$",
"port",
")",
")",
"{",
"throw",
"new",
"\\",... | Filtre un port.
@param string|int|null $port Port à filtrer.
@throws \InvalidArgumentException Le port n'est pas dans la gamme des ports TCP/UDP.
@return int|null Port normalisé. | [
"Filtre",
"un",
"port",
"."
] | d8dec2155bf9bc1d8ded176b4b65c183e2082049 | https://github.com/soosyze/framework/blob/d8dec2155bf9bc1d8ded176b4b65c183e2082049/src/Components/Http/Uri.php#L479-L492 | train |
soosyze/framework | src/Components/Http/Uri.php | Uri.filterFragment | protected function filterFragment($fragment)
{
$fragmentStr = $this->filterString($fragment);
$fragmentDecode = rawurldecode($fragmentStr);
return rawurlencode(ltrim($fragmentDecode, '#'));
} | php | protected function filterFragment($fragment)
{
$fragmentStr = $this->filterString($fragment);
$fragmentDecode = rawurldecode($fragmentStr);
return rawurlencode(ltrim($fragmentDecode, '#'));
} | [
"protected",
"function",
"filterFragment",
"(",
"$",
"fragment",
")",
"{",
"$",
"fragmentStr",
"=",
"$",
"this",
"->",
"filterString",
"(",
"$",
"fragment",
")",
";",
"$",
"fragmentDecode",
"=",
"rawurldecode",
"(",
"$",
"fragmentStr",
")",
";",
"return",
... | Filtre une ancre.
@param string|null $fragment Ancre à filtrer.
@return string Ancre normalisée. | [
"Filtre",
"une",
"ancre",
"."
] | d8dec2155bf9bc1d8ded176b4b65c183e2082049 | https://github.com/soosyze/framework/blob/d8dec2155bf9bc1d8ded176b4b65c183e2082049/src/Components/Http/Uri.php#L516-L522 | train |
soosyze/framework | src/Components/Http/Uri.php | Uri.filterPath | protected function filterPath($path)
{
$pathStr = $this->filterString($path);
$pathDecode = rawurldecode($pathStr);
$dataPath = array_map(
function ($value) {
return rawurlencode($value);
},
explode('/', $pathDecode)
);
return implode('/', $dataPath);
} | php | protected function filterPath($path)
{
$pathStr = $this->filterString($path);
$pathDecode = rawurldecode($pathStr);
$dataPath = array_map(
function ($value) {
return rawurlencode($value);
},
explode('/', $pathDecode)
);
return implode('/', $dataPath);
} | [
"protected",
"function",
"filterPath",
"(",
"$",
"path",
")",
"{",
"$",
"pathStr",
"=",
"$",
"this",
"->",
"filterString",
"(",
"$",
"path",
")",
";",
"$",
"pathDecode",
"=",
"rawurldecode",
"(",
"$",
"pathStr",
")",
";",
"$",
"dataPath",
"=",
"array_m... | Filtre un chemin.
@param string|null $path Chemin à filtrer.
@return string Chemin normalisé. | [
"Filtre",
"un",
"chemin",
"."
] | d8dec2155bf9bc1d8ded176b4b65c183e2082049 | https://github.com/soosyze/framework/blob/d8dec2155bf9bc1d8ded176b4b65c183e2082049/src/Components/Http/Uri.php#L531-L544 | train |
soosyze/framework | src/Components/Http/Uri.php | Uri.validPortStandard | protected function validPortStandard($port)
{
return in_array($port, $this->ports) &&
$this->scheme === array_keys($this->ports, $port)[ 0 ];
} | php | protected function validPortStandard($port)
{
return in_array($port, $this->ports) &&
$this->scheme === array_keys($this->ports, $port)[ 0 ];
} | [
"protected",
"function",
"validPortStandard",
"(",
"$",
"port",
")",
"{",
"return",
"in_array",
"(",
"$",
"port",
",",
"$",
"this",
"->",
"ports",
")",
"&&",
"$",
"this",
"->",
"scheme",
"===",
"array_keys",
"(",
"$",
"this",
"->",
"ports",
",",
"$",
... | Si le port est prise en charge.
@param int $port
@return bool | [
"Si",
"le",
"port",
"est",
"prise",
"en",
"charge",
"."
] | d8dec2155bf9bc1d8ded176b4b65c183e2082049 | https://github.com/soosyze/framework/blob/d8dec2155bf9bc1d8ded176b4b65c183e2082049/src/Components/Http/Uri.php#L584-L588 | train |
aimeos/ai-typo3 | lib/custom/setup/FEUsersAddSiteIdTypo3.php | FEUsersAddSiteIdTypo3.migrate | public function migrate()
{
$table = 'fe_users';
$column = 'siteid';
$this->msg( sprintf( 'Adding "%1$s" column to "%2$s" table', $column, $table ), 0 );
$schema = $this->getSchema( 'db-customer' );
if( isset( $this->migrate[$schema->getName()] )
&& $schema->tableExists( $table ) === true
&& $schema->columnExists( $table, $column ) === false )
{
foreach ( $this->migrate[$schema->getName()] as $stmt )
{
$this->execute( $stmt );
}
$this->status( 'done' );
}
else
{
$this->status( 'OK' );
}
} | php | public function migrate()
{
$table = 'fe_users';
$column = 'siteid';
$this->msg( sprintf( 'Adding "%1$s" column to "%2$s" table', $column, $table ), 0 );
$schema = $this->getSchema( 'db-customer' );
if( isset( $this->migrate[$schema->getName()] )
&& $schema->tableExists( $table ) === true
&& $schema->columnExists( $table, $column ) === false )
{
foreach ( $this->migrate[$schema->getName()] as $stmt )
{
$this->execute( $stmt );
}
$this->status( 'done' );
}
else
{
$this->status( 'OK' );
}
} | [
"public",
"function",
"migrate",
"(",
")",
"{",
"$",
"table",
"=",
"'fe_users'",
";",
"$",
"column",
"=",
"'siteid'",
";",
"$",
"this",
"->",
"msg",
"(",
"sprintf",
"(",
"'Adding \"%1$s\" column to \"%2$s\" table'",
",",
"$",
"column",
",",
"$",
"table",
"... | Add column siteid to fe_users table.
@param array $stmts Associative array of tables names and lists of SQL statements to execute. | [
"Add",
"column",
"siteid",
"to",
"fe_users",
"table",
"."
] | 74902c312900c8c5659acd4e85fea61ed1cd7c9a | https://github.com/aimeos/ai-typo3/blob/74902c312900c8c5659acd4e85fea61ed1cd7c9a/lib/custom/setup/FEUsersAddSiteIdTypo3.php#L40-L63 | train |
PHP-DI/ZF2-Bridge | src/DI/ZendFramework2/Service/DIContainerFactory.php | DIContainerFactory.getDefinitionsFilePath | private function getDefinitionsFilePath(array $config)
{
$filePath = __DIR__ . '/../../../../../../../config/php-di.config.php';
if (isset($config['definitionsFile'])) {
$filePath = $config['definitionsFile'];
}
if (!file_exists($filePath)) {
throw new \Exception('DI definitions file missing.');
}
return $filePath;
} | php | private function getDefinitionsFilePath(array $config)
{
$filePath = __DIR__ . '/../../../../../../../config/php-di.config.php';
if (isset($config['definitionsFile'])) {
$filePath = $config['definitionsFile'];
}
if (!file_exists($filePath)) {
throw new \Exception('DI definitions file missing.');
}
return $filePath;
} | [
"private",
"function",
"getDefinitionsFilePath",
"(",
"array",
"$",
"config",
")",
"{",
"$",
"filePath",
"=",
"__DIR__",
".",
"'/../../../../../../../config/php-di.config.php'",
";",
"if",
"(",
"isset",
"(",
"$",
"config",
"[",
"'definitionsFile'",
"]",
")",
")",
... | return definitions file path
@param array $config
@return string
@throws | [
"return",
"definitions",
"file",
"path"
] | 369dc7122251a262e133f05ccfcace20ccd5d00f | https://github.com/PHP-DI/ZF2-Bridge/blob/369dc7122251a262e133f05ccfcace20ccd5d00f/src/DI/ZendFramework2/Service/DIContainerFactory.php#L81-L94 | train |
PHP-DI/ZF2-Bridge | src/DI/ZendFramework2/Controller/ConsoleController.php | ConsoleController.clearCacheAction | public function clearCacheAction()
{
/* @var $cache FlushableCache */
$cache = $this->serviceLocator->get('DiCache');
if ($cache instanceof FlushableCache) {
$cache->flushAll();
}
echo "PHP DI definitions cache was cleared." . PHP_EOL . PHP_EOL;
} | php | public function clearCacheAction()
{
/* @var $cache FlushableCache */
$cache = $this->serviceLocator->get('DiCache');
if ($cache instanceof FlushableCache) {
$cache->flushAll();
}
echo "PHP DI definitions cache was cleared." . PHP_EOL . PHP_EOL;
} | [
"public",
"function",
"clearCacheAction",
"(",
")",
"{",
"/* @var $cache FlushableCache */",
"$",
"cache",
"=",
"$",
"this",
"->",
"serviceLocator",
"->",
"get",
"(",
"'DiCache'",
")",
";",
"if",
"(",
"$",
"cache",
"instanceof",
"FlushableCache",
")",
"{",
"$"... | flushes php di definitions cache | [
"flushes",
"php",
"di",
"definitions",
"cache"
] | 369dc7122251a262e133f05ccfcace20ccd5d00f | https://github.com/PHP-DI/ZF2-Bridge/blob/369dc7122251a262e133f05ccfcace20ccd5d00f/src/DI/ZendFramework2/Controller/ConsoleController.php#L23-L33 | train |
mikemirten/JsonApi | src/Document/Behaviour/ErrorsContainer.php | ErrorsContainer.errorsToArray | protected function errorsToArray(): array
{
$errors = [];
foreach ($this->errors as $error)
{
$errors[] = $error->toArray();
}
return $errors;
} | php | protected function errorsToArray(): array
{
$errors = [];
foreach ($this->errors as $error)
{
$errors[] = $error->toArray();
}
return $errors;
} | [
"protected",
"function",
"errorsToArray",
"(",
")",
":",
"array",
"{",
"$",
"errors",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"errors",
"as",
"$",
"error",
")",
"{",
"$",
"errors",
"[",
"]",
"=",
"$",
"error",
"->",
"toArray",
"(",
... | Cast errors to an array
@return array | [
"Cast",
"errors",
"to",
"an",
"array"
] | a3c1baf8f753c040f24e4522495b7d34565e6560 | https://github.com/mikemirten/JsonApi/blob/a3c1baf8f753c040f24e4522495b7d34565e6560/src/Document/Behaviour/ErrorsContainer.php#L57-L67 | train |
scherersoftware/cake-attachments | src/Model/Table/AttachmentsTable.php | AttachmentsTable.addUploads | public function addUploads(EntityInterface $entity, array $uploads)
{
$attachments = [];
foreach ($uploads as $path => $tags) {
if (!(array_keys($uploads) !== range(0, count($uploads) - 1))) {
// if only paths and no tags
$path = $tags;
$tags = [];
}
$file = Configure::read('Attachments.tmpUploadsPath') . $path;
$attachment = $this->createAttachmentEntity($entity, $file, $tags);
$this->save($attachment);
$attachments[] = $attachment;
}
$entity->attachments = $attachments;
} | php | public function addUploads(EntityInterface $entity, array $uploads)
{
$attachments = [];
foreach ($uploads as $path => $tags) {
if (!(array_keys($uploads) !== range(0, count($uploads) - 1))) {
// if only paths and no tags
$path = $tags;
$tags = [];
}
$file = Configure::read('Attachments.tmpUploadsPath') . $path;
$attachment = $this->createAttachmentEntity($entity, $file, $tags);
$this->save($attachment);
$attachments[] = $attachment;
}
$entity->attachments = $attachments;
} | [
"public",
"function",
"addUploads",
"(",
"EntityInterface",
"$",
"entity",
",",
"array",
"$",
"uploads",
")",
"{",
"$",
"attachments",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"uploads",
"as",
"$",
"path",
"=>",
"$",
"tags",
")",
"{",
"if",
"(",
"!",... | Takes the array from the attachments area hidden form field and creates
attachment records for the given entity
@param EntityInterface $entity Entity to attach the files to
@param array $uploads List of paths relative to the Attachments.tmpUploadsPath
config value or ['path_to_file' => [tag1, tag2, tag3, ...]]
@return void | [
"Takes",
"the",
"array",
"from",
"the",
"attachments",
"area",
"hidden",
"form",
"field",
"and",
"creates",
"attachment",
"records",
"for",
"the",
"given",
"entity"
] | 3571005fac399639d609e06a4b3cd445ee16d104 | https://github.com/scherersoftware/cake-attachments/blob/3571005fac399639d609e06a4b3cd445ee16d104/src/Model/Table/AttachmentsTable.php#L73-L89 | train |
scherersoftware/cake-attachments | src/Model/Table/AttachmentsTable.php | AttachmentsTable.addUpload | public function addUpload(EntityInterface $entity, $upload)
{
$tags = [];
$path = $upload;
if (is_array($upload)) {
$tags = reset($upload);
$path = reset(array_flip($upload));
}
$file = Configure::read('Attachments.tmpUploadsPath') . $path;
$attachment = $this->createAttachmentEntity($entity, $file, $tags);
$save = $this->save($attachment);
if ($save) {
return $attachment;
}
return $save;
} | php | public function addUpload(EntityInterface $entity, $upload)
{
$tags = [];
$path = $upload;
if (is_array($upload)) {
$tags = reset($upload);
$path = reset(array_flip($upload));
}
$file = Configure::read('Attachments.tmpUploadsPath') . $path;
$attachment = $this->createAttachmentEntity($entity, $file, $tags);
$save = $this->save($attachment);
if ($save) {
return $attachment;
}
return $save;
} | [
"public",
"function",
"addUpload",
"(",
"EntityInterface",
"$",
"entity",
",",
"$",
"upload",
")",
"{",
"$",
"tags",
"=",
"[",
"]",
";",
"$",
"path",
"=",
"$",
"upload",
";",
"if",
"(",
"is_array",
"(",
"$",
"upload",
")",
")",
"{",
"$",
"tags",
... | Save one Attachemnt
@param EntityInterface $entity Entity
@param string $upload String to uploaded file or ['path_to_file' => [tag1, tag2, tag3, ...]]
@return entity | [
"Save",
"one",
"Attachemnt"
] | 3571005fac399639d609e06a4b3cd445ee16d104 | https://github.com/scherersoftware/cake-attachments/blob/3571005fac399639d609e06a4b3cd445ee16d104/src/Model/Table/AttachmentsTable.php#L98-L113 | train |
scherersoftware/cake-attachments | src/Model/Table/AttachmentsTable.php | AttachmentsTable.afterSave | public function afterSave(Event $event, Attachment $attachment, \ArrayObject $options)
{
if ($attachment->tmpPath) {
// Make sure the folder is created
$folder = new Folder();
$targetDir = Configure::read('Attachments.path') . dirname($attachment->filepath);
if (!$folder->create($targetDir)) {
throw new \Exception("Folder {$targetDir} could not be created.");
}
$targetPath = Configure::read('Attachments.path') . $attachment->filepath;
if (!rename($attachment->tmpPath, $targetPath)) {
throw new \Exception("Temporary file {$attachment->tmpPath} could not be moved to {$attachment->filepath}");
}
$attachment->tmpPath = null;
}
} | php | public function afterSave(Event $event, Attachment $attachment, \ArrayObject $options)
{
if ($attachment->tmpPath) {
// Make sure the folder is created
$folder = new Folder();
$targetDir = Configure::read('Attachments.path') . dirname($attachment->filepath);
if (!$folder->create($targetDir)) {
throw new \Exception("Folder {$targetDir} could not be created.");
}
$targetPath = Configure::read('Attachments.path') . $attachment->filepath;
if (!rename($attachment->tmpPath, $targetPath)) {
throw new \Exception("Temporary file {$attachment->tmpPath} could not be moved to {$attachment->filepath}");
}
$attachment->tmpPath = null;
}
} | [
"public",
"function",
"afterSave",
"(",
"Event",
"$",
"event",
",",
"Attachment",
"$",
"attachment",
",",
"\\",
"ArrayObject",
"$",
"options",
")",
"{",
"if",
"(",
"$",
"attachment",
"->",
"tmpPath",
")",
"{",
"// Make sure the folder is created",
"$",
"folder... | afterSave Event. If an attachment entity has its tmpPath value set, it will be moved
to the defined filepath
@param Event $event Event
@param Attachment $attachment Entity
@param ArrayObject $options Options
@return void
@throws \Exception If the file couldn't be moved | [
"afterSave",
"Event",
".",
"If",
"an",
"attachment",
"entity",
"has",
"its",
"tmpPath",
"value",
"set",
"it",
"will",
"be",
"moved",
"to",
"the",
"defined",
"filepath"
] | 3571005fac399639d609e06a4b3cd445ee16d104 | https://github.com/scherersoftware/cake-attachments/blob/3571005fac399639d609e06a4b3cd445ee16d104/src/Model/Table/AttachmentsTable.php#L124-L140 | train |
scherersoftware/cake-attachments | src/Model/Table/AttachmentsTable.php | AttachmentsTable.createAttachmentEntity | public function createAttachmentEntity(EntityInterface $entity, $filePath, array $tags = [])
{
if (!file_exists($filePath)) {
throw new \Exception("File {$filePath} does not exist.");
}
if (!is_readable($filePath)) {
throw new \Exception("File {$filePath} cannot be read.");
}
$file = new File($filePath);
$info = $file->info();
// in filepath, we store the path relative to the Attachment.path configuration
// to make it easy to switch storage
$info = $this->__getFileName($info, $entity);
$targetPath = $entity->source() . '/' . $entity->id . '/' . $info['basename'];
$attachment = $this->newEntity([
'model' => $entity->source(),
'foreign_key' => $entity->id,
'filename' => $info['basename'],
'filesize' => $info['filesize'],
'filetype' => $info['mime'],
'filepath' => $targetPath,
'tmpPath' => $filePath,
'tags' => $tags
]);
return $attachment;
} | php | public function createAttachmentEntity(EntityInterface $entity, $filePath, array $tags = [])
{
if (!file_exists($filePath)) {
throw new \Exception("File {$filePath} does not exist.");
}
if (!is_readable($filePath)) {
throw new \Exception("File {$filePath} cannot be read.");
}
$file = new File($filePath);
$info = $file->info();
// in filepath, we store the path relative to the Attachment.path configuration
// to make it easy to switch storage
$info = $this->__getFileName($info, $entity);
$targetPath = $entity->source() . '/' . $entity->id . '/' . $info['basename'];
$attachment = $this->newEntity([
'model' => $entity->source(),
'foreign_key' => $entity->id,
'filename' => $info['basename'],
'filesize' => $info['filesize'],
'filetype' => $info['mime'],
'filepath' => $targetPath,
'tmpPath' => $filePath,
'tags' => $tags
]);
return $attachment;
} | [
"public",
"function",
"createAttachmentEntity",
"(",
"EntityInterface",
"$",
"entity",
",",
"$",
"filePath",
",",
"array",
"$",
"tags",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"filePath",
")",
")",
"{",
"throw",
"new",
"\\",
"... | Creates an Attachment entity based on the given file
@param EntityInterface $entity Entity the file will be attached to
@param string $filePath Absolute path to the file
@param array $tags Indexed array of tags to be assigned
@return Attachment
@throws \Exception If the given file doesn't exist or isn't readable | [
"Creates",
"an",
"Attachment",
"entity",
"based",
"on",
"the",
"given",
"file"
] | 3571005fac399639d609e06a4b3cd445ee16d104 | https://github.com/scherersoftware/cake-attachments/blob/3571005fac399639d609e06a4b3cd445ee16d104/src/Model/Table/AttachmentsTable.php#L164-L191 | train |
scherersoftware/cake-attachments | src/Model/Table/AttachmentsTable.php | AttachmentsTable.__getFileName | private function __getFileName($fileInfo, EntityInterface $entity, $id = 0)
{
if (!file_exists(Configure::read('Attachments.path') . $entity->source() . '/' . $entity->id . '/' . $fileInfo['basename'])) {
return $fileInfo;
}
$fileInfo['basename'] = $fileInfo['filename'] . ' (' . ++$id . ').' . $fileInfo['extension'];
return $this->__getFileName($fileInfo, $entity, $id);
} | php | private function __getFileName($fileInfo, EntityInterface $entity, $id = 0)
{
if (!file_exists(Configure::read('Attachments.path') . $entity->source() . '/' . $entity->id . '/' . $fileInfo['basename'])) {
return $fileInfo;
}
$fileInfo['basename'] = $fileInfo['filename'] . ' (' . ++$id . ').' . $fileInfo['extension'];
return $this->__getFileName($fileInfo, $entity, $id);
} | [
"private",
"function",
"__getFileName",
"(",
"$",
"fileInfo",
",",
"EntityInterface",
"$",
"entity",
",",
"$",
"id",
"=",
"0",
")",
"{",
"if",
"(",
"!",
"file_exists",
"(",
"Configure",
"::",
"read",
"(",
"'Attachments.path'",
")",
".",
"$",
"entity",
"-... | recursive method to increase the filename in case the file already exists
@param string $fileInfo Array of information about the file
@param EntityInterface $entity Entity
@param string $id counter varibale to extend the filename
@return array | [
"recursive",
"method",
"to",
"increase",
"the",
"filename",
"in",
"case",
"the",
"file",
"already",
"exists"
] | 3571005fac399639d609e06a4b3cd445ee16d104 | https://github.com/scherersoftware/cake-attachments/blob/3571005fac399639d609e06a4b3cd445ee16d104/src/Model/Table/AttachmentsTable.php#L201-L208 | train |
mikemirten/JsonApi | src/Hydrator/DocumentHydrator.php | DocumentHydrator.hydrate | public function hydrate($source): AbstractDocument
{
if (! isset($source->data)) {
return $this->processNoDataDocument($source);
}
if (is_object($source->data)) {
return $this->processSingleResourceDocument($source);
}
if (is_array($source->data)) {
return $this->processResourceCollectionDocument($source);
}
throw new InvalidDocumentException('If data is present and is not null it must be an object or an array');
} | php | public function hydrate($source): AbstractDocument
{
if (! isset($source->data)) {
return $this->processNoDataDocument($source);
}
if (is_object($source->data)) {
return $this->processSingleResourceDocument($source);
}
if (is_array($source->data)) {
return $this->processResourceCollectionDocument($source);
}
throw new InvalidDocumentException('If data is present and is not null it must be an object or an array');
} | [
"public",
"function",
"hydrate",
"(",
"$",
"source",
")",
":",
"AbstractDocument",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"source",
"->",
"data",
")",
")",
"{",
"return",
"$",
"this",
"->",
"processNoDataDocument",
"(",
"$",
"source",
")",
";",
"}",
... | Hydrate source to a document
@param object $source
@return AbstractDocument | [
"Hydrate",
"source",
"to",
"a",
"document"
] | a3c1baf8f753c040f24e4522495b7d34565e6560 | https://github.com/mikemirten/JsonApi/blob/a3c1baf8f753c040f24e4522495b7d34565e6560/src/Hydrator/DocumentHydrator.php#L50-L65 | train |
mikemirten/JsonApi | src/Hydrator/DocumentHydrator.php | DocumentHydrator.processNoDataDocument | protected function processNoDataDocument($source): NoDataDocument
{
$document = new NoDataDocument();
$this->hydrateObject($document, $source);
return $document;
} | php | protected function processNoDataDocument($source): NoDataDocument
{
$document = new NoDataDocument();
$this->hydrateObject($document, $source);
return $document;
} | [
"protected",
"function",
"processNoDataDocument",
"(",
"$",
"source",
")",
":",
"NoDataDocument",
"{",
"$",
"document",
"=",
"new",
"NoDataDocument",
"(",
")",
";",
"$",
"this",
"->",
"hydrateObject",
"(",
"$",
"document",
",",
"$",
"source",
")",
";",
"re... | Process document contains no data
@param mixed $source
@return NoDataDocument | [
"Process",
"document",
"contains",
"no",
"data"
] | a3c1baf8f753c040f24e4522495b7d34565e6560 | https://github.com/mikemirten/JsonApi/blob/a3c1baf8f753c040f24e4522495b7d34565e6560/src/Hydrator/DocumentHydrator.php#L89-L96 | train |
mikemirten/JsonApi | src/Hydrator/DocumentHydrator.php | DocumentHydrator.processSingleResourceDocument | protected function processSingleResourceDocument($source): SingleResourceDocument
{
$resource = $this->hydrateResource($source->data);
$document = new SingleResourceDocument($resource);
$this->hydrateObject($document, $source);
return $document;
} | php | protected function processSingleResourceDocument($source): SingleResourceDocument
{
$resource = $this->hydrateResource($source->data);
$document = new SingleResourceDocument($resource);
$this->hydrateObject($document, $source);
return $document;
} | [
"protected",
"function",
"processSingleResourceDocument",
"(",
"$",
"source",
")",
":",
"SingleResourceDocument",
"{",
"$",
"resource",
"=",
"$",
"this",
"->",
"hydrateResource",
"(",
"$",
"source",
"->",
"data",
")",
";",
"$",
"document",
"=",
"new",
"SingleR... | Process document with single resource
@param mixed $source
@return SingleResourceDocument | [
"Process",
"document",
"with",
"single",
"resource"
] | a3c1baf8f753c040f24e4522495b7d34565e6560 | https://github.com/mikemirten/JsonApi/blob/a3c1baf8f753c040f24e4522495b7d34565e6560/src/Hydrator/DocumentHydrator.php#L104-L112 | train |
mikemirten/JsonApi | src/Hydrator/DocumentHydrator.php | DocumentHydrator.processResourceCollectionDocument | protected function processResourceCollectionDocument($source): ResourceCollectionDocument
{
$document = new ResourceCollectionDocument();
foreach ($source->data as $resourceSrc)
{
$document->addResource($this->hydrateResource($resourceSrc));
}
$this->hydrateObject($document, $source);
return $document;
} | php | protected function processResourceCollectionDocument($source): ResourceCollectionDocument
{
$document = new ResourceCollectionDocument();
foreach ($source->data as $resourceSrc)
{
$document->addResource($this->hydrateResource($resourceSrc));
}
$this->hydrateObject($document, $source);
return $document;
} | [
"protected",
"function",
"processResourceCollectionDocument",
"(",
"$",
"source",
")",
":",
"ResourceCollectionDocument",
"{",
"$",
"document",
"=",
"new",
"ResourceCollectionDocument",
"(",
")",
";",
"foreach",
"(",
"$",
"source",
"->",
"data",
"as",
"$",
"resour... | Process document with collection of resources
@param mixed $source
@return ResourceCollectionDocument | [
"Process",
"document",
"with",
"collection",
"of",
"resources"
] | a3c1baf8f753c040f24e4522495b7d34565e6560 | https://github.com/mikemirten/JsonApi/blob/a3c1baf8f753c040f24e4522495b7d34565e6560/src/Hydrator/DocumentHydrator.php#L120-L132 | train |
BootstrapCMS/Contact | src/Mailer.php | Mailer.send | public function send($first, $last, $email, $message)
{
$quote = nl2br($message);
$name = $first.' '.$last;
$this->sendMessage($name, $email, $quote);
$this->sendThanks($first, $email, $quote);
} | php | public function send($first, $last, $email, $message)
{
$quote = nl2br($message);
$name = $first.' '.$last;
$this->sendMessage($name, $email, $quote);
$this->sendThanks($first, $email, $quote);
} | [
"public",
"function",
"send",
"(",
"$",
"first",
",",
"$",
"last",
",",
"$",
"email",
",",
"$",
"message",
")",
"{",
"$",
"quote",
"=",
"nl2br",
"(",
"$",
"message",
")",
";",
"$",
"name",
"=",
"$",
"first",
".",
"' '",
".",
"$",
"last",
";",
... | Send the emails.
@param string $first
@param string $last
@param string $email
@param string $message
@return void | [
"Send",
"the",
"emails",
"."
] | 299cc7f8a724348406a030ca138d9e25b49c4337 | https://github.com/BootstrapCMS/Contact/blob/299cc7f8a724348406a030ca138d9e25b49c4337/src/Mailer.php#L88-L97 | train |
mikemirten/JsonApi | src/HttpClient/HttpClient.php | HttpClient.streamToDocument | protected function streamToDocument(StreamInterface $stream): AbstractDocument
{
$content = $stream->getContents();
$decoded = json_decode($content);
if (json_last_error() !== JSON_ERROR_NONE) {
throw new \RuntimeException('Decoding error: "' . json_last_error_msg() . '""');
}
return $this->hydrator->hydrate($decoded);
} | php | protected function streamToDocument(StreamInterface $stream): AbstractDocument
{
$content = $stream->getContents();
$decoded = json_decode($content);
if (json_last_error() !== JSON_ERROR_NONE) {
throw new \RuntimeException('Decoding error: "' . json_last_error_msg() . '""');
}
return $this->hydrator->hydrate($decoded);
} | [
"protected",
"function",
"streamToDocument",
"(",
"StreamInterface",
"$",
"stream",
")",
":",
"AbstractDocument",
"{",
"$",
"content",
"=",
"$",
"stream",
"->",
"getContents",
"(",
")",
";",
"$",
"decoded",
"=",
"json_decode",
"(",
"$",
"content",
")",
";",
... | Create a JsonApi document by serialized data from stream
@param StreamInterface $stream
@return AbstractDocument | [
"Create",
"a",
"JsonApi",
"document",
"by",
"serialized",
"data",
"from",
"stream"
] | a3c1baf8f753c040f24e4522495b7d34565e6560 | https://github.com/mikemirten/JsonApi/blob/a3c1baf8f753c040f24e4522495b7d34565e6560/src/HttpClient/HttpClient.php#L153-L163 | train |
mikemirten/JsonApi | src/HttpClient/HttpClient.php | HttpClient.documentToStream | protected function documentToStream(AbstractDocument $document): StreamInterface
{
$encoded = json_encode($document->toArray());
if (json_last_error() !== JSON_ERROR_NONE) {
throw new \RuntimeException('Encoding error: "' . json_last_error_msg() . '""');
}
$stream = fopen('php://memory', 'r+');
fwrite($stream, $encoded);
fseek($stream, 0);
return new Stream($stream);
} | php | protected function documentToStream(AbstractDocument $document): StreamInterface
{
$encoded = json_encode($document->toArray());
if (json_last_error() !== JSON_ERROR_NONE) {
throw new \RuntimeException('Encoding error: "' . json_last_error_msg() . '""');
}
$stream = fopen('php://memory', 'r+');
fwrite($stream, $encoded);
fseek($stream, 0);
return new Stream($stream);
} | [
"protected",
"function",
"documentToStream",
"(",
"AbstractDocument",
"$",
"document",
")",
":",
"StreamInterface",
"{",
"$",
"encoded",
"=",
"json_encode",
"(",
"$",
"document",
"->",
"toArray",
"(",
")",
")",
";",
"if",
"(",
"json_last_error",
"(",
")",
"!... | Create a stream contains serialized JsonApi-document
@param AbstractDocument $document
@return StreamInterface | [
"Create",
"a",
"stream",
"contains",
"serialized",
"JsonApi",
"-",
"document"
] | a3c1baf8f753c040f24e4522495b7d34565e6560 | https://github.com/mikemirten/JsonApi/blob/a3c1baf8f753c040f24e4522495b7d34565e6560/src/HttpClient/HttpClient.php#L171-L185 | train |
dreamfactorysoftware/azure-documentdb-php-sdk | src/Resources/BaseResource.php | BaseResource.getId | protected function getId($id = null)
{
$id = (empty($id)) ? $this->resourceId : $id;
if (empty($id)) {
throw new \Exception('Invalid id supplied [' . $id . ']. Operation requires valid resource id.');
}
return $id;
} | php | protected function getId($id = null)
{
$id = (empty($id)) ? $this->resourceId : $id;
if (empty($id)) {
throw new \Exception('Invalid id supplied [' . $id . ']. Operation requires valid resource id.');
}
return $id;
} | [
"protected",
"function",
"getId",
"(",
"$",
"id",
"=",
"null",
")",
"{",
"$",
"id",
"=",
"(",
"empty",
"(",
"$",
"id",
")",
")",
"?",
"$",
"this",
"->",
"resourceId",
":",
"$",
"id",
";",
"if",
"(",
"empty",
"(",
"$",
"id",
")",
")",
"{",
"... | Determines the resource id to use.
@param string|null $id Resource id
@return string|null Resource id
@throws \Exception | [
"Determines",
"the",
"resource",
"id",
"to",
"use",
"."
] | 73152d23284e9501332a307cfc3411cb3de57245 | https://github.com/dreamfactorysoftware/azure-documentdb-php-sdk/blob/73152d23284e9501332a307cfc3411cb3de57245/src/Resources/BaseResource.php#L58-L66 | train |
dreamfactorysoftware/azure-documentdb-php-sdk | src/Resources/BaseResource.php | BaseResource.request | protected function request($verb, $path, $resource = '', array $payload = [])
{
return $this->client->request($verb, $path, $this->resourceType, $resource, $payload, $this->headers);
} | php | protected function request($verb, $path, $resource = '', array $payload = [])
{
return $this->client->request($verb, $path, $this->resourceType, $resource, $payload, $this->headers);
} | [
"protected",
"function",
"request",
"(",
"$",
"verb",
",",
"$",
"path",
",",
"$",
"resource",
"=",
"''",
",",
"array",
"$",
"payload",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"client",
"->",
"request",
"(",
"$",
"verb",
",",
"$",
"p... | Makes the request for resources
@param string $verb Request Method (HEAD, GET, POST, PUT, DELETE)
@param string $path Requested resource path
@param string $resource Requested resource
@param array $payload Posted data
@return array | [
"Makes",
"the",
"request",
"for",
"resources"
] | 73152d23284e9501332a307cfc3411cb3de57245 | https://github.com/dreamfactorysoftware/azure-documentdb-php-sdk/blob/73152d23284e9501332a307cfc3411cb3de57245/src/Resources/BaseResource.php#L78-L81 | train |
soosyze/framework | src/Components/Template/Template.php | Template.render | public function render()
{
require_once 'functions_include.php';
$block = [];
foreach ($this->blocks as $key => &$subTpl) {
$block[ $key ] = !is_null($subTpl)
? $this->filter('block.' . $key, $subTpl->render())
: '';
}
foreach ($this->vars as $key => $value) {
$$key = $this->filter('var.' . $key, $value);
}
ob_start();
require $this->path . $this->name;
$html = ob_get_clean();
return $this->filter('output', $html);
} | php | public function render()
{
require_once 'functions_include.php';
$block = [];
foreach ($this->blocks as $key => &$subTpl) {
$block[ $key ] = !is_null($subTpl)
? $this->filter('block.' . $key, $subTpl->render())
: '';
}
foreach ($this->vars as $key => $value) {
$$key = $this->filter('var.' . $key, $value);
}
ob_start();
require $this->path . $this->name;
$html = ob_get_clean();
return $this->filter('output', $html);
} | [
"public",
"function",
"render",
"(",
")",
"{",
"require_once",
"'functions_include.php'",
";",
"$",
"block",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"blocks",
"as",
"$",
"key",
"=>",
"&",
"$",
"subTpl",
")",
"{",
"$",
"block",
"[",
"$"... | Compile la template, ses sous templates et ses variables.
@return string La template compilée. | [
"Compile",
"la",
"template",
"ses",
"sous",
"templates",
"et",
"ses",
"variables",
"."
] | d8dec2155bf9bc1d8ded176b4b65c183e2082049 | https://github.com/soosyze/framework/blob/d8dec2155bf9bc1d8ded176b4b65c183e2082049/src/Components/Template/Template.php#L259-L278 | train |
aimeos/ai-typo3 | lib/custom/setup/CustomerRemoveLostUserDataTypo3.php | CustomerRemoveLostUserDataTypo3.migrate | public function migrate()
{
$this->msg( 'Remove left over TYPO3 fe_users references', 0, '' );
foreach( $this->sql as $table => $stmt )
{
$this->msg( sprintf( 'Remove unused %1$s records', $table ), 1 );
if( $this->schema->tableExists( 'fe_users' ) && $this->schema->tableExists( $table ) )
{
$this->execute( $stmt );
$this->status( 'done' );
}
else
{
$this->status( 'OK' );
}
}
} | php | public function migrate()
{
$this->msg( 'Remove left over TYPO3 fe_users references', 0, '' );
foreach( $this->sql as $table => $stmt )
{
$this->msg( sprintf( 'Remove unused %1$s records', $table ), 1 );
if( $this->schema->tableExists( 'fe_users' ) && $this->schema->tableExists( $table ) )
{
$this->execute( $stmt );
$this->status( 'done' );
}
else
{
$this->status( 'OK' );
}
}
} | [
"public",
"function",
"migrate",
"(",
")",
"{",
"$",
"this",
"->",
"msg",
"(",
"'Remove left over TYPO3 fe_users references'",
",",
"0",
",",
"''",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"sql",
"as",
"$",
"table",
"=>",
"$",
"stmt",
")",
"{",
"$"... | Migrate database schema | [
"Migrate",
"database",
"schema"
] | 74902c312900c8c5659acd4e85fea61ed1cd7c9a | https://github.com/aimeos/ai-typo3/blob/74902c312900c8c5659acd4e85fea61ed1cd7c9a/lib/custom/setup/CustomerRemoveLostUserDataTypo3.php#L38-L56 | train |
soosyze/framework | src/Components/Form/FormBuilder.php | FormBuilder.group | public function group($name, $balise, callable $callback, $attr = null)
{
$form = new FormBuilder([]);
call_user_func_array($callback, [ &$form ]);
$group = $this->merge_attr([ 'balise' => $balise ], $attr);
return $this->input($name, [ 'type' => 'group', 'subform' => $form, 'attr' => $group ]);
} | php | public function group($name, $balise, callable $callback, $attr = null)
{
$form = new FormBuilder([]);
call_user_func_array($callback, [ &$form ]);
$group = $this->merge_attr([ 'balise' => $balise ], $attr);
return $this->input($name, [ 'type' => 'group', 'subform' => $form, 'attr' => $group ]);
} | [
"public",
"function",
"group",
"(",
"$",
"name",
",",
"$",
"balise",
",",
"callable",
"$",
"callback",
",",
"$",
"attr",
"=",
"null",
")",
"{",
"$",
"form",
"=",
"new",
"FormBuilder",
"(",
"[",
"]",
")",
";",
"call_user_func_array",
"(",
"$",
"callba... | Enregistre un groupe d'input.
@param string $name Nom du groupe.
@param string $balise Type de balise (div|span|fieldset).
@param callable $callback Fonction de création du sous-formulaire.
@param array|null $attr Liste d'attributs.
@return $this | [
"Enregistre",
"un",
"groupe",
"d",
"input",
"."
] | d8dec2155bf9bc1d8ded176b4b65c183e2082049 | https://github.com/soosyze/framework/blob/d8dec2155bf9bc1d8ded176b4b65c183e2082049/src/Components/Form/FormBuilder.php#L236-L243 | train |
soosyze/framework | src/Components/Form/FormBuilder.php | FormBuilder.label | public function label($name, $label, array $attr = null)
{
return $this->input($name, [ 'type' => 'label', 'label' => $label, 'attr' => $attr ]);
} | php | public function label($name, $label, array $attr = null)
{
return $this->input($name, [ 'type' => 'label', 'label' => $label, 'attr' => $attr ]);
} | [
"public",
"function",
"label",
"(",
"$",
"name",
",",
"$",
"label",
",",
"array",
"$",
"attr",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"input",
"(",
"$",
"name",
",",
"[",
"'type'",
"=>",
"'label'",
",",
"'label'",
"=>",
"$",
"label",
... | Enregistre un label.
@param string $name Clé unique.
@param string $label Texte à afficher.
@param array|null $attr Liste d'attributs.
@return $this | [
"Enregistre",
"un",
"label",
"."
] | d8dec2155bf9bc1d8ded176b4b65c183e2082049 | https://github.com/soosyze/framework/blob/d8dec2155bf9bc1d8ded176b4b65c183e2082049/src/Components/Form/FormBuilder.php#L254-L257 | train |
soosyze/framework | src/Components/Form/FormBuilder.php | FormBuilder.legend | public function legend($name, $legend, array $attr = null)
{
return $this->input($name, [ 'type' => 'legend', 'legend' => $legend, 'attr' => $attr ]);
} | php | public function legend($name, $legend, array $attr = null)
{
return $this->input($name, [ 'type' => 'legend', 'legend' => $legend, 'attr' => $attr ]);
} | [
"public",
"function",
"legend",
"(",
"$",
"name",
",",
"$",
"legend",
",",
"array",
"$",
"attr",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"input",
"(",
"$",
"name",
",",
"[",
"'type'",
"=>",
"'legend'",
",",
"'legend'",
"=>",
"$",
"legen... | Enregistre une legende.
@param string $name Clé unique.
@param string $legend Texte à afficher.
@param array|null $attr Liste d'attributs.
@return $this | [
"Enregistre",
"une",
"legende",
"."
] | d8dec2155bf9bc1d8ded176b4b65c183e2082049 | https://github.com/soosyze/framework/blob/d8dec2155bf9bc1d8ded176b4b65c183e2082049/src/Components/Form/FormBuilder.php#L268-L271 | train |
soosyze/framework | src/Components/Form/FormBuilder.php | FormBuilder.textarea | public function textarea($name, $id, $content = '', array $attr = null)
{
$basic = $this->merge_attr([ 'id' => $id ], $attr);
return $this->input($name, [ 'id' => $id, 'type' => 'textarea', 'content' => $content,
'attr' => $basic ]);
} | php | public function textarea($name, $id, $content = '', array $attr = null)
{
$basic = $this->merge_attr([ 'id' => $id ], $attr);
return $this->input($name, [ 'id' => $id, 'type' => 'textarea', 'content' => $content,
'attr' => $basic ]);
} | [
"public",
"function",
"textarea",
"(",
"$",
"name",
",",
"$",
"id",
",",
"$",
"content",
"=",
"''",
",",
"array",
"$",
"attr",
"=",
"null",
")",
"{",
"$",
"basic",
"=",
"$",
"this",
"->",
"merge_attr",
"(",
"[",
"'id'",
"=>",
"$",
"id",
"]",
",... | Enregistre un textarea.
@param string $name Clé unique.
@param string $id Selecteur CSS.
@param string $content Contenu du textarea.
@param array|null $attr Liste d'attributs.
@return $this | [
"Enregistre",
"un",
"textarea",
"."
] | d8dec2155bf9bc1d8ded176b4b65c183e2082049 | https://github.com/soosyze/framework/blob/d8dec2155bf9bc1d8ded176b4b65c183e2082049/src/Components/Form/FormBuilder.php#L283-L289 | train |
soosyze/framework | src/Components/Form/FormBuilder.php | FormBuilder.inputBasic | public function inputBasic($type, $name, $id, array $attr = null)
{
$basic = $this->merge_attr([ 'id' => $id ], $attr);
return $this->input($name, [ 'type' => $type, 'attr' => $basic ]);
} | php | public function inputBasic($type, $name, $id, array $attr = null)
{
$basic = $this->merge_attr([ 'id' => $id ], $attr);
return $this->input($name, [ 'type' => $type, 'attr' => $basic ]);
} | [
"public",
"function",
"inputBasic",
"(",
"$",
"type",
",",
"$",
"name",
",",
"$",
"id",
",",
"array",
"$",
"attr",
"=",
"null",
")",
"{",
"$",
"basic",
"=",
"$",
"this",
"->",
"merge_attr",
"(",
"[",
"'id'",
"=>",
"$",
"id",
"]",
",",
"$",
"att... | Enregistre un input standard.
@param string $type Type d'input.
@param string $name Clé unique.
@param string $id Selecteur CSS.
@param array|null $attr Liste d'attributs.
@return $this | [
"Enregistre",
"un",
"input",
"standard",
"."
] | d8dec2155bf9bc1d8ded176b4b65c183e2082049 | https://github.com/soosyze/framework/blob/d8dec2155bf9bc1d8ded176b4b65c183e2082049/src/Components/Form/FormBuilder.php#L318-L323 | train |
soosyze/framework | src/Components/Form/FormBuilder.php | FormBuilder.submit | public function submit($name, $value, array $attr = null)
{
$basic = $this->merge_attr([ 'value' => $value ], $attr);
return $this->input($name, [ 'type' => 'submit', 'attr' => $basic ]);
} | php | public function submit($name, $value, array $attr = null)
{
$basic = $this->merge_attr([ 'value' => $value ], $attr);
return $this->input($name, [ 'type' => 'submit', 'attr' => $basic ]);
} | [
"public",
"function",
"submit",
"(",
"$",
"name",
",",
"$",
"value",
",",
"array",
"$",
"attr",
"=",
"null",
")",
"{",
"$",
"basic",
"=",
"$",
"this",
"->",
"merge_attr",
"(",
"[",
"'value'",
"=>",
"$",
"value",
"]",
",",
"$",
"attr",
")",
";",
... | Enregistre un submit.
@param string $name Clé unique.
@param string $value Texte à afficher.
@param array|null $attr Liste d'attributs.
@return $this | [
"Enregistre",
"un",
"submit",
"."
] | d8dec2155bf9bc1d8ded176b4b65c183e2082049 | https://github.com/soosyze/framework/blob/d8dec2155bf9bc1d8ded176b4b65c183e2082049/src/Components/Form/FormBuilder.php#L334-L339 | train |
soosyze/framework | src/Components/Form/FormBuilder.php | FormBuilder.input | protected function input($name, array $attr)
{
/**
* Si le for n'est pas précisé dans le label précédent
* il devient automatiquement l'id de la balise courante.
*/
$previous = end($this->form);
if ($previous && $previous[ 'type' ] == 'label' && !isset($previous[ 'attr' ][ 'for' ]) && isset($attr[ 'attr' ][ 'id' ])) {
$this->form[ key($this->form) ][ 'attr' ][ 'for' ] = $attr[ 'attr' ][ 'id' ];
}
$this->form[ $name ] = $attr;
return $this;
} | php | protected function input($name, array $attr)
{
/**
* Si le for n'est pas précisé dans le label précédent
* il devient automatiquement l'id de la balise courante.
*/
$previous = end($this->form);
if ($previous && $previous[ 'type' ] == 'label' && !isset($previous[ 'attr' ][ 'for' ]) && isset($attr[ 'attr' ][ 'id' ])) {
$this->form[ key($this->form) ][ 'attr' ][ 'for' ] = $attr[ 'attr' ][ 'id' ];
}
$this->form[ $name ] = $attr;
return $this;
} | [
"protected",
"function",
"input",
"(",
"$",
"name",
",",
"array",
"$",
"attr",
")",
"{",
"/**\n * Si le for n'est pas précisé dans le label précédent\n * il devient automatiquement l'id de la balise courante.\n */",
"$",
"previous",
"=",
"end",
"(",
"$",
... | Enregistre un input.
@param string $name Clé unique.
@param array $attr Options des champs et attributs de la balise.
@return $this | [
"Enregistre",
"un",
"input",
"."
] | d8dec2155bf9bc1d8ded176b4b65c183e2082049 | https://github.com/soosyze/framework/blob/d8dec2155bf9bc1d8ded176b4b65c183e2082049/src/Components/Form/FormBuilder.php#L808-L821 | train |
soosyze/framework | src/Components/Form/FormBuilder.php | FormBuilder.getAttributesCSS | protected function getAttributesCSS(array $attr)
{
$output = [];
foreach ($attr as $key => $values) {
if (in_array($key, $this->attributesCss) && $values !== '') {
$output[] = $key . '="' . $values . '"';
}
}
$implode = implode(' ', $output);
return $implode
? " $implode"
: '';
} | php | protected function getAttributesCSS(array $attr)
{
$output = [];
foreach ($attr as $key => $values) {
if (in_array($key, $this->attributesCss) && $values !== '') {
$output[] = $key . '="' . $values . '"';
}
}
$implode = implode(' ', $output);
return $implode
? " $implode"
: '';
} | [
"protected",
"function",
"getAttributesCSS",
"(",
"array",
"$",
"attr",
")",
"{",
"$",
"output",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"attr",
"as",
"$",
"key",
"=>",
"$",
"values",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"key",
",",
"$",
"... | Met en forme les attributs CSS pour les balises.
@param array $attr Listes des attributs enregistrés.
@return string | [
"Met",
"en",
"forme",
"les",
"attributs",
"CSS",
"pour",
"les",
"balises",
"."
] | d8dec2155bf9bc1d8ded176b4b65c183e2082049 | https://github.com/soosyze/framework/blob/d8dec2155bf9bc1d8ded176b4b65c183e2082049/src/Components/Form/FormBuilder.php#L830-L843 | train |
soosyze/framework | src/Components/Form/FormBuilder.php | FormBuilder.getAttributesInput | protected function getAttributesInput(array $attr)
{
$output = [];
foreach ($attr as $key => $values) {
if (empty($values)) {
continue;
}
if (in_array($key, $this->attributesUnique)) {
$output[] = $key;
} elseif (!in_array($key, $this->attributesCss) && $key !== 'selected') {
$output[] = $key . '="' . $values . '"';
}
}
$implode = implode(' ', $output);
return $implode
? " $implode"
: '';
} | php | protected function getAttributesInput(array $attr)
{
$output = [];
foreach ($attr as $key => $values) {
if (empty($values)) {
continue;
}
if (in_array($key, $this->attributesUnique)) {
$output[] = $key;
} elseif (!in_array($key, $this->attributesCss) && $key !== 'selected') {
$output[] = $key . '="' . $values . '"';
}
}
$implode = implode(' ', $output);
return $implode
? " $implode"
: '';
} | [
"protected",
"function",
"getAttributesInput",
"(",
"array",
"$",
"attr",
")",
"{",
"$",
"output",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"attr",
"as",
"$",
"key",
"=>",
"$",
"values",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"values",
")",
")",
... | Met en forme les attributs pour les balises inputs standards.
@param array $attr Listes des attributs enregistrés.
@return string | [
"Met",
"en",
"forme",
"les",
"attributs",
"pour",
"les",
"balises",
"inputs",
"standards",
"."
] | d8dec2155bf9bc1d8ded176b4b65c183e2082049 | https://github.com/soosyze/framework/blob/d8dec2155bf9bc1d8ded176b4b65c183e2082049/src/Components/Form/FormBuilder.php#L852-L870 | train |
soosyze/framework | src/Components/Validator/Rules/Size.php | Size.getSize | protected function getSize($value)
{
if (is_numeric($value)) {
/* numeric+0 = int|float */
return $value + 0;
}
if (is_string($value)) {
return strlen($value);
}
if (is_array($value)) {
return count($value);
}
if ($value instanceof UploadedFileInterface) {
if ($value->getError() !== UPLOAD_ERR_OK) {
return 0;
}
return $value->getStream()->getSize();
}
if (is_resource($value)) {
$stats = fstat($value);
return isset($stats[ 'size' ])
? $stats[ 'size' ]
: 0;
}
if (is_object($value) && method_exists($value, '__toString')) {
return strlen((string) $value);
}
throw new \InvalidArgumentException('The between function can not test this type of value.');
} | php | protected function getSize($value)
{
if (is_numeric($value)) {
/* numeric+0 = int|float */
return $value + 0;
}
if (is_string($value)) {
return strlen($value);
}
if (is_array($value)) {
return count($value);
}
if ($value instanceof UploadedFileInterface) {
if ($value->getError() !== UPLOAD_ERR_OK) {
return 0;
}
return $value->getStream()->getSize();
}
if (is_resource($value)) {
$stats = fstat($value);
return isset($stats[ 'size' ])
? $stats[ 'size' ]
: 0;
}
if (is_object($value) && method_exists($value, '__toString')) {
return strlen((string) $value);
}
throw new \InvalidArgumentException('The between function can not test this type of value.');
} | [
"protected",
"function",
"getSize",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"is_numeric",
"(",
"$",
"value",
")",
")",
"{",
"/* numeric+0 = int|float */",
"return",
"$",
"value",
"+",
"0",
";",
"}",
"if",
"(",
"is_string",
"(",
"$",
"value",
")",
")",
... | Retourne la longueur de valeur en fonction de son type.
@param array|float|int|object|numeric|ressource|string|UploadedFileInterface $value Valeur à tester.
@throws \InvalidArgumentException La fonction max ne peut pas tester pas ce type de valeur.
@return int|float Longueur. | [
"Retourne",
"la",
"longueur",
"de",
"valeur",
"en",
"fonction",
"de",
"son",
"type",
"."
] | d8dec2155bf9bc1d8ded176b4b65c183e2082049 | https://github.com/soosyze/framework/blob/d8dec2155bf9bc1d8ded176b4b65c183e2082049/src/Components/Validator/Rules/Size.php#L30-L61 | train |
ScriptFUSION/ByteFormatter | src/Byte/ByteFormatter.php | ByteFormatter.format | public function format($bytes, $precision = null)
{
// Use default precision when not specified.
$precision === null && $precision = $this->getPrecision();
$log = log($bytes, $this->getBase());
$exponent = $this->hasFixedExponent() ? $this->getFixedExponent() : max(0, $log|0);
$value = round(pow($this->getBase(), $log - $exponent), $precision);
$units = $this->getUnitDecorator()->decorate($exponent, $this->getBase(), $value);
return trim(sprintf($this->sprintfFormat, $this->formatValue($value, $precision), $units));
} | php | public function format($bytes, $precision = null)
{
// Use default precision when not specified.
$precision === null && $precision = $this->getPrecision();
$log = log($bytes, $this->getBase());
$exponent = $this->hasFixedExponent() ? $this->getFixedExponent() : max(0, $log|0);
$value = round(pow($this->getBase(), $log - $exponent), $precision);
$units = $this->getUnitDecorator()->decorate($exponent, $this->getBase(), $value);
return trim(sprintf($this->sprintfFormat, $this->formatValue($value, $precision), $units));
} | [
"public",
"function",
"format",
"(",
"$",
"bytes",
",",
"$",
"precision",
"=",
"null",
")",
"{",
"// Use default precision when not specified.",
"$",
"precision",
"===",
"null",
"&&",
"$",
"precision",
"=",
"$",
"this",
"->",
"getPrecision",
"(",
")",
";",
"... | Formats the specified number of bytes as a human-readable string.
@param int $bytes Number of bytes.
@param int|null $precision Optional. Number of fractional digits.
@return string Formatted bytes. | [
"Formats",
"the",
"specified",
"number",
"of",
"bytes",
"as",
"a",
"human",
"-",
"readable",
"string",
"."
] | f030d5be5e06bdd28e0ed82fc27274f57f3eebb3 | https://github.com/ScriptFUSION/ByteFormatter/blob/f030d5be5e06bdd28e0ed82fc27274f57f3eebb3/src/Byte/ByteFormatter.php#L57-L68 | train |
ScriptFUSION/ByteFormatter | src/Byte/ByteFormatter.php | ByteFormatter.formatValue | private function formatValue($value, $precision)
{
$formatted = sprintf("%0.${precision}F", $value);
if ($this->hasAutomaticPrecision()) {
// [0 => integer part, 1 => fractional part].
$formattedParts = explode('.', $formatted);
if (isset($formattedParts[1])) {
// Strip trailing 0s in fractional part.
if (!$formattedParts[1] = chop($formattedParts[1], '0')) {
// Remove fractional part.
unset($formattedParts[1]);
}
$formatted = join('.', $formattedParts);
}
}
return $formatted;
} | php | private function formatValue($value, $precision)
{
$formatted = sprintf("%0.${precision}F", $value);
if ($this->hasAutomaticPrecision()) {
// [0 => integer part, 1 => fractional part].
$formattedParts = explode('.', $formatted);
if (isset($formattedParts[1])) {
// Strip trailing 0s in fractional part.
if (!$formattedParts[1] = chop($formattedParts[1], '0')) {
// Remove fractional part.
unset($formattedParts[1]);
}
$formatted = join('.', $formattedParts);
}
}
return $formatted;
} | [
"private",
"function",
"formatValue",
"(",
"$",
"value",
",",
"$",
"precision",
")",
"{",
"$",
"formatted",
"=",
"sprintf",
"(",
"\"%0.${precision}F\"",
",",
"$",
"value",
")",
";",
"if",
"(",
"$",
"this",
"->",
"hasAutomaticPrecision",
"(",
")",
")",
"{... | Formats the specified number with the specified precision.
If precision scaling is enabled the precision may be reduced when it
contains insignificant digits. If the fractional part is zero it will
be completely removed.
@param float $value Number.
@param $precision Number of fractional digits.
@return string Formatted number. | [
"Formats",
"the",
"specified",
"number",
"with",
"the",
"specified",
"precision",
"."
] | f030d5be5e06bdd28e0ed82fc27274f57f3eebb3 | https://github.com/ScriptFUSION/ByteFormatter/blob/f030d5be5e06bdd28e0ed82fc27274f57f3eebb3/src/Byte/ByteFormatter.php#L82-L102 | train |
mikemirten/JsonApi | src/Document/Behaviour/RelationshipsContainer.php | RelationshipsContainer.relationshipsToArray | protected function relationshipsToArray(): array
{
$relationships = [];
foreach ($this->relationships as $name => $relationship)
{
$relationships[$name] = $relationship->toArray();
}
return $relationships;
} | php | protected function relationshipsToArray(): array
{
$relationships = [];
foreach ($this->relationships as $name => $relationship)
{
$relationships[$name] = $relationship->toArray();
}
return $relationships;
} | [
"protected",
"function",
"relationshipsToArray",
"(",
")",
":",
"array",
"{",
"$",
"relationships",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"relationships",
"as",
"$",
"name",
"=>",
"$",
"relationship",
")",
"{",
"$",
"relationships",
"[",
... | Cast relationships to an array
@return array | [
"Cast",
"relationships",
"to",
"an",
"array"
] | a3c1baf8f753c040f24e4522495b7d34565e6560 | https://github.com/mikemirten/JsonApi/blob/a3c1baf8f753c040f24e4522495b7d34565e6560/src/Document/Behaviour/RelationshipsContainer.php#L102-L112 | train |
mikemirten/JsonApi | src/HttpClient/Decorator/SymfonyEventDispatcherDecorator.php | SymfonyEventDispatcherDecorator.dispatchOnRequest | protected function dispatchOnRequest(RequestInterface $request): RequestInterface
{
$requestEvent = new RequestEvent($request);
$this->dispatcher->dispatch($this->requestEvent, $requestEvent);
return $requestEvent->getRequest();
} | php | protected function dispatchOnRequest(RequestInterface $request): RequestInterface
{
$requestEvent = new RequestEvent($request);
$this->dispatcher->dispatch($this->requestEvent, $requestEvent);
return $requestEvent->getRequest();
} | [
"protected",
"function",
"dispatchOnRequest",
"(",
"RequestInterface",
"$",
"request",
")",
":",
"RequestInterface",
"{",
"$",
"requestEvent",
"=",
"new",
"RequestEvent",
"(",
"$",
"request",
")",
";",
"$",
"this",
"->",
"dispatcher",
"->",
"dispatch",
"(",
"$... | Dispatch on-request event
@param RequestInterface $request
@return RequestInterface | [
"Dispatch",
"on",
"-",
"request",
"event"
] | a3c1baf8f753c040f24e4522495b7d34565e6560 | https://github.com/mikemirten/JsonApi/blob/a3c1baf8f753c040f24e4522495b7d34565e6560/src/HttpClient/Decorator/SymfonyEventDispatcherDecorator.php#L125-L131 | train |
mikemirten/JsonApi | src/HttpClient/Decorator/SymfonyEventDispatcherDecorator.php | SymfonyEventDispatcherDecorator.dispatchOnResponse | protected function dispatchOnResponse(ResponseInterface $response): ResponseInterface
{
$responseEvent = new ResponseEvent($response);
$this->dispatcher->dispatch($this->responseEvent, $responseEvent);
return $responseEvent->getResponse();
} | php | protected function dispatchOnResponse(ResponseInterface $response): ResponseInterface
{
$responseEvent = new ResponseEvent($response);
$this->dispatcher->dispatch($this->responseEvent, $responseEvent);
return $responseEvent->getResponse();
} | [
"protected",
"function",
"dispatchOnResponse",
"(",
"ResponseInterface",
"$",
"response",
")",
":",
"ResponseInterface",
"{",
"$",
"responseEvent",
"=",
"new",
"ResponseEvent",
"(",
"$",
"response",
")",
";",
"$",
"this",
"->",
"dispatcher",
"->",
"dispatch",
"(... | Dispatch on-response event
@param ResponseInterface $response
@return ResponseInterface | [
"Dispatch",
"on",
"-",
"response",
"event"
] | a3c1baf8f753c040f24e4522495b7d34565e6560 | https://github.com/mikemirten/JsonApi/blob/a3c1baf8f753c040f24e4522495b7d34565e6560/src/HttpClient/Decorator/SymfonyEventDispatcherDecorator.php#L139-L145 | train |
aimeos/ai-typo3 | lib/custom/src/MShop/Customer/Manager/Group/Typo3.php | Typo3.saveItem | public function saveItem( \Aimeos\MShop\Common\Item\Iface $item, $fetch = true )
{
self::checkClass( \Aimeos\MShop\Customer\Item\Group\Iface::class, $item );
if( !$item->isModified() ) {
return $item;
}
$context = $this->getContext();
$dbm = $context->getDatabaseManager();
$dbname = $this->getResourceName();
$conn = $dbm->acquire( $dbname );
try
{
$id = $item->getId();
if( $id === null )
{
/** mshop/customer/manager/group/typo3/insert/mysql
* Inserts a new customer group record into the database table
*
* @see mshop/customer/manager/group/typo3/insert/ansi
*/
/** mshop/customer/manager/group/typo3/insert/ansi
* Inserts a new customer group record into the database table
*
* Items with no ID yet (i.e. the ID is NULL) will be created in
* the database and the newly created ID retrieved afterwards
* using the "newid" SQL statement.
*
* The SQL statement must be a string suitable for being used as
* prepared statement. It must include question marks for binding
* the values from the customer group item to the statement before
* they are sent to the database server. The number of question
* marks must be the same as the number of columns listed in the
* INSERT statement. The order of the columns must correspond to
* the order in the saveItems() method, so the correct values are
* bound to the columns.
*
* The SQL statement should conform to the ANSI standard to be
* compatible with most relational database systems. This also
* includes using double quotes for table and column names.
*
* @param string SQL statement for inserting records
* @since 2015.08
* @category Developer
* @see mshop/customer/manager/group/typo3/update/ansi
* @see mshop/customer/manager/group/typo3/newid/ansi
* @see mshop/customer/manager/group/typo3/delete/ansi
* @see mshop/customer/manager/group/typo3/search/ansi
* @see mshop/customer/manager/group/typo3/count/ansi
*/
$path = 'mshop/customer/manager/group/typo3/insert';
}
else
{
/** mshop/customer/manager/group/typo3/update/mysql
* Updates an existing customer group record in the database
*
* @see mshop/customer/manager/group/typo3/update/ansi
*/
/** mshop/customer/manager/group/typo3/update/ansi
* Updates an existing customer group record in the database
*
* Items which already have an ID (i.e. the ID is not NULL) will
* be updated in the database.
*
* The SQL statement must be a string suitable for being used as
* prepared statement. It must include question marks for binding
* the values from the customer group item to the statement before
* they are sent to the database server. The order of the columns
* must correspond to the order in the saveItems() method, so the
* correct values are bound to the columns.
*
* The SQL statement should conform to the ANSI standard to be
* compatible with most relational database systems. This also
* includes using double quotes for table and column names.
*
* @param string SQL statement for updating records
* @since 2015.08
* @category Developer
* @see mshop/customer/manager/group/typo3/insert/ansi
* @see mshop/customer/manager/group/typo3/newid/ansi
* @see mshop/customer/manager/group/typo3/delete/ansi
* @see mshop/customer/manager/group/typo3/search/ansi
* @see mshop/customer/manager/group/typo3/count/ansi
*/
$path = 'mshop/customer/manager/group/typo3/update';
}
$stmt = $this->getCachedStatement( $conn, $path );
$stmt->bind( 1, $this->pid, \Aimeos\MW\DB\Statement\Base::PARAM_INT );
$stmt->bind( 2, $item->getCode() );
$stmt->bind( 3, $item->getLabel() );
$stmt->bind( 4, time(), \Aimeos\MW\DB\Statement\Base::PARAM_INT ); // mtime
if( $id !== null ) {
$stmt->bind( 5, $id, \Aimeos\MW\DB\Statement\Base::PARAM_INT );
$item->setId( $id );
} else {
$stmt->bind( 5, time() ); // ctime
}
$stmt->execute()->finish();
if( $id === null && $fetch === true )
{
/** mshop/customer/manager/group/typo3/newid/mysql
* Retrieves the ID generated by the database when inserting a new record
*
* @see mshop/customer/manager/group/typo3/newid/ansi
*/
/** mshop/customer/manager/group/typo3/newid/ansi
* Retrieves the ID generated by the database when inserting a new record
*
* As soon as a new record is inserted into the database table,
* the database server generates a new and unique identifier for
* that record. This ID can be used for retrieving, updating and
* deleting that specific record from the table again.
*
* For MySQL:
* SELECT LAST_INSERT_ID()
* For PostgreSQL:
* SELECT currval('seq_mcus_id')
* For SQL Server:
* SELECT SCOPE_IDENTITY()
* For Oracle:
* SELECT "seq_mcus_id".CURRVAL FROM DUAL
*
* There's no way to retrive the new ID by a SQL statements that
* fits for most database servers as they implement their own
* specific way.
*
* @param string SQL statement for retrieving the last inserted record ID
* @since 2015.08
* @category Developer
* @see mshop/customer/manager/group/typo3/insert/ansi
* @see mshop/customer/manager/group/typo3/update/ansi
* @see mshop/customer/manager/group/typo3/delete/ansi
* @see mshop/customer/manager/group/typo3/search/ansi
* @see mshop/customer/manager/group/typo3/count/ansi
*/
$path = 'mshop/customer/manager/group/typo3/newid';
$item->setId( $this->newId( $conn, $path ) );
}
$dbm->release( $conn, $dbname );
}
catch( \Exception $e )
{
$dbm->release( $conn, $dbname );
throw $e;
}
return $item;
} | php | public function saveItem( \Aimeos\MShop\Common\Item\Iface $item, $fetch = true )
{
self::checkClass( \Aimeos\MShop\Customer\Item\Group\Iface::class, $item );
if( !$item->isModified() ) {
return $item;
}
$context = $this->getContext();
$dbm = $context->getDatabaseManager();
$dbname = $this->getResourceName();
$conn = $dbm->acquire( $dbname );
try
{
$id = $item->getId();
if( $id === null )
{
/** mshop/customer/manager/group/typo3/insert/mysql
* Inserts a new customer group record into the database table
*
* @see mshop/customer/manager/group/typo3/insert/ansi
*/
/** mshop/customer/manager/group/typo3/insert/ansi
* Inserts a new customer group record into the database table
*
* Items with no ID yet (i.e. the ID is NULL) will be created in
* the database and the newly created ID retrieved afterwards
* using the "newid" SQL statement.
*
* The SQL statement must be a string suitable for being used as
* prepared statement. It must include question marks for binding
* the values from the customer group item to the statement before
* they are sent to the database server. The number of question
* marks must be the same as the number of columns listed in the
* INSERT statement. The order of the columns must correspond to
* the order in the saveItems() method, so the correct values are
* bound to the columns.
*
* The SQL statement should conform to the ANSI standard to be
* compatible with most relational database systems. This also
* includes using double quotes for table and column names.
*
* @param string SQL statement for inserting records
* @since 2015.08
* @category Developer
* @see mshop/customer/manager/group/typo3/update/ansi
* @see mshop/customer/manager/group/typo3/newid/ansi
* @see mshop/customer/manager/group/typo3/delete/ansi
* @see mshop/customer/manager/group/typo3/search/ansi
* @see mshop/customer/manager/group/typo3/count/ansi
*/
$path = 'mshop/customer/manager/group/typo3/insert';
}
else
{
/** mshop/customer/manager/group/typo3/update/mysql
* Updates an existing customer group record in the database
*
* @see mshop/customer/manager/group/typo3/update/ansi
*/
/** mshop/customer/manager/group/typo3/update/ansi
* Updates an existing customer group record in the database
*
* Items which already have an ID (i.e. the ID is not NULL) will
* be updated in the database.
*
* The SQL statement must be a string suitable for being used as
* prepared statement. It must include question marks for binding
* the values from the customer group item to the statement before
* they are sent to the database server. The order of the columns
* must correspond to the order in the saveItems() method, so the
* correct values are bound to the columns.
*
* The SQL statement should conform to the ANSI standard to be
* compatible with most relational database systems. This also
* includes using double quotes for table and column names.
*
* @param string SQL statement for updating records
* @since 2015.08
* @category Developer
* @see mshop/customer/manager/group/typo3/insert/ansi
* @see mshop/customer/manager/group/typo3/newid/ansi
* @see mshop/customer/manager/group/typo3/delete/ansi
* @see mshop/customer/manager/group/typo3/search/ansi
* @see mshop/customer/manager/group/typo3/count/ansi
*/
$path = 'mshop/customer/manager/group/typo3/update';
}
$stmt = $this->getCachedStatement( $conn, $path );
$stmt->bind( 1, $this->pid, \Aimeos\MW\DB\Statement\Base::PARAM_INT );
$stmt->bind( 2, $item->getCode() );
$stmt->bind( 3, $item->getLabel() );
$stmt->bind( 4, time(), \Aimeos\MW\DB\Statement\Base::PARAM_INT ); // mtime
if( $id !== null ) {
$stmt->bind( 5, $id, \Aimeos\MW\DB\Statement\Base::PARAM_INT );
$item->setId( $id );
} else {
$stmt->bind( 5, time() ); // ctime
}
$stmt->execute()->finish();
if( $id === null && $fetch === true )
{
/** mshop/customer/manager/group/typo3/newid/mysql
* Retrieves the ID generated by the database when inserting a new record
*
* @see mshop/customer/manager/group/typo3/newid/ansi
*/
/** mshop/customer/manager/group/typo3/newid/ansi
* Retrieves the ID generated by the database when inserting a new record
*
* As soon as a new record is inserted into the database table,
* the database server generates a new and unique identifier for
* that record. This ID can be used for retrieving, updating and
* deleting that specific record from the table again.
*
* For MySQL:
* SELECT LAST_INSERT_ID()
* For PostgreSQL:
* SELECT currval('seq_mcus_id')
* For SQL Server:
* SELECT SCOPE_IDENTITY()
* For Oracle:
* SELECT "seq_mcus_id".CURRVAL FROM DUAL
*
* There's no way to retrive the new ID by a SQL statements that
* fits for most database servers as they implement their own
* specific way.
*
* @param string SQL statement for retrieving the last inserted record ID
* @since 2015.08
* @category Developer
* @see mshop/customer/manager/group/typo3/insert/ansi
* @see mshop/customer/manager/group/typo3/update/ansi
* @see mshop/customer/manager/group/typo3/delete/ansi
* @see mshop/customer/manager/group/typo3/search/ansi
* @see mshop/customer/manager/group/typo3/count/ansi
*/
$path = 'mshop/customer/manager/group/typo3/newid';
$item->setId( $this->newId( $conn, $path ) );
}
$dbm->release( $conn, $dbname );
}
catch( \Exception $e )
{
$dbm->release( $conn, $dbname );
throw $e;
}
return $item;
} | [
"public",
"function",
"saveItem",
"(",
"\\",
"Aimeos",
"\\",
"MShop",
"\\",
"Common",
"\\",
"Item",
"\\",
"Iface",
"$",
"item",
",",
"$",
"fetch",
"=",
"true",
")",
"{",
"self",
"::",
"checkClass",
"(",
"\\",
"Aimeos",
"\\",
"MShop",
"\\",
"Customer",
... | Inserts a new or updates an existing customer group item
@param \Aimeos\MShop\Customer\Item\Group\Iface $item Customer group item
@param boolean $fetch True if the new ID should be returned in the item | [
"Inserts",
"a",
"new",
"or",
"updates",
"an",
"existing",
"customer",
"group",
"item"
] | 74902c312900c8c5659acd4e85fea61ed1cd7c9a | https://github.com/aimeos/ai-typo3/blob/74902c312900c8c5659acd4e85fea61ed1cd7c9a/lib/custom/src/MShop/Customer/Manager/Group/Typo3.php#L182-L343 | train |
mikemirten/JsonApi | src/Mapper/Definition/AnnotationProcessor/RelationshipProcessor.php | RelationshipProcessor.process | public function process(\ReflectionClass $reflection, Definition $definition)
{
foreach ($reflection->getProperties() as $property)
{
$this->processProperty($property, $definition);
}
} | php | public function process(\ReflectionClass $reflection, Definition $definition)
{
foreach ($reflection->getProperties() as $property)
{
$this->processProperty($property, $definition);
}
} | [
"public",
"function",
"process",
"(",
"\\",
"ReflectionClass",
"$",
"reflection",
",",
"Definition",
"$",
"definition",
")",
"{",
"foreach",
"(",
"$",
"reflection",
"->",
"getProperties",
"(",
")",
"as",
"$",
"property",
")",
"{",
"$",
"this",
"->",
"proce... | Process properties of class
@param \ReflectionClass $reflection
@param Definition $definition | [
"Process",
"properties",
"of",
"class"
] | a3c1baf8f753c040f24e4522495b7d34565e6560 | https://github.com/mikemirten/JsonApi/blob/a3c1baf8f753c040f24e4522495b7d34565e6560/src/Mapper/Definition/AnnotationProcessor/RelationshipProcessor.php#L23-L29 | train |
mikemirten/JsonApi | src/Mapper/Definition/AnnotationProcessor/RelationshipProcessor.php | RelationshipProcessor.handleDataControl | protected function handleDataControl(RelationshipAnnotation $annotation, Relationship $relationship)
{
$relationship->setIncludeData($annotation->dataAllowed);
$relationship->setDataLimit($annotation->dataLimit);
} | php | protected function handleDataControl(RelationshipAnnotation $annotation, Relationship $relationship)
{
$relationship->setIncludeData($annotation->dataAllowed);
$relationship->setDataLimit($annotation->dataLimit);
} | [
"protected",
"function",
"handleDataControl",
"(",
"RelationshipAnnotation",
"$",
"annotation",
",",
"Relationship",
"$",
"relationship",
")",
"{",
"$",
"relationship",
"->",
"setIncludeData",
"(",
"$",
"annotation",
"->",
"dataAllowed",
")",
";",
"$",
"relationship... | Handle control of data-section
@param RelationshipAnnotation $annotation
@param Relationship $relationship | [
"Handle",
"control",
"of",
"data",
"-",
"section"
] | a3c1baf8f753c040f24e4522495b7d34565e6560 | https://github.com/mikemirten/JsonApi/blob/a3c1baf8f753c040f24e4522495b7d34565e6560/src/Mapper/Definition/AnnotationProcessor/RelationshipProcessor.php#L101-L105 | train |
mikemirten/JsonApi | src/Mapper/Definition/AnnotationProcessor/RelationshipProcessor.php | RelationshipProcessor.resolveType | protected function resolveType(RelationshipAnnotation $annotation): int
{
if ($annotation->type === RelationshipAnnotation::TYPE_ONE) {
return Relationship::TYPE_X_TO_ONE;
}
if ($annotation->type === RelationshipAnnotation::TYPE_MANY) {
return Relationship::TYPE_X_TO_MANY;
}
throw new \LogicException(sprintf('Invalid type of relation "%s" defined.', $annotation->type));
} | php | protected function resolveType(RelationshipAnnotation $annotation): int
{
if ($annotation->type === RelationshipAnnotation::TYPE_ONE) {
return Relationship::TYPE_X_TO_ONE;
}
if ($annotation->type === RelationshipAnnotation::TYPE_MANY) {
return Relationship::TYPE_X_TO_MANY;
}
throw new \LogicException(sprintf('Invalid type of relation "%s" defined.', $annotation->type));
} | [
"protected",
"function",
"resolveType",
"(",
"RelationshipAnnotation",
"$",
"annotation",
")",
":",
"int",
"{",
"if",
"(",
"$",
"annotation",
"->",
"type",
"===",
"RelationshipAnnotation",
"::",
"TYPE_ONE",
")",
"{",
"return",
"Relationship",
"::",
"TYPE_X_TO_ONE"... | Resolve type of relationship
@param RelationshipAnnotation $annotation
@return int | [
"Resolve",
"type",
"of",
"relationship"
] | a3c1baf8f753c040f24e4522495b7d34565e6560 | https://github.com/mikemirten/JsonApi/blob/a3c1baf8f753c040f24e4522495b7d34565e6560/src/Mapper/Definition/AnnotationProcessor/RelationshipProcessor.php#L113-L124 | train |
maximebf/ConsoleKit | src/ConsoleKit/Console.php | Console.addCommand | public function addCommand($callback, $alias = null, $default = false)
{
if ($alias instanceof \Closure && is_string($callback)) {
list($alias, $callback) = array($callback, $alias);
}
if (is_array($callback) && is_string($callback[0])) {
$callback = implode('::', $callback);
}
$name = '';
if (is_string($callback)) {
$name = $callback;
if (is_callable($callback)) {
if (strpos($callback, '::') !== false) {
list($classname, $methodname) = explode('::', $callback);
$name = Utils::dashized($methodname);
} else {
$name = strtolower(trim(str_replace('_', '-', $name), '-'));
}
} else {
if (substr($name, -7) === 'Command') {
$name = substr($name, 0, -7);
}
$name = Utils::dashized(basename(str_replace('\\', '/', $name)));
}
} else if (is_object($callback) && !($callback instanceof Closure)) {
$classname = get_class($callback);
if (!($callback instanceof Command)) {
throw new ConsoleException("'$classname' must inherit from 'ConsoleKit\Command'");
}
if (substr($classname, -7) === 'Command') {
$classname = substr($classname, 0, -7);
}
$name = Utils::dashized(basename(str_replace('\\', '/', $classname)));
} else if (!$alias) {
throw new ConsoleException("Commands using closures must have an alias");
}
$name = $alias ?: $name;
$this->commands[$name] = $callback;
if ($default) {
$this->defaultCommand = $name;
}
return $this;
} | php | public function addCommand($callback, $alias = null, $default = false)
{
if ($alias instanceof \Closure && is_string($callback)) {
list($alias, $callback) = array($callback, $alias);
}
if (is_array($callback) && is_string($callback[0])) {
$callback = implode('::', $callback);
}
$name = '';
if (is_string($callback)) {
$name = $callback;
if (is_callable($callback)) {
if (strpos($callback, '::') !== false) {
list($classname, $methodname) = explode('::', $callback);
$name = Utils::dashized($methodname);
} else {
$name = strtolower(trim(str_replace('_', '-', $name), '-'));
}
} else {
if (substr($name, -7) === 'Command') {
$name = substr($name, 0, -7);
}
$name = Utils::dashized(basename(str_replace('\\', '/', $name)));
}
} else if (is_object($callback) && !($callback instanceof Closure)) {
$classname = get_class($callback);
if (!($callback instanceof Command)) {
throw new ConsoleException("'$classname' must inherit from 'ConsoleKit\Command'");
}
if (substr($classname, -7) === 'Command') {
$classname = substr($classname, 0, -7);
}
$name = Utils::dashized(basename(str_replace('\\', '/', $classname)));
} else if (!$alias) {
throw new ConsoleException("Commands using closures must have an alias");
}
$name = $alias ?: $name;
$this->commands[$name] = $callback;
if ($default) {
$this->defaultCommand = $name;
}
return $this;
} | [
"public",
"function",
"addCommand",
"(",
"$",
"callback",
",",
"$",
"alias",
"=",
"null",
",",
"$",
"default",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"alias",
"instanceof",
"\\",
"Closure",
"&&",
"is_string",
"(",
"$",
"callback",
")",
")",
"{",
"li... | Registers a command
@param callback $callback Associated class name, function name, Command instance or closure
@param string $alias Command name to be used in the shell
@param bool $default True to set the command as the default one
@return Console | [
"Registers",
"a",
"command"
] | a05c0c5a4c48882599d59323314ac963a836d58f | https://github.com/maximebf/ConsoleKit/blob/a05c0c5a4c48882599d59323314ac963a836d58f/src/ConsoleKit/Console.php#L160-L204 | train |
maximebf/ConsoleKit | src/ConsoleKit/Console.php | Console.addCommandsFromDir | public function addCommandsFromDir($dir, $namespace = '', $includeFiles = false)
{
foreach (new DirectoryIterator($dir) as $file) {
$filename = $file->getFilename();
if ($file->isDir() || substr($filename, 0, 1) === '.' || strlen($filename) <= 11
|| strtolower(substr($filename, -11)) !== 'command.php') {
continue;
}
if ($includeFiles) {
include $file->getPathname();
}
$className = trim($namespace . '\\' . substr($filename, 0, -4), '\\');
$this->addCommand($className);
}
return $this;
} | php | public function addCommandsFromDir($dir, $namespace = '', $includeFiles = false)
{
foreach (new DirectoryIterator($dir) as $file) {
$filename = $file->getFilename();
if ($file->isDir() || substr($filename, 0, 1) === '.' || strlen($filename) <= 11
|| strtolower(substr($filename, -11)) !== 'command.php') {
continue;
}
if ($includeFiles) {
include $file->getPathname();
}
$className = trim($namespace . '\\' . substr($filename, 0, -4), '\\');
$this->addCommand($className);
}
return $this;
} | [
"public",
"function",
"addCommandsFromDir",
"(",
"$",
"dir",
",",
"$",
"namespace",
"=",
"''",
",",
"$",
"includeFiles",
"=",
"false",
")",
"{",
"foreach",
"(",
"new",
"DirectoryIterator",
"(",
"$",
"dir",
")",
"as",
"$",
"file",
")",
"{",
"$",
"filena... | Registers commands from a directory
@param string $dir
@param string $namespace
@param bool $includeFiles
@return Console | [
"Registers",
"commands",
"from",
"a",
"directory"
] | a05c0c5a4c48882599d59323314ac963a836d58f | https://github.com/maximebf/ConsoleKit/blob/a05c0c5a4c48882599d59323314ac963a836d58f/src/ConsoleKit/Console.php#L214-L229 | train |
maximebf/ConsoleKit | src/ConsoleKit/Console.php | Console.writeln | public function writeln($text = '', $pipe = TextWriter::STDOUT)
{
$this->textWriter->writeln($text, $pipe);
return $this;
} | php | public function writeln($text = '', $pipe = TextWriter::STDOUT)
{
$this->textWriter->writeln($text, $pipe);
return $this;
} | [
"public",
"function",
"writeln",
"(",
"$",
"text",
"=",
"''",
",",
"$",
"pipe",
"=",
"TextWriter",
"::",
"STDOUT",
")",
"{",
"$",
"this",
"->",
"textWriter",
"->",
"writeln",
"(",
"$",
"text",
",",
"$",
"pipe",
")",
";",
"return",
"$",
"this",
";",... | Writes a line of text
@see TextWriter::writeln()
@param string $text
@param array $formatOptions
@return Console | [
"Writes",
"a",
"line",
"of",
"text"
] | a05c0c5a4c48882599d59323314ac963a836d58f | https://github.com/maximebf/ConsoleKit/blob/a05c0c5a4c48882599d59323314ac963a836d58f/src/ConsoleKit/Console.php#L386-L390 | train |
maximebf/ConsoleKit | src/ConsoleKit/Console.php | Console.writeException | public function writeException(\Exception $e)
{
if ($this->verboseException) {
$text = sprintf("[%s]\n%s\nIn %s at line %s\n%s",
get_class($e),
$e->getMessage(),
$e->getFile(),
$e->getLine(),
$e->getTraceAsString()
);
} else {
$text = sprintf("\n[%s]\n%s\n", get_class($e), $e->getMessage());
}
$box = new Widgets\Box($this->textWriter, $text, '');
$out = Colors::colorizeLines($box, Colors::WHITE, Colors::RED);
$out = TextFormater::apply($out, array('indent' => 2));
$this->textWriter->writeln($out);
return $this;
} | php | public function writeException(\Exception $e)
{
if ($this->verboseException) {
$text = sprintf("[%s]\n%s\nIn %s at line %s\n%s",
get_class($e),
$e->getMessage(),
$e->getFile(),
$e->getLine(),
$e->getTraceAsString()
);
} else {
$text = sprintf("\n[%s]\n%s\n", get_class($e), $e->getMessage());
}
$box = new Widgets\Box($this->textWriter, $text, '');
$out = Colors::colorizeLines($box, Colors::WHITE, Colors::RED);
$out = TextFormater::apply($out, array('indent' => 2));
$this->textWriter->writeln($out);
return $this;
} | [
"public",
"function",
"writeException",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"verboseException",
")",
"{",
"$",
"text",
"=",
"sprintf",
"(",
"\"[%s]\\n%s\\nIn %s at line %s\\n%s\"",
",",
"get_class",
"(",
"$",
"e",
")",
... | Writes an error message to stderr
@param \Exception $e
@return Console | [
"Writes",
"an",
"error",
"message",
"to",
"stderr"
] | a05c0c5a4c48882599d59323314ac963a836d58f | https://github.com/maximebf/ConsoleKit/blob/a05c0c5a4c48882599d59323314ac963a836d58f/src/ConsoleKit/Console.php#L398-L417 | train |
payneteasy/php-library-payneteasy-api | source/PaynetEasy/PaynetEasyApi/Query/Prototype/Query.php | Query.validatePaymentTransaction | protected function validatePaymentTransaction(PaymentTransaction $paymentTransaction)
{
$this->validateQueryConfig($paymentTransaction);
$errorMessage = '';
$missedFields = array();
$invalidFields = array();
foreach (static::$requestFieldsDefinition as $fieldDescription)
{
list($fieldName, $propertyPath, $isFieldRequired, $validationRule) = $fieldDescription;
$fieldValue = PropertyAccessor::getValue($paymentTransaction, $propertyPath, false);
if (!empty($fieldValue))
{
try
{
Validator::validateByRule($fieldValue, $validationRule);
}
catch (ValidationException $e)
{
$invalidFields[] = "Field '{$fieldName}' from property path '{$propertyPath}', {$e->getMessage()}.";
}
}
elseif ($isFieldRequired)
{
$missedFields[] = "Field '{$fieldName}' from property path '{$propertyPath}' missed or empty.";
}
}
if (!empty($missedFields))
{
$errorMessage .= "Some required fields missed or empty in PaymentTransaction: \n" .
implode("\n", $missedFields) . "\n";
}
if (!empty($invalidFields))
{
$errorMessage .= "Some fields invalid in PaymentTransaction: \n" .
implode("\n", $invalidFields) . "\n";
}
if (!empty($errorMessage))
{
throw new ValidationException($errorMessage);
}
} | php | protected function validatePaymentTransaction(PaymentTransaction $paymentTransaction)
{
$this->validateQueryConfig($paymentTransaction);
$errorMessage = '';
$missedFields = array();
$invalidFields = array();
foreach (static::$requestFieldsDefinition as $fieldDescription)
{
list($fieldName, $propertyPath, $isFieldRequired, $validationRule) = $fieldDescription;
$fieldValue = PropertyAccessor::getValue($paymentTransaction, $propertyPath, false);
if (!empty($fieldValue))
{
try
{
Validator::validateByRule($fieldValue, $validationRule);
}
catch (ValidationException $e)
{
$invalidFields[] = "Field '{$fieldName}' from property path '{$propertyPath}', {$e->getMessage()}.";
}
}
elseif ($isFieldRequired)
{
$missedFields[] = "Field '{$fieldName}' from property path '{$propertyPath}' missed or empty.";
}
}
if (!empty($missedFields))
{
$errorMessage .= "Some required fields missed or empty in PaymentTransaction: \n" .
implode("\n", $missedFields) . "\n";
}
if (!empty($invalidFields))
{
$errorMessage .= "Some fields invalid in PaymentTransaction: \n" .
implode("\n", $invalidFields) . "\n";
}
if (!empty($errorMessage))
{
throw new ValidationException($errorMessage);
}
} | [
"protected",
"function",
"validatePaymentTransaction",
"(",
"PaymentTransaction",
"$",
"paymentTransaction",
")",
"{",
"$",
"this",
"->",
"validateQueryConfig",
"(",
"$",
"paymentTransaction",
")",
";",
"$",
"errorMessage",
"=",
"''",
";",
"$",
"missedFields",
"=",
... | Validates payment transaction before request constructing
@param PaymentTransaction $paymentTransaction Payment transaction for validation | [
"Validates",
"payment",
"transaction",
"before",
"request",
"constructing"
] | e3484aa37b6594231f59b1f43523603aa704f093 | https://github.com/payneteasy/php-library-payneteasy-api/blob/e3484aa37b6594231f59b1f43523603aa704f093/source/PaynetEasy/PaynetEasyApi/Query/Prototype/Query.php#L154-L201 | train |
payneteasy/php-library-payneteasy-api | source/PaynetEasy/PaynetEasyApi/Query/Prototype/Query.php | Query.paymentTransactionToRequest | protected function paymentTransactionToRequest(PaymentTransaction $paymentTransaction)
{
$requestFields = array();
foreach (static::$requestFieldsDefinition as $fieldDescription)
{
list($fieldName, $propertyPath) = $fieldDescription;
$fieldValue = PropertyAccessor::getValue($paymentTransaction, $propertyPath);
if (!empty($fieldValue))
{
$requestFields[$fieldName] = $fieldValue;
}
}
return new Request($requestFields);
} | php | protected function paymentTransactionToRequest(PaymentTransaction $paymentTransaction)
{
$requestFields = array();
foreach (static::$requestFieldsDefinition as $fieldDescription)
{
list($fieldName, $propertyPath) = $fieldDescription;
$fieldValue = PropertyAccessor::getValue($paymentTransaction, $propertyPath);
if (!empty($fieldValue))
{
$requestFields[$fieldName] = $fieldValue;
}
}
return new Request($requestFields);
} | [
"protected",
"function",
"paymentTransactionToRequest",
"(",
"PaymentTransaction",
"$",
"paymentTransaction",
")",
"{",
"$",
"requestFields",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"static",
"::",
"$",
"requestFieldsDefinition",
"as",
"$",
"fieldDescription",
... | Creates request from payment transaction
@param PaymentTransaction $paymentTransaction Payment transaction for request constructing
@return Request Request object | [
"Creates",
"request",
"from",
"payment",
"transaction"
] | e3484aa37b6594231f59b1f43523603aa704f093 | https://github.com/payneteasy/php-library-payneteasy-api/blob/e3484aa37b6594231f59b1f43523603aa704f093/source/PaynetEasy/PaynetEasyApi/Query/Prototype/Query.php#L210-L227 | train |
payneteasy/php-library-payneteasy-api | source/PaynetEasy/PaynetEasyApi/Query/Prototype/Query.php | Query.validateResponseOnSuccess | protected function validateResponseOnSuccess(PaymentTransaction $paymentTransaction, Response $response)
{
if ($response->getType() !== static::$successResponseType)
{
throw new ValidationException("Response type '{$response->getType()}' does not match " .
"success response type '" . static::$successResponseType . "'");
}
$missedFields = array();
foreach (static::$responseFieldsDefinition as $fieldName)
{
if (empty($response[$fieldName]))
{
$missedFields[] = $fieldName;
}
}
if (!empty($missedFields))
{
throw new ValidationException("Some required fields missed or empty in Response: " .
implode(', ', $missedFields) . ". \n");
}
$this->validateClientId($paymentTransaction, $response);
} | php | protected function validateResponseOnSuccess(PaymentTransaction $paymentTransaction, Response $response)
{
if ($response->getType() !== static::$successResponseType)
{
throw new ValidationException("Response type '{$response->getType()}' does not match " .
"success response type '" . static::$successResponseType . "'");
}
$missedFields = array();
foreach (static::$responseFieldsDefinition as $fieldName)
{
if (empty($response[$fieldName]))
{
$missedFields[] = $fieldName;
}
}
if (!empty($missedFields))
{
throw new ValidationException("Some required fields missed or empty in Response: " .
implode(', ', $missedFields) . ". \n");
}
$this->validateClientId($paymentTransaction, $response);
} | [
"protected",
"function",
"validateResponseOnSuccess",
"(",
"PaymentTransaction",
"$",
"paymentTransaction",
",",
"Response",
"$",
"response",
")",
"{",
"if",
"(",
"$",
"response",
"->",
"getType",
"(",
")",
"!==",
"static",
"::",
"$",
"successResponseType",
")",
... | Validates response before payment transaction updating
if payment transaction is processing or approved
@param PaymentTransaction $paymentTransaction Payment transaction
@param Response $response Response for validating | [
"Validates",
"response",
"before",
"payment",
"transaction",
"updating",
"if",
"payment",
"transaction",
"is",
"processing",
"or",
"approved"
] | e3484aa37b6594231f59b1f43523603aa704f093 | https://github.com/payneteasy/php-library-payneteasy-api/blob/e3484aa37b6594231f59b1f43523603aa704f093/source/PaynetEasy/PaynetEasyApi/Query/Prototype/Query.php#L256-L281 | train |
payneteasy/php-library-payneteasy-api | source/PaynetEasy/PaynetEasyApi/Query/Prototype/Query.php | Query.validateResponseOnError | protected function validateResponseOnError(PaymentTransaction $paymentTransaction, Response $response)
{
$allowedTypes = array(static::$successResponseType, 'error', 'validation-error');
if (!in_array($response->getType(), $allowedTypes))
{
throw new ValidationException("Unknown response type '{$response->getType()}'");
}
$this->validateClientId($paymentTransaction, $response);
} | php | protected function validateResponseOnError(PaymentTransaction $paymentTransaction, Response $response)
{
$allowedTypes = array(static::$successResponseType, 'error', 'validation-error');
if (!in_array($response->getType(), $allowedTypes))
{
throw new ValidationException("Unknown response type '{$response->getType()}'");
}
$this->validateClientId($paymentTransaction, $response);
} | [
"protected",
"function",
"validateResponseOnError",
"(",
"PaymentTransaction",
"$",
"paymentTransaction",
",",
"Response",
"$",
"response",
")",
"{",
"$",
"allowedTypes",
"=",
"array",
"(",
"static",
"::",
"$",
"successResponseType",
",",
"'error'",
",",
"'validatio... | Validates response before payment transaction updating
if payment transaction is not processing or approved
@param PaymentTransaction $paymentTransaction Payment transaction
@param Response $response Response for validating | [
"Validates",
"response",
"before",
"payment",
"transaction",
"updating",
"if",
"payment",
"transaction",
"is",
"not",
"processing",
"or",
"approved"
] | e3484aa37b6594231f59b1f43523603aa704f093 | https://github.com/payneteasy/php-library-payneteasy-api/blob/e3484aa37b6594231f59b1f43523603aa704f093/source/PaynetEasy/PaynetEasyApi/Query/Prototype/Query.php#L290-L300 | train |
payneteasy/php-library-payneteasy-api | source/PaynetEasy/PaynetEasyApi/Query/Prototype/Query.php | Query.updatePaymentTransactionOnSuccess | protected function updatePaymentTransactionOnSuccess(PaymentTransaction $paymentTransaction, Response $response)
{
$paymentTransaction->setStatus($response->getStatus());
$this->setPaynetId($paymentTransaction, $response);
} | php | protected function updatePaymentTransactionOnSuccess(PaymentTransaction $paymentTransaction, Response $response)
{
$paymentTransaction->setStatus($response->getStatus());
$this->setPaynetId($paymentTransaction, $response);
} | [
"protected",
"function",
"updatePaymentTransactionOnSuccess",
"(",
"PaymentTransaction",
"$",
"paymentTransaction",
",",
"Response",
"$",
"response",
")",
"{",
"$",
"paymentTransaction",
"->",
"setStatus",
"(",
"$",
"response",
"->",
"getStatus",
"(",
")",
")",
";",... | Updates payment transaction by query response data
if payment transaction is processing or approved
@param PaymentTransaction $paymentTransaction Payment transaction for updating
@param Response $response Response for payment transaction updating | [
"Updates",
"payment",
"transaction",
"by",
"query",
"response",
"data",
"if",
"payment",
"transaction",
"is",
"processing",
"or",
"approved"
] | e3484aa37b6594231f59b1f43523603aa704f093 | https://github.com/payneteasy/php-library-payneteasy-api/blob/e3484aa37b6594231f59b1f43523603aa704f093/source/PaynetEasy/PaynetEasyApi/Query/Prototype/Query.php#L309-L313 | train |
payneteasy/php-library-payneteasy-api | source/PaynetEasy/PaynetEasyApi/Query/Prototype/Query.php | Query.updatePaymentTransactionOnError | protected function updatePaymentTransactionOnError(PaymentTransaction $paymentTransaction, Response $response)
{
if ($response->isDeclined())
{
$paymentTransaction->setStatus($response->getStatus());
}
else
{
$paymentTransaction->setStatus(PaymentTransaction::STATUS_ERROR);
}
$paymentTransaction->addError($response->getError());
$this->setPaynetId($paymentTransaction, $response);
} | php | protected function updatePaymentTransactionOnError(PaymentTransaction $paymentTransaction, Response $response)
{
if ($response->isDeclined())
{
$paymentTransaction->setStatus($response->getStatus());
}
else
{
$paymentTransaction->setStatus(PaymentTransaction::STATUS_ERROR);
}
$paymentTransaction->addError($response->getError());
$this->setPaynetId($paymentTransaction, $response);
} | [
"protected",
"function",
"updatePaymentTransactionOnError",
"(",
"PaymentTransaction",
"$",
"paymentTransaction",
",",
"Response",
"$",
"response",
")",
"{",
"if",
"(",
"$",
"response",
"->",
"isDeclined",
"(",
")",
")",
"{",
"$",
"paymentTransaction",
"->",
"setS... | Updates payment transaction by query response data
if payment transaction is not processing or approved
@param PaymentTransaction $paymentTransaction Payment transaction for updating
@param Response $response Response for payment transaction updating | [
"Updates",
"payment",
"transaction",
"by",
"query",
"response",
"data",
"if",
"payment",
"transaction",
"is",
"not",
"processing",
"or",
"approved"
] | e3484aa37b6594231f59b1f43523603aa704f093 | https://github.com/payneteasy/php-library-payneteasy-api/blob/e3484aa37b6594231f59b1f43523603aa704f093/source/PaynetEasy/PaynetEasyApi/Query/Prototype/Query.php#L322-L336 | train |
payneteasy/php-library-payneteasy-api | source/PaynetEasy/PaynetEasyApi/Query/Prototype/Query.php | Query.validateQueryDefinition | protected function validateQueryDefinition()
{
if (empty(static::$requestFieldsDefinition))
{
throw new RuntimeException('You must configure requestFieldsDefinition property');
}
if (empty(static::$signatureDefinition))
{
throw new RuntimeException('You must configure signatureDefinition property');
}
if (empty(static::$responseFieldsDefinition))
{
throw new RuntimeException('You must configure responseFieldsDefinition property');
}
if (empty(static::$successResponseType))
{
throw new RuntimeException('You must configure allowedResponseTypes property');
}
} | php | protected function validateQueryDefinition()
{
if (empty(static::$requestFieldsDefinition))
{
throw new RuntimeException('You must configure requestFieldsDefinition property');
}
if (empty(static::$signatureDefinition))
{
throw new RuntimeException('You must configure signatureDefinition property');
}
if (empty(static::$responseFieldsDefinition))
{
throw new RuntimeException('You must configure responseFieldsDefinition property');
}
if (empty(static::$successResponseType))
{
throw new RuntimeException('You must configure allowedResponseTypes property');
}
} | [
"protected",
"function",
"validateQueryDefinition",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"static",
"::",
"$",
"requestFieldsDefinition",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"'You must configure requestFieldsDefinition property'",
")",
";",
"}",
... | Validates query object definition
@throws RuntimeException | [
"Validates",
"query",
"object",
"definition"
] | e3484aa37b6594231f59b1f43523603aa704f093 | https://github.com/payneteasy/php-library-payneteasy-api/blob/e3484aa37b6594231f59b1f43523603aa704f093/source/PaynetEasy/PaynetEasyApi/Query/Prototype/Query.php#L343-L364 | train |
payneteasy/php-library-payneteasy-api | source/PaynetEasy/PaynetEasyApi/Query/Prototype/Query.php | Query.validateQueryConfig | protected function validateQueryConfig(PaymentTransaction $paymentTransaction)
{
$queryConfig = $paymentTransaction->getQueryConfig();
if(strlen($queryConfig->getSigningKey()) === 0)
{
throw new ValidationException("Property 'signingKey' does not defined in PaymentTransaction property 'queryConfig'");
}
if (strlen($queryConfig->getEndPoint()) == 0 && strlen($queryConfig->getEndPointGroup()) === 0)
{
throw new ValidationException(
"Properties 'endPont' and 'endPointGroup' do not defined in " .
"PaymentTransaction property 'queryConfig'. Set one of them."
);
}
if (strlen($queryConfig->getEndPoint()) > 0 && strlen($queryConfig->getEndPointGroup()) > 0)
{
throw new ValidationException(
"Property 'endPont' was set and property 'endPointGroup' was set in " .
"PaymentTransaction property 'queryConfig'. Set only one of them."
);
}
} | php | protected function validateQueryConfig(PaymentTransaction $paymentTransaction)
{
$queryConfig = $paymentTransaction->getQueryConfig();
if(strlen($queryConfig->getSigningKey()) === 0)
{
throw new ValidationException("Property 'signingKey' does not defined in PaymentTransaction property 'queryConfig'");
}
if (strlen($queryConfig->getEndPoint()) == 0 && strlen($queryConfig->getEndPointGroup()) === 0)
{
throw new ValidationException(
"Properties 'endPont' and 'endPointGroup' do not defined in " .
"PaymentTransaction property 'queryConfig'. Set one of them."
);
}
if (strlen($queryConfig->getEndPoint()) > 0 && strlen($queryConfig->getEndPointGroup()) > 0)
{
throw new ValidationException(
"Property 'endPont' was set and property 'endPointGroup' was set in " .
"PaymentTransaction property 'queryConfig'. Set only one of them."
);
}
} | [
"protected",
"function",
"validateQueryConfig",
"(",
"PaymentTransaction",
"$",
"paymentTransaction",
")",
"{",
"$",
"queryConfig",
"=",
"$",
"paymentTransaction",
"->",
"getQueryConfig",
"(",
")",
";",
"if",
"(",
"strlen",
"(",
"$",
"queryConfig",
"->",
"getSigni... | Validates payment transaction query config
@param PaymentTransaction $paymentTransaction Payment transaction
@throws RuntimeException Some query config property is empty | [
"Validates",
"payment",
"transaction",
"query",
"config"
] | e3484aa37b6594231f59b1f43523603aa704f093 | https://github.com/payneteasy/php-library-payneteasy-api/blob/e3484aa37b6594231f59b1f43523603aa704f093/source/PaynetEasy/PaynetEasyApi/Query/Prototype/Query.php#L373-L397 | train |
payneteasy/php-library-payneteasy-api | source/PaynetEasy/PaynetEasyApi/Query/Prototype/Query.php | Query.validateClientId | protected function validateClientId(PaymentTransaction $paymentTransaction, Response $response)
{
$paymentClientId = $paymentTransaction->getPayment()->getClientId();
$responseClientId = $response->getPaymentClientId();
if ( strlen($responseClientId) > 0
&& $paymentClientId != $responseClientId)
{
throw new ValidationException("Response clientId '{$responseClientId}' does " .
"not match Payment clientId '{$paymentClientId}'");
}
} | php | protected function validateClientId(PaymentTransaction $paymentTransaction, Response $response)
{
$paymentClientId = $paymentTransaction->getPayment()->getClientId();
$responseClientId = $response->getPaymentClientId();
if ( strlen($responseClientId) > 0
&& $paymentClientId != $responseClientId)
{
throw new ValidationException("Response clientId '{$responseClientId}' does " .
"not match Payment clientId '{$paymentClientId}'");
}
} | [
"protected",
"function",
"validateClientId",
"(",
"PaymentTransaction",
"$",
"paymentTransaction",
",",
"Response",
"$",
"response",
")",
"{",
"$",
"paymentClientId",
"=",
"$",
"paymentTransaction",
"->",
"getPayment",
"(",
")",
"->",
"getClientId",
"(",
")",
";",... | Check, is payment transaction client order id and query response client order id equal or not.
@param PaymentTransaction $paymentTransaction Payment transaction
@param Response $response Query response
@throws ValidationException | [
"Check",
"is",
"payment",
"transaction",
"client",
"order",
"id",
"and",
"query",
"response",
"client",
"order",
"id",
"equal",
"or",
"not",
"."
] | e3484aa37b6594231f59b1f43523603aa704f093 | https://github.com/payneteasy/php-library-payneteasy-api/blob/e3484aa37b6594231f59b1f43523603aa704f093/source/PaynetEasy/PaynetEasyApi/Query/Prototype/Query.php#L407-L418 | train |
payneteasy/php-library-payneteasy-api | source/PaynetEasy/PaynetEasyApi/Query/Prototype/Query.php | Query.setPaynetId | protected function setPaynetId(PaymentTransaction $paymentTransaction, Response $response)
{
$responsePaynetId = $response->getPaymentPaynetId();
if(strlen($responsePaynetId) > 0)
{
$paymentTransaction
->getPayment()
->setPaynetId($responsePaynetId)
;
}
} | php | protected function setPaynetId(PaymentTransaction $paymentTransaction, Response $response)
{
$responsePaynetId = $response->getPaymentPaynetId();
if(strlen($responsePaynetId) > 0)
{
$paymentTransaction
->getPayment()
->setPaynetId($responsePaynetId)
;
}
} | [
"protected",
"function",
"setPaynetId",
"(",
"PaymentTransaction",
"$",
"paymentTransaction",
",",
"Response",
"$",
"response",
")",
"{",
"$",
"responsePaynetId",
"=",
"$",
"response",
"->",
"getPaymentPaynetId",
"(",
")",
";",
"if",
"(",
"strlen",
"(",
"$",
"... | Set PaynetEasy payment id to payment transaction Payment
@param PaymentTransaction $paymentTransaction Payment transaction
@param Response $response Query response | [
"Set",
"PaynetEasy",
"payment",
"id",
"to",
"payment",
"transaction",
"Payment"
] | e3484aa37b6594231f59b1f43523603aa704f093 | https://github.com/payneteasy/php-library-payneteasy-api/blob/e3484aa37b6594231f59b1f43523603aa704f093/source/PaynetEasy/PaynetEasyApi/Query/Prototype/Query.php#L426-L437 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.