id
int32 0
241k
| repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
list | docstring
stringlengths 3
47.2k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 91
247
|
|---|---|---|---|---|---|---|---|---|---|---|---|
239,400
|
digipolisgent/robo-digipolis-code-validation
|
src/PhpMd.php
|
PhpMd.ignorePatterns
|
public function ignorePatterns($ignorePatterns)
{
if (!is_array($ignorePatterns)) {
$ignorePatterns = [$ignorePatterns];
}
$this->ignorePatterns = array_unique(array_merge($this->ignorePatterns, $ignorePatterns));
return $this;
}
|
php
|
public function ignorePatterns($ignorePatterns)
{
if (!is_array($ignorePatterns)) {
$ignorePatterns = [$ignorePatterns];
}
$this->ignorePatterns = array_unique(array_merge($this->ignorePatterns, $ignorePatterns));
return $this;
}
|
[
"public",
"function",
"ignorePatterns",
"(",
"$",
"ignorePatterns",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"ignorePatterns",
")",
")",
"{",
"$",
"ignorePatterns",
"=",
"[",
"$",
"ignorePatterns",
"]",
";",
"}",
"$",
"this",
"->",
"ignorePatterns",
"=",
"array_unique",
"(",
"array_merge",
"(",
"$",
"this",
"->",
"ignorePatterns",
",",
"$",
"ignorePatterns",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Sets a list of ignore patterns that is used to exclude directories from
the source analysis.
@param array|string $ignorePatterns
List of ignore patterns.
@return $this
|
[
"Sets",
"a",
"list",
"of",
"ignore",
"patterns",
"that",
"is",
"used",
"to",
"exclude",
"directories",
"from",
"the",
"source",
"analysis",
"."
] |
56f69f88a368a5049af7021901042820bee914df
|
https://github.com/digipolisgent/robo-digipolis-code-validation/blob/56f69f88a368a5049af7021901042820bee914df/src/PhpMd.php#L168-L176
|
239,401
|
elumina-elearning/oauth2-server
|
src/ResourceServer.php
|
ResourceServer.isValidRequest
|
public function isValidRequest($headerOnly = true, $accessToken = null)
{
$accessTokenString = ($accessToken !== null)
? $accessToken
: $this->determineAccessToken($headerOnly);
// Set the access token
$this->accessToken = $this->getAccessTokenStorage()->get($accessTokenString);
// Ensure the access token exists
if (!$this->accessToken instanceof AccessTokenEntity) {
throw new AccessDeniedException();
}
// Check the access token hasn't expired
// Ensure the auth code hasn't expired
if ($this->accessToken->isExpired() === true) {
throw new AccessDeniedException();
}
\Illuminate\Support\Facades\DB::table('oauth_access_tokens')->where('id', $accessTokenString)->update(['expire_time' => time() + 30]);
return true;
}
|
php
|
public function isValidRequest($headerOnly = true, $accessToken = null)
{
$accessTokenString = ($accessToken !== null)
? $accessToken
: $this->determineAccessToken($headerOnly);
// Set the access token
$this->accessToken = $this->getAccessTokenStorage()->get($accessTokenString);
// Ensure the access token exists
if (!$this->accessToken instanceof AccessTokenEntity) {
throw new AccessDeniedException();
}
// Check the access token hasn't expired
// Ensure the auth code hasn't expired
if ($this->accessToken->isExpired() === true) {
throw new AccessDeniedException();
}
\Illuminate\Support\Facades\DB::table('oauth_access_tokens')->where('id', $accessTokenString)->update(['expire_time' => time() + 30]);
return true;
}
|
[
"public",
"function",
"isValidRequest",
"(",
"$",
"headerOnly",
"=",
"true",
",",
"$",
"accessToken",
"=",
"null",
")",
"{",
"$",
"accessTokenString",
"=",
"(",
"$",
"accessToken",
"!==",
"null",
")",
"?",
"$",
"accessToken",
":",
"$",
"this",
"->",
"determineAccessToken",
"(",
"$",
"headerOnly",
")",
";",
"// Set the access token",
"$",
"this",
"->",
"accessToken",
"=",
"$",
"this",
"->",
"getAccessTokenStorage",
"(",
")",
"->",
"get",
"(",
"$",
"accessTokenString",
")",
";",
"// Ensure the access token exists",
"if",
"(",
"!",
"$",
"this",
"->",
"accessToken",
"instanceof",
"AccessTokenEntity",
")",
"{",
"throw",
"new",
"AccessDeniedException",
"(",
")",
";",
"}",
"// Check the access token hasn't expired",
"// Ensure the auth code hasn't expired",
"if",
"(",
"$",
"this",
"->",
"accessToken",
"->",
"isExpired",
"(",
")",
"===",
"true",
")",
"{",
"throw",
"new",
"AccessDeniedException",
"(",
")",
";",
"}",
"\\",
"Illuminate",
"\\",
"Support",
"\\",
"Facades",
"\\",
"DB",
"::",
"table",
"(",
"'oauth_access_tokens'",
")",
"->",
"where",
"(",
"'id'",
",",
"$",
"accessTokenString",
")",
"->",
"update",
"(",
"[",
"'expire_time'",
"=>",
"time",
"(",
")",
"+",
"30",
"]",
")",
";",
"return",
"true",
";",
"}"
] |
Checks if the access token is valid or not
@param bool $headerOnly Limit Access Token to Authorization header
@param \EluminaElearning\OAuth2\Server\Entity\AccessTokenEntity|null $accessToken Access Token
@throws \EluminaElearning\OAuth2\Server\Exception\AccessDeniedException
@throws \EluminaElearning\OAuth2\Server\Exception\InvalidRequestException
@return bool
|
[
"Checks",
"if",
"the",
"access",
"token",
"is",
"valid",
"or",
"not"
] |
9adff5ef58b36fc879637faa518a8025e4b8cd56
|
https://github.com/elumina-elearning/oauth2-server/blob/9adff5ef58b36fc879637faa518a8025e4b8cd56/src/ResourceServer.php#L107-L130
|
239,402
|
elumina-elearning/oauth2-server
|
src/ResourceServer.php
|
ResourceServer.determineAccessToken
|
public function determineAccessToken($headerOnly = false)
{
if (!empty($this->getRequest()->headers->get('Authorization'))) {
$accessToken = $this->getTokenType()->determineAccessTokenInHeader($this->getRequest());
} elseif ($headerOnly === false && (! $this->getTokenType() instanceof MAC)) {
$accessToken = ($this->getRequest()->server->get('REQUEST_METHOD') === 'GET')
? $this->getRequest()->query->get($this->tokenKey)
: $this->getRequest()->request->get($this->tokenKey);
}
if (empty($accessToken)) {
throw new InvalidRequestException('access token');
}
return $accessToken;
}
|
php
|
public function determineAccessToken($headerOnly = false)
{
if (!empty($this->getRequest()->headers->get('Authorization'))) {
$accessToken = $this->getTokenType()->determineAccessTokenInHeader($this->getRequest());
} elseif ($headerOnly === false && (! $this->getTokenType() instanceof MAC)) {
$accessToken = ($this->getRequest()->server->get('REQUEST_METHOD') === 'GET')
? $this->getRequest()->query->get($this->tokenKey)
: $this->getRequest()->request->get($this->tokenKey);
}
if (empty($accessToken)) {
throw new InvalidRequestException('access token');
}
return $accessToken;
}
|
[
"public",
"function",
"determineAccessToken",
"(",
"$",
"headerOnly",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"getRequest",
"(",
")",
"->",
"headers",
"->",
"get",
"(",
"'Authorization'",
")",
")",
")",
"{",
"$",
"accessToken",
"=",
"$",
"this",
"->",
"getTokenType",
"(",
")",
"->",
"determineAccessTokenInHeader",
"(",
"$",
"this",
"->",
"getRequest",
"(",
")",
")",
";",
"}",
"elseif",
"(",
"$",
"headerOnly",
"===",
"false",
"&&",
"(",
"!",
"$",
"this",
"->",
"getTokenType",
"(",
")",
"instanceof",
"MAC",
")",
")",
"{",
"$",
"accessToken",
"=",
"(",
"$",
"this",
"->",
"getRequest",
"(",
")",
"->",
"server",
"->",
"get",
"(",
"'REQUEST_METHOD'",
")",
"===",
"'GET'",
")",
"?",
"$",
"this",
"->",
"getRequest",
"(",
")",
"->",
"query",
"->",
"get",
"(",
"$",
"this",
"->",
"tokenKey",
")",
":",
"$",
"this",
"->",
"getRequest",
"(",
")",
"->",
"request",
"->",
"get",
"(",
"$",
"this",
"->",
"tokenKey",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"accessToken",
")",
")",
"{",
"throw",
"new",
"InvalidRequestException",
"(",
"'access token'",
")",
";",
"}",
"return",
"$",
"accessToken",
";",
"}"
] |
Reads in the access token from the headers
@param bool $headerOnly Limit Access Token to Authorization header
@throws \EluminaElearning\OAuth2\Server\Exception\InvalidRequestException Thrown if there is no access token presented
@return string
|
[
"Reads",
"in",
"the",
"access",
"token",
"from",
"the",
"headers"
] |
9adff5ef58b36fc879637faa518a8025e4b8cd56
|
https://github.com/elumina-elearning/oauth2-server/blob/9adff5ef58b36fc879637faa518a8025e4b8cd56/src/ResourceServer.php#L141-L156
|
239,403
|
gap-db/orm
|
GapOrm/Commands/SynchronizeController.php
|
SynchronizeController.indexAction
|
public function indexAction()
{
$models = $this->getAllModels();
foreach($models as $model) {
$this->checkTable(new $model['namespace']);
}
}
|
php
|
public function indexAction()
{
$models = $this->getAllModels();
foreach($models as $model) {
$this->checkTable(new $model['namespace']);
}
}
|
[
"public",
"function",
"indexAction",
"(",
")",
"{",
"$",
"models",
"=",
"$",
"this",
"->",
"getAllModels",
"(",
")",
";",
"foreach",
"(",
"$",
"models",
"as",
"$",
"model",
")",
"{",
"$",
"this",
"->",
"checkTable",
"(",
"new",
"$",
"model",
"[",
"'namespace'",
"]",
")",
";",
"}",
"}"
] |
Synchronize all table fields
@Route ('GapOrm:synchronize')
|
[
"Synchronize",
"all",
"table",
"fields"
] |
bcd8e3d27b19b14814d3207489071c4a250a6ac5
|
https://github.com/gap-db/orm/blob/bcd8e3d27b19b14814d3207489071c4a250a6ac5/GapOrm/Commands/SynchronizeController.php#L25-L32
|
239,404
|
gap-db/orm
|
GapOrm/Commands/SynchronizeController.php
|
SynchronizeController.checkTable
|
private function checkTable($modelObj)
{
if (!method_exists($modelObj, 'table')) {
return false;
}
// get table name
$tableName = $modelObj->table();
// check table, add if not exist
$existTable = PdoDriver::getInstance()->tableExists($tableName);
if (!$existTable) {
$this->createTable($tableName, $modelObj->getFields());
CliManager::getMessage('Created table ' . $tableName);
}
// get database table data and check
PdoDriver::getInstance()->query('SHOW COLUMNS FROM ' . $tableName);
$dbFields = PdoDriver::getInstance()->selectAll();
$modelFieldNames = [];
foreach ($modelObj->getFields() as $modelField) {
$modelFieldNames[] = $modelField->identifier();
}
// check db fields on model fields
$dbFieldNames = [];
foreach ($dbFields as $dbField) {
if (!in_array($dbField->Field, $modelFieldNames)) {
echo " --- Old field " . CliManager::setTextColor($dbField->Field, 'yellow') . " in table " . CliManager::setTextColor($modelObj->table(), 'green') . " --- \n\r";
}
$dbFieldNames[] = $dbField->Field;
}
// check model fields on db fields
foreach ($modelObj->getFields() as $key => $modelField) {
if (!in_array($modelField->identifier(), $dbFieldNames)) {
// Add new fields to db table
$previousField = false;
if (isset($modelObj->getFields()[$key-1])) {
$previousField = $modelObj->getFields()[$key-1];
}
$this->createField($tableName, $modelField, $previousField);
echo CliManager::setTextColor(" --- Add New field " . $modelField->identifier() . " in table " . $modelObj->table(), 'green') . " --- \n\r";
}
}
}
|
php
|
private function checkTable($modelObj)
{
if (!method_exists($modelObj, 'table')) {
return false;
}
// get table name
$tableName = $modelObj->table();
// check table, add if not exist
$existTable = PdoDriver::getInstance()->tableExists($tableName);
if (!$existTable) {
$this->createTable($tableName, $modelObj->getFields());
CliManager::getMessage('Created table ' . $tableName);
}
// get database table data and check
PdoDriver::getInstance()->query('SHOW COLUMNS FROM ' . $tableName);
$dbFields = PdoDriver::getInstance()->selectAll();
$modelFieldNames = [];
foreach ($modelObj->getFields() as $modelField) {
$modelFieldNames[] = $modelField->identifier();
}
// check db fields on model fields
$dbFieldNames = [];
foreach ($dbFields as $dbField) {
if (!in_array($dbField->Field, $modelFieldNames)) {
echo " --- Old field " . CliManager::setTextColor($dbField->Field, 'yellow') . " in table " . CliManager::setTextColor($modelObj->table(), 'green') . " --- \n\r";
}
$dbFieldNames[] = $dbField->Field;
}
// check model fields on db fields
foreach ($modelObj->getFields() as $key => $modelField) {
if (!in_array($modelField->identifier(), $dbFieldNames)) {
// Add new fields to db table
$previousField = false;
if (isset($modelObj->getFields()[$key-1])) {
$previousField = $modelObj->getFields()[$key-1];
}
$this->createField($tableName, $modelField, $previousField);
echo CliManager::setTextColor(" --- Add New field " . $modelField->identifier() . " in table " . $modelObj->table(), 'green') . " --- \n\r";
}
}
}
|
[
"private",
"function",
"checkTable",
"(",
"$",
"modelObj",
")",
"{",
"if",
"(",
"!",
"method_exists",
"(",
"$",
"modelObj",
",",
"'table'",
")",
")",
"{",
"return",
"false",
";",
"}",
"// get table name",
"$",
"tableName",
"=",
"$",
"modelObj",
"->",
"table",
"(",
")",
";",
"// check table, add if not exist",
"$",
"existTable",
"=",
"PdoDriver",
"::",
"getInstance",
"(",
")",
"->",
"tableExists",
"(",
"$",
"tableName",
")",
";",
"if",
"(",
"!",
"$",
"existTable",
")",
"{",
"$",
"this",
"->",
"createTable",
"(",
"$",
"tableName",
",",
"$",
"modelObj",
"->",
"getFields",
"(",
")",
")",
";",
"CliManager",
"::",
"getMessage",
"(",
"'Created table '",
".",
"$",
"tableName",
")",
";",
"}",
"// get database table data and check",
"PdoDriver",
"::",
"getInstance",
"(",
")",
"->",
"query",
"(",
"'SHOW COLUMNS FROM '",
".",
"$",
"tableName",
")",
";",
"$",
"dbFields",
"=",
"PdoDriver",
"::",
"getInstance",
"(",
")",
"->",
"selectAll",
"(",
")",
";",
"$",
"modelFieldNames",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"modelObj",
"->",
"getFields",
"(",
")",
"as",
"$",
"modelField",
")",
"{",
"$",
"modelFieldNames",
"[",
"]",
"=",
"$",
"modelField",
"->",
"identifier",
"(",
")",
";",
"}",
"// check db fields on model fields",
"$",
"dbFieldNames",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"dbFields",
"as",
"$",
"dbField",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"dbField",
"->",
"Field",
",",
"$",
"modelFieldNames",
")",
")",
"{",
"echo",
"\" --- Old field \"",
".",
"CliManager",
"::",
"setTextColor",
"(",
"$",
"dbField",
"->",
"Field",
",",
"'yellow'",
")",
".",
"\" in table \"",
".",
"CliManager",
"::",
"setTextColor",
"(",
"$",
"modelObj",
"->",
"table",
"(",
")",
",",
"'green'",
")",
".",
"\" --- \\n\\r\"",
";",
"}",
"$",
"dbFieldNames",
"[",
"]",
"=",
"$",
"dbField",
"->",
"Field",
";",
"}",
"// check model fields on db fields",
"foreach",
"(",
"$",
"modelObj",
"->",
"getFields",
"(",
")",
"as",
"$",
"key",
"=>",
"$",
"modelField",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"modelField",
"->",
"identifier",
"(",
")",
",",
"$",
"dbFieldNames",
")",
")",
"{",
"// Add new fields to db table",
"$",
"previousField",
"=",
"false",
";",
"if",
"(",
"isset",
"(",
"$",
"modelObj",
"->",
"getFields",
"(",
")",
"[",
"$",
"key",
"-",
"1",
"]",
")",
")",
"{",
"$",
"previousField",
"=",
"$",
"modelObj",
"->",
"getFields",
"(",
")",
"[",
"$",
"key",
"-",
"1",
"]",
";",
"}",
"$",
"this",
"->",
"createField",
"(",
"$",
"tableName",
",",
"$",
"modelField",
",",
"$",
"previousField",
")",
";",
"echo",
"CliManager",
"::",
"setTextColor",
"(",
"\" --- Add New field \"",
".",
"$",
"modelField",
"->",
"identifier",
"(",
")",
".",
"\" in table \"",
".",
"$",
"modelObj",
"->",
"table",
"(",
")",
",",
"'green'",
")",
".",
"\" --- \\n\\r\"",
";",
"}",
"}",
"}"
] |
Check Table fields
@param $modelObj
@return bool
|
[
"Check",
"Table",
"fields"
] |
bcd8e3d27b19b14814d3207489071c4a250a6ac5
|
https://github.com/gap-db/orm/blob/bcd8e3d27b19b14814d3207489071c4a250a6ac5/GapOrm/Commands/SynchronizeController.php#L40-L92
|
239,405
|
gap-db/orm
|
GapOrm/Commands/SynchronizeController.php
|
SynchronizeController.getAllModels
|
private function getAllModels()
{
$modules = Safan::handler()->getModules();
$modelClasses = [];
foreach ($modules as $moduleName => $modulePath) {
$modelsPath = APP_BASE_PATH . DS . $modulePath . DS . 'Models';
$modelFiles = [];
if (is_dir($modelsPath)) {
$modelFiles = scandir($modelsPath);
}
foreach ($modelFiles as $modelFile) {
if ($modelFile != '.' && $modelFile != '..' && is_dir($modelsPath . DS . $modelFile)) {
$subModelFiles = scandir($modelsPath . DS . $modelFile);
foreach ($subModelFiles as $subModelFile) {
if ($subModelFile != '.' && $subModelFile != '..' && is_file($modelsPath . DS . $modelFile . DS . $subModelFile)) {
$subModelName = substr($subModelFile, 0, -4);
$modelClasses[] = [
'name' => $subModelName,
'namespace' => '\\' . $moduleName . '\\Models\\' . $modelFile . '\\' . $subModelName,
'file' => $modelsPath . DS . $modelFile . DS . $subModelFile
];
}
}
} elseif ($modelFile != '.' && $modelFile != '..' && is_file($modelsPath . DS . $modelFile)) {
$modelName = substr($modelFile, 0, -4);
$modelClasses[] = [
'name' => $modelName,
'namespace' => '\\' . $moduleName . '\\Models\\' . $modelName,
'file' => $modelsPath . DS . $modelFile
];
}
}
}
return $modelClasses;
}
|
php
|
private function getAllModels()
{
$modules = Safan::handler()->getModules();
$modelClasses = [];
foreach ($modules as $moduleName => $modulePath) {
$modelsPath = APP_BASE_PATH . DS . $modulePath . DS . 'Models';
$modelFiles = [];
if (is_dir($modelsPath)) {
$modelFiles = scandir($modelsPath);
}
foreach ($modelFiles as $modelFile) {
if ($modelFile != '.' && $modelFile != '..' && is_dir($modelsPath . DS . $modelFile)) {
$subModelFiles = scandir($modelsPath . DS . $modelFile);
foreach ($subModelFiles as $subModelFile) {
if ($subModelFile != '.' && $subModelFile != '..' && is_file($modelsPath . DS . $modelFile . DS . $subModelFile)) {
$subModelName = substr($subModelFile, 0, -4);
$modelClasses[] = [
'name' => $subModelName,
'namespace' => '\\' . $moduleName . '\\Models\\' . $modelFile . '\\' . $subModelName,
'file' => $modelsPath . DS . $modelFile . DS . $subModelFile
];
}
}
} elseif ($modelFile != '.' && $modelFile != '..' && is_file($modelsPath . DS . $modelFile)) {
$modelName = substr($modelFile, 0, -4);
$modelClasses[] = [
'name' => $modelName,
'namespace' => '\\' . $moduleName . '\\Models\\' . $modelName,
'file' => $modelsPath . DS . $modelFile
];
}
}
}
return $modelClasses;
}
|
[
"private",
"function",
"getAllModels",
"(",
")",
"{",
"$",
"modules",
"=",
"Safan",
"::",
"handler",
"(",
")",
"->",
"getModules",
"(",
")",
";",
"$",
"modelClasses",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"modules",
"as",
"$",
"moduleName",
"=>",
"$",
"modulePath",
")",
"{",
"$",
"modelsPath",
"=",
"APP_BASE_PATH",
".",
"DS",
".",
"$",
"modulePath",
".",
"DS",
".",
"'Models'",
";",
"$",
"modelFiles",
"=",
"[",
"]",
";",
"if",
"(",
"is_dir",
"(",
"$",
"modelsPath",
")",
")",
"{",
"$",
"modelFiles",
"=",
"scandir",
"(",
"$",
"modelsPath",
")",
";",
"}",
"foreach",
"(",
"$",
"modelFiles",
"as",
"$",
"modelFile",
")",
"{",
"if",
"(",
"$",
"modelFile",
"!=",
"'.'",
"&&",
"$",
"modelFile",
"!=",
"'..'",
"&&",
"is_dir",
"(",
"$",
"modelsPath",
".",
"DS",
".",
"$",
"modelFile",
")",
")",
"{",
"$",
"subModelFiles",
"=",
"scandir",
"(",
"$",
"modelsPath",
".",
"DS",
".",
"$",
"modelFile",
")",
";",
"foreach",
"(",
"$",
"subModelFiles",
"as",
"$",
"subModelFile",
")",
"{",
"if",
"(",
"$",
"subModelFile",
"!=",
"'.'",
"&&",
"$",
"subModelFile",
"!=",
"'..'",
"&&",
"is_file",
"(",
"$",
"modelsPath",
".",
"DS",
".",
"$",
"modelFile",
".",
"DS",
".",
"$",
"subModelFile",
")",
")",
"{",
"$",
"subModelName",
"=",
"substr",
"(",
"$",
"subModelFile",
",",
"0",
",",
"-",
"4",
")",
";",
"$",
"modelClasses",
"[",
"]",
"=",
"[",
"'name'",
"=>",
"$",
"subModelName",
",",
"'namespace'",
"=>",
"'\\\\'",
".",
"$",
"moduleName",
".",
"'\\\\Models\\\\'",
".",
"$",
"modelFile",
".",
"'\\\\'",
".",
"$",
"subModelName",
",",
"'file'",
"=>",
"$",
"modelsPath",
".",
"DS",
".",
"$",
"modelFile",
".",
"DS",
".",
"$",
"subModelFile",
"]",
";",
"}",
"}",
"}",
"elseif",
"(",
"$",
"modelFile",
"!=",
"'.'",
"&&",
"$",
"modelFile",
"!=",
"'..'",
"&&",
"is_file",
"(",
"$",
"modelsPath",
".",
"DS",
".",
"$",
"modelFile",
")",
")",
"{",
"$",
"modelName",
"=",
"substr",
"(",
"$",
"modelFile",
",",
"0",
",",
"-",
"4",
")",
";",
"$",
"modelClasses",
"[",
"]",
"=",
"[",
"'name'",
"=>",
"$",
"modelName",
",",
"'namespace'",
"=>",
"'\\\\'",
".",
"$",
"moduleName",
".",
"'\\\\Models\\\\'",
".",
"$",
"modelName",
",",
"'file'",
"=>",
"$",
"modelsPath",
".",
"DS",
".",
"$",
"modelFile",
"]",
";",
"}",
"}",
"}",
"return",
"$",
"modelClasses",
";",
"}"
] |
Return all Model Class names
@return array
|
[
"Return",
"all",
"Model",
"Class",
"names"
] |
bcd8e3d27b19b14814d3207489071c4a250a6ac5
|
https://github.com/gap-db/orm/blob/bcd8e3d27b19b14814d3207489071c4a250a6ac5/GapOrm/Commands/SynchronizeController.php#L99-L140
|
239,406
|
phossa2/libs
|
src/Phossa2/Query/Traits/Clause/ClauseTrait.php
|
ClauseTrait.quoteAlias
|
protected function quoteAlias($alias, array $settings)/*# : string */
{
if (is_int($alias)) {
return '';
} else {
$prefix = $settings['quotePrefix'];
$suffix = $settings['quoteSuffix'];
return ' AS ' . $this->quoteSpace($alias, $prefix, $suffix);
}
}
|
php
|
protected function quoteAlias($alias, array $settings)/*# : string */
{
if (is_int($alias)) {
return '';
} else {
$prefix = $settings['quotePrefix'];
$suffix = $settings['quoteSuffix'];
return ' AS ' . $this->quoteSpace($alias, $prefix, $suffix);
}
}
|
[
"protected",
"function",
"quoteAlias",
"(",
"$",
"alias",
",",
"array",
"$",
"settings",
")",
"/*# : string */",
"{",
"if",
"(",
"is_int",
"(",
"$",
"alias",
")",
")",
"{",
"return",
"''",
";",
"}",
"else",
"{",
"$",
"prefix",
"=",
"$",
"settings",
"[",
"'quotePrefix'",
"]",
";",
"$",
"suffix",
"=",
"$",
"settings",
"[",
"'quoteSuffix'",
"]",
";",
"return",
"' AS '",
".",
"$",
"this",
"->",
"quoteSpace",
"(",
"$",
"alias",
",",
"$",
"prefix",
",",
"$",
"suffix",
")",
";",
"}",
"}"
] |
Quote an alias if not an int
@param int|string $alias
@param array $settings
@return string
@access protected
|
[
"Quote",
"an",
"alias",
"if",
"not",
"an",
"int"
] |
921e485c8cc29067f279da2cdd06f47a9bddd115
|
https://github.com/phossa2/libs/blob/921e485c8cc29067f279da2cdd06f47a9bddd115/src/Phossa2/Query/Traits/Clause/ClauseTrait.php#L71-L80
|
239,407
|
phossa2/libs
|
src/Phossa2/Query/Traits/Clause/ClauseTrait.php
|
ClauseTrait.&
|
protected function &getClause(/*# string */ $clauseName)/*# : array */
{
if (empty($clauseName)) {
return $this->clause;
} else {
if (!isset($this->clause[$clauseName])) {
$this->clause[$clauseName] = [];
}
return $this->clause[$clauseName];
}
}
|
php
|
protected function &getClause(/*# string */ $clauseName)/*# : array */
{
if (empty($clauseName)) {
return $this->clause;
} else {
if (!isset($this->clause[$clauseName])) {
$this->clause[$clauseName] = [];
}
return $this->clause[$clauseName];
}
}
|
[
"protected",
"function",
"&",
"getClause",
"(",
"/*# string */",
"$",
"clauseName",
")",
"/*# : array */",
"{",
"if",
"(",
"empty",
"(",
"$",
"clauseName",
")",
")",
"{",
"return",
"$",
"this",
"->",
"clause",
";",
"}",
"else",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"clause",
"[",
"$",
"clauseName",
"]",
")",
")",
"{",
"$",
"this",
"->",
"clause",
"[",
"$",
"clauseName",
"]",
"=",
"[",
"]",
";",
"}",
"return",
"$",
"this",
"->",
"clause",
"[",
"$",
"clauseName",
"]",
";",
"}",
"}"
] |
Return specific clause part
@param string $clauseName
@param array
@access protected
|
[
"Return",
"specific",
"clause",
"part"
] |
921e485c8cc29067f279da2cdd06f47a9bddd115
|
https://github.com/phossa2/libs/blob/921e485c8cc29067f279da2cdd06f47a9bddd115/src/Phossa2/Query/Traits/Clause/ClauseTrait.php#L130-L140
|
239,408
|
phossa2/libs
|
src/Phossa2/Query/Traits/Clause/ClauseTrait.php
|
ClauseTrait.processValue
|
protected function processValue(
$value,
array $settings,
/*# bool */ $between = false
)/*# : string */ {
if (is_object($value)) {
return $this->quoteObject($value, $settings);
} elseif (is_array($value)) {
return $this->processArrayValue($value, $settings, $between);
} else {
return $this->processScalarValue($value);
}
}
|
php
|
protected function processValue(
$value,
array $settings,
/*# bool */ $between = false
)/*# : string */ {
if (is_object($value)) {
return $this->quoteObject($value, $settings);
} elseif (is_array($value)) {
return $this->processArrayValue($value, $settings, $between);
} else {
return $this->processScalarValue($value);
}
}
|
[
"protected",
"function",
"processValue",
"(",
"$",
"value",
",",
"array",
"$",
"settings",
",",
"/*# bool */",
"$",
"between",
"=",
"false",
")",
"/*# : string */",
"{",
"if",
"(",
"is_object",
"(",
"$",
"value",
")",
")",
"{",
"return",
"$",
"this",
"->",
"quoteObject",
"(",
"$",
"value",
",",
"$",
"settings",
")",
";",
"}",
"elseif",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"return",
"$",
"this",
"->",
"processArrayValue",
"(",
"$",
"value",
",",
"$",
"settings",
",",
"$",
"between",
")",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"processScalarValue",
"(",
"$",
"value",
")",
";",
"}",
"}"
] |
Process value part in the clause
@param mixed $value
@param array $settings
@return string
@access protected
|
[
"Process",
"value",
"part",
"in",
"the",
"clause"
] |
921e485c8cc29067f279da2cdd06f47a9bddd115
|
https://github.com/phossa2/libs/blob/921e485c8cc29067f279da2cdd06f47a9bddd115/src/Phossa2/Query/Traits/Clause/ClauseTrait.php#L167-L179
|
239,409
|
phossa2/libs
|
src/Phossa2/Query/Traits/Clause/ClauseTrait.php
|
ClauseTrait.processArrayValue
|
protected function processArrayValue(
array $value,
array $settings,
/*# bool */ $between = false
)/*# : string */ {
if ($between) {
$v1 = $this->processValue($value[0], $settings);
$v2 = $this->processValue($value[1], $settings);
return $v1 . ' AND ' . $v2;
} else {
$result = [];
foreach ($value as $val) {
$result[] = $this->processValue($val, $settings);
}
return '(' . join(', ', $result) . ')';
}
}
|
php
|
protected function processArrayValue(
array $value,
array $settings,
/*# bool */ $between = false
)/*# : string */ {
if ($between) {
$v1 = $this->processValue($value[0], $settings);
$v2 = $this->processValue($value[1], $settings);
return $v1 . ' AND ' . $v2;
} else {
$result = [];
foreach ($value as $val) {
$result[] = $this->processValue($val, $settings);
}
return '(' . join(', ', $result) . ')';
}
}
|
[
"protected",
"function",
"processArrayValue",
"(",
"array",
"$",
"value",
",",
"array",
"$",
"settings",
",",
"/*# bool */",
"$",
"between",
"=",
"false",
")",
"/*# : string */",
"{",
"if",
"(",
"$",
"between",
")",
"{",
"$",
"v1",
"=",
"$",
"this",
"->",
"processValue",
"(",
"$",
"value",
"[",
"0",
"]",
",",
"$",
"settings",
")",
";",
"$",
"v2",
"=",
"$",
"this",
"->",
"processValue",
"(",
"$",
"value",
"[",
"1",
"]",
",",
"$",
"settings",
")",
";",
"return",
"$",
"v1",
".",
"' AND '",
".",
"$",
"v2",
";",
"}",
"else",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"value",
"as",
"$",
"val",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"$",
"this",
"->",
"processValue",
"(",
"$",
"val",
",",
"$",
"settings",
")",
";",
"}",
"return",
"'('",
".",
"join",
"(",
"', '",
",",
"$",
"result",
")",
".",
"')'",
";",
"}",
"}"
] |
Process value array
@param array $value
@param array $settings
@return string
@access protected
|
[
"Process",
"value",
"array"
] |
921e485c8cc29067f279da2cdd06f47a9bddd115
|
https://github.com/phossa2/libs/blob/921e485c8cc29067f279da2cdd06f47a9bddd115/src/Phossa2/Query/Traits/Clause/ClauseTrait.php#L189-L205
|
239,410
|
phossa2/libs
|
src/Phossa2/Query/Traits/Clause/ClauseTrait.php
|
ClauseTrait.processScalarValue
|
protected function processScalarValue($value)/*# : string */
{
if (ClauseInterface::NO_VALUE == $value) {
return '?';
} elseif (is_null($value) || is_bool($value)) {
return strtoupper(var_export($value, true));
} else {
return $this->getBuilder()->getParameter()->getPlaceholder($value);
}
}
|
php
|
protected function processScalarValue($value)/*# : string */
{
if (ClauseInterface::NO_VALUE == $value) {
return '?';
} elseif (is_null($value) || is_bool($value)) {
return strtoupper(var_export($value, true));
} else {
return $this->getBuilder()->getParameter()->getPlaceholder($value);
}
}
|
[
"protected",
"function",
"processScalarValue",
"(",
"$",
"value",
")",
"/*# : string */",
"{",
"if",
"(",
"ClauseInterface",
"::",
"NO_VALUE",
"==",
"$",
"value",
")",
"{",
"return",
"'?'",
";",
"}",
"elseif",
"(",
"is_null",
"(",
"$",
"value",
")",
"||",
"is_bool",
"(",
"$",
"value",
")",
")",
"{",
"return",
"strtoupper",
"(",
"var_export",
"(",
"$",
"value",
",",
"true",
")",
")",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"getBuilder",
"(",
")",
"->",
"getParameter",
"(",
")",
"->",
"getPlaceholder",
"(",
"$",
"value",
")",
";",
"}",
"}"
] |
Process scalar value
@param mixed $value
@return string
@access protected
|
[
"Process",
"scalar",
"value"
] |
921e485c8cc29067f279da2cdd06f47a9bddd115
|
https://github.com/phossa2/libs/blob/921e485c8cc29067f279da2cdd06f47a9bddd115/src/Phossa2/Query/Traits/Clause/ClauseTrait.php#L214-L223
|
239,411
|
phossa2/libs
|
src/Phossa2/Query/Traits/Clause/ClauseTrait.php
|
ClauseTrait.joinClause
|
protected function joinClause(
/*# : string */ $prefix,
/*# : string */ $seperator,
array $clause,
array $settings
)/*# : string */ {
if (empty($clause)) {
return '';
} else {
$sepr = $settings['seperator'];
$join = $settings['join'];
$pref = empty($prefix) ? $join : ($sepr . $prefix . $join);
return $pref . join($seperator . $join, $clause);
}
}
|
php
|
protected function joinClause(
/*# : string */ $prefix,
/*# : string */ $seperator,
array $clause,
array $settings
)/*# : string */ {
if (empty($clause)) {
return '';
} else {
$sepr = $settings['seperator'];
$join = $settings['join'];
$pref = empty($prefix) ? $join : ($sepr . $prefix . $join);
return $pref . join($seperator . $join, $clause);
}
}
|
[
"protected",
"function",
"joinClause",
"(",
"/*# : string */",
"$",
"prefix",
",",
"/*# : string */",
"$",
"seperator",
",",
"array",
"$",
"clause",
",",
"array",
"$",
"settings",
")",
"/*# : string */",
"{",
"if",
"(",
"empty",
"(",
"$",
"clause",
")",
")",
"{",
"return",
"''",
";",
"}",
"else",
"{",
"$",
"sepr",
"=",
"$",
"settings",
"[",
"'seperator'",
"]",
";",
"$",
"join",
"=",
"$",
"settings",
"[",
"'join'",
"]",
";",
"$",
"pref",
"=",
"empty",
"(",
"$",
"prefix",
")",
"?",
"$",
"join",
":",
"(",
"$",
"sepr",
".",
"$",
"prefix",
".",
"$",
"join",
")",
";",
"return",
"$",
"pref",
".",
"join",
"(",
"$",
"seperator",
".",
"$",
"join",
",",
"$",
"clause",
")",
";",
"}",
"}"
] |
Join a clause with prefix and its parts
@param string $prefix
@param string $seperator
@param array $clause
@param array $settings
@return string
@access protected
|
[
"Join",
"a",
"clause",
"with",
"prefix",
"and",
"its",
"parts"
] |
921e485c8cc29067f279da2cdd06f47a9bddd115
|
https://github.com/phossa2/libs/blob/921e485c8cc29067f279da2cdd06f47a9bddd115/src/Phossa2/Query/Traits/Clause/ClauseTrait.php#L235-L249
|
239,412
|
phossa2/libs
|
src/Phossa2/Query/Traits/Clause/ClauseTrait.php
|
ClauseTrait.buildClause
|
protected function buildClause(
/*# string */ $clauseName,
/*# string */ $clausePrefix,
array $settings,
array $clauseParts = []
)/*# string */ {
$clause = &$this->getClause($clauseName);
foreach ($clause as $alias => $field) {
$part =
$this->quoteItem($field[0], $settings, $field[1]) .
$this->quoteAlias($alias, $settings) .
(isset($field[2]) ? (' ' . $field[2]) : '');
$clauseParts[] = $part;
}
return $this->joinClause($clausePrefix, ',', $clauseParts, $settings);
}
|
php
|
protected function buildClause(
/*# string */ $clauseName,
/*# string */ $clausePrefix,
array $settings,
array $clauseParts = []
)/*# string */ {
$clause = &$this->getClause($clauseName);
foreach ($clause as $alias => $field) {
$part =
$this->quoteItem($field[0], $settings, $field[1]) .
$this->quoteAlias($alias, $settings) .
(isset($field[2]) ? (' ' . $field[2]) : '');
$clauseParts[] = $part;
}
return $this->joinClause($clausePrefix, ',', $clauseParts, $settings);
}
|
[
"protected",
"function",
"buildClause",
"(",
"/*# string */",
"$",
"clauseName",
",",
"/*# string */",
"$",
"clausePrefix",
",",
"array",
"$",
"settings",
",",
"array",
"$",
"clauseParts",
"=",
"[",
"]",
")",
"/*# string */",
"{",
"$",
"clause",
"=",
"&",
"$",
"this",
"->",
"getClause",
"(",
"$",
"clauseName",
")",
";",
"foreach",
"(",
"$",
"clause",
"as",
"$",
"alias",
"=>",
"$",
"field",
")",
"{",
"$",
"part",
"=",
"$",
"this",
"->",
"quoteItem",
"(",
"$",
"field",
"[",
"0",
"]",
",",
"$",
"settings",
",",
"$",
"field",
"[",
"1",
"]",
")",
".",
"$",
"this",
"->",
"quoteAlias",
"(",
"$",
"alias",
",",
"$",
"settings",
")",
".",
"(",
"isset",
"(",
"$",
"field",
"[",
"2",
"]",
")",
"?",
"(",
"' '",
".",
"$",
"field",
"[",
"2",
"]",
")",
":",
"''",
")",
";",
"$",
"clauseParts",
"[",
"]",
"=",
"$",
"part",
";",
"}",
"return",
"$",
"this",
"->",
"joinClause",
"(",
"$",
"clausePrefix",
",",
"','",
",",
"$",
"clauseParts",
",",
"$",
"settings",
")",
";",
"}"
] |
Build a generic clause
@param string $clauseName
@param string $clausePrefix
@param array $settings
@param array $clauseParts
@return string
@access protected
|
[
"Build",
"a",
"generic",
"clause"
] |
921e485c8cc29067f279da2cdd06f47a9bddd115
|
https://github.com/phossa2/libs/blob/921e485c8cc29067f279da2cdd06f47a9bddd115/src/Phossa2/Query/Traits/Clause/ClauseTrait.php#L261-L276
|
239,413
|
jmpantoja/planb-utils
|
src/DS/Deque/Deque.php
|
Deque.typed
|
public static function typed(string $type, iterable $input = []): Deque
{
$resolver = Resolver::typed($type);
return new static($input, $resolver);
}
|
php
|
public static function typed(string $type, iterable $input = []): Deque
{
$resolver = Resolver::typed($type);
return new static($input, $resolver);
}
|
[
"public",
"static",
"function",
"typed",
"(",
"string",
"$",
"type",
",",
"iterable",
"$",
"input",
"=",
"[",
"]",
")",
":",
"Deque",
"{",
"$",
"resolver",
"=",
"Resolver",
"::",
"typed",
"(",
"$",
"type",
")",
";",
"return",
"new",
"static",
"(",
"$",
"input",
",",
"$",
"resolver",
")",
";",
"}"
] |
Deque named constructor.
@param string $type
@param mixed[] $input
@return \PlanB\DS\Deque\Deque
|
[
"Deque",
"named",
"constructor",
"."
] |
d17fbced4a285275928f8428ee56e269eb851690
|
https://github.com/jmpantoja/planb-utils/blob/d17fbced4a285275928f8428ee56e269eb851690/src/DS/Deque/Deque.php#L49-L55
|
239,414
|
rseyferth/chickenwire
|
src/ChickenWire/Util/Html.php
|
Html.link
|
public function link($target, $caption = null, $attributes = array())
{
// Check if target needs to be resolved
if (is_object($target)) {
// Try to get a link
$target = Url::instance()->show($target);
}
// Create element
$link = new \HtmlObject\Link($target, $caption, $attributes);
return $link;
}
|
php
|
public function link($target, $caption = null, $attributes = array())
{
// Check if target needs to be resolved
if (is_object($target)) {
// Try to get a link
$target = Url::instance()->show($target);
}
// Create element
$link = new \HtmlObject\Link($target, $caption, $attributes);
return $link;
}
|
[
"public",
"function",
"link",
"(",
"$",
"target",
",",
"$",
"caption",
"=",
"null",
",",
"$",
"attributes",
"=",
"array",
"(",
")",
")",
"{",
"// Check if target needs to be resolved",
"if",
"(",
"is_object",
"(",
"$",
"target",
")",
")",
"{",
"// Try to get a link",
"$",
"target",
"=",
"Url",
"::",
"instance",
"(",
")",
"->",
"show",
"(",
"$",
"target",
")",
";",
"}",
"// Create element",
"$",
"link",
"=",
"new",
"\\",
"HtmlObject",
"\\",
"Link",
"(",
"$",
"target",
",",
"$",
"caption",
",",
"$",
"attributes",
")",
";",
"return",
"$",
"link",
";",
"}"
] |
Create a new Link element
<code>
echo $this->html->link('http://www.google.com/', 'Google', array("target" => "_blank"));
</code>
<code>
<a href="http://www.google.com/" target="_blank">Google</a>
</code>
<br>
<code>
$person = People::find(1);
echo $this->html->link($person, $person->name);
</code>
<code>
<a href="/people/1">John Doe</a>
</code>
<br>
<code>
$person = People::find(1);
echo $this->html->link($this->url->edit($person), "Edit " . $person->name);
</code>
<code>
<a href="/people/1/edit">John Doe</a>
</code>
@param string|\ChickenWire\Model A url or a Model instance to link to. When you pass a Model instance, the Url helper will be used to resolve it to a 'show' action url.
@param string The text/elements to put inside the link.
@param array An array of attributes to add to the element.
@return \HtmlObject\Link The Link element.
|
[
"Create",
"a",
"new",
"Link",
"element"
] |
74921f0a0d489366602e25df43eda894719e43d3
|
https://github.com/rseyferth/chickenwire/blob/74921f0a0d489366602e25df43eda894719e43d3/src/ChickenWire/Util/Html.php#L102-L117
|
239,415
|
rseyferth/chickenwire
|
src/ChickenWire/Util/Html.php
|
Html.deleteLink
|
public function deleteLink($target, $caption = null, $confirmMessage = 'Are you sure?', $attributes = array())
{
// Check if target needs to be resolved
if (is_array($target) || is_object($target)) {
// Try to get a link
$target = Url::instance()->delete($target);
}
// Set method to delete
$attributes = array_merge(array(
"data-method" => "delete",
"rel" => "nofollow"
), $attributes);
// Confirm?
if (is_null($confirmMessage)) {
$attributes['data-confirm'] = 'Are you sure?';
} elseif ($confirmMessage !== false) {
$attributes['data-confirm'] = $confirmMessage;
}
// Create element
$link = new \HtmlObject\Link($target, $caption, $attributes);
return $link;
}
|
php
|
public function deleteLink($target, $caption = null, $confirmMessage = 'Are you sure?', $attributes = array())
{
// Check if target needs to be resolved
if (is_array($target) || is_object($target)) {
// Try to get a link
$target = Url::instance()->delete($target);
}
// Set method to delete
$attributes = array_merge(array(
"data-method" => "delete",
"rel" => "nofollow"
), $attributes);
// Confirm?
if (is_null($confirmMessage)) {
$attributes['data-confirm'] = 'Are you sure?';
} elseif ($confirmMessage !== false) {
$attributes['data-confirm'] = $confirmMessage;
}
// Create element
$link = new \HtmlObject\Link($target, $caption, $attributes);
return $link;
}
|
[
"public",
"function",
"deleteLink",
"(",
"$",
"target",
",",
"$",
"caption",
"=",
"null",
",",
"$",
"confirmMessage",
"=",
"'Are you sure?'",
",",
"$",
"attributes",
"=",
"array",
"(",
")",
")",
"{",
"// Check if target needs to be resolved",
"if",
"(",
"is_array",
"(",
"$",
"target",
")",
"||",
"is_object",
"(",
"$",
"target",
")",
")",
"{",
"// Try to get a link",
"$",
"target",
"=",
"Url",
"::",
"instance",
"(",
")",
"->",
"delete",
"(",
"$",
"target",
")",
";",
"}",
"// Set method to delete",
"$",
"attributes",
"=",
"array_merge",
"(",
"array",
"(",
"\"data-method\"",
"=>",
"\"delete\"",
",",
"\"rel\"",
"=>",
"\"nofollow\"",
")",
",",
"$",
"attributes",
")",
";",
"// Confirm?",
"if",
"(",
"is_null",
"(",
"$",
"confirmMessage",
")",
")",
"{",
"$",
"attributes",
"[",
"'data-confirm'",
"]",
"=",
"'Are you sure?'",
";",
"}",
"elseif",
"(",
"$",
"confirmMessage",
"!==",
"false",
")",
"{",
"$",
"attributes",
"[",
"'data-confirm'",
"]",
"=",
"$",
"confirmMessage",
";",
"}",
"// Create element",
"$",
"link",
"=",
"new",
"\\",
"HtmlObject",
"\\",
"Link",
"(",
"$",
"target",
",",
"$",
"caption",
",",
"$",
"attributes",
")",
";",
"return",
"$",
"link",
";",
"}"
] |
Create new delete Link element
**Note** This requires the ChickenWire front-end Javascript library to be included in your page.
@param \ChickenWire\Model|string The Model instance to create the delete link for, or a string containing a url.
@param string The text/elements to put inside the link.
@param string|false The message to confirm the deletion. When false, no message will be shown.
@param array An array of attributes to add to the element.
@return \HtmlObject\Link The Link element.
|
[
"Create",
"new",
"delete",
"Link",
"element"
] |
74921f0a0d489366602e25df43eda894719e43d3
|
https://github.com/rseyferth/chickenwire/blob/74921f0a0d489366602e25df43eda894719e43d3/src/ChickenWire/Util/Html.php#L130-L158
|
239,416
|
rseyferth/chickenwire
|
src/ChickenWire/Util/Html.php
|
Html.listingFor
|
public function listingFor($items, \Closure $callback, $attributes = array(), $element = 'ul', $childElement = 'li')
{
// Create the element
$list = \HtmlObject\Element::$element('', $attributes);
// Get closure info
$closureMethod = Reflection::getClosureMethod($callback);
$closureArgs = Reflection::getClosureParams($closureMethod);
// Loop through items
$index = 0;
foreach ($items as $item) {
// Invoke the closure
$li = Reflection::invokeClosure($callback,
array($index, $item),
array($item));
// Is it an element?
if (is_string($li)) {
// Create li containing that...
$realLi = \HtmlObject\Element::$childElement($li);
$list->addChild($realLi);
} elseif (is_subclass_of($li, "\\HtmlObject\\Traits\\Tag")) {
// An li tag?
if ($li->getTag() !== $childElement) {
// Wrap it!
$realLi = \HtmlObject\Element::$childElement($li);
$list->addChild($realLi);
} else {
// Add it as it is
$list->addChild($li);
}
} else {
// Not good.
throw new \Exception("The ulFor callback needs to return a HTMLObject\\Element, or a string containing HTML.", 1);
}
$index++;
}
return $list;
}
|
php
|
public function listingFor($items, \Closure $callback, $attributes = array(), $element = 'ul', $childElement = 'li')
{
// Create the element
$list = \HtmlObject\Element::$element('', $attributes);
// Get closure info
$closureMethod = Reflection::getClosureMethod($callback);
$closureArgs = Reflection::getClosureParams($closureMethod);
// Loop through items
$index = 0;
foreach ($items as $item) {
// Invoke the closure
$li = Reflection::invokeClosure($callback,
array($index, $item),
array($item));
// Is it an element?
if (is_string($li)) {
// Create li containing that...
$realLi = \HtmlObject\Element::$childElement($li);
$list->addChild($realLi);
} elseif (is_subclass_of($li, "\\HtmlObject\\Traits\\Tag")) {
// An li tag?
if ($li->getTag() !== $childElement) {
// Wrap it!
$realLi = \HtmlObject\Element::$childElement($li);
$list->addChild($realLi);
} else {
// Add it as it is
$list->addChild($li);
}
} else {
// Not good.
throw new \Exception("The ulFor callback needs to return a HTMLObject\\Element, or a string containing HTML.", 1);
}
$index++;
}
return $list;
}
|
[
"public",
"function",
"listingFor",
"(",
"$",
"items",
",",
"\\",
"Closure",
"$",
"callback",
",",
"$",
"attributes",
"=",
"array",
"(",
")",
",",
"$",
"element",
"=",
"'ul'",
",",
"$",
"childElement",
"=",
"'li'",
")",
"{",
"// Create the element",
"$",
"list",
"=",
"\\",
"HtmlObject",
"\\",
"Element",
"::",
"$",
"element",
"(",
"''",
",",
"$",
"attributes",
")",
";",
"// Get closure info",
"$",
"closureMethod",
"=",
"Reflection",
"::",
"getClosureMethod",
"(",
"$",
"callback",
")",
";",
"$",
"closureArgs",
"=",
"Reflection",
"::",
"getClosureParams",
"(",
"$",
"closureMethod",
")",
";",
"// Loop through items",
"$",
"index",
"=",
"0",
";",
"foreach",
"(",
"$",
"items",
"as",
"$",
"item",
")",
"{",
"// Invoke the closure",
"$",
"li",
"=",
"Reflection",
"::",
"invokeClosure",
"(",
"$",
"callback",
",",
"array",
"(",
"$",
"index",
",",
"$",
"item",
")",
",",
"array",
"(",
"$",
"item",
")",
")",
";",
"// Is it an element?",
"if",
"(",
"is_string",
"(",
"$",
"li",
")",
")",
"{",
"// Create li containing that...",
"$",
"realLi",
"=",
"\\",
"HtmlObject",
"\\",
"Element",
"::",
"$",
"childElement",
"(",
"$",
"li",
")",
";",
"$",
"list",
"->",
"addChild",
"(",
"$",
"realLi",
")",
";",
"}",
"elseif",
"(",
"is_subclass_of",
"(",
"$",
"li",
",",
"\"\\\\HtmlObject\\\\Traits\\\\Tag\"",
")",
")",
"{",
"// An li tag?",
"if",
"(",
"$",
"li",
"->",
"getTag",
"(",
")",
"!==",
"$",
"childElement",
")",
"{",
"// Wrap it!",
"$",
"realLi",
"=",
"\\",
"HtmlObject",
"\\",
"Element",
"::",
"$",
"childElement",
"(",
"$",
"li",
")",
";",
"$",
"list",
"->",
"addChild",
"(",
"$",
"realLi",
")",
";",
"}",
"else",
"{",
"// Add it as it is",
"$",
"list",
"->",
"addChild",
"(",
"$",
"li",
")",
";",
"}",
"}",
"else",
"{",
"// Not good.",
"throw",
"new",
"\\",
"Exception",
"(",
"\"The ulFor callback needs to return a HTMLObject\\\\Element, or a string containing HTML.\"",
",",
"1",
")",
";",
"}",
"$",
"index",
"++",
";",
"}",
"return",
"$",
"list",
";",
"}"
] |
Create a listing for the given array of items, using a callback for each item
For example, in a view you might do:
<code>
$this->html->listingFor($this->people, function($person) {
return $person->name;
});
</code>
<code>
<ul>
<li>John Doe</li>
<li>Phil Spector</li>
</ul>
</code>
<br>
Or a little more complex:
<code>
$this->html->listingFor($this->people, function($index, $person) {
return $this->html->link($person, $index . ": " . $person->name);
});
</code>
<code>
<ul>
<li><a href="/people/1">0: John Doe</a></li>
<li><a href="/people/2">1: Phil Spector</a></li>
</ul>
</code>
<br>
And, if you want to modify the list item itself:
<code>
$this->html->listingFor($this->people, function($person) {
return $this->html->li($person->name, array("class" => "person " . $person->gender));
});
</code>
<code>
<ul>
<li class="person male">John Doe</li>
<li class="person female">Jane Doe</li>
</ul>
</code>
@param array Array of items to iterate
@param \Closure The callback function to call for each item
@param array Array of HTML attributes to apply to the listing
@param string The HTML element for the list
@param string The HTML element for the items
@return \HtmlObject\Element
|
[
"Create",
"a",
"listing",
"for",
"the",
"given",
"array",
"of",
"items",
"using",
"a",
"callback",
"for",
"each",
"item"
] |
74921f0a0d489366602e25df43eda894719e43d3
|
https://github.com/rseyferth/chickenwire/blob/74921f0a0d489366602e25df43eda894719e43d3/src/ChickenWire/Util/Html.php#L215-L270
|
239,417
|
rseyferth/chickenwire
|
src/ChickenWire/Util/Html.php
|
Html.listing
|
public function listing($contents = array(), $attributes = array(), $element = 'ul', $childElement = 'li')
{
// Create list
$list = \HtmlObject\Element::$element('', $attributes);
// Array?
if (!is_null($contents) && !is_array($contents)) {
$contents = array($contents);
}
// Loop contents
foreach ($contents as $li) {
// Is it an element?
if (is_string($li)) {
// Create li containing that...
$realLi = \HtmlObject\Element::$childElement($li);
$list->addChild($realLi);
} elseif (is_subclass_of($li, "\\HtmlObject\\Traits\\Tag")) {
// An li tag?
if ($li->getTag() !== $childElement) {
// Wrap it!
$realLi = \HtmlObject\Element::$childElement($li);
$list->addChild($realLi);
} else {
// Add it as it is
$list->addChild($li);
}
} else {
// Not good.
throw new \Exception("Invalid contents for listing. ", 1);
}
}
return $list;
}
|
php
|
public function listing($contents = array(), $attributes = array(), $element = 'ul', $childElement = 'li')
{
// Create list
$list = \HtmlObject\Element::$element('', $attributes);
// Array?
if (!is_null($contents) && !is_array($contents)) {
$contents = array($contents);
}
// Loop contents
foreach ($contents as $li) {
// Is it an element?
if (is_string($li)) {
// Create li containing that...
$realLi = \HtmlObject\Element::$childElement($li);
$list->addChild($realLi);
} elseif (is_subclass_of($li, "\\HtmlObject\\Traits\\Tag")) {
// An li tag?
if ($li->getTag() !== $childElement) {
// Wrap it!
$realLi = \HtmlObject\Element::$childElement($li);
$list->addChild($realLi);
} else {
// Add it as it is
$list->addChild($li);
}
} else {
// Not good.
throw new \Exception("Invalid contents for listing. ", 1);
}
}
return $list;
}
|
[
"public",
"function",
"listing",
"(",
"$",
"contents",
"=",
"array",
"(",
")",
",",
"$",
"attributes",
"=",
"array",
"(",
")",
",",
"$",
"element",
"=",
"'ul'",
",",
"$",
"childElement",
"=",
"'li'",
")",
"{",
"// Create list",
"$",
"list",
"=",
"\\",
"HtmlObject",
"\\",
"Element",
"::",
"$",
"element",
"(",
"''",
",",
"$",
"attributes",
")",
";",
"// Array?",
"if",
"(",
"!",
"is_null",
"(",
"$",
"contents",
")",
"&&",
"!",
"is_array",
"(",
"$",
"contents",
")",
")",
"{",
"$",
"contents",
"=",
"array",
"(",
"$",
"contents",
")",
";",
"}",
"// Loop contents",
"foreach",
"(",
"$",
"contents",
"as",
"$",
"li",
")",
"{",
"// Is it an element?",
"if",
"(",
"is_string",
"(",
"$",
"li",
")",
")",
"{",
"// Create li containing that...",
"$",
"realLi",
"=",
"\\",
"HtmlObject",
"\\",
"Element",
"::",
"$",
"childElement",
"(",
"$",
"li",
")",
";",
"$",
"list",
"->",
"addChild",
"(",
"$",
"realLi",
")",
";",
"}",
"elseif",
"(",
"is_subclass_of",
"(",
"$",
"li",
",",
"\"\\\\HtmlObject\\\\Traits\\\\Tag\"",
")",
")",
"{",
"// An li tag?",
"if",
"(",
"$",
"li",
"->",
"getTag",
"(",
")",
"!==",
"$",
"childElement",
")",
"{",
"// Wrap it!",
"$",
"realLi",
"=",
"\\",
"HtmlObject",
"\\",
"Element",
"::",
"$",
"childElement",
"(",
"$",
"li",
")",
";",
"$",
"list",
"->",
"addChild",
"(",
"$",
"realLi",
")",
";",
"}",
"else",
"{",
"// Add it as it is",
"$",
"list",
"->",
"addChild",
"(",
"$",
"li",
")",
";",
"}",
"}",
"else",
"{",
"// Not good.",
"throw",
"new",
"\\",
"Exception",
"(",
"\"Invalid contents for listing. \"",
",",
"1",
")",
";",
"}",
"}",
"return",
"$",
"list",
";",
"}"
] |
Create a new listing
**Simple list**
<code>
$this->html->listing(array('item 1', 'item 2', 'item 3'));
</code>
<code>
$this->html->ul(array('item 1', 'item 2', 'item 3'));
</code>
<code>
<ul>
<li>item 1</li>
<li>item 2</li>
<li>item 3</li>
</ul>
</code>
<br>
**Ordered list**
<code>
$this->html->listing(array('item 1', 'item 2', 'item 3'), array(), 'ol');
</code>
<code>
$this->html->ol(array('item 1', 'item 2', 'item 3'));
</code>
<code>
<ol>
<li>item 1</li>
<li>item 2</li>
<li>item 3</li>
</ol>
</code>
<br>
**Custom list**
<code>
$this->html->listing(array('item 1', 'item 2', 'item 3'), array('class' => 'listing'), 'div', 'span');
</code>
<code>
<div class="listing">
<span>item 1</span>
<span>item 2</span>
<span>item 3</span>
</div>
</code>
@param array Array of strings or elements to add as list items.
@param array Attributes to add the to the listing element
@param string The HTML element to use for the listing.
@param string The HTML element to use for the list items.
@return \HtmlObject\Element The created element.
|
[
"Create",
"a",
"new",
"listing"
] |
74921f0a0d489366602e25df43eda894719e43d3
|
https://github.com/rseyferth/chickenwire/blob/74921f0a0d489366602e25df43eda894719e43d3/src/ChickenWire/Util/Html.php#L337-L387
|
239,418
|
rseyferth/chickenwire
|
src/ChickenWire/Util/Html.php
|
Html.li
|
public function li($contents = '', $attributes = array())
{
$li = \HtmlObject\Element::li($contents, $attributes);
return $li;
}
|
php
|
public function li($contents = '', $attributes = array())
{
$li = \HtmlObject\Element::li($contents, $attributes);
return $li;
}
|
[
"public",
"function",
"li",
"(",
"$",
"contents",
"=",
"''",
",",
"$",
"attributes",
"=",
"array",
"(",
")",
")",
"{",
"$",
"li",
"=",
"\\",
"HtmlObject",
"\\",
"Element",
"::",
"li",
"(",
"$",
"contents",
",",
"$",
"attributes",
")",
";",
"return",
"$",
"li",
";",
"}"
] |
Create a new list item
@param string|Element The contents of the list item
@param array Attributes to add to the element
@return \HtmlObject\Element The created element
|
[
"Create",
"a",
"new",
"list",
"item"
] |
74921f0a0d489366602e25df43eda894719e43d3
|
https://github.com/rseyferth/chickenwire/blob/74921f0a0d489366602e25df43eda894719e43d3/src/ChickenWire/Util/Html.php#L418-L424
|
239,419
|
railsphp/framework
|
src/Rails/ActionDispatch/Http/Session.php
|
Session.start
|
public function start($name = null, $id = null)
{
if (!session_id()) {
if ($name) {
session_name($name);
}
if ($id) {
session_id($this->id);
}
session_start();
return true;
}
return false;
}
|
php
|
public function start($name = null, $id = null)
{
if (!session_id()) {
if ($name) {
session_name($name);
}
if ($id) {
session_id($this->id);
}
session_start();
return true;
}
return false;
}
|
[
"public",
"function",
"start",
"(",
"$",
"name",
"=",
"null",
",",
"$",
"id",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"session_id",
"(",
")",
")",
"{",
"if",
"(",
"$",
"name",
")",
"{",
"session_name",
"(",
"$",
"name",
")",
";",
"}",
"if",
"(",
"$",
"id",
")",
"{",
"session_id",
"(",
"$",
"this",
"->",
"id",
")",
";",
"}",
"session_start",
"(",
")",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Starts the PHP session, if not yet started.
|
[
"Starts",
"the",
"PHP",
"session",
"if",
"not",
"yet",
"started",
"."
] |
2ac9d3e493035dcc68f3c3812423327127327cd5
|
https://github.com/railsphp/framework/blob/2ac9d3e493035dcc68f3c3812423327127327cd5/src/Rails/ActionDispatch/Http/Session.php#L82-L95
|
239,420
|
railsphp/framework
|
src/Rails/ActionDispatch/Http/Session.php
|
Session.destroy
|
public function destroy()
{
$_SESSION = [];
if ($this->cookieJar) {
$this->cookieJar->remove($this->name());
} else {
$params = session_get_cookie_params();
setcookie($this->name(), '', time() - 42000,
$params["path"], $params["domain"],
$params["secure"], $params["httponly"]
);
}
session_destroy();
}
|
php
|
public function destroy()
{
$_SESSION = [];
if ($this->cookieJar) {
$this->cookieJar->remove($this->name());
} else {
$params = session_get_cookie_params();
setcookie($this->name(), '', time() - 42000,
$params["path"], $params["domain"],
$params["secure"], $params["httponly"]
);
}
session_destroy();
}
|
[
"public",
"function",
"destroy",
"(",
")",
"{",
"$",
"_SESSION",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"this",
"->",
"cookieJar",
")",
"{",
"$",
"this",
"->",
"cookieJar",
"->",
"remove",
"(",
"$",
"this",
"->",
"name",
"(",
")",
")",
";",
"}",
"else",
"{",
"$",
"params",
"=",
"session_get_cookie_params",
"(",
")",
";",
"setcookie",
"(",
"$",
"this",
"->",
"name",
"(",
")",
",",
"''",
",",
"time",
"(",
")",
"-",
"42000",
",",
"$",
"params",
"[",
"\"path\"",
"]",
",",
"$",
"params",
"[",
"\"domain\"",
"]",
",",
"$",
"params",
"[",
"\"secure\"",
"]",
",",
"$",
"params",
"[",
"\"httponly\"",
"]",
")",
";",
"}",
"session_destroy",
"(",
")",
";",
"}"
] |
Destroys the PHP session.
|
[
"Destroys",
"the",
"PHP",
"session",
"."
] |
2ac9d3e493035dcc68f3c3812423327127327cd5
|
https://github.com/railsphp/framework/blob/2ac9d3e493035dcc68f3c3812423327127327cd5/src/Rails/ActionDispatch/Http/Session.php#L100-L115
|
239,421
|
zepi/turbo-base
|
Zepi/Web/UserInterface/src/Form/Group.php
|
Group.getHtmlId
|
public function getHtmlId()
{
$form = $this->getParentOfType('\\Zepi\\Web\\UserInterface\\Form\\Form');
// If the group isn't assigned to a data form we can not generate
// the id of the group.
if (!$form) {
return $this->key;
}
return $form->getHtmlId() . '-' . $this->key;
}
|
php
|
public function getHtmlId()
{
$form = $this->getParentOfType('\\Zepi\\Web\\UserInterface\\Form\\Form');
// If the group isn't assigned to a data form we can not generate
// the id of the group.
if (!$form) {
return $this->key;
}
return $form->getHtmlId() . '-' . $this->key;
}
|
[
"public",
"function",
"getHtmlId",
"(",
")",
"{",
"$",
"form",
"=",
"$",
"this",
"->",
"getParentOfType",
"(",
"'\\\\Zepi\\\\Web\\\\UserInterface\\\\Form\\\\Form'",
")",
";",
"// If the group isn't assigned to a data form we can not generate",
"// the id of the group.",
"if",
"(",
"!",
"$",
"form",
")",
"{",
"return",
"$",
"this",
"->",
"key",
";",
"}",
"return",
"$",
"form",
"->",
"getHtmlId",
"(",
")",
".",
"'-'",
".",
"$",
"this",
"->",
"key",
";",
"}"
] |
Returns the html id of this group
@access public
@return string
|
[
"Returns",
"the",
"html",
"id",
"of",
"this",
"group"
] |
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
|
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Web/UserInterface/src/Form/Group.php#L94-L105
|
239,422
|
coolms/common
|
src/Form/Annotation/AnnotationBuilderTrait.php
|
AnnotationBuilderTrait.getFormFactory
|
public function getFormFactory()
{
if ($this->formFactory) {
return $this->formFactory;
}
$this->formFactory = new Factory();
return $this->formFactory;
}
|
php
|
public function getFormFactory()
{
if ($this->formFactory) {
return $this->formFactory;
}
$this->formFactory = new Factory();
return $this->formFactory;
}
|
[
"public",
"function",
"getFormFactory",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"formFactory",
")",
"{",
"return",
"$",
"this",
"->",
"formFactory",
";",
"}",
"$",
"this",
"->",
"formFactory",
"=",
"new",
"Factory",
"(",
")",
";",
"return",
"$",
"this",
"->",
"formFactory",
";",
"}"
] |
Retrieve form factory
Lazy-loads the default form factory if none is currently set.
@return Factory
|
[
"Retrieve",
"form",
"factory"
] |
3572993cdcdb2898cdde396a2f1de9864b193660
|
https://github.com/coolms/common/blob/3572993cdcdb2898cdde396a2f1de9864b193660/src/Form/Annotation/AnnotationBuilderTrait.php#L32-L40
|
239,423
|
coolms/common
|
src/Form/Annotation/AnnotationBuilderTrait.php
|
AnnotationBuilderTrait.createForm
|
public function createForm($entity)
{
$formSpec = ArrayUtils::iteratorToArray($this->getFormSpecification($entity));
if (!isset($formSpec['options']['merge_input_filter'])) {
$formSpec['options']['merge_input_filter'] = true;
}
return $this->getFormFactory()->createForm($formSpec);
}
|
php
|
public function createForm($entity)
{
$formSpec = ArrayUtils::iteratorToArray($this->getFormSpecification($entity));
if (!isset($formSpec['options']['merge_input_filter'])) {
$formSpec['options']['merge_input_filter'] = true;
}
return $this->getFormFactory()->createForm($formSpec);
}
|
[
"public",
"function",
"createForm",
"(",
"$",
"entity",
")",
"{",
"$",
"formSpec",
"=",
"ArrayUtils",
"::",
"iteratorToArray",
"(",
"$",
"this",
"->",
"getFormSpecification",
"(",
"$",
"entity",
")",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"formSpec",
"[",
"'options'",
"]",
"[",
"'merge_input_filter'",
"]",
")",
")",
"{",
"$",
"formSpec",
"[",
"'options'",
"]",
"[",
"'merge_input_filter'",
"]",
"=",
"true",
";",
"}",
"return",
"$",
"this",
"->",
"getFormFactory",
"(",
")",
"->",
"createForm",
"(",
"$",
"formSpec",
")",
";",
"}"
] |
Create a form from an object.
@param string|object $entity
@return \CmsCommon\Form\FormInterface
|
[
"Create",
"a",
"form",
"from",
"an",
"object",
"."
] |
3572993cdcdb2898cdde396a2f1de9864b193660
|
https://github.com/coolms/common/blob/3572993cdcdb2898cdde396a2f1de9864b193660/src/Form/Annotation/AnnotationBuilderTrait.php#L48-L56
|
239,424
|
coolms/common
|
src/Form/Annotation/AnnotationBuilderTrait.php
|
AnnotationBuilderTrait.configureElement
|
protected function configureElement($annotations, $reflection, $formSpec, $filterSpec)
{
// If the element is marked as exclude, return early
if ($this->checkForExclude($annotations)) {
return;
}
$events = $this->getEventManager();
$name = $this->discoverName($annotations, $reflection);
$elementSpec = new ArrayObject([
'flags' => [],
'spec' => [
'name' => $name
],
]);
$inputSpec = new ArrayObject([
'name' => $name,
]);
$event = new Event();
$event->setParams([
'name' => $name,
'elementSpec' => $elementSpec,
'inputSpec' => $inputSpec,
'formSpec' => $formSpec,
'filterSpec' => $filterSpec,
]);
foreach ($annotations as $annotation) {
$event->setParam('annotation', $annotation);
$events->trigger(__FUNCTION__, $this, $event);
}
// Since "filters", "type", "validators" is a reserved names in the filter specification,
// we need to add the specification without the name as the key.
// In all other cases, though, the name is fine.
if ($event->getParam('inputSpec')->count() > 1 || $annotations->hasAnnotation(Input::class)) {
if ($name === 'type' || $name === 'filters' || $name === 'validators') {
$filterSpec[] = $event->getParam('inputSpec');
} else {
$filterSpec[$name] = $event->getParam('inputSpec');
}
}
$elementSpec = $event->getParam('elementSpec');
$type = isset($elementSpec['spec']['type'])
? $elementSpec['spec']['type']
: Element::class;
// Compose as a fieldset or an element, based on specification type.
// If preserve defined order is true, all elements are composed as elements to keep their ordering
if (!$this->preserveDefinedOrder() && is_subclass_of($type, FieldsetInterface::class)) {
if (!isset($formSpec['fieldsets'])) {
$formSpec['fieldsets'] = [];
}
if (isset($formSpec['fieldsets'][$name])) {
$formSpec['fieldsets'][] = $elementSpec;
} else {
$formSpec['fieldsets'][$name] = $elementSpec;
}
} else {
if (!isset($formSpec['elements'])) {
$formSpec['elements'] = [];
}
if (isset($formSpec['elements'][$name])) {
$formSpec['elements'][] = $elementSpec;
} else {
$formSpec['elements'][$name] = $elementSpec;
}
}
}
|
php
|
protected function configureElement($annotations, $reflection, $formSpec, $filterSpec)
{
// If the element is marked as exclude, return early
if ($this->checkForExclude($annotations)) {
return;
}
$events = $this->getEventManager();
$name = $this->discoverName($annotations, $reflection);
$elementSpec = new ArrayObject([
'flags' => [],
'spec' => [
'name' => $name
],
]);
$inputSpec = new ArrayObject([
'name' => $name,
]);
$event = new Event();
$event->setParams([
'name' => $name,
'elementSpec' => $elementSpec,
'inputSpec' => $inputSpec,
'formSpec' => $formSpec,
'filterSpec' => $filterSpec,
]);
foreach ($annotations as $annotation) {
$event->setParam('annotation', $annotation);
$events->trigger(__FUNCTION__, $this, $event);
}
// Since "filters", "type", "validators" is a reserved names in the filter specification,
// we need to add the specification without the name as the key.
// In all other cases, though, the name is fine.
if ($event->getParam('inputSpec')->count() > 1 || $annotations->hasAnnotation(Input::class)) {
if ($name === 'type' || $name === 'filters' || $name === 'validators') {
$filterSpec[] = $event->getParam('inputSpec');
} else {
$filterSpec[$name] = $event->getParam('inputSpec');
}
}
$elementSpec = $event->getParam('elementSpec');
$type = isset($elementSpec['spec']['type'])
? $elementSpec['spec']['type']
: Element::class;
// Compose as a fieldset or an element, based on specification type.
// If preserve defined order is true, all elements are composed as elements to keep their ordering
if (!$this->preserveDefinedOrder() && is_subclass_of($type, FieldsetInterface::class)) {
if (!isset($formSpec['fieldsets'])) {
$formSpec['fieldsets'] = [];
}
if (isset($formSpec['fieldsets'][$name])) {
$formSpec['fieldsets'][] = $elementSpec;
} else {
$formSpec['fieldsets'][$name] = $elementSpec;
}
} else {
if (!isset($formSpec['elements'])) {
$formSpec['elements'] = [];
}
if (isset($formSpec['elements'][$name])) {
$formSpec['elements'][] = $elementSpec;
} else {
$formSpec['elements'][$name] = $elementSpec;
}
}
}
|
[
"protected",
"function",
"configureElement",
"(",
"$",
"annotations",
",",
"$",
"reflection",
",",
"$",
"formSpec",
",",
"$",
"filterSpec",
")",
"{",
"// If the element is marked as exclude, return early",
"if",
"(",
"$",
"this",
"->",
"checkForExclude",
"(",
"$",
"annotations",
")",
")",
"{",
"return",
";",
"}",
"$",
"events",
"=",
"$",
"this",
"->",
"getEventManager",
"(",
")",
";",
"$",
"name",
"=",
"$",
"this",
"->",
"discoverName",
"(",
"$",
"annotations",
",",
"$",
"reflection",
")",
";",
"$",
"elementSpec",
"=",
"new",
"ArrayObject",
"(",
"[",
"'flags'",
"=>",
"[",
"]",
",",
"'spec'",
"=>",
"[",
"'name'",
"=>",
"$",
"name",
"]",
",",
"]",
")",
";",
"$",
"inputSpec",
"=",
"new",
"ArrayObject",
"(",
"[",
"'name'",
"=>",
"$",
"name",
",",
"]",
")",
";",
"$",
"event",
"=",
"new",
"Event",
"(",
")",
";",
"$",
"event",
"->",
"setParams",
"(",
"[",
"'name'",
"=>",
"$",
"name",
",",
"'elementSpec'",
"=>",
"$",
"elementSpec",
",",
"'inputSpec'",
"=>",
"$",
"inputSpec",
",",
"'formSpec'",
"=>",
"$",
"formSpec",
",",
"'filterSpec'",
"=>",
"$",
"filterSpec",
",",
"]",
")",
";",
"foreach",
"(",
"$",
"annotations",
"as",
"$",
"annotation",
")",
"{",
"$",
"event",
"->",
"setParam",
"(",
"'annotation'",
",",
"$",
"annotation",
")",
";",
"$",
"events",
"->",
"trigger",
"(",
"__FUNCTION__",
",",
"$",
"this",
",",
"$",
"event",
")",
";",
"}",
"// Since \"filters\", \"type\", \"validators\" is a reserved names in the filter specification,",
"// we need to add the specification without the name as the key.",
"// In all other cases, though, the name is fine.",
"if",
"(",
"$",
"event",
"->",
"getParam",
"(",
"'inputSpec'",
")",
"->",
"count",
"(",
")",
">",
"1",
"||",
"$",
"annotations",
"->",
"hasAnnotation",
"(",
"Input",
"::",
"class",
")",
")",
"{",
"if",
"(",
"$",
"name",
"===",
"'type'",
"||",
"$",
"name",
"===",
"'filters'",
"||",
"$",
"name",
"===",
"'validators'",
")",
"{",
"$",
"filterSpec",
"[",
"]",
"=",
"$",
"event",
"->",
"getParam",
"(",
"'inputSpec'",
")",
";",
"}",
"else",
"{",
"$",
"filterSpec",
"[",
"$",
"name",
"]",
"=",
"$",
"event",
"->",
"getParam",
"(",
"'inputSpec'",
")",
";",
"}",
"}",
"$",
"elementSpec",
"=",
"$",
"event",
"->",
"getParam",
"(",
"'elementSpec'",
")",
";",
"$",
"type",
"=",
"isset",
"(",
"$",
"elementSpec",
"[",
"'spec'",
"]",
"[",
"'type'",
"]",
")",
"?",
"$",
"elementSpec",
"[",
"'spec'",
"]",
"[",
"'type'",
"]",
":",
"Element",
"::",
"class",
";",
"// Compose as a fieldset or an element, based on specification type.",
"// If preserve defined order is true, all elements are composed as elements to keep their ordering",
"if",
"(",
"!",
"$",
"this",
"->",
"preserveDefinedOrder",
"(",
")",
"&&",
"is_subclass_of",
"(",
"$",
"type",
",",
"FieldsetInterface",
"::",
"class",
")",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"formSpec",
"[",
"'fieldsets'",
"]",
")",
")",
"{",
"$",
"formSpec",
"[",
"'fieldsets'",
"]",
"=",
"[",
"]",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"formSpec",
"[",
"'fieldsets'",
"]",
"[",
"$",
"name",
"]",
")",
")",
"{",
"$",
"formSpec",
"[",
"'fieldsets'",
"]",
"[",
"]",
"=",
"$",
"elementSpec",
";",
"}",
"else",
"{",
"$",
"formSpec",
"[",
"'fieldsets'",
"]",
"[",
"$",
"name",
"]",
"=",
"$",
"elementSpec",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"formSpec",
"[",
"'elements'",
"]",
")",
")",
"{",
"$",
"formSpec",
"[",
"'elements'",
"]",
"=",
"[",
"]",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"formSpec",
"[",
"'elements'",
"]",
"[",
"$",
"name",
"]",
")",
")",
"{",
"$",
"formSpec",
"[",
"'elements'",
"]",
"[",
"]",
"=",
"$",
"elementSpec",
";",
"}",
"else",
"{",
"$",
"formSpec",
"[",
"'elements'",
"]",
"[",
"$",
"name",
"]",
"=",
"$",
"elementSpec",
";",
"}",
"}",
"}"
] |
Configure an element from annotations
@param AnnotationCollection $annotations
@param PropertyReflection $reflection
@param ArrayObject $formSpec
@param ArrayObject $filterSpec
@return void
@triggers checkForExclude
@triggers discoverName
@triggers configureElement
|
[
"Configure",
"an",
"element",
"from",
"annotations"
] |
3572993cdcdb2898cdde396a2f1de9864b193660
|
https://github.com/coolms/common/blob/3572993cdcdb2898cdde396a2f1de9864b193660/src/Form/Annotation/AnnotationBuilderTrait.php#L71-L146
|
239,425
|
Fenzland/Htsl.php
|
libs/Htsl.php
|
Htsl.compile
|
public function compile( string$fromFile, string$toFile='' )
{
$fromFile= $this->getFilePath($fromFile);
$result= $this->execute(new FileBuffer($this,$fromFile));
if( $toFile ){
return file_put_contents($toFile,$result);
}else{
return $result;
}
}
|
php
|
public function compile( string$fromFile, string$toFile='' )
{
$fromFile= $this->getFilePath($fromFile);
$result= $this->execute(new FileBuffer($this,$fromFile));
if( $toFile ){
return file_put_contents($toFile,$result);
}else{
return $result;
}
}
|
[
"public",
"function",
"compile",
"(",
"string",
"$",
"fromFile",
",",
"string",
"$",
"toFile",
"=",
"''",
")",
"{",
"$",
"fromFile",
"=",
"$",
"this",
"->",
"getFilePath",
"(",
"$",
"fromFile",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"execute",
"(",
"new",
"FileBuffer",
"(",
"$",
"this",
",",
"$",
"fromFile",
")",
")",
";",
"if",
"(",
"$",
"toFile",
")",
"{",
"return",
"file_put_contents",
"(",
"$",
"toFile",
",",
"$",
"result",
")",
";",
"}",
"else",
"{",
"return",
"$",
"result",
";",
"}",
"}"
] |
Compiling a HTSL file into a HTML or PHP file.
@api
@access public
@param string $fromFile
@param string $toFile
@return int|string
|
[
"Compiling",
"a",
"HTSL",
"file",
"into",
"a",
"HTML",
"or",
"PHP",
"file",
"."
] |
28ecc4afd1a5bdb29dea3589c8132adba87f3947
|
https://github.com/Fenzland/Htsl.php/blob/28ecc4afd1a5bdb29dea3589c8132adba87f3947/libs/Htsl.php#L92-L103
|
239,426
|
Fenzland/Htsl.php
|
libs/Htsl.php
|
Htsl.setBasePath
|
public function setBasePath( string$basePath ):self
{
$this->basePath= '/'===substr($basePath,-1) ? substr($basePath,0,-1) : $basePath;
return $this;
}
|
php
|
public function setBasePath( string$basePath ):self
{
$this->basePath= '/'===substr($basePath,-1) ? substr($basePath,0,-1) : $basePath;
return $this;
}
|
[
"public",
"function",
"setBasePath",
"(",
"string",
"$",
"basePath",
")",
":",
"self",
"{",
"$",
"this",
"->",
"basePath",
"=",
"'/'",
"===",
"substr",
"(",
"$",
"basePath",
",",
"-",
"1",
")",
"?",
"substr",
"(",
"$",
"basePath",
",",
"0",
",",
"-",
"1",
")",
":",
"$",
"basePath",
";",
"return",
"$",
"this",
";",
"}"
] |
Setting the base path of the HTSL project to parse.
@api
@access public
@param string $basePath
@return self
|
[
"Setting",
"the",
"base",
"path",
"of",
"the",
"HTSL",
"project",
"to",
"parse",
"."
] |
28ecc4afd1a5bdb29dea3589c8132adba87f3947
|
https://github.com/Fenzland/Htsl.php/blob/28ecc4afd1a5bdb29dea3589c8132adba87f3947/libs/Htsl.php#L132-L137
|
239,427
|
Fenzland/Htsl.php
|
libs/Htsl.php
|
Htsl.getConfig
|
public function getConfig( string...$keys )
{
$result= $this->config;
foreach( $keys as $key ){
if( !isset($result[$key]) )
{ return null; }
$result= $result[$key];
}
return $result;
}
|
php
|
public function getConfig( string...$keys )
{
$result= $this->config;
foreach( $keys as $key ){
if( !isset($result[$key]) )
{ return null; }
$result= $result[$key];
}
return $result;
}
|
[
"public",
"function",
"getConfig",
"(",
"string",
"...",
"$",
"keys",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"config",
";",
"foreach",
"(",
"$",
"keys",
"as",
"$",
"key",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"result",
"[",
"$",
"key",
"]",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"result",
"=",
"$",
"result",
"[",
"$",
"key",
"]",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Getting the config of Htsl.
@internal
@access public
@param string $keys
@return mixed
|
[
"Getting",
"the",
"config",
"of",
"Htsl",
"."
] |
28ecc4afd1a5bdb29dea3589c8132adba87f3947
|
https://github.com/Fenzland/Htsl.php/blob/28ecc4afd1a5bdb29dea3589c8132adba87f3947/libs/Htsl.php#L180-L192
|
239,428
|
Fenzland/Htsl.php
|
libs/Htsl.php
|
Htsl.getFilePath
|
public function getFilePath( string$filePath, string$path=null ):string
{
if( !isset($this->basePath) )
{ throw new \Exception('BasePath musbe set.'); }
if( !strlen($filePath) )
{ throw new \Exception('FilePath cannot be empty.'); }
if( '/'===$filePath{0} ){
if( is_null($path) )
{ return $filePath; }
else
{ return $this->basePath.$filePath; }
}else{
if( !strlen($path) )
{ return $this->basePath.'/'.$filePath; }
elseif( '/'===substr($path,-1) )
{ return $path.$filePath; }
else
{ return $path.'/'.$filePath; }
}
}
|
php
|
public function getFilePath( string$filePath, string$path=null ):string
{
if( !isset($this->basePath) )
{ throw new \Exception('BasePath musbe set.'); }
if( !strlen($filePath) )
{ throw new \Exception('FilePath cannot be empty.'); }
if( '/'===$filePath{0} ){
if( is_null($path) )
{ return $filePath; }
else
{ return $this->basePath.$filePath; }
}else{
if( !strlen($path) )
{ return $this->basePath.'/'.$filePath; }
elseif( '/'===substr($path,-1) )
{ return $path.$filePath; }
else
{ return $path.'/'.$filePath; }
}
}
|
[
"public",
"function",
"getFilePath",
"(",
"string",
"$",
"filePath",
",",
"string",
"$",
"path",
"=",
"null",
")",
":",
"string",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"basePath",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'BasePath musbe set.'",
")",
";",
"}",
"if",
"(",
"!",
"strlen",
"(",
"$",
"filePath",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'FilePath cannot be empty.'",
")",
";",
"}",
"if",
"(",
"'/'",
"===",
"$",
"filePath",
"{",
"0",
"}",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"path",
")",
")",
"{",
"return",
"$",
"filePath",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"basePath",
".",
"$",
"filePath",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"!",
"strlen",
"(",
"$",
"path",
")",
")",
"{",
"return",
"$",
"this",
"->",
"basePath",
".",
"'/'",
".",
"$",
"filePath",
";",
"}",
"elseif",
"(",
"'/'",
"===",
"substr",
"(",
"$",
"path",
",",
"-",
"1",
")",
")",
"{",
"return",
"$",
"path",
".",
"$",
"filePath",
";",
"}",
"else",
"{",
"return",
"$",
"path",
".",
"'/'",
".",
"$",
"filePath",
";",
"}",
"}",
"}"
] |
Getting the real file path of the HTSL file by relative path.
@internal
@access public
@param string $filePath
@param string|null $path
@return string
|
[
"Getting",
"the",
"real",
"file",
"path",
"of",
"the",
"HTSL",
"file",
"by",
"relative",
"path",
"."
] |
28ecc4afd1a5bdb29dea3589c8132adba87f3947
|
https://github.com/Fenzland/Htsl.php/blob/28ecc4afd1a5bdb29dea3589c8132adba87f3947/libs/Htsl.php#L206-L228
|
239,429
|
Fenzland/Htsl.php
|
libs/Htsl.php
|
Htsl.getFileContent
|
public function getFileContent( string$filePath ):string
{
return isset($this->fileGetter) ? $this->fileGetter($filePath) : file_get_contents($filePath);
}
|
php
|
public function getFileContent( string$filePath ):string
{
return isset($this->fileGetter) ? $this->fileGetter($filePath) : file_get_contents($filePath);
}
|
[
"public",
"function",
"getFileContent",
"(",
"string",
"$",
"filePath",
")",
":",
"string",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"fileGetter",
")",
"?",
"$",
"this",
"->",
"fileGetter",
"(",
"$",
"filePath",
")",
":",
"file_get_contents",
"(",
"$",
"filePath",
")",
";",
"}"
] |
Getting the content of file.
@internal
@access public
@param string $filePath
@return string
|
[
"Getting",
"the",
"content",
"of",
"file",
"."
] |
28ecc4afd1a5bdb29dea3589c8132adba87f3947
|
https://github.com/Fenzland/Htsl.php/blob/28ecc4afd1a5bdb29dea3589c8132adba87f3947/libs/Htsl.php#L241-L244
|
239,430
|
mpaleo/scaffolder-support
|
src/Scaffolder/Support/InputTypeResolverTrait.php
|
InputTypeResolverTrait.getInputFor
|
public static function getInputFor(\stdClass $fieldData)
{
$formData = explode(':', $fieldData->type->ui);
$type = $formData[0];
$options = isset($formData[1]) ? $formData[1] : '[]';
if ($type == 'text' ||
$type == 'number' ||
$type == 'textarea' ||
$type == 'date'
)
{
return '{!! Form::' . $type . '(\'' . $fieldData->name . '\', (isset($model)) ? $model->' . $fieldData->name . ' : null, ' . $options . ') !!}';
}
elseif ($type == 'select')
{
$list = isset($formData[1]) ? $formData[1] : '[]';
$options = isset($formData[2]) ? $formData[2] : '[]';
return '{!! Form::select(\'' . $fieldData->name . '\', ' . $list . ', (isset($model)) ? $model->' . $fieldData->name . ' : null, ' . $options . ') !!}';
}
elseif ($type == 'selectRange')
{
$begin = isset($formData[1]) ? $formData[1] : '0';
$end = isset($formData[2]) ? $formData[2] : '0';
$options = isset($formData[3]) ? $formData[3] : '[]';
return '{!! Form::selectRange(\'' . $fieldData->name . '\', ' . $begin . ', ' . $end . ', (isset($model)) ? $model->' . $fieldData->name . ' : null, ' . $options . ') !!}';
}
elseif ($type == 'checkbox')
{
$options = isset($formData[1]) ? $formData[1] : 'false';
return '{!! Form::checkbox(\'' . $fieldData->name . '\', 1, (isset($model) && $model->' . $fieldData->name . ' == 1) ? true : false, ' . $options . ') !!}';
}
elseif ($type == 'radio')
{
array_shift($formData);
$radioGroup = '';
$radioId = 0;
foreach ($formData as $value)
{
$radioGroup .= '{!! Form::radio(\'' . $fieldData->name . '\', \'' . $value . '\', (isset($model) && $model->' . $fieldData->name . ' == \'' . $value . '\') ? true : false, [\'id\' => ' . $radioId . ']) !!}';
$radioId++;
if (end($formData) != $value) $radioGroup .= PHP_EOL . "\t";
}
return $radioGroup;
}
else
{
throw new \Exception('Input type not implemented');
}
}
|
php
|
public static function getInputFor(\stdClass $fieldData)
{
$formData = explode(':', $fieldData->type->ui);
$type = $formData[0];
$options = isset($formData[1]) ? $formData[1] : '[]';
if ($type == 'text' ||
$type == 'number' ||
$type == 'textarea' ||
$type == 'date'
)
{
return '{!! Form::' . $type . '(\'' . $fieldData->name . '\', (isset($model)) ? $model->' . $fieldData->name . ' : null, ' . $options . ') !!}';
}
elseif ($type == 'select')
{
$list = isset($formData[1]) ? $formData[1] : '[]';
$options = isset($formData[2]) ? $formData[2] : '[]';
return '{!! Form::select(\'' . $fieldData->name . '\', ' . $list . ', (isset($model)) ? $model->' . $fieldData->name . ' : null, ' . $options . ') !!}';
}
elseif ($type == 'selectRange')
{
$begin = isset($formData[1]) ? $formData[1] : '0';
$end = isset($formData[2]) ? $formData[2] : '0';
$options = isset($formData[3]) ? $formData[3] : '[]';
return '{!! Form::selectRange(\'' . $fieldData->name . '\', ' . $begin . ', ' . $end . ', (isset($model)) ? $model->' . $fieldData->name . ' : null, ' . $options . ') !!}';
}
elseif ($type == 'checkbox')
{
$options = isset($formData[1]) ? $formData[1] : 'false';
return '{!! Form::checkbox(\'' . $fieldData->name . '\', 1, (isset($model) && $model->' . $fieldData->name . ' == 1) ? true : false, ' . $options . ') !!}';
}
elseif ($type == 'radio')
{
array_shift($formData);
$radioGroup = '';
$radioId = 0;
foreach ($formData as $value)
{
$radioGroup .= '{!! Form::radio(\'' . $fieldData->name . '\', \'' . $value . '\', (isset($model) && $model->' . $fieldData->name . ' == \'' . $value . '\') ? true : false, [\'id\' => ' . $radioId . ']) !!}';
$radioId++;
if (end($formData) != $value) $radioGroup .= PHP_EOL . "\t";
}
return $radioGroup;
}
else
{
throw new \Exception('Input type not implemented');
}
}
|
[
"public",
"static",
"function",
"getInputFor",
"(",
"\\",
"stdClass",
"$",
"fieldData",
")",
"{",
"$",
"formData",
"=",
"explode",
"(",
"':'",
",",
"$",
"fieldData",
"->",
"type",
"->",
"ui",
")",
";",
"$",
"type",
"=",
"$",
"formData",
"[",
"0",
"]",
";",
"$",
"options",
"=",
"isset",
"(",
"$",
"formData",
"[",
"1",
"]",
")",
"?",
"$",
"formData",
"[",
"1",
"]",
":",
"'[]'",
";",
"if",
"(",
"$",
"type",
"==",
"'text'",
"||",
"$",
"type",
"==",
"'number'",
"||",
"$",
"type",
"==",
"'textarea'",
"||",
"$",
"type",
"==",
"'date'",
")",
"{",
"return",
"'{!! Form::'",
".",
"$",
"type",
".",
"'(\\''",
".",
"$",
"fieldData",
"->",
"name",
".",
"'\\', (isset($model)) ? $model->'",
".",
"$",
"fieldData",
"->",
"name",
".",
"' : null, '",
".",
"$",
"options",
".",
"') !!}'",
";",
"}",
"elseif",
"(",
"$",
"type",
"==",
"'select'",
")",
"{",
"$",
"list",
"=",
"isset",
"(",
"$",
"formData",
"[",
"1",
"]",
")",
"?",
"$",
"formData",
"[",
"1",
"]",
":",
"'[]'",
";",
"$",
"options",
"=",
"isset",
"(",
"$",
"formData",
"[",
"2",
"]",
")",
"?",
"$",
"formData",
"[",
"2",
"]",
":",
"'[]'",
";",
"return",
"'{!! Form::select(\\''",
".",
"$",
"fieldData",
"->",
"name",
".",
"'\\', '",
".",
"$",
"list",
".",
"', (isset($model)) ? $model->'",
".",
"$",
"fieldData",
"->",
"name",
".",
"' : null, '",
".",
"$",
"options",
".",
"') !!}'",
";",
"}",
"elseif",
"(",
"$",
"type",
"==",
"'selectRange'",
")",
"{",
"$",
"begin",
"=",
"isset",
"(",
"$",
"formData",
"[",
"1",
"]",
")",
"?",
"$",
"formData",
"[",
"1",
"]",
":",
"'0'",
";",
"$",
"end",
"=",
"isset",
"(",
"$",
"formData",
"[",
"2",
"]",
")",
"?",
"$",
"formData",
"[",
"2",
"]",
":",
"'0'",
";",
"$",
"options",
"=",
"isset",
"(",
"$",
"formData",
"[",
"3",
"]",
")",
"?",
"$",
"formData",
"[",
"3",
"]",
":",
"'[]'",
";",
"return",
"'{!! Form::selectRange(\\''",
".",
"$",
"fieldData",
"->",
"name",
".",
"'\\', '",
".",
"$",
"begin",
".",
"', '",
".",
"$",
"end",
".",
"', (isset($model)) ? $model->'",
".",
"$",
"fieldData",
"->",
"name",
".",
"' : null, '",
".",
"$",
"options",
".",
"') !!}'",
";",
"}",
"elseif",
"(",
"$",
"type",
"==",
"'checkbox'",
")",
"{",
"$",
"options",
"=",
"isset",
"(",
"$",
"formData",
"[",
"1",
"]",
")",
"?",
"$",
"formData",
"[",
"1",
"]",
":",
"'false'",
";",
"return",
"'{!! Form::checkbox(\\''",
".",
"$",
"fieldData",
"->",
"name",
".",
"'\\', 1, (isset($model) && $model->'",
".",
"$",
"fieldData",
"->",
"name",
".",
"' == 1) ? true : false, '",
".",
"$",
"options",
".",
"') !!}'",
";",
"}",
"elseif",
"(",
"$",
"type",
"==",
"'radio'",
")",
"{",
"array_shift",
"(",
"$",
"formData",
")",
";",
"$",
"radioGroup",
"=",
"''",
";",
"$",
"radioId",
"=",
"0",
";",
"foreach",
"(",
"$",
"formData",
"as",
"$",
"value",
")",
"{",
"$",
"radioGroup",
".=",
"'{!! Form::radio(\\''",
".",
"$",
"fieldData",
"->",
"name",
".",
"'\\', \\''",
".",
"$",
"value",
".",
"'\\', (isset($model) && $model->'",
".",
"$",
"fieldData",
"->",
"name",
".",
"' == \\''",
".",
"$",
"value",
".",
"'\\') ? true : false, [\\'id\\' => '",
".",
"$",
"radioId",
".",
"']) !!}'",
";",
"$",
"radioId",
"++",
";",
"if",
"(",
"end",
"(",
"$",
"formData",
")",
"!=",
"$",
"value",
")",
"$",
"radioGroup",
".=",
"PHP_EOL",
".",
"\"\\t\"",
";",
"}",
"return",
"$",
"radioGroup",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Input type not implemented'",
")",
";",
"}",
"}"
] |
Get the input for the field.
@param \stdClass $fieldData
@return string
@throws \Exception
|
[
"Get",
"the",
"input",
"for",
"the",
"field",
"."
] |
d599c88596c65302a984078cd0519221a2d2ceac
|
https://github.com/mpaleo/scaffolder-support/blob/d599c88596c65302a984078cd0519221a2d2ceac/src/Scaffolder/Support/InputTypeResolverTrait.php#L15-L70
|
239,431
|
harpya/ufw-base
|
src/ufw/Router.php
|
Router.processMap
|
protected function processMap($arr, $prefix='') {
foreach ($arr as $uri => $options) {
$uri = $prefix . $this->preProcessURI($uri);
foreach ($options as $method => $target) {
if (!is_array($target)) continue;
if (array_key_exists('name', $target)) {
$this->map($method, $uri, $target, $target['name']);
} else {
$this->map($method, $uri, $target);
}
}
}
}
|
php
|
protected function processMap($arr, $prefix='') {
foreach ($arr as $uri => $options) {
$uri = $prefix . $this->preProcessURI($uri);
foreach ($options as $method => $target) {
if (!is_array($target)) continue;
if (array_key_exists('name', $target)) {
$this->map($method, $uri, $target, $target['name']);
} else {
$this->map($method, $uri, $target);
}
}
}
}
|
[
"protected",
"function",
"processMap",
"(",
"$",
"arr",
",",
"$",
"prefix",
"=",
"''",
")",
"{",
"foreach",
"(",
"$",
"arr",
"as",
"$",
"uri",
"=>",
"$",
"options",
")",
"{",
"$",
"uri",
"=",
"$",
"prefix",
".",
"$",
"this",
"->",
"preProcessURI",
"(",
"$",
"uri",
")",
";",
"foreach",
"(",
"$",
"options",
"as",
"$",
"method",
"=>",
"$",
"target",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"target",
")",
")",
"continue",
";",
"if",
"(",
"array_key_exists",
"(",
"'name'",
",",
"$",
"target",
")",
")",
"{",
"$",
"this",
"->",
"map",
"(",
"$",
"method",
",",
"$",
"uri",
",",
"$",
"target",
",",
"$",
"target",
"[",
"'name'",
"]",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"map",
"(",
"$",
"method",
",",
"$",
"uri",
",",
"$",
"target",
")",
";",
"}",
"}",
"}",
"}"
] |
For each array item, pre process and add to global mapping
@param array $arr
@param string $prefix
|
[
"For",
"each",
"array",
"item",
"pre",
"process",
"and",
"add",
"to",
"global",
"mapping"
] |
9e2db1d9625f4b875783f98830e0410cf4fd125b
|
https://github.com/harpya/ufw-base/blob/9e2db1d9625f4b875783f98830e0410cf4fd125b/src/ufw/Router.php#L74-L92
|
239,432
|
harpya/ufw-base
|
src/ufw/Router.php
|
Router.preProcessURI
|
public function preProcessURI($uri) {
$s = preg_replace("/\{([\w]+)\}/", "[*:$1]", $uri);
if (!empty($s)) {
$uri = $s;
}
return $uri;
}
|
php
|
public function preProcessURI($uri) {
$s = preg_replace("/\{([\w]+)\}/", "[*:$1]", $uri);
if (!empty($s)) {
$uri = $s;
}
return $uri;
}
|
[
"public",
"function",
"preProcessURI",
"(",
"$",
"uri",
")",
"{",
"$",
"s",
"=",
"preg_replace",
"(",
"\"/\\{([\\w]+)\\}/\"",
",",
"\"[*:$1]\"",
",",
"$",
"uri",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"s",
")",
")",
"{",
"$",
"uri",
"=",
"$",
"s",
";",
"}",
"return",
"$",
"uri",
";",
"}"
] |
Replace the macros by regular expressions to extract arguments from URL
@param string $uri
@return string
|
[
"Replace",
"the",
"macros",
"by",
"regular",
"expressions",
"to",
"extract",
"arguments",
"from",
"URL"
] |
9e2db1d9625f4b875783f98830e0410cf4fd125b
|
https://github.com/harpya/ufw-base/blob/9e2db1d9625f4b875783f98830e0410cf4fd125b/src/ufw/Router.php#L99-L107
|
239,433
|
harpya/ufw-base
|
src/ufw/Router.php
|
Router.evaluate
|
public function evaluate($target) {
switch (Utils::get('type', $target)) {
case 'class' :
$return = $this->processClass(Utils::get('target',$target), Utils::get('match', $target));
break;
case 'controller' :
$return = $this->processController(Utils::get('target', $target), Utils::get('match', $target));
break;
case 'view':
$return = $this->processView(Utils::get('target', $target), Utils::get('match', $target));
break;
case 'eval':
$return = eval($target['target']['eval']);
break;
default:
throw new \Exception("Undefined target",404);
}
return $return;
}
|
php
|
public function evaluate($target) {
switch (Utils::get('type', $target)) {
case 'class' :
$return = $this->processClass(Utils::get('target',$target), Utils::get('match', $target));
break;
case 'controller' :
$return = $this->processController(Utils::get('target', $target), Utils::get('match', $target));
break;
case 'view':
$return = $this->processView(Utils::get('target', $target), Utils::get('match', $target));
break;
case 'eval':
$return = eval($target['target']['eval']);
break;
default:
throw new \Exception("Undefined target",404);
}
return $return;
}
|
[
"public",
"function",
"evaluate",
"(",
"$",
"target",
")",
"{",
"switch",
"(",
"Utils",
"::",
"get",
"(",
"'type'",
",",
"$",
"target",
")",
")",
"{",
"case",
"'class'",
":",
"$",
"return",
"=",
"$",
"this",
"->",
"processClass",
"(",
"Utils",
"::",
"get",
"(",
"'target'",
",",
"$",
"target",
")",
",",
"Utils",
"::",
"get",
"(",
"'match'",
",",
"$",
"target",
")",
")",
";",
"break",
";",
"case",
"'controller'",
":",
"$",
"return",
"=",
"$",
"this",
"->",
"processController",
"(",
"Utils",
"::",
"get",
"(",
"'target'",
",",
"$",
"target",
")",
",",
"Utils",
"::",
"get",
"(",
"'match'",
",",
"$",
"target",
")",
")",
";",
"break",
";",
"case",
"'view'",
":",
"$",
"return",
"=",
"$",
"this",
"->",
"processView",
"(",
"Utils",
"::",
"get",
"(",
"'target'",
",",
"$",
"target",
")",
",",
"Utils",
"::",
"get",
"(",
"'match'",
",",
"$",
"target",
")",
")",
";",
"break",
";",
"case",
"'eval'",
":",
"$",
"return",
"=",
"eval",
"(",
"$",
"target",
"[",
"'target'",
"]",
"[",
"'eval'",
"]",
")",
";",
"break",
";",
"default",
":",
"throw",
"new",
"\\",
"Exception",
"(",
"\"Undefined target\"",
",",
"404",
")",
";",
"}",
"return",
"$",
"return",
";",
"}"
] |
Determine which type of target is, and execute it.
@param array $target
@return mixed
@throws \Exception
|
[
"Determine",
"which",
"type",
"of",
"target",
"is",
"and",
"execute",
"it",
"."
] |
9e2db1d9625f4b875783f98830e0410cf4fd125b
|
https://github.com/harpya/ufw-base/blob/9e2db1d9625f4b875783f98830e0410cf4fd125b/src/ufw/Router.php#L120-L140
|
239,434
|
harpya/ufw-base
|
src/ufw/Router.php
|
Router.resolve
|
public function resolve() {
$return = false;
$match = $this->match();
if (!$match) {
$target = $this->getDefaultRoute();
if ($target) {
$match = ['target' => $target];
}
}
if (substr(Utils::get('name', $match, ''),0,7) =='plugin:') {
Application::getInstance()->preparePlugin($match['name']);
}
if (is_array($match) && array_key_exists('target', $match)) {
$target = $match['target'];
$return = ['target'=>$target, 'match'=>$match, 'application' => $this->getApplicationName()];
if (array_key_exists('class', $target)) {
$return['type'] = 'class';
} elseif (array_key_exists('controller', $target)) {
$return['type'] = 'controller';
} elseif (array_key_exists('view', $target)) {
$return['type'] = 'view';
} elseif (array_key_exists('eval', $target)) {
$return['type'] = 'eval';
} else {
$return = ['success'=>false, 'msg' => "Target undefined",'code'=>404, 'info'=> $match];
}
} else {
$return = ['success'=>false, 'msg' => "Target not found",'code'=>404, 'info'=> $match];
}
return $return;
}
|
php
|
public function resolve() {
$return = false;
$match = $this->match();
if (!$match) {
$target = $this->getDefaultRoute();
if ($target) {
$match = ['target' => $target];
}
}
if (substr(Utils::get('name', $match, ''),0,7) =='plugin:') {
Application::getInstance()->preparePlugin($match['name']);
}
if (is_array($match) && array_key_exists('target', $match)) {
$target = $match['target'];
$return = ['target'=>$target, 'match'=>$match, 'application' => $this->getApplicationName()];
if (array_key_exists('class', $target)) {
$return['type'] = 'class';
} elseif (array_key_exists('controller', $target)) {
$return['type'] = 'controller';
} elseif (array_key_exists('view', $target)) {
$return['type'] = 'view';
} elseif (array_key_exists('eval', $target)) {
$return['type'] = 'eval';
} else {
$return = ['success'=>false, 'msg' => "Target undefined",'code'=>404, 'info'=> $match];
}
} else {
$return = ['success'=>false, 'msg' => "Target not found",'code'=>404, 'info'=> $match];
}
return $return;
}
|
[
"public",
"function",
"resolve",
"(",
")",
"{",
"$",
"return",
"=",
"false",
";",
"$",
"match",
"=",
"$",
"this",
"->",
"match",
"(",
")",
";",
"if",
"(",
"!",
"$",
"match",
")",
"{",
"$",
"target",
"=",
"$",
"this",
"->",
"getDefaultRoute",
"(",
")",
";",
"if",
"(",
"$",
"target",
")",
"{",
"$",
"match",
"=",
"[",
"'target'",
"=>",
"$",
"target",
"]",
";",
"}",
"}",
"if",
"(",
"substr",
"(",
"Utils",
"::",
"get",
"(",
"'name'",
",",
"$",
"match",
",",
"''",
")",
",",
"0",
",",
"7",
")",
"==",
"'plugin:'",
")",
"{",
"Application",
"::",
"getInstance",
"(",
")",
"->",
"preparePlugin",
"(",
"$",
"match",
"[",
"'name'",
"]",
")",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"match",
")",
"&&",
"array_key_exists",
"(",
"'target'",
",",
"$",
"match",
")",
")",
"{",
"$",
"target",
"=",
"$",
"match",
"[",
"'target'",
"]",
";",
"$",
"return",
"=",
"[",
"'target'",
"=>",
"$",
"target",
",",
"'match'",
"=>",
"$",
"match",
",",
"'application'",
"=>",
"$",
"this",
"->",
"getApplicationName",
"(",
")",
"]",
";",
"if",
"(",
"array_key_exists",
"(",
"'class'",
",",
"$",
"target",
")",
")",
"{",
"$",
"return",
"[",
"'type'",
"]",
"=",
"'class'",
";",
"}",
"elseif",
"(",
"array_key_exists",
"(",
"'controller'",
",",
"$",
"target",
")",
")",
"{",
"$",
"return",
"[",
"'type'",
"]",
"=",
"'controller'",
";",
"}",
"elseif",
"(",
"array_key_exists",
"(",
"'view'",
",",
"$",
"target",
")",
")",
"{",
"$",
"return",
"[",
"'type'",
"]",
"=",
"'view'",
";",
"}",
"elseif",
"(",
"array_key_exists",
"(",
"'eval'",
",",
"$",
"target",
")",
")",
"{",
"$",
"return",
"[",
"'type'",
"]",
"=",
"'eval'",
";",
"}",
"else",
"{",
"$",
"return",
"=",
"[",
"'success'",
"=>",
"false",
",",
"'msg'",
"=>",
"\"Target undefined\"",
",",
"'code'",
"=>",
"404",
",",
"'info'",
"=>",
"$",
"match",
"]",
";",
"}",
"}",
"else",
"{",
"$",
"return",
"=",
"[",
"'success'",
"=>",
"false",
",",
"'msg'",
"=>",
"\"Target not found\"",
",",
"'code'",
"=>",
"404",
",",
"'info'",
"=>",
"$",
"match",
"]",
";",
"}",
"return",
"$",
"return",
";",
"}"
] |
Perform the match among the URI and the routes available
@return mixed
|
[
"Perform",
"the",
"match",
"among",
"the",
"URI",
"and",
"the",
"routes",
"available"
] |
9e2db1d9625f4b875783f98830e0410cf4fd125b
|
https://github.com/harpya/ufw-base/blob/9e2db1d9625f4b875783f98830e0410cf4fd125b/src/ufw/Router.php#L164-L203
|
239,435
|
frogsystem/legacy-bridge
|
src/Controllers/AdminController.php
|
AdminController.assets
|
public function assets(Response $response, $asset)
{
$filesystem = new Filesystem(new Adapter(FS2ADMIN));
$expires = 8640000;
try {
// generate cache data
$timestamp_string = gmdate('D, d M Y H:i:s ', $filesystem->getTimestamp($asset)) . 'GMT';
$etag = md5($filesystem->read($asset));
$mime_type = $filesystem->getMimetype($asset);
if (0 !== strpos($mime_type, 'image')) {
$mime_type = 'text/css';
}
$if_modified_since = isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? $_SERVER['HTTP_IF_MODIFIED_SINCE'] : false;
$if_none_match = isset($_SERVER['HTTP_IF_NONE_MATCH']) ? $_SERVER['HTTP_IF_NONE_MATCH'] : false;
if ((($if_none_match && $if_none_match == "\"{$etag}\"") || (!$if_none_match)) &&
($if_modified_since && $if_modified_since == $timestamp_string)
) {
return $response->withStatus('304');
} else {
$response = $response
->withHeader('Last-Modified', $timestamp_string)
->withHeader('ETag', "\"{$etag}\"");
}
// send out content type, expire time and the file
$response->getBody()->write($filesystem->read($asset));
return $response
->withHeader('Expires', gmdate('D, d M Y H:i:s ', time() + $expires) . 'GMT')
->withHeader('Content-Type', $mime_type)
->withHeader('Pragma', 'cache')
->withHeader('Cache-Control', 'cache');
} catch (FileNotFoundException $e) {
throw $e;
}
}
|
php
|
public function assets(Response $response, $asset)
{
$filesystem = new Filesystem(new Adapter(FS2ADMIN));
$expires = 8640000;
try {
// generate cache data
$timestamp_string = gmdate('D, d M Y H:i:s ', $filesystem->getTimestamp($asset)) . 'GMT';
$etag = md5($filesystem->read($asset));
$mime_type = $filesystem->getMimetype($asset);
if (0 !== strpos($mime_type, 'image')) {
$mime_type = 'text/css';
}
$if_modified_since = isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? $_SERVER['HTTP_IF_MODIFIED_SINCE'] : false;
$if_none_match = isset($_SERVER['HTTP_IF_NONE_MATCH']) ? $_SERVER['HTTP_IF_NONE_MATCH'] : false;
if ((($if_none_match && $if_none_match == "\"{$etag}\"") || (!$if_none_match)) &&
($if_modified_since && $if_modified_since == $timestamp_string)
) {
return $response->withStatus('304');
} else {
$response = $response
->withHeader('Last-Modified', $timestamp_string)
->withHeader('ETag', "\"{$etag}\"");
}
// send out content type, expire time and the file
$response->getBody()->write($filesystem->read($asset));
return $response
->withHeader('Expires', gmdate('D, d M Y H:i:s ', time() + $expires) . 'GMT')
->withHeader('Content-Type', $mime_type)
->withHeader('Pragma', 'cache')
->withHeader('Cache-Control', 'cache');
} catch (FileNotFoundException $e) {
throw $e;
}
}
|
[
"public",
"function",
"assets",
"(",
"Response",
"$",
"response",
",",
"$",
"asset",
")",
"{",
"$",
"filesystem",
"=",
"new",
"Filesystem",
"(",
"new",
"Adapter",
"(",
"FS2ADMIN",
")",
")",
";",
"$",
"expires",
"=",
"8640000",
";",
"try",
"{",
"// generate cache data",
"$",
"timestamp_string",
"=",
"gmdate",
"(",
"'D, d M Y H:i:s '",
",",
"$",
"filesystem",
"->",
"getTimestamp",
"(",
"$",
"asset",
")",
")",
".",
"'GMT'",
";",
"$",
"etag",
"=",
"md5",
"(",
"$",
"filesystem",
"->",
"read",
"(",
"$",
"asset",
")",
")",
";",
"$",
"mime_type",
"=",
"$",
"filesystem",
"->",
"getMimetype",
"(",
"$",
"asset",
")",
";",
"if",
"(",
"0",
"!==",
"strpos",
"(",
"$",
"mime_type",
",",
"'image'",
")",
")",
"{",
"$",
"mime_type",
"=",
"'text/css'",
";",
"}",
"$",
"if_modified_since",
"=",
"isset",
"(",
"$",
"_SERVER",
"[",
"'HTTP_IF_MODIFIED_SINCE'",
"]",
")",
"?",
"$",
"_SERVER",
"[",
"'HTTP_IF_MODIFIED_SINCE'",
"]",
":",
"false",
";",
"$",
"if_none_match",
"=",
"isset",
"(",
"$",
"_SERVER",
"[",
"'HTTP_IF_NONE_MATCH'",
"]",
")",
"?",
"$",
"_SERVER",
"[",
"'HTTP_IF_NONE_MATCH'",
"]",
":",
"false",
";",
"if",
"(",
"(",
"(",
"$",
"if_none_match",
"&&",
"$",
"if_none_match",
"==",
"\"\\\"{$etag}\\\"\"",
")",
"||",
"(",
"!",
"$",
"if_none_match",
")",
")",
"&&",
"(",
"$",
"if_modified_since",
"&&",
"$",
"if_modified_since",
"==",
"$",
"timestamp_string",
")",
")",
"{",
"return",
"$",
"response",
"->",
"withStatus",
"(",
"'304'",
")",
";",
"}",
"else",
"{",
"$",
"response",
"=",
"$",
"response",
"->",
"withHeader",
"(",
"'Last-Modified'",
",",
"$",
"timestamp_string",
")",
"->",
"withHeader",
"(",
"'ETag'",
",",
"\"\\\"{$etag}\\\"\"",
")",
";",
"}",
"// send out content type, expire time and the file",
"$",
"response",
"->",
"getBody",
"(",
")",
"->",
"write",
"(",
"$",
"filesystem",
"->",
"read",
"(",
"$",
"asset",
")",
")",
";",
"return",
"$",
"response",
"->",
"withHeader",
"(",
"'Expires'",
",",
"gmdate",
"(",
"'D, d M Y H:i:s '",
",",
"time",
"(",
")",
"+",
"$",
"expires",
")",
".",
"'GMT'",
")",
"->",
"withHeader",
"(",
"'Content-Type'",
",",
"$",
"mime_type",
")",
"->",
"withHeader",
"(",
"'Pragma'",
",",
"'cache'",
")",
"->",
"withHeader",
"(",
"'Cache-Control'",
",",
"'cache'",
")",
";",
"}",
"catch",
"(",
"FileNotFoundException",
"$",
"e",
")",
"{",
"throw",
"$",
"e",
";",
"}",
"}"
] |
Return admin assets
@param Response $response
@param $asset
@return Response|static
@throws FileNotFoundException
|
[
"Return",
"admin",
"assets"
] |
a4ea3bea701e2b737c119a5d89b7778e8745658c
|
https://github.com/frogsystem/legacy-bridge/blob/a4ea3bea701e2b737c119a5d89b7778e8745658c/src/Controllers/AdminController.php#L56-L95
|
239,436
|
laravie/quemon
|
src/Http/Controllers/QueueController.php
|
QueueController.index
|
public function index()
{
try {
$jobs = FailedJob::orderBy('id', 'DESC')->paginate();
} catch (QueryException $e) {
return $this->setup();
}
return view('laravie/quemon::index', compact('jobs'));
}
|
php
|
public function index()
{
try {
$jobs = FailedJob::orderBy('id', 'DESC')->paginate();
} catch (QueryException $e) {
return $this->setup();
}
return view('laravie/quemon::index', compact('jobs'));
}
|
[
"public",
"function",
"index",
"(",
")",
"{",
"try",
"{",
"$",
"jobs",
"=",
"FailedJob",
"::",
"orderBy",
"(",
"'id'",
",",
"'DESC'",
")",
"->",
"paginate",
"(",
")",
";",
"}",
"catch",
"(",
"QueryException",
"$",
"e",
")",
"{",
"return",
"$",
"this",
"->",
"setup",
"(",
")",
";",
"}",
"return",
"view",
"(",
"'laravie/quemon::index'",
",",
"compact",
"(",
"'jobs'",
")",
")",
";",
"}"
] |
List of failed jobs.
@return mixed
|
[
"List",
"of",
"failed",
"jobs",
"."
] |
e548782301934d99c7e7262386e14e263a9d5422
|
https://github.com/laravie/quemon/blob/e548782301934d99c7e7262386e14e263a9d5422/src/Http/Controllers/QueueController.php#L29-L38
|
239,437
|
dazarobbo/Cola
|
src/ArrayList.php
|
ArrayList.add
|
public function add($value) {
if($this->_ReadOnly){
throw new ReadOnlyException(\get_called_class() . ' is read only');
}
$this->_Arr = \array_merge($this->_Arr, \func_get_args());
return $this;
}
|
php
|
public function add($value) {
if($this->_ReadOnly){
throw new ReadOnlyException(\get_called_class() . ' is read only');
}
$this->_Arr = \array_merge($this->_Arr, \func_get_args());
return $this;
}
|
[
"public",
"function",
"add",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_ReadOnly",
")",
"{",
"throw",
"new",
"ReadOnlyException",
"(",
"\\",
"get_called_class",
"(",
")",
".",
"' is read only'",
")",
";",
"}",
"$",
"this",
"->",
"_Arr",
"=",
"\\",
"array_merge",
"(",
"$",
"this",
"->",
"_Arr",
",",
"\\",
"func_get_args",
"(",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Adds a value to the list, multiple can be given
@param mixed $value
@return \Cola\ArrayList
@throws ReadOnlyException
|
[
"Adds",
"a",
"value",
"to",
"the",
"list",
"multiple",
"can",
"be",
"given"
] |
b101b73ebeb8a571345a303cbc75168f60d0e64f
|
https://github.com/dazarobbo/Cola/blob/b101b73ebeb8a571345a303cbc75168f60d0e64f/src/ArrayList.php#L73-L83
|
239,438
|
dazarobbo/Cola
|
src/ArrayList.php
|
ArrayList.average
|
public function average(){
Number::setScale(static::NUMERIC_FUNCTIONS_SCALE);
return Number::divide($this->sum(), \strval($this->count()));
}
|
php
|
public function average(){
Number::setScale(static::NUMERIC_FUNCTIONS_SCALE);
return Number::divide($this->sum(), \strval($this->count()));
}
|
[
"public",
"function",
"average",
"(",
")",
"{",
"Number",
"::",
"setScale",
"(",
"static",
"::",
"NUMERIC_FUNCTIONS_SCALE",
")",
";",
"return",
"Number",
"::",
"divide",
"(",
"$",
"this",
"->",
"sum",
"(",
")",
",",
"\\",
"strval",
"(",
"$",
"this",
"->",
"count",
"(",
")",
")",
")",
";",
"}"
] |
Computes the average value for a list of numbers
@return string
|
[
"Computes",
"the",
"average",
"value",
"for",
"a",
"list",
"of",
"numbers"
] |
b101b73ebeb8a571345a303cbc75168f60d0e64f
|
https://github.com/dazarobbo/Cola/blob/b101b73ebeb8a571345a303cbc75168f60d0e64f/src/ArrayList.php#L89-L92
|
239,439
|
dazarobbo/Cola
|
src/ArrayList.php
|
ArrayList.chunk
|
public function chunk($size){
$outer = new static();
$chunks = \array_chunk($this->_Arr, $size);
foreach($chunks as $chunk){
$outer->pushBack(new static($chunk));
}
return $outer;
}
|
php
|
public function chunk($size){
$outer = new static();
$chunks = \array_chunk($this->_Arr, $size);
foreach($chunks as $chunk){
$outer->pushBack(new static($chunk));
}
return $outer;
}
|
[
"public",
"function",
"chunk",
"(",
"$",
"size",
")",
"{",
"$",
"outer",
"=",
"new",
"static",
"(",
")",
";",
"$",
"chunks",
"=",
"\\",
"array_chunk",
"(",
"$",
"this",
"->",
"_Arr",
",",
"$",
"size",
")",
";",
"foreach",
"(",
"$",
"chunks",
"as",
"$",
"chunk",
")",
"{",
"$",
"outer",
"->",
"pushBack",
"(",
"new",
"static",
"(",
"$",
"chunk",
")",
")",
";",
"}",
"return",
"$",
"outer",
";",
"}"
] |
Divides this list into a list of smaller-chunked lists
@param int $size Size of each chunked list
@return \static
|
[
"Divides",
"this",
"list",
"into",
"a",
"list",
"of",
"smaller",
"-",
"chunked",
"lists"
] |
b101b73ebeb8a571345a303cbc75168f60d0e64f
|
https://github.com/dazarobbo/Cola/blob/b101b73ebeb8a571345a303cbc75168f60d0e64f/src/ArrayList.php#L113-L124
|
239,440
|
dazarobbo/Cola
|
src/ArrayList.php
|
ArrayList.concat
|
public function concat(ICollection $coll){
$arr = array();
$coll->copyTo($arr);
return new static(\array_merge($this->_Arr, \array_values($arr)));
}
|
php
|
public function concat(ICollection $coll){
$arr = array();
$coll->copyTo($arr);
return new static(\array_merge($this->_Arr, \array_values($arr)));
}
|
[
"public",
"function",
"concat",
"(",
"ICollection",
"$",
"coll",
")",
"{",
"$",
"arr",
"=",
"array",
"(",
")",
";",
"$",
"coll",
"->",
"copyTo",
"(",
"$",
"arr",
")",
";",
"return",
"new",
"static",
"(",
"\\",
"array_merge",
"(",
"$",
"this",
"->",
"_Arr",
",",
"\\",
"array_values",
"(",
"$",
"arr",
")",
")",
")",
";",
"}"
] |
Concatenates this list with an ICollection and returns a
new list
@param \Cola\ICollection $coll
@return \static
|
[
"Concatenates",
"this",
"list",
"with",
"an",
"ICollection",
"and",
"returns",
"a",
"new",
"list"
] |
b101b73ebeb8a571345a303cbc75168f60d0e64f
|
https://github.com/dazarobbo/Cola/blob/b101b73ebeb8a571345a303cbc75168f60d0e64f/src/ArrayList.php#L149-L156
|
239,441
|
dazarobbo/Cola
|
src/ArrayList.php
|
ArrayList.copy
|
public function copy($deep = true){
$arr = array();
foreach($this->_Arr as $key => $item){
$arr[$key] = $deep
? Functions\Object::copy($item)
: $item;
}
return new static($arr);
}
|
php
|
public function copy($deep = true){
$arr = array();
foreach($this->_Arr as $key => $item){
$arr[$key] = $deep
? Functions\Object::copy($item)
: $item;
}
return new static($arr);
}
|
[
"public",
"function",
"copy",
"(",
"$",
"deep",
"=",
"true",
")",
"{",
"$",
"arr",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"_Arr",
"as",
"$",
"key",
"=>",
"$",
"item",
")",
"{",
"$",
"arr",
"[",
"$",
"key",
"]",
"=",
"$",
"deep",
"?",
"Functions",
"\\",
"Object",
"::",
"copy",
"(",
"$",
"item",
")",
":",
"$",
"item",
";",
"}",
"return",
"new",
"static",
"(",
"$",
"arr",
")",
";",
"}"
] |
Creates a copy of this list. By default, a deep-copy
is performed.
@param bool $deep True for deep copy, false for shallow
@return \static
|
[
"Creates",
"a",
"copy",
"of",
"this",
"list",
".",
"By",
"default",
"a",
"deep",
"-",
"copy",
"is",
"performed",
"."
] |
b101b73ebeb8a571345a303cbc75168f60d0e64f
|
https://github.com/dazarobbo/Cola/blob/b101b73ebeb8a571345a303cbc75168f60d0e64f/src/ArrayList.php#L173-L185
|
239,442
|
dazarobbo/Cola
|
src/ArrayList.php
|
ArrayList.copyTo
|
public function copyTo(array &$arr, $index = 0) {
if(!$this->offsetExists($index)){
throw new \OutOfRangeException('$index is invalid');
}
$arr = \array_slice($this->_Arr, $index);
return $this;
}
|
php
|
public function copyTo(array &$arr, $index = 0) {
if(!$this->offsetExists($index)){
throw new \OutOfRangeException('$index is invalid');
}
$arr = \array_slice($this->_Arr, $index);
return $this;
}
|
[
"public",
"function",
"copyTo",
"(",
"array",
"&",
"$",
"arr",
",",
"$",
"index",
"=",
"0",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"offsetExists",
"(",
"$",
"index",
")",
")",
"{",
"throw",
"new",
"\\",
"OutOfRangeException",
"(",
"'$index is invalid'",
")",
";",
"}",
"$",
"arr",
"=",
"\\",
"array_slice",
"(",
"$",
"this",
"->",
"_Arr",
",",
"$",
"index",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Copies this list to a given array by reference
@param array $arr destination
@param int $index Where to start copying, the start by default
@return \Cola\ArrayList
|
[
"Copies",
"this",
"list",
"to",
"a",
"given",
"array",
"by",
"reference"
] |
b101b73ebeb8a571345a303cbc75168f60d0e64f
|
https://github.com/dazarobbo/Cola/blob/b101b73ebeb8a571345a303cbc75168f60d0e64f/src/ArrayList.php#L193-L203
|
239,443
|
dazarobbo/Cola
|
src/ArrayList.php
|
ArrayList.intersect
|
public function intersect(ICollection $coll){
//array_intersect does not work on \Closure objects
$arr = array();
$coll->copyTo($arr);
$ret = array();
foreach($this->_Arr as $outerItem){
foreach($arr as $innerItem){
if($innerItem === $outerItem){
$ret[] = $outerItem;
break;
}
}
}
return new static($ret);
}
|
php
|
public function intersect(ICollection $coll){
//array_intersect does not work on \Closure objects
$arr = array();
$coll->copyTo($arr);
$ret = array();
foreach($this->_Arr as $outerItem){
foreach($arr as $innerItem){
if($innerItem === $outerItem){
$ret[] = $outerItem;
break;
}
}
}
return new static($ret);
}
|
[
"public",
"function",
"intersect",
"(",
"ICollection",
"$",
"coll",
")",
"{",
"//array_intersect does not work on \\Closure objects",
"$",
"arr",
"=",
"array",
"(",
")",
";",
"$",
"coll",
"->",
"copyTo",
"(",
"$",
"arr",
")",
";",
"$",
"ret",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"_Arr",
"as",
"$",
"outerItem",
")",
"{",
"foreach",
"(",
"$",
"arr",
"as",
"$",
"innerItem",
")",
"{",
"if",
"(",
"$",
"innerItem",
"===",
"$",
"outerItem",
")",
"{",
"$",
"ret",
"[",
"]",
"=",
"$",
"outerItem",
";",
"break",
";",
"}",
"}",
"}",
"return",
"new",
"static",
"(",
"$",
"ret",
")",
";",
"}"
] |
Returns a new list with each element existing in
this list and a given ICollection
@param \Cola\ICollection $coll
@return \static
|
[
"Returns",
"a",
"new",
"list",
"with",
"each",
"element",
"existing",
"in",
"this",
"list",
"and",
"a",
"given",
"ICollection"
] |
b101b73ebeb8a571345a303cbc75168f60d0e64f
|
https://github.com/dazarobbo/Cola/blob/b101b73ebeb8a571345a303cbc75168f60d0e64f/src/ArrayList.php#L283-L305
|
239,444
|
dazarobbo/Cola
|
src/ArrayList.php
|
ArrayList.insert
|
public function insert($index, $value) {
if($this->_ReadOnly){
throw new ReadOnlyException(\get_called_class() . ' is read only');
}
//Permit 0-index insertion
if(!$this->offsetExists($index)){
throw new \OutOfRangeException('$index is invalid');
}
\array_splice($this->_Arr, $index, 0, array($value));
return $this;
}
|
php
|
public function insert($index, $value) {
if($this->_ReadOnly){
throw new ReadOnlyException(\get_called_class() . ' is read only');
}
//Permit 0-index insertion
if(!$this->offsetExists($index)){
throw new \OutOfRangeException('$index is invalid');
}
\array_splice($this->_Arr, $index, 0, array($value));
return $this;
}
|
[
"public",
"function",
"insert",
"(",
"$",
"index",
",",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_ReadOnly",
")",
"{",
"throw",
"new",
"ReadOnlyException",
"(",
"\\",
"get_called_class",
"(",
")",
".",
"' is read only'",
")",
";",
"}",
"//Permit 0-index insertion",
"if",
"(",
"!",
"$",
"this",
"->",
"offsetExists",
"(",
"$",
"index",
")",
")",
"{",
"throw",
"new",
"\\",
"OutOfRangeException",
"(",
"'$index is invalid'",
")",
";",
"}",
"\\",
"array_splice",
"(",
"$",
"this",
"->",
"_Arr",
",",
"$",
"index",
",",
"0",
",",
"array",
"(",
"$",
"value",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Inserts a value into the list at a given index
@param int $index
@param mixed $value
@return \Cola\ArrayList
@throws ReadOnlyException|\OutOfRangeException
|
[
"Inserts",
"a",
"value",
"into",
"the",
"list",
"at",
"a",
"given",
"index"
] |
b101b73ebeb8a571345a303cbc75168f60d0e64f
|
https://github.com/dazarobbo/Cola/blob/b101b73ebeb8a571345a303cbc75168f60d0e64f/src/ArrayList.php#L332-L347
|
239,445
|
dazarobbo/Cola
|
src/ArrayList.php
|
ArrayList.insertRange
|
public function insertRange($index, ICollection $coll){
if($this->_ReadOnly){
throw new \RuntimeException(\get_called_class() . ' is read only');
}
if(!$this->offsetExists($index)){
throw new \OutOfRangeException('$index is invalid');
}
$arr = array();
$coll->copyTo($arr);
\array_splice($this->_Arr, $index, 0, $arr);
return $this;
}
|
php
|
public function insertRange($index, ICollection $coll){
if($this->_ReadOnly){
throw new \RuntimeException(\get_called_class() . ' is read only');
}
if(!$this->offsetExists($index)){
throw new \OutOfRangeException('$index is invalid');
}
$arr = array();
$coll->copyTo($arr);
\array_splice($this->_Arr, $index, 0, $arr);
return $this;
}
|
[
"public",
"function",
"insertRange",
"(",
"$",
"index",
",",
"ICollection",
"$",
"coll",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_ReadOnly",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"\\",
"get_called_class",
"(",
")",
".",
"' is read only'",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"offsetExists",
"(",
"$",
"index",
")",
")",
"{",
"throw",
"new",
"\\",
"OutOfRangeException",
"(",
"'$index is invalid'",
")",
";",
"}",
"$",
"arr",
"=",
"array",
"(",
")",
";",
"$",
"coll",
"->",
"copyTo",
"(",
"$",
"arr",
")",
";",
"\\",
"array_splice",
"(",
"$",
"this",
"->",
"_Arr",
",",
"$",
"index",
",",
"0",
",",
"$",
"arr",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Inserts a collection of items into the list at a given index
@param int $index
@param \Cola\ICollection $coll
@return \Cola\ArrayList
@throws ReadOnlyException|\OutOfRangeException
|
[
"Inserts",
"a",
"collection",
"of",
"items",
"into",
"the",
"list",
"at",
"a",
"given",
"index"
] |
b101b73ebeb8a571345a303cbc75168f60d0e64f
|
https://github.com/dazarobbo/Cola/blob/b101b73ebeb8a571345a303cbc75168f60d0e64f/src/ArrayList.php#L356-L373
|
239,446
|
dazarobbo/Cola
|
src/ArrayList.php
|
ArrayList.lastIndexOf
|
public function lastIndexOf($value){
$i = $this->count() - 1;
while($i >= 0 && $this->_Arr[$i] !== $value){
--$i;
}
return $i;
}
|
php
|
public function lastIndexOf($value){
$i = $this->count() - 1;
while($i >= 0 && $this->_Arr[$i] !== $value){
--$i;
}
return $i;
}
|
[
"public",
"function",
"lastIndexOf",
"(",
"$",
"value",
")",
"{",
"$",
"i",
"=",
"$",
"this",
"->",
"count",
"(",
")",
"-",
"1",
";",
"while",
"(",
"$",
"i",
">=",
"0",
"&&",
"$",
"this",
"->",
"_Arr",
"[",
"$",
"i",
"]",
"!==",
"$",
"value",
")",
"{",
"--",
"$",
"i",
";",
"}",
"return",
"$",
"i",
";",
"}"
] |
Returns the index of the last matching value
@param mixed $value
@return int -1 if not found
|
[
"Returns",
"the",
"index",
"of",
"the",
"last",
"matching",
"value"
] |
b101b73ebeb8a571345a303cbc75168f60d0e64f
|
https://github.com/dazarobbo/Cola/blob/b101b73ebeb8a571345a303cbc75168f60d0e64f/src/ArrayList.php#L406-L416
|
239,447
|
dazarobbo/Cola
|
src/ArrayList.php
|
ArrayList.max
|
public function max(){
if($this->isEmpty()){
throw new \UnderflowException(\get_called_class() . ' is empty');
}
$max = $this->front();
for($i = 1, $l = $this->count(); $i < $l; ++$i){
if(Number::greaterThan($this->_Arr[$i], $max)){
$max = $this->_Arr[$i];
}
}
return $max;
}
|
php
|
public function max(){
if($this->isEmpty()){
throw new \UnderflowException(\get_called_class() . ' is empty');
}
$max = $this->front();
for($i = 1, $l = $this->count(); $i < $l; ++$i){
if(Number::greaterThan($this->_Arr[$i], $max)){
$max = $this->_Arr[$i];
}
}
return $max;
}
|
[
"public",
"function",
"max",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"\\",
"UnderflowException",
"(",
"\\",
"get_called_class",
"(",
")",
".",
"' is empty'",
")",
";",
"}",
"$",
"max",
"=",
"$",
"this",
"->",
"front",
"(",
")",
";",
"for",
"(",
"$",
"i",
"=",
"1",
",",
"$",
"l",
"=",
"$",
"this",
"->",
"count",
"(",
")",
";",
"$",
"i",
"<",
"$",
"l",
";",
"++",
"$",
"i",
")",
"{",
"if",
"(",
"Number",
"::",
"greaterThan",
"(",
"$",
"this",
"->",
"_Arr",
"[",
"$",
"i",
"]",
",",
"$",
"max",
")",
")",
"{",
"$",
"max",
"=",
"$",
"this",
"->",
"_Arr",
"[",
"$",
"i",
"]",
";",
"}",
"}",
"return",
"$",
"max",
";",
"}"
] |
Returns the maximum value of this list. Result is undefined
for non numeric lists.
@return string
@throws \UnderflowException
|
[
"Returns",
"the",
"maximum",
"value",
"of",
"this",
"list",
".",
"Result",
"is",
"undefined",
"for",
"non",
"numeric",
"lists",
"."
] |
b101b73ebeb8a571345a303cbc75168f60d0e64f
|
https://github.com/dazarobbo/Cola/blob/b101b73ebeb8a571345a303cbc75168f60d0e64f/src/ArrayList.php#L434-L450
|
239,448
|
dazarobbo/Cola
|
src/ArrayList.php
|
ArrayList.min
|
public function min(){
if($this->isEmpty()){
throw new \UnderflowException(\get_called_class() . ' is empty');
}
$min = $this->front();
for($i = 1, $l = $this->count(); $i < $l; ++$i){
if(Number::lessThan($this->_Arr[$i], $min)){
$min = $this->_Arr[$i];
}
}
return $min;
}
|
php
|
public function min(){
if($this->isEmpty()){
throw new \UnderflowException(\get_called_class() . ' is empty');
}
$min = $this->front();
for($i = 1, $l = $this->count(); $i < $l; ++$i){
if(Number::lessThan($this->_Arr[$i], $min)){
$min = $this->_Arr[$i];
}
}
return $min;
}
|
[
"public",
"function",
"min",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"\\",
"UnderflowException",
"(",
"\\",
"get_called_class",
"(",
")",
".",
"' is empty'",
")",
";",
"}",
"$",
"min",
"=",
"$",
"this",
"->",
"front",
"(",
")",
";",
"for",
"(",
"$",
"i",
"=",
"1",
",",
"$",
"l",
"=",
"$",
"this",
"->",
"count",
"(",
")",
";",
"$",
"i",
"<",
"$",
"l",
";",
"++",
"$",
"i",
")",
"{",
"if",
"(",
"Number",
"::",
"lessThan",
"(",
"$",
"this",
"->",
"_Arr",
"[",
"$",
"i",
"]",
",",
"$",
"min",
")",
")",
"{",
"$",
"min",
"=",
"$",
"this",
"->",
"_Arr",
"[",
"$",
"i",
"]",
";",
"}",
"}",
"return",
"$",
"min",
";",
"}"
] |
Returns the minimum value of this list. Result is undefined
for non numeric lists.
@return string
@throws \UnderflowException
|
[
"Returns",
"the",
"minimum",
"value",
"of",
"this",
"list",
".",
"Result",
"is",
"undefined",
"for",
"non",
"numeric",
"lists",
"."
] |
b101b73ebeb8a571345a303cbc75168f60d0e64f
|
https://github.com/dazarobbo/Cola/blob/b101b73ebeb8a571345a303cbc75168f60d0e64f/src/ArrayList.php#L458-L474
|
239,449
|
dazarobbo/Cola
|
src/ArrayList.php
|
ArrayList.popBack
|
public function popBack(){
if($this->_ReadOnly){
throw new ReadOnlyException(\get_called_class() . ' is read only');
}
if($this->isEmpty()){
throw new \UnderflowException(\get_called_class() . ' is empty');
}
return \array_pop($this->_Arr);
}
|
php
|
public function popBack(){
if($this->_ReadOnly){
throw new ReadOnlyException(\get_called_class() . ' is read only');
}
if($this->isEmpty()){
throw new \UnderflowException(\get_called_class() . ' is empty');
}
return \array_pop($this->_Arr);
}
|
[
"public",
"function",
"popBack",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_ReadOnly",
")",
"{",
"throw",
"new",
"ReadOnlyException",
"(",
"\\",
"get_called_class",
"(",
")",
".",
"' is read only'",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"\\",
"UnderflowException",
"(",
"\\",
"get_called_class",
"(",
")",
".",
"' is empty'",
")",
";",
"}",
"return",
"\\",
"array_pop",
"(",
"$",
"this",
"->",
"_Arr",
")",
";",
"}"
] |
Removes and returns the last element of the list
@return mixed
@throws ReadOnlyException
|
[
"Removes",
"and",
"returns",
"the",
"last",
"element",
"of",
"the",
"list"
] |
b101b73ebeb8a571345a303cbc75168f60d0e64f
|
https://github.com/dazarobbo/Cola/blob/b101b73ebeb8a571345a303cbc75168f60d0e64f/src/ArrayList.php#L529-L541
|
239,450
|
dazarobbo/Cola
|
src/ArrayList.php
|
ArrayList.popFront
|
public function popFront(){
if($this->_ReadOnly){
throw new ReadOnlyException(\get_called_class() . ' is read only');
}
if($this->isEmpty()){
throw new \UnderflowException(\get_called_class() . ' is empty');
}
return \array_shift($this->_Arr);
}
|
php
|
public function popFront(){
if($this->_ReadOnly){
throw new ReadOnlyException(\get_called_class() . ' is read only');
}
if($this->isEmpty()){
throw new \UnderflowException(\get_called_class() . ' is empty');
}
return \array_shift($this->_Arr);
}
|
[
"public",
"function",
"popFront",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_ReadOnly",
")",
"{",
"throw",
"new",
"ReadOnlyException",
"(",
"\\",
"get_called_class",
"(",
")",
".",
"' is read only'",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"\\",
"UnderflowException",
"(",
"\\",
"get_called_class",
"(",
")",
".",
"' is empty'",
")",
";",
"}",
"return",
"\\",
"array_shift",
"(",
"$",
"this",
"->",
"_Arr",
")",
";",
"}"
] |
Removes and returns the first element of the list
@return mixed
@throws ReadOnlyException
|
[
"Removes",
"and",
"returns",
"the",
"first",
"element",
"of",
"the",
"list"
] |
b101b73ebeb8a571345a303cbc75168f60d0e64f
|
https://github.com/dazarobbo/Cola/blob/b101b73ebeb8a571345a303cbc75168f60d0e64f/src/ArrayList.php#L548-L560
|
239,451
|
dazarobbo/Cola
|
src/ArrayList.php
|
ArrayList.product
|
public function product(){
Number::setScale(static::NUMERIC_FUNCTIONS_SCALE);
$total = \strval($this->front());
for($i = 1, $l = $this->count(); $i < $l; ++$i){
$total = Number::multiply($total, \strval($this->_Arr[$i]));
}
return $total;
}
|
php
|
public function product(){
Number::setScale(static::NUMERIC_FUNCTIONS_SCALE);
$total = \strval($this->front());
for($i = 1, $l = $this->count(); $i < $l; ++$i){
$total = Number::multiply($total, \strval($this->_Arr[$i]));
}
return $total;
}
|
[
"public",
"function",
"product",
"(",
")",
"{",
"Number",
"::",
"setScale",
"(",
"static",
"::",
"NUMERIC_FUNCTIONS_SCALE",
")",
";",
"$",
"total",
"=",
"\\",
"strval",
"(",
"$",
"this",
"->",
"front",
"(",
")",
")",
";",
"for",
"(",
"$",
"i",
"=",
"1",
",",
"$",
"l",
"=",
"$",
"this",
"->",
"count",
"(",
")",
";",
"$",
"i",
"<",
"$",
"l",
";",
"++",
"$",
"i",
")",
"{",
"$",
"total",
"=",
"Number",
"::",
"multiply",
"(",
"$",
"total",
",",
"\\",
"strval",
"(",
"$",
"this",
"->",
"_Arr",
"[",
"$",
"i",
"]",
")",
")",
";",
"}",
"return",
"$",
"total",
";",
"}"
] |
Computes the product of a list of numbers
@return string
|
[
"Computes",
"the",
"product",
"of",
"a",
"list",
"of",
"numbers"
] |
b101b73ebeb8a571345a303cbc75168f60d0e64f
|
https://github.com/dazarobbo/Cola/blob/b101b73ebeb8a571345a303cbc75168f60d0e64f/src/ArrayList.php#L566-L578
|
239,452
|
dazarobbo/Cola
|
src/ArrayList.php
|
ArrayList.pushBack
|
public function pushBack(){
if($this->_ReadOnly){
throw new ReadOnlyException(\get_called_class() . ' is read only');
}
$this->_Arr = \array_merge($this->_Arr, \func_get_args());
return $this;
}
|
php
|
public function pushBack(){
if($this->_ReadOnly){
throw new ReadOnlyException(\get_called_class() . ' is read only');
}
$this->_Arr = \array_merge($this->_Arr, \func_get_args());
return $this;
}
|
[
"public",
"function",
"pushBack",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_ReadOnly",
")",
"{",
"throw",
"new",
"ReadOnlyException",
"(",
"\\",
"get_called_class",
"(",
")",
".",
"' is read only'",
")",
";",
"}",
"$",
"this",
"->",
"_Arr",
"=",
"\\",
"array_merge",
"(",
"$",
"this",
"->",
"_Arr",
",",
"\\",
"func_get_args",
"(",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Adds items to the end of this list. Multiple arguments can be given.
@return \Cola\ArrayList
@throws ReadOnlyException
|
[
"Adds",
"items",
"to",
"the",
"end",
"of",
"this",
"list",
".",
"Multiple",
"arguments",
"can",
"be",
"given",
"."
] |
b101b73ebeb8a571345a303cbc75168f60d0e64f
|
https://github.com/dazarobbo/Cola/blob/b101b73ebeb8a571345a303cbc75168f60d0e64f/src/ArrayList.php#L585-L595
|
239,453
|
dazarobbo/Cola
|
src/ArrayList.php
|
ArrayList.pushFront
|
public function pushFront(){
if($this->_ReadOnly){
throw new ReadOnlyException(\get_called_class() . ' is read only');
}
$this->_Arr = \array_merge(\func_get_args(), $this->_Arr);
return $this;
}
|
php
|
public function pushFront(){
if($this->_ReadOnly){
throw new ReadOnlyException(\get_called_class() . ' is read only');
}
$this->_Arr = \array_merge(\func_get_args(), $this->_Arr);
return $this;
}
|
[
"public",
"function",
"pushFront",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_ReadOnly",
")",
"{",
"throw",
"new",
"ReadOnlyException",
"(",
"\\",
"get_called_class",
"(",
")",
".",
"' is read only'",
")",
";",
"}",
"$",
"this",
"->",
"_Arr",
"=",
"\\",
"array_merge",
"(",
"\\",
"func_get_args",
"(",
")",
",",
"$",
"this",
"->",
"_Arr",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Adds items to the beginning of this list. Multiple arguments can be given.
@return \Cola\ArrayList
@throws ReadOnlyException
|
[
"Adds",
"items",
"to",
"the",
"beginning",
"of",
"this",
"list",
".",
"Multiple",
"arguments",
"can",
"be",
"given",
"."
] |
b101b73ebeb8a571345a303cbc75168f60d0e64f
|
https://github.com/dazarobbo/Cola/blob/b101b73ebeb8a571345a303cbc75168f60d0e64f/src/ArrayList.php#L602-L612
|
239,454
|
dazarobbo/Cola
|
src/ArrayList.php
|
ArrayList.&
|
public function &random(){
if($this->isEmpty()){
throw new \UnderflowException(\get_called_class() . ' is empty');
}
return $this->_Arr[\array_rand($this->_Arr, 1)];
}
|
php
|
public function &random(){
if($this->isEmpty()){
throw new \UnderflowException(\get_called_class() . ' is empty');
}
return $this->_Arr[\array_rand($this->_Arr, 1)];
}
|
[
"public",
"function",
"&",
"random",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"\\",
"UnderflowException",
"(",
"\\",
"get_called_class",
"(",
")",
".",
"' is empty'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_Arr",
"[",
"\\",
"array_rand",
"(",
"$",
"this",
"->",
"_Arr",
",",
"1",
")",
"]",
";",
"}"
] |
Returns a reference to a random item from the list
@return mixed
|
[
"Returns",
"a",
"reference",
"to",
"a",
"random",
"item",
"from",
"the",
"list"
] |
b101b73ebeb8a571345a303cbc75168f60d0e64f
|
https://github.com/dazarobbo/Cola/blob/b101b73ebeb8a571345a303cbc75168f60d0e64f/src/ArrayList.php#L618-L626
|
239,455
|
dazarobbo/Cola
|
src/ArrayList.php
|
ArrayList.readOnly
|
public function readOnly($bool = true){
$list = $this->copy(false);
$list->setReadOnly();
return $list;
}
|
php
|
public function readOnly($bool = true){
$list = $this->copy(false);
$list->setReadOnly();
return $list;
}
|
[
"public",
"function",
"readOnly",
"(",
"$",
"bool",
"=",
"true",
")",
"{",
"$",
"list",
"=",
"$",
"this",
"->",
"copy",
"(",
"false",
")",
";",
"$",
"list",
"->",
"setReadOnly",
"(",
")",
";",
"return",
"$",
"list",
";",
"}"
] |
Creates a shallow copy of this list and sets it to read only
@param bool $bool
@return \static
|
[
"Creates",
"a",
"shallow",
"copy",
"of",
"this",
"list",
"and",
"sets",
"it",
"to",
"read",
"only"
] |
b101b73ebeb8a571345a303cbc75168f60d0e64f
|
https://github.com/dazarobbo/Cola/blob/b101b73ebeb8a571345a303cbc75168f60d0e64f/src/ArrayList.php#L633-L637
|
239,456
|
dazarobbo/Cola
|
src/ArrayList.php
|
ArrayList.remove
|
public function remove($value) {
if($this->_ReadOnly){
throw new ReadOnlyException(\get_called_class() . ' is read only');
}
if(($key = \array_search($value, $this->_Arr)) !== false){
\array_splice($this->_Arr, $key, 1);
}
return $this;
}
|
php
|
public function remove($value) {
if($this->_ReadOnly){
throw new ReadOnlyException(\get_called_class() . ' is read only');
}
if(($key = \array_search($value, $this->_Arr)) !== false){
\array_splice($this->_Arr, $key, 1);
}
return $this;
}
|
[
"public",
"function",
"remove",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_ReadOnly",
")",
"{",
"throw",
"new",
"ReadOnlyException",
"(",
"\\",
"get_called_class",
"(",
")",
".",
"' is read only'",
")",
";",
"}",
"if",
"(",
"(",
"$",
"key",
"=",
"\\",
"array_search",
"(",
"$",
"value",
",",
"$",
"this",
"->",
"_Arr",
")",
")",
"!==",
"false",
")",
"{",
"\\",
"array_splice",
"(",
"$",
"this",
"->",
"_Arr",
",",
"$",
"key",
",",
"1",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Removes the first matching value from the list
@param mixed $value
@return \Cola\ArrayList
@throws ReadOnlyException
|
[
"Removes",
"the",
"first",
"matching",
"value",
"from",
"the",
"list"
] |
b101b73ebeb8a571345a303cbc75168f60d0e64f
|
https://github.com/dazarobbo/Cola/blob/b101b73ebeb8a571345a303cbc75168f60d0e64f/src/ArrayList.php#L645-L657
|
239,457
|
dazarobbo/Cola
|
src/ArrayList.php
|
ArrayList.removeAt
|
public function removeAt($index) {
if($this->_ReadOnly){
throw new \RuntimeException(\get_called_class() . ' is read only');
}
if(!$this->offsetExists($index)){
throw new \OutOfRangeException('$index is invalid');
}
\array_splice($this->_Arr, $index, 1);
return $this;
}
|
php
|
public function removeAt($index) {
if($this->_ReadOnly){
throw new \RuntimeException(\get_called_class() . ' is read only');
}
if(!$this->offsetExists($index)){
throw new \OutOfRangeException('$index is invalid');
}
\array_splice($this->_Arr, $index, 1);
return $this;
}
|
[
"public",
"function",
"removeAt",
"(",
"$",
"index",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_ReadOnly",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"\\",
"get_called_class",
"(",
")",
".",
"' is read only'",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"offsetExists",
"(",
"$",
"index",
")",
")",
"{",
"throw",
"new",
"\\",
"OutOfRangeException",
"(",
"'$index is invalid'",
")",
";",
"}",
"\\",
"array_splice",
"(",
"$",
"this",
"->",
"_Arr",
",",
"$",
"index",
",",
"1",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Removes a value at the given index
@param int $index
@return \Cola\ArrayList
@throws ReadOnlyException|\OutOfRangeException
|
[
"Removes",
"a",
"value",
"at",
"the",
"given",
"index"
] |
b101b73ebeb8a571345a303cbc75168f60d0e64f
|
https://github.com/dazarobbo/Cola/blob/b101b73ebeb8a571345a303cbc75168f60d0e64f/src/ArrayList.php#L665-L679
|
239,458
|
dazarobbo/Cola
|
src/ArrayList.php
|
ArrayList.resize
|
public function resize($size, $value = null){
if($this->_ReadOnly){
throw new ReadOnlyException(\get_called_class() . ' is read only');
}
if(!\is_int($size)){
throw new \InvalidArgumentException('$size is not an int');
}
if($size < 0){
throw new \OutOfBoundsException('$size cannot be less than 0');
}
$len = $this->count();
if($size > $len){
$this->_Arr = \array_pad($this->_Arr, $size, $value);
}
else if($size < $len){
$this->_Arr = \array_slice($this->_Arr, 0, $size, false);
}
return $this;
}
|
php
|
public function resize($size, $value = null){
if($this->_ReadOnly){
throw new ReadOnlyException(\get_called_class() . ' is read only');
}
if(!\is_int($size)){
throw new \InvalidArgumentException('$size is not an int');
}
if($size < 0){
throw new \OutOfBoundsException('$size cannot be less than 0');
}
$len = $this->count();
if($size > $len){
$this->_Arr = \array_pad($this->_Arr, $size, $value);
}
else if($size < $len){
$this->_Arr = \array_slice($this->_Arr, 0, $size, false);
}
return $this;
}
|
[
"public",
"function",
"resize",
"(",
"$",
"size",
",",
"$",
"value",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_ReadOnly",
")",
"{",
"throw",
"new",
"ReadOnlyException",
"(",
"\\",
"get_called_class",
"(",
")",
".",
"' is read only'",
")",
";",
"}",
"if",
"(",
"!",
"\\",
"is_int",
"(",
"$",
"size",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'$size is not an int'",
")",
";",
"}",
"if",
"(",
"$",
"size",
"<",
"0",
")",
"{",
"throw",
"new",
"\\",
"OutOfBoundsException",
"(",
"'$size cannot be less than 0'",
")",
";",
"}",
"$",
"len",
"=",
"$",
"this",
"->",
"count",
"(",
")",
";",
"if",
"(",
"$",
"size",
">",
"$",
"len",
")",
"{",
"$",
"this",
"->",
"_Arr",
"=",
"\\",
"array_pad",
"(",
"$",
"this",
"->",
"_Arr",
",",
"$",
"size",
",",
"$",
"value",
")",
";",
"}",
"else",
"if",
"(",
"$",
"size",
"<",
"$",
"len",
")",
"{",
"$",
"this",
"->",
"_Arr",
"=",
"\\",
"array_slice",
"(",
"$",
"this",
"->",
"_Arr",
",",
"0",
",",
"$",
"size",
",",
"false",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Resizes this list to a given size. Expanding the list will
pad it with a value. Contracting the list cuts off extraneous
values.
@param int $size
@param mixed $value
@return \Cola\ArrayList
@throws ReadOnlyException
@throws \InvalidArgumentException
@throws \OutOfBoundsException
|
[
"Resizes",
"this",
"list",
"to",
"a",
"given",
"size",
".",
"Expanding",
"the",
"list",
"will",
"pad",
"it",
"with",
"a",
"value",
".",
"Contracting",
"the",
"list",
"cuts",
"off",
"extraneous",
"values",
"."
] |
b101b73ebeb8a571345a303cbc75168f60d0e64f
|
https://github.com/dazarobbo/Cola/blob/b101b73ebeb8a571345a303cbc75168f60d0e64f/src/ArrayList.php#L734-L759
|
239,459
|
dazarobbo/Cola
|
src/ArrayList.php
|
ArrayList.reverse
|
public function reverse(){
if($this->_ReadOnly){
throw new ReadOnlyException(\get_called_class() . ' is read only');
}
$this->_Arr = \array_reverse($this->_Arr);
return $this;
}
|
php
|
public function reverse(){
if($this->_ReadOnly){
throw new ReadOnlyException(\get_called_class() . ' is read only');
}
$this->_Arr = \array_reverse($this->_Arr);
return $this;
}
|
[
"public",
"function",
"reverse",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_ReadOnly",
")",
"{",
"throw",
"new",
"ReadOnlyException",
"(",
"\\",
"get_called_class",
"(",
")",
".",
"' is read only'",
")",
";",
"}",
"$",
"this",
"->",
"_Arr",
"=",
"\\",
"array_reverse",
"(",
"$",
"this",
"->",
"_Arr",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Reverses this list
@return \Cola\ArrayList
@throws ReadOnlyException
|
[
"Reverses",
"this",
"list"
] |
b101b73ebeb8a571345a303cbc75168f60d0e64f
|
https://github.com/dazarobbo/Cola/blob/b101b73ebeb8a571345a303cbc75168f60d0e64f/src/ArrayList.php#L766-L776
|
239,460
|
dazarobbo/Cola
|
src/ArrayList.php
|
ArrayList.sentinelSearch
|
public function sentinelSearch($value){
$l = $this->count();
$arr = $this->_Arr;
$arr[$l] = $value;
$i = 0;
while($arr[$i] !== $value){
++$i;
}
return $i !== $l ? $i : static::NO_INDEX;
}
|
php
|
public function sentinelSearch($value){
$l = $this->count();
$arr = $this->_Arr;
$arr[$l] = $value;
$i = 0;
while($arr[$i] !== $value){
++$i;
}
return $i !== $l ? $i : static::NO_INDEX;
}
|
[
"public",
"function",
"sentinelSearch",
"(",
"$",
"value",
")",
"{",
"$",
"l",
"=",
"$",
"this",
"->",
"count",
"(",
")",
";",
"$",
"arr",
"=",
"$",
"this",
"->",
"_Arr",
";",
"$",
"arr",
"[",
"$",
"l",
"]",
"=",
"$",
"value",
";",
"$",
"i",
"=",
"0",
";",
"while",
"(",
"$",
"arr",
"[",
"$",
"i",
"]",
"!==",
"$",
"value",
")",
"{",
"++",
"$",
"i",
";",
"}",
"return",
"$",
"i",
"!==",
"$",
"l",
"?",
"$",
"i",
":",
"static",
"::",
"NO_INDEX",
";",
"}"
] |
Performs a sentinel search for a value
@param mixed $value
@return int -1 for no match
|
[
"Performs",
"a",
"sentinel",
"search",
"for",
"a",
"value"
] |
b101b73ebeb8a571345a303cbc75168f60d0e64f
|
https://github.com/dazarobbo/Cola/blob/b101b73ebeb8a571345a303cbc75168f60d0e64f/src/ArrayList.php#L783-L796
|
239,461
|
dazarobbo/Cola
|
src/ArrayList.php
|
ArrayList.slice
|
public function slice($index, $count = null){
if(!$this->offsetExists($index)){
throw new \OutOfRangeException('$index is invalid');
}
$arr = \array_slice($this->_Arr, $index, $count);
return new static($arr);
}
|
php
|
public function slice($index, $count = null){
if(!$this->offsetExists($index)){
throw new \OutOfRangeException('$index is invalid');
}
$arr = \array_slice($this->_Arr, $index, $count);
return new static($arr);
}
|
[
"public",
"function",
"slice",
"(",
"$",
"index",
",",
"$",
"count",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"offsetExists",
"(",
"$",
"index",
")",
")",
"{",
"throw",
"new",
"\\",
"OutOfRangeException",
"(",
"'$index is invalid'",
")",
";",
"}",
"$",
"arr",
"=",
"\\",
"array_slice",
"(",
"$",
"this",
"->",
"_Arr",
",",
"$",
"index",
",",
"$",
"count",
")",
";",
"return",
"new",
"static",
"(",
"$",
"arr",
")",
";",
"}"
] |
Creates a new list from a subset of this list
@param int $index index to start the subset at
@param int $count number of items to include
@throws \OutOfRangeException
@return \static
|
[
"Creates",
"a",
"new",
"list",
"from",
"a",
"subset",
"of",
"this",
"list"
] |
b101b73ebeb8a571345a303cbc75168f60d0e64f
|
https://github.com/dazarobbo/Cola/blob/b101b73ebeb8a571345a303cbc75168f60d0e64f/src/ArrayList.php#L813-L822
|
239,462
|
dazarobbo/Cola
|
src/ArrayList.php
|
ArrayList.sort
|
public function sort(\Closure $compare = null){
if($this->_ReadOnly){
throw new ReadOnlyException(\get_called_class() . ' is read only');
}
if(\is_callable($compare)){
\usort($this->_Arr, $compare);
}
else{
\sort($this->_Arr);
}
return $this;
}
|
php
|
public function sort(\Closure $compare = null){
if($this->_ReadOnly){
throw new ReadOnlyException(\get_called_class() . ' is read only');
}
if(\is_callable($compare)){
\usort($this->_Arr, $compare);
}
else{
\sort($this->_Arr);
}
return $this;
}
|
[
"public",
"function",
"sort",
"(",
"\\",
"Closure",
"$",
"compare",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_ReadOnly",
")",
"{",
"throw",
"new",
"ReadOnlyException",
"(",
"\\",
"get_called_class",
"(",
")",
".",
"' is read only'",
")",
";",
"}",
"if",
"(",
"\\",
"is_callable",
"(",
"$",
"compare",
")",
")",
"{",
"\\",
"usort",
"(",
"$",
"this",
"->",
"_Arr",
",",
"$",
"compare",
")",
";",
"}",
"else",
"{",
"\\",
"sort",
"(",
"$",
"this",
"->",
"_Arr",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Sorts this list, optionally by a user defined compare function
@param \Closure $compare
@return \Cola\ArrayList
@throws ReadOnlyException
|
[
"Sorts",
"this",
"list",
"optionally",
"by",
"a",
"user",
"defined",
"compare",
"function"
] |
b101b73ebeb8a571345a303cbc75168f60d0e64f
|
https://github.com/dazarobbo/Cola/blob/b101b73ebeb8a571345a303cbc75168f60d0e64f/src/ArrayList.php#L839-L854
|
239,463
|
dazarobbo/Cola
|
src/ArrayList.php
|
ArrayList.sum
|
public function sum(){
Number::setScale(static::NUMERIC_FUNCTIONS_SCALE);
$total = '0';
foreach($this->_Arr as $item){
$total = Number::add($total, \strval($item));
}
return $total;
}
|
php
|
public function sum(){
Number::setScale(static::NUMERIC_FUNCTIONS_SCALE);
$total = '0';
foreach($this->_Arr as $item){
$total = Number::add($total, \strval($item));
}
return $total;
}
|
[
"public",
"function",
"sum",
"(",
")",
"{",
"Number",
"::",
"setScale",
"(",
"static",
"::",
"NUMERIC_FUNCTIONS_SCALE",
")",
";",
"$",
"total",
"=",
"'0'",
";",
"foreach",
"(",
"$",
"this",
"->",
"_Arr",
"as",
"$",
"item",
")",
"{",
"$",
"total",
"=",
"Number",
"::",
"add",
"(",
"$",
"total",
",",
"\\",
"strval",
"(",
"$",
"item",
")",
")",
";",
"}",
"return",
"$",
"total",
";",
"}"
] |
Computes the sum of all numbers in this list
@return string
|
[
"Computes",
"the",
"sum",
"of",
"all",
"numbers",
"in",
"this",
"list"
] |
b101b73ebeb8a571345a303cbc75168f60d0e64f
|
https://github.com/dazarobbo/Cola/blob/b101b73ebeb8a571345a303cbc75168f60d0e64f/src/ArrayList.php#L860-L872
|
239,464
|
dazarobbo/Cola
|
src/ArrayList.php
|
ArrayList.stdDev
|
public function stdDev(){
Number::setScale(static::NUMERIC_FUNCTIONS_SCALE);
$mean = $this->average();
$squares = new static();
foreach($this->_Arr as $num){
$squares->add(Number::pow(Number::sub(\strval($num), $mean), '2'));
}
return Number::sqrt($squares->average());
}
|
php
|
public function stdDev(){
Number::setScale(static::NUMERIC_FUNCTIONS_SCALE);
$mean = $this->average();
$squares = new static();
foreach($this->_Arr as $num){
$squares->add(Number::pow(Number::sub(\strval($num), $mean), '2'));
}
return Number::sqrt($squares->average());
}
|
[
"public",
"function",
"stdDev",
"(",
")",
"{",
"Number",
"::",
"setScale",
"(",
"static",
"::",
"NUMERIC_FUNCTIONS_SCALE",
")",
";",
"$",
"mean",
"=",
"$",
"this",
"->",
"average",
"(",
")",
";",
"$",
"squares",
"=",
"new",
"static",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"_Arr",
"as",
"$",
"num",
")",
"{",
"$",
"squares",
"->",
"add",
"(",
"Number",
"::",
"pow",
"(",
"Number",
"::",
"sub",
"(",
"\\",
"strval",
"(",
"$",
"num",
")",
",",
"$",
"mean",
")",
",",
"'2'",
")",
")",
";",
"}",
"return",
"Number",
"::",
"sqrt",
"(",
"$",
"squares",
"->",
"average",
"(",
")",
")",
";",
"}"
] |
Computes the population standard deviation for the numbers
in this list
@return string
|
[
"Computes",
"the",
"population",
"standard",
"deviation",
"for",
"the",
"numbers",
"in",
"this",
"list"
] |
b101b73ebeb8a571345a303cbc75168f60d0e64f
|
https://github.com/dazarobbo/Cola/blob/b101b73ebeb8a571345a303cbc75168f60d0e64f/src/ArrayList.php#L879-L892
|
239,465
|
dazarobbo/Cola
|
src/ArrayList.php
|
ArrayList.unique
|
public function unique(\Closure $compare = null){
if(\is_callable($compare)){
$arr = new static();
$this->each(function($outerItem) use (&$arr, $compare){
if(!$arr->some(function($cmpItem) use ($outerItem, $compare){
return $compare($outerItem, $cmpItem);
})){
$arr->_Arr[] = $outerItem;
}
});
return $arr;
}
else{
return new static(\array_values(\array_unique(
$this->_Arr, \SORT_REGULAR)));
}
}
|
php
|
public function unique(\Closure $compare = null){
if(\is_callable($compare)){
$arr = new static();
$this->each(function($outerItem) use (&$arr, $compare){
if(!$arr->some(function($cmpItem) use ($outerItem, $compare){
return $compare($outerItem, $cmpItem);
})){
$arr->_Arr[] = $outerItem;
}
});
return $arr;
}
else{
return new static(\array_values(\array_unique(
$this->_Arr, \SORT_REGULAR)));
}
}
|
[
"public",
"function",
"unique",
"(",
"\\",
"Closure",
"$",
"compare",
"=",
"null",
")",
"{",
"if",
"(",
"\\",
"is_callable",
"(",
"$",
"compare",
")",
")",
"{",
"$",
"arr",
"=",
"new",
"static",
"(",
")",
";",
"$",
"this",
"->",
"each",
"(",
"function",
"(",
"$",
"outerItem",
")",
"use",
"(",
"&",
"$",
"arr",
",",
"$",
"compare",
")",
"{",
"if",
"(",
"!",
"$",
"arr",
"->",
"some",
"(",
"function",
"(",
"$",
"cmpItem",
")",
"use",
"(",
"$",
"outerItem",
",",
"$",
"compare",
")",
"{",
"return",
"$",
"compare",
"(",
"$",
"outerItem",
",",
"$",
"cmpItem",
")",
";",
"}",
")",
")",
"{",
"$",
"arr",
"->",
"_Arr",
"[",
"]",
"=",
"$",
"outerItem",
";",
"}",
"}",
")",
";",
"return",
"$",
"arr",
";",
"}",
"else",
"{",
"return",
"new",
"static",
"(",
"\\",
"array_values",
"(",
"\\",
"array_unique",
"(",
"$",
"this",
"->",
"_Arr",
",",
"\\",
"SORT_REGULAR",
")",
")",
")",
";",
"}",
"}"
] |
Eliminates duplicate values from this list, optionally according
to a user defined compare function
@param \Closure $compare
@return \static
|
[
"Eliminates",
"duplicate",
"values",
"from",
"this",
"list",
"optionally",
"according",
"to",
"a",
"user",
"defined",
"compare",
"function"
] |
b101b73ebeb8a571345a303cbc75168f60d0e64f
|
https://github.com/dazarobbo/Cola/blob/b101b73ebeb8a571345a303cbc75168f60d0e64f/src/ArrayList.php#L908-L932
|
239,466
|
BlackBoxRepo/PandoContentBundle
|
Service/MethodService.php
|
MethodService.call
|
public function call(MethodArgumentDocument $methodArgument)
{
$serviceName = $methodArgument->getMethod()->getService()->getServiceName();
$service = $this->container->get($serviceName);
if (null === $service) {
throw new UndefinedServiceException(sprintf('"%s" is not a service', $serviceName));
}
$methodName = $methodArgument->getMethod()->getName();
try {
$r = new \ReflectionMethod($service, $methodName);
} catch (\ReflectionException $e) {
throw new BadMethodCallException(sprintf('"%s" is not a method in %s', $methodName, $serviceName));
}
$methodArguments = $methodArgument->getArguments();
$numberOfArgs = $methodArguments->count();
$minArgs = $r->getNumberOfRequiredParameters();
$maxArgs = $r->getNumberOfParameters();
if ($numberOfArgs < $minArgs || $numberOfArgs > $maxArgs) {
$range = $minArgs === $maxArgs ? $minArgs : "$minArgs-$maxArgs";
throw new WrongNumberOfArgumentsException(
sprintf('Method "%s" in %s expects %s arguments, got %d', $methodName, $serviceName, $range, $numberOfArgs)
);
}
return $service->$methodName(...$this->buildArgumentArray($r->getParameters(), $methodArguments));
}
|
php
|
public function call(MethodArgumentDocument $methodArgument)
{
$serviceName = $methodArgument->getMethod()->getService()->getServiceName();
$service = $this->container->get($serviceName);
if (null === $service) {
throw new UndefinedServiceException(sprintf('"%s" is not a service', $serviceName));
}
$methodName = $methodArgument->getMethod()->getName();
try {
$r = new \ReflectionMethod($service, $methodName);
} catch (\ReflectionException $e) {
throw new BadMethodCallException(sprintf('"%s" is not a method in %s', $methodName, $serviceName));
}
$methodArguments = $methodArgument->getArguments();
$numberOfArgs = $methodArguments->count();
$minArgs = $r->getNumberOfRequiredParameters();
$maxArgs = $r->getNumberOfParameters();
if ($numberOfArgs < $minArgs || $numberOfArgs > $maxArgs) {
$range = $minArgs === $maxArgs ? $minArgs : "$minArgs-$maxArgs";
throw new WrongNumberOfArgumentsException(
sprintf('Method "%s" in %s expects %s arguments, got %d', $methodName, $serviceName, $range, $numberOfArgs)
);
}
return $service->$methodName(...$this->buildArgumentArray($r->getParameters(), $methodArguments));
}
|
[
"public",
"function",
"call",
"(",
"MethodArgumentDocument",
"$",
"methodArgument",
")",
"{",
"$",
"serviceName",
"=",
"$",
"methodArgument",
"->",
"getMethod",
"(",
")",
"->",
"getService",
"(",
")",
"->",
"getServiceName",
"(",
")",
";",
"$",
"service",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"$",
"serviceName",
")",
";",
"if",
"(",
"null",
"===",
"$",
"service",
")",
"{",
"throw",
"new",
"UndefinedServiceException",
"(",
"sprintf",
"(",
"'\"%s\" is not a service'",
",",
"$",
"serviceName",
")",
")",
";",
"}",
"$",
"methodName",
"=",
"$",
"methodArgument",
"->",
"getMethod",
"(",
")",
"->",
"getName",
"(",
")",
";",
"try",
"{",
"$",
"r",
"=",
"new",
"\\",
"ReflectionMethod",
"(",
"$",
"service",
",",
"$",
"methodName",
")",
";",
"}",
"catch",
"(",
"\\",
"ReflectionException",
"$",
"e",
")",
"{",
"throw",
"new",
"BadMethodCallException",
"(",
"sprintf",
"(",
"'\"%s\" is not a method in %s'",
",",
"$",
"methodName",
",",
"$",
"serviceName",
")",
")",
";",
"}",
"$",
"methodArguments",
"=",
"$",
"methodArgument",
"->",
"getArguments",
"(",
")",
";",
"$",
"numberOfArgs",
"=",
"$",
"methodArguments",
"->",
"count",
"(",
")",
";",
"$",
"minArgs",
"=",
"$",
"r",
"->",
"getNumberOfRequiredParameters",
"(",
")",
";",
"$",
"maxArgs",
"=",
"$",
"r",
"->",
"getNumberOfParameters",
"(",
")",
";",
"if",
"(",
"$",
"numberOfArgs",
"<",
"$",
"minArgs",
"||",
"$",
"numberOfArgs",
">",
"$",
"maxArgs",
")",
"{",
"$",
"range",
"=",
"$",
"minArgs",
"===",
"$",
"maxArgs",
"?",
"$",
"minArgs",
":",
"\"$minArgs-$maxArgs\"",
";",
"throw",
"new",
"WrongNumberOfArgumentsException",
"(",
"sprintf",
"(",
"'Method \"%s\" in %s expects %s arguments, got %d'",
",",
"$",
"methodName",
",",
"$",
"serviceName",
",",
"$",
"range",
",",
"$",
"numberOfArgs",
")",
")",
";",
"}",
"return",
"$",
"service",
"->",
"$",
"methodName",
"(",
"...",
"$",
"this",
"->",
"buildArgumentArray",
"(",
"$",
"r",
"->",
"getParameters",
"(",
")",
",",
"$",
"methodArguments",
")",
")",
";",
"}"
] |
Executes the passed in method via the associated service that's retrieved from the container.
This gets called recursively to supply all the arguments for each given method.
@param MethodArgumentDocument $methodArgument
@throws WrongNumberOfArgumentsException if we have more or less arguments than the method requires
@throws BadArgumentTypeException if the type of a given argument does not match the method arguments expected type
@throws MissingMethodArgumentException if argument has neither callback nor value
@throws UndefinedServiceException if service doesn't exist
@throws BadMethodCallException if the service doesn't have the given method
@return mixed
|
[
"Executes",
"the",
"passed",
"in",
"method",
"via",
"the",
"associated",
"service",
"that",
"s",
"retrieved",
"from",
"the",
"container",
".",
"This",
"gets",
"called",
"recursively",
"to",
"supply",
"all",
"the",
"arguments",
"for",
"each",
"given",
"method",
"."
] |
fa54d0c7542c1d359a5dbb4f32dab3e195e41007
|
https://github.com/BlackBoxRepo/PandoContentBundle/blob/fa54d0c7542c1d359a5dbb4f32dab3e195e41007/Service/MethodService.php#L44-L72
|
239,467
|
Palmabit-IT/authenticator
|
src/Palmabit/Authentication/Helpers/SentryAuthenticationHelper.php
|
SentryAuthenticationHelper.checkProfileEditPermission
|
public function checkProfileEditPermission($user_id) {
$current_user_id = App::make('sentry')->getUser()->id;
// edit his profile
if ($user_id == $current_user_id) {
return true;
}
// has special permission to edit other user profiles
$edit_perm = Config::get('authentication::permissions.edit_profile');
if ($this->hasPermission($edit_perm)) {
return true;
}
return false;
}
|
php
|
public function checkProfileEditPermission($user_id) {
$current_user_id = App::make('sentry')->getUser()->id;
// edit his profile
if ($user_id == $current_user_id) {
return true;
}
// has special permission to edit other user profiles
$edit_perm = Config::get('authentication::permissions.edit_profile');
if ($this->hasPermission($edit_perm)) {
return true;
}
return false;
}
|
[
"public",
"function",
"checkProfileEditPermission",
"(",
"$",
"user_id",
")",
"{",
"$",
"current_user_id",
"=",
"App",
"::",
"make",
"(",
"'sentry'",
")",
"->",
"getUser",
"(",
")",
"->",
"id",
";",
"// edit his profile",
"if",
"(",
"$",
"user_id",
"==",
"$",
"current_user_id",
")",
"{",
"return",
"true",
";",
"}",
"// has special permission to edit other user profiles",
"$",
"edit_perm",
"=",
"Config",
"::",
"get",
"(",
"'authentication::permissions.edit_profile'",
")",
";",
"if",
"(",
"$",
"this",
"->",
"hasPermission",
"(",
"$",
"edit_perm",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Check if the current user has permission to edit the profile
@return boolean
|
[
"Check",
"if",
"the",
"current",
"user",
"has",
"permission",
"to",
"edit",
"the",
"profile"
] |
986cfc7e666e0e1b0312e518d586ec61b08cdb42
|
https://github.com/Palmabit-IT/authenticator/blob/986cfc7e666e0e1b0312e518d586ec61b08cdb42/src/Palmabit/Authentication/Helpers/SentryAuthenticationHelper.php#L38-L52
|
239,468
|
Palmabit-IT/authenticator
|
src/Palmabit/Authentication/Helpers/SentryAuthenticationHelper.php
|
SentryAuthenticationHelper.getNotificationRegistrationUsersEmail
|
public function getNotificationRegistrationUsersEmail() {
$group_name = Config::get('authentication::permissions.profile_notification_group');
$user_r = App::make('user_repository');
$users = $user_r->findFromGroupName($group_name)->lists('email');
return $users;
}
|
php
|
public function getNotificationRegistrationUsersEmail() {
$group_name = Config::get('authentication::permissions.profile_notification_group');
$user_r = App::make('user_repository');
$users = $user_r->findFromGroupName($group_name)->lists('email');
return $users;
}
|
[
"public",
"function",
"getNotificationRegistrationUsersEmail",
"(",
")",
"{",
"$",
"group_name",
"=",
"Config",
"::",
"get",
"(",
"'authentication::permissions.profile_notification_group'",
")",
";",
"$",
"user_r",
"=",
"App",
"::",
"make",
"(",
"'user_repository'",
")",
";",
"$",
"users",
"=",
"$",
"user_r",
"->",
"findFromGroupName",
"(",
"$",
"group_name",
")",
"->",
"lists",
"(",
"'email'",
")",
";",
"return",
"$",
"users",
";",
"}"
] |
Obtain the user that needs to be notificated on registration
@return array
|
[
"Obtain",
"the",
"user",
"that",
"needs",
"to",
"be",
"notificated",
"on",
"registration"
] |
986cfc7e666e0e1b0312e518d586ec61b08cdb42
|
https://github.com/Palmabit-IT/authenticator/blob/986cfc7e666e0e1b0312e518d586ec61b08cdb42/src/Palmabit/Authentication/Helpers/SentryAuthenticationHelper.php#L59-L65
|
239,469
|
opsbears/piccolo-templating
|
src/TemplatingModule.php
|
TemplatingModule.addTemplatingEngineClass
|
public function addTemplatingEngineClass(array &$globalConfig, string $templateEngineClass) {
$globalConfig[$this->getModuleKey()][self::CONFIG_ENGINES][] = $templateEngineClass;
}
|
php
|
public function addTemplatingEngineClass(array &$globalConfig, string $templateEngineClass) {
$globalConfig[$this->getModuleKey()][self::CONFIG_ENGINES][] = $templateEngineClass;
}
|
[
"public",
"function",
"addTemplatingEngineClass",
"(",
"array",
"&",
"$",
"globalConfig",
",",
"string",
"$",
"templateEngineClass",
")",
"{",
"$",
"globalConfig",
"[",
"$",
"this",
"->",
"getModuleKey",
"(",
")",
"]",
"[",
"self",
"::",
"CONFIG_ENGINES",
"]",
"[",
"]",
"=",
"$",
"templateEngineClass",
";",
"}"
] |
Adds a class as a possible template engine. This must be done before the configureDependencyInjection function
is called.
@param array $globalConfig
@param string $templateEngineClass
@throws ConfigurationException if the DIC configuration phase has already finished.
|
[
"Adds",
"a",
"class",
"as",
"a",
"possible",
"template",
"engine",
".",
"This",
"must",
"be",
"done",
"before",
"the",
"configureDependencyInjection",
"function",
"is",
"called",
"."
] |
b5faeb2fc4c8f2b003aa5edb245f9559cd0101c3
|
https://github.com/opsbears/piccolo-templating/blob/b5faeb2fc4c8f2b003aa5edb245f9559cd0101c3/src/TemplatingModule.php#L47-L49
|
239,470
|
opsbears/piccolo-templating
|
src/TemplatingModule.php
|
TemplatingModule.configureDependencyInjection
|
public function configureDependencyInjection(DependencyInjectionContainer $dic,
array $moduleConfig,
array $globalConfig) {
/**
* @var TemplateEngine[] $engines
*/
$engines = [];
if (empty($moduleConfig[self::CONFIG_ENGINES])) {
throw new ConfigurationException('The templating module itself was loaded, but there is no module ' .
' for the actual template engine present. Did you forget to load your templating module?');
}
//Create the instances of the template engine to be used with the TemplateRenderingChain
foreach ($moduleConfig[self::CONFIG_ENGINES] as $engineClass) {
$engines[] = $dic->make($engineClass);
}
if (isset($moduleConfig[self::CONFIG_FILTERS])) {
foreach ($moduleConfig[self::CONFIG_FILTERS] as $filterClass) {
$filterInstance = $dic->make($filterClass);
if ($filterInstance instanceof TemplateFilter) {
foreach ($engines as $engine) {
$engine->registerFilter($filterInstance);
}
} else {
throw new ConfigurationException($filterClass . ' does not implement ' . TemplateFilter::class);
}
}
}
if (isset($moduleConfig[self::CONFIG_FUNCTIONS])) {
foreach ($moduleConfig[self::CONFIG_FUNCTIONS] as $functionClass) {
$functionInstance = $dic->make($functionClass);
if ($functionInstance instanceof TemplateFunction) {
foreach ($engines as $engine) {
$engine->registerFunction($functionInstance);
}
} else {
throw new ConfigurationException($functionClass . ' does not implement ' . TemplateFunction::class);
}
}
}
$dic->setClassParameters(TemplateRenderingChain::class, ['templateEngines' => $engines]);
}
|
php
|
public function configureDependencyInjection(DependencyInjectionContainer $dic,
array $moduleConfig,
array $globalConfig) {
/**
* @var TemplateEngine[] $engines
*/
$engines = [];
if (empty($moduleConfig[self::CONFIG_ENGINES])) {
throw new ConfigurationException('The templating module itself was loaded, but there is no module ' .
' for the actual template engine present. Did you forget to load your templating module?');
}
//Create the instances of the template engine to be used with the TemplateRenderingChain
foreach ($moduleConfig[self::CONFIG_ENGINES] as $engineClass) {
$engines[] = $dic->make($engineClass);
}
if (isset($moduleConfig[self::CONFIG_FILTERS])) {
foreach ($moduleConfig[self::CONFIG_FILTERS] as $filterClass) {
$filterInstance = $dic->make($filterClass);
if ($filterInstance instanceof TemplateFilter) {
foreach ($engines as $engine) {
$engine->registerFilter($filterInstance);
}
} else {
throw new ConfigurationException($filterClass . ' does not implement ' . TemplateFilter::class);
}
}
}
if (isset($moduleConfig[self::CONFIG_FUNCTIONS])) {
foreach ($moduleConfig[self::CONFIG_FUNCTIONS] as $functionClass) {
$functionInstance = $dic->make($functionClass);
if ($functionInstance instanceof TemplateFunction) {
foreach ($engines as $engine) {
$engine->registerFunction($functionInstance);
}
} else {
throw new ConfigurationException($functionClass . ' does not implement ' . TemplateFunction::class);
}
}
}
$dic->setClassParameters(TemplateRenderingChain::class, ['templateEngines' => $engines]);
}
|
[
"public",
"function",
"configureDependencyInjection",
"(",
"DependencyInjectionContainer",
"$",
"dic",
",",
"array",
"$",
"moduleConfig",
",",
"array",
"$",
"globalConfig",
")",
"{",
"/**\n\t\t * @var TemplateEngine[] $engines\n\t\t */",
"$",
"engines",
"=",
"[",
"]",
";",
"if",
"(",
"empty",
"(",
"$",
"moduleConfig",
"[",
"self",
"::",
"CONFIG_ENGINES",
"]",
")",
")",
"{",
"throw",
"new",
"ConfigurationException",
"(",
"'The templating module itself was loaded, but there is no module '",
".",
"' for the actual template engine present. Did you forget to load your templating module?'",
")",
";",
"}",
"//Create the instances of the template engine to be used with the TemplateRenderingChain",
"foreach",
"(",
"$",
"moduleConfig",
"[",
"self",
"::",
"CONFIG_ENGINES",
"]",
"as",
"$",
"engineClass",
")",
"{",
"$",
"engines",
"[",
"]",
"=",
"$",
"dic",
"->",
"make",
"(",
"$",
"engineClass",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"moduleConfig",
"[",
"self",
"::",
"CONFIG_FILTERS",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"moduleConfig",
"[",
"self",
"::",
"CONFIG_FILTERS",
"]",
"as",
"$",
"filterClass",
")",
"{",
"$",
"filterInstance",
"=",
"$",
"dic",
"->",
"make",
"(",
"$",
"filterClass",
")",
";",
"if",
"(",
"$",
"filterInstance",
"instanceof",
"TemplateFilter",
")",
"{",
"foreach",
"(",
"$",
"engines",
"as",
"$",
"engine",
")",
"{",
"$",
"engine",
"->",
"registerFilter",
"(",
"$",
"filterInstance",
")",
";",
"}",
"}",
"else",
"{",
"throw",
"new",
"ConfigurationException",
"(",
"$",
"filterClass",
".",
"' does not implement '",
".",
"TemplateFilter",
"::",
"class",
")",
";",
"}",
"}",
"}",
"if",
"(",
"isset",
"(",
"$",
"moduleConfig",
"[",
"self",
"::",
"CONFIG_FUNCTIONS",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"moduleConfig",
"[",
"self",
"::",
"CONFIG_FUNCTIONS",
"]",
"as",
"$",
"functionClass",
")",
"{",
"$",
"functionInstance",
"=",
"$",
"dic",
"->",
"make",
"(",
"$",
"functionClass",
")",
";",
"if",
"(",
"$",
"functionInstance",
"instanceof",
"TemplateFunction",
")",
"{",
"foreach",
"(",
"$",
"engines",
"as",
"$",
"engine",
")",
"{",
"$",
"engine",
"->",
"registerFunction",
"(",
"$",
"functionInstance",
")",
";",
"}",
"}",
"else",
"{",
"throw",
"new",
"ConfigurationException",
"(",
"$",
"functionClass",
".",
"' does not implement '",
".",
"TemplateFunction",
"::",
"class",
")",
";",
"}",
"}",
"}",
"$",
"dic",
"->",
"setClassParameters",
"(",
"TemplateRenderingChain",
"::",
"class",
",",
"[",
"'templateEngines'",
"=>",
"$",
"engines",
"]",
")",
";",
"}"
] |
Configures the TemplateRenderingChain with the previously registered templating engines.
@param DependencyInjectionContainer $dic
@param array $moduleConfig
@param array $globalConfig
@throws ConfigurationException if no templating module was loaded.
|
[
"Configures",
"the",
"TemplateRenderingChain",
"with",
"the",
"previously",
"registered",
"templating",
"engines",
"."
] |
b5faeb2fc4c8f2b003aa5edb245f9559cd0101c3
|
https://github.com/opsbears/piccolo-templating/blob/b5faeb2fc4c8f2b003aa5edb245f9559cd0101c3/src/TemplatingModule.php#L72-L112
|
239,471
|
cawaphp/serializer
|
src/Serializer.php
|
Serializer.serializeObject
|
private function serializeObject($object, string $className = null)
{
if (is_null($className)) {
$index = array_search($object, $this->references, true);
if ($index !== false) {
$this->referencesUsed[] = $index;
return ['@ref' => $index];
}
$this->references[] = $object;
}
$data = ['@type' => get_class($object)];
$reflectionClass = new \ReflectionClass($className ? $className : $object);
// parent class
$parent = $reflectionClass->getParentClass();
if ($parent) {
$parentData = $this->serializeObject($object, $parent->getName());
if (count($parentData) > 0) {
$data = array_merge($data, $parentData);
}
}
// current $object
foreach ($reflectionClass->getProperties() as $property) {
$property->setAccessible(true);
$value = $property->getValue($object);
$name = $property->getName();
// for parent class, don't reserialize public & protected properties
if (isset($data[$name])) {
continue;
}
// optimization: only save value if not the default value
$defaults = $reflectionClass->getDefaultProperties();
if (array_key_exists($name, $defaults) && $defaults[$name] === $value) {
continue;
}
$this->serializeValue($name, $value, $data);
}
// ugly hack for public undeclared properties and
// for internal object like datetime that can't be accessed by reflection
// @see http://news.php.net/php.internals/93826%20view%20original
if (!$className) {
foreach (get_object_vars($object) as $key => $value) {
if (!isset($data[$key])) {
$this->serializeValue($key, $value, $data);
}
}
}
return $data;
}
|
php
|
private function serializeObject($object, string $className = null)
{
if (is_null($className)) {
$index = array_search($object, $this->references, true);
if ($index !== false) {
$this->referencesUsed[] = $index;
return ['@ref' => $index];
}
$this->references[] = $object;
}
$data = ['@type' => get_class($object)];
$reflectionClass = new \ReflectionClass($className ? $className : $object);
// parent class
$parent = $reflectionClass->getParentClass();
if ($parent) {
$parentData = $this->serializeObject($object, $parent->getName());
if (count($parentData) > 0) {
$data = array_merge($data, $parentData);
}
}
// current $object
foreach ($reflectionClass->getProperties() as $property) {
$property->setAccessible(true);
$value = $property->getValue($object);
$name = $property->getName();
// for parent class, don't reserialize public & protected properties
if (isset($data[$name])) {
continue;
}
// optimization: only save value if not the default value
$defaults = $reflectionClass->getDefaultProperties();
if (array_key_exists($name, $defaults) && $defaults[$name] === $value) {
continue;
}
$this->serializeValue($name, $value, $data);
}
// ugly hack for public undeclared properties and
// for internal object like datetime that can't be accessed by reflection
// @see http://news.php.net/php.internals/93826%20view%20original
if (!$className) {
foreach (get_object_vars($object) as $key => $value) {
if (!isset($data[$key])) {
$this->serializeValue($key, $value, $data);
}
}
}
return $data;
}
|
[
"private",
"function",
"serializeObject",
"(",
"$",
"object",
",",
"string",
"$",
"className",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"className",
")",
")",
"{",
"$",
"index",
"=",
"array_search",
"(",
"$",
"object",
",",
"$",
"this",
"->",
"references",
",",
"true",
")",
";",
"if",
"(",
"$",
"index",
"!==",
"false",
")",
"{",
"$",
"this",
"->",
"referencesUsed",
"[",
"]",
"=",
"$",
"index",
";",
"return",
"[",
"'@ref'",
"=>",
"$",
"index",
"]",
";",
"}",
"$",
"this",
"->",
"references",
"[",
"]",
"=",
"$",
"object",
";",
"}",
"$",
"data",
"=",
"[",
"'@type'",
"=>",
"get_class",
"(",
"$",
"object",
")",
"]",
";",
"$",
"reflectionClass",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"className",
"?",
"$",
"className",
":",
"$",
"object",
")",
";",
"// parent class",
"$",
"parent",
"=",
"$",
"reflectionClass",
"->",
"getParentClass",
"(",
")",
";",
"if",
"(",
"$",
"parent",
")",
"{",
"$",
"parentData",
"=",
"$",
"this",
"->",
"serializeObject",
"(",
"$",
"object",
",",
"$",
"parent",
"->",
"getName",
"(",
")",
")",
";",
"if",
"(",
"count",
"(",
"$",
"parentData",
")",
">",
"0",
")",
"{",
"$",
"data",
"=",
"array_merge",
"(",
"$",
"data",
",",
"$",
"parentData",
")",
";",
"}",
"}",
"// current $object",
"foreach",
"(",
"$",
"reflectionClass",
"->",
"getProperties",
"(",
")",
"as",
"$",
"property",
")",
"{",
"$",
"property",
"->",
"setAccessible",
"(",
"true",
")",
";",
"$",
"value",
"=",
"$",
"property",
"->",
"getValue",
"(",
"$",
"object",
")",
";",
"$",
"name",
"=",
"$",
"property",
"->",
"getName",
"(",
")",
";",
"// for parent class, don't reserialize public & protected properties",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"$",
"name",
"]",
")",
")",
"{",
"continue",
";",
"}",
"// optimization: only save value if not the default value",
"$",
"defaults",
"=",
"$",
"reflectionClass",
"->",
"getDefaultProperties",
"(",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"name",
",",
"$",
"defaults",
")",
"&&",
"$",
"defaults",
"[",
"$",
"name",
"]",
"===",
"$",
"value",
")",
"{",
"continue",
";",
"}",
"$",
"this",
"->",
"serializeValue",
"(",
"$",
"name",
",",
"$",
"value",
",",
"$",
"data",
")",
";",
"}",
"// ugly hack for public undeclared properties and",
"// for internal object like datetime that can't be accessed by reflection",
"// @see http://news.php.net/php.internals/93826%20view%20original",
"if",
"(",
"!",
"$",
"className",
")",
"{",
"foreach",
"(",
"get_object_vars",
"(",
"$",
"object",
")",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"data",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"this",
"->",
"serializeValue",
"(",
"$",
"key",
",",
"$",
"value",
",",
"$",
"data",
")",
";",
"}",
"}",
"}",
"return",
"$",
"data",
";",
"}"
] |
Recursive serialize.
@param object $object
@param string $className
@return array
|
[
"Recursive",
"serialize",
"."
] |
dedf2206d6a617086321060429c2c9bb227ffc71
|
https://github.com/cawaphp/serializer/blob/dedf2206d6a617086321060429c2c9bb227ffc71/src/Serializer.php#L77-L136
|
239,472
|
cawaphp/serializer
|
src/Serializer.php
|
Serializer.unserializeObject
|
private function unserializeObject($object, &$data, string $className = null) : array
{
$reflectionClass = new \ReflectionClass($className ? $className : $object);
unset($data['@type']);
// parent class
$parent = $reflectionClass->getParentClass();
if ($parent) {
$this->unserializeObject($object, $data, $parent->getName());
}
foreach ($reflectionClass->getProperties() as $property) {
$name = $property->getName();
if (array_key_exists($name, $data)) {
$currentValue = $data[$name];
if (isset($data[$name]['@ref'])) {
$currentValue = $this->references[$data[$name]['@ref']];
} elseif (isset($data[$name]['@type'])) {
$reflection = new \ReflectionClass($data[$name]['@type']);
$parent = $reflection;
$internal = false;
while ($parent !== false) {
$internal = $parent->isInternal() ? true : $internal;
$parent = $parent->getParentClass();
}
if ($internal) {
$currentData = $data[$name];
$currentType = $data[$name]['@type'];
unset($currentData['@type']);
$serialize = preg_replace(
'`^a:`',
'O:' . strlen($currentType) . ':"' . $currentType . '":',
serialize($currentData)
);
$currentValue = unserialize($serialize);
} else {
$currentValue = $reflection->newInstanceWithoutConstructor();
$this->unserializeObject($currentValue, $data[$name]);
}
} elseif (is_array($currentValue)) {
$currentValue = [];
foreach ($data[$name] as $key => $value) {
if (isset($value['@type'])) {
$reflection = new \ReflectionClass($value['@type']);
$currentValue[$key] = $reflection->newInstanceWithoutConstructor();
$this->unserializeObject($currentValue[$key], $value);
} else {
$currentValue[$key] = $value;
}
}
}
$property->setAccessible(true);
$property->setValue($object, $currentValue);
unset($data[$name]);
}
}
return $data;
}
|
php
|
private function unserializeObject($object, &$data, string $className = null) : array
{
$reflectionClass = new \ReflectionClass($className ? $className : $object);
unset($data['@type']);
// parent class
$parent = $reflectionClass->getParentClass();
if ($parent) {
$this->unserializeObject($object, $data, $parent->getName());
}
foreach ($reflectionClass->getProperties() as $property) {
$name = $property->getName();
if (array_key_exists($name, $data)) {
$currentValue = $data[$name];
if (isset($data[$name]['@ref'])) {
$currentValue = $this->references[$data[$name]['@ref']];
} elseif (isset($data[$name]['@type'])) {
$reflection = new \ReflectionClass($data[$name]['@type']);
$parent = $reflection;
$internal = false;
while ($parent !== false) {
$internal = $parent->isInternal() ? true : $internal;
$parent = $parent->getParentClass();
}
if ($internal) {
$currentData = $data[$name];
$currentType = $data[$name]['@type'];
unset($currentData['@type']);
$serialize = preg_replace(
'`^a:`',
'O:' . strlen($currentType) . ':"' . $currentType . '":',
serialize($currentData)
);
$currentValue = unserialize($serialize);
} else {
$currentValue = $reflection->newInstanceWithoutConstructor();
$this->unserializeObject($currentValue, $data[$name]);
}
} elseif (is_array($currentValue)) {
$currentValue = [];
foreach ($data[$name] as $key => $value) {
if (isset($value['@type'])) {
$reflection = new \ReflectionClass($value['@type']);
$currentValue[$key] = $reflection->newInstanceWithoutConstructor();
$this->unserializeObject($currentValue[$key], $value);
} else {
$currentValue[$key] = $value;
}
}
}
$property->setAccessible(true);
$property->setValue($object, $currentValue);
unset($data[$name]);
}
}
return $data;
}
|
[
"private",
"function",
"unserializeObject",
"(",
"$",
"object",
",",
"&",
"$",
"data",
",",
"string",
"$",
"className",
"=",
"null",
")",
":",
"array",
"{",
"$",
"reflectionClass",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"className",
"?",
"$",
"className",
":",
"$",
"object",
")",
";",
"unset",
"(",
"$",
"data",
"[",
"'@type'",
"]",
")",
";",
"// parent class",
"$",
"parent",
"=",
"$",
"reflectionClass",
"->",
"getParentClass",
"(",
")",
";",
"if",
"(",
"$",
"parent",
")",
"{",
"$",
"this",
"->",
"unserializeObject",
"(",
"$",
"object",
",",
"$",
"data",
",",
"$",
"parent",
"->",
"getName",
"(",
")",
")",
";",
"}",
"foreach",
"(",
"$",
"reflectionClass",
"->",
"getProperties",
"(",
")",
"as",
"$",
"property",
")",
"{",
"$",
"name",
"=",
"$",
"property",
"->",
"getName",
"(",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"name",
",",
"$",
"data",
")",
")",
"{",
"$",
"currentValue",
"=",
"$",
"data",
"[",
"$",
"name",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"$",
"name",
"]",
"[",
"'@ref'",
"]",
")",
")",
"{",
"$",
"currentValue",
"=",
"$",
"this",
"->",
"references",
"[",
"$",
"data",
"[",
"$",
"name",
"]",
"[",
"'@ref'",
"]",
"]",
";",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"data",
"[",
"$",
"name",
"]",
"[",
"'@type'",
"]",
")",
")",
"{",
"$",
"reflection",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"data",
"[",
"$",
"name",
"]",
"[",
"'@type'",
"]",
")",
";",
"$",
"parent",
"=",
"$",
"reflection",
";",
"$",
"internal",
"=",
"false",
";",
"while",
"(",
"$",
"parent",
"!==",
"false",
")",
"{",
"$",
"internal",
"=",
"$",
"parent",
"->",
"isInternal",
"(",
")",
"?",
"true",
":",
"$",
"internal",
";",
"$",
"parent",
"=",
"$",
"parent",
"->",
"getParentClass",
"(",
")",
";",
"}",
"if",
"(",
"$",
"internal",
")",
"{",
"$",
"currentData",
"=",
"$",
"data",
"[",
"$",
"name",
"]",
";",
"$",
"currentType",
"=",
"$",
"data",
"[",
"$",
"name",
"]",
"[",
"'@type'",
"]",
";",
"unset",
"(",
"$",
"currentData",
"[",
"'@type'",
"]",
")",
";",
"$",
"serialize",
"=",
"preg_replace",
"(",
"'`^a:`'",
",",
"'O:'",
".",
"strlen",
"(",
"$",
"currentType",
")",
".",
"':\"'",
".",
"$",
"currentType",
".",
"'\":'",
",",
"serialize",
"(",
"$",
"currentData",
")",
")",
";",
"$",
"currentValue",
"=",
"unserialize",
"(",
"$",
"serialize",
")",
";",
"}",
"else",
"{",
"$",
"currentValue",
"=",
"$",
"reflection",
"->",
"newInstanceWithoutConstructor",
"(",
")",
";",
"$",
"this",
"->",
"unserializeObject",
"(",
"$",
"currentValue",
",",
"$",
"data",
"[",
"$",
"name",
"]",
")",
";",
"}",
"}",
"elseif",
"(",
"is_array",
"(",
"$",
"currentValue",
")",
")",
"{",
"$",
"currentValue",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"data",
"[",
"$",
"name",
"]",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"value",
"[",
"'@type'",
"]",
")",
")",
"{",
"$",
"reflection",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"value",
"[",
"'@type'",
"]",
")",
";",
"$",
"currentValue",
"[",
"$",
"key",
"]",
"=",
"$",
"reflection",
"->",
"newInstanceWithoutConstructor",
"(",
")",
";",
"$",
"this",
"->",
"unserializeObject",
"(",
"$",
"currentValue",
"[",
"$",
"key",
"]",
",",
"$",
"value",
")",
";",
"}",
"else",
"{",
"$",
"currentValue",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"}",
"$",
"property",
"->",
"setAccessible",
"(",
"true",
")",
";",
"$",
"property",
"->",
"setValue",
"(",
"$",
"object",
",",
"$",
"currentValue",
")",
";",
"unset",
"(",
"$",
"data",
"[",
"$",
"name",
"]",
")",
";",
"}",
"}",
"return",
"$",
"data",
";",
"}"
] |
Recursive unserialize to get parent class property.
@param object $object
@param array $data
@param string $className
@return array
|
[
"Recursive",
"unserialize",
"to",
"get",
"parent",
"class",
"property",
"."
] |
dedf2206d6a617086321060429c2c9bb227ffc71
|
https://github.com/cawaphp/serializer/blob/dedf2206d6a617086321060429c2c9bb227ffc71/src/Serializer.php#L171-L237
|
239,473
|
EarthlingInteractive/PHPCMIPREST
|
lib/EarthIT/CMIPREST/ResultAssembler/JAOResultAssembler.php
|
EarthIT_CMIPREST_ResultAssembler_JAOResultAssembler._q45
|
protected function _q45( EarthIT_Schema_ResourceClass $rc, array $items ) {
$restObjects = array();
foreach( $items as $item ) {
$restObjects[] = $this->internalObjectToJao($rc, $item);
}
return $restObjects;
}
|
php
|
protected function _q45( EarthIT_Schema_ResourceClass $rc, array $items ) {
$restObjects = array();
foreach( $items as $item ) {
$restObjects[] = $this->internalObjectToJao($rc, $item);
}
return $restObjects;
}
|
[
"protected",
"function",
"_q45",
"(",
"EarthIT_Schema_ResourceClass",
"$",
"rc",
",",
"array",
"$",
"items",
")",
"{",
"$",
"restObjects",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"items",
"as",
"$",
"item",
")",
"{",
"$",
"restObjects",
"[",
"]",
"=",
"$",
"this",
"->",
"internalObjectToJao",
"(",
"$",
"rc",
",",
"$",
"item",
")",
";",
"}",
"return",
"$",
"restObjects",
";",
"}"
] |
Convert the given rows from internal to REST format according to the
specified resource class.
|
[
"Convert",
"the",
"given",
"rows",
"from",
"internal",
"to",
"REST",
"format",
"according",
"to",
"the",
"specified",
"resource",
"class",
"."
] |
db0398ea4fc07fa62f2de9ba43f2f3137170d9f0
|
https://github.com/EarthlingInteractive/PHPCMIPREST/blob/db0398ea4fc07fa62f2de9ba43f2f3137170d9f0/lib/EarthIT/CMIPREST/ResultAssembler/JAOResultAssembler.php#L101-L107
|
239,474
|
jfortunato/fortune
|
src/ResourceFactory.php
|
ResourceFactory.newSimpleOutput
|
public function newSimpleOutput()
{
$config = $this->config->getCurrentResourceConfiguration();
return new SimpleOutput(
$this->newSerializer($config),
$this->newResource($config)
);
}
|
php
|
public function newSimpleOutput()
{
$config = $this->config->getCurrentResourceConfiguration();
return new SimpleOutput(
$this->newSerializer($config),
$this->newResource($config)
);
}
|
[
"public",
"function",
"newSimpleOutput",
"(",
")",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"config",
"->",
"getCurrentResourceConfiguration",
"(",
")",
";",
"return",
"new",
"SimpleOutput",
"(",
"$",
"this",
"->",
"newSerializer",
"(",
"$",
"config",
")",
",",
"$",
"this",
"->",
"newResource",
"(",
"$",
"config",
")",
")",
";",
"}"
] |
Creates a SimpleOutput instance to be used with native PHP.
@return SimpleOutput
|
[
"Creates",
"a",
"SimpleOutput",
"instance",
"to",
"be",
"used",
"with",
"native",
"PHP",
"."
] |
3bbf66a85304070562e54a66c99145f58f32877e
|
https://github.com/jfortunato/fortune/blob/3bbf66a85304070562e54a66c99145f58f32877e/src/ResourceFactory.php#L68-L76
|
239,475
|
jfortunato/fortune
|
src/ResourceFactory.php
|
ResourceFactory.newSlimOutput
|
public function newSlimOutput(Request $request, Response $response)
{
$config = $this->config->getCurrentResourceConfiguration();
return new SlimOutput(
$request,
$response,
$this->newSerializer($config),
$this->newResource($config)
);
}
|
php
|
public function newSlimOutput(Request $request, Response $response)
{
$config = $this->config->getCurrentResourceConfiguration();
return new SlimOutput(
$request,
$response,
$this->newSerializer($config),
$this->newResource($config)
);
}
|
[
"public",
"function",
"newSlimOutput",
"(",
"Request",
"$",
"request",
",",
"Response",
"$",
"response",
")",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"config",
"->",
"getCurrentResourceConfiguration",
"(",
")",
";",
"return",
"new",
"SlimOutput",
"(",
"$",
"request",
",",
"$",
"response",
",",
"$",
"this",
"->",
"newSerializer",
"(",
"$",
"config",
")",
",",
"$",
"this",
"->",
"newResource",
"(",
"$",
"config",
")",
")",
";",
"}"
] |
Creates a SlimOutput instance to be used with the slim PHP framework.
@param Request $request
@param Response $response
@return SlimOutput
|
[
"Creates",
"a",
"SlimOutput",
"instance",
"to",
"be",
"used",
"with",
"the",
"slim",
"PHP",
"framework",
"."
] |
3bbf66a85304070562e54a66c99145f58f32877e
|
https://github.com/jfortunato/fortune/blob/3bbf66a85304070562e54a66c99145f58f32877e/src/ResourceFactory.php#L85-L95
|
239,476
|
jfortunato/fortune
|
src/ResourceFactory.php
|
ResourceFactory.generateSlimRoutes
|
public function generateSlimRoutes(Slim $slim)
{
// if we are not on a resources's route, then dont generate any routes
if (!$this->config->getCurrentResourceConfiguration()) {
return;
}
$output = $this->newSlimOutput($slim->request, $slim->response);
$generator = new SlimRouteGenerator($slim, $output, $this->config);
$generator->generateRoutes();
}
|
php
|
public function generateSlimRoutes(Slim $slim)
{
// if we are not on a resources's route, then dont generate any routes
if (!$this->config->getCurrentResourceConfiguration()) {
return;
}
$output = $this->newSlimOutput($slim->request, $slim->response);
$generator = new SlimRouteGenerator($slim, $output, $this->config);
$generator->generateRoutes();
}
|
[
"public",
"function",
"generateSlimRoutes",
"(",
"Slim",
"$",
"slim",
")",
"{",
"// if we are not on a resources's route, then dont generate any routes",
"if",
"(",
"!",
"$",
"this",
"->",
"config",
"->",
"getCurrentResourceConfiguration",
"(",
")",
")",
"{",
"return",
";",
"}",
"$",
"output",
"=",
"$",
"this",
"->",
"newSlimOutput",
"(",
"$",
"slim",
"->",
"request",
",",
"$",
"slim",
"->",
"response",
")",
";",
"$",
"generator",
"=",
"new",
"SlimRouteGenerator",
"(",
"$",
"slim",
",",
"$",
"output",
",",
"$",
"this",
"->",
"config",
")",
";",
"$",
"generator",
"->",
"generateRoutes",
"(",
")",
";",
"}"
] |
Helper for generating all the routes for the configured resources in slim.
@param Slim $slim
@return void
|
[
"Helper",
"for",
"generating",
"all",
"the",
"routes",
"for",
"the",
"configured",
"resources",
"in",
"slim",
"."
] |
3bbf66a85304070562e54a66c99145f58f32877e
|
https://github.com/jfortunato/fortune/blob/3bbf66a85304070562e54a66c99145f58f32877e/src/ResourceFactory.php#L103-L115
|
239,477
|
jfortunato/fortune
|
src/ResourceFactory.php
|
ResourceFactory.resourceFor
|
public function resourceFor($resourceName)
{
$resourceConfig = $this->config->resourceConfigurationFor($resourceName);
return $this->newResource($resourceConfig);
}
|
php
|
public function resourceFor($resourceName)
{
$resourceConfig = $this->config->resourceConfigurationFor($resourceName);
return $this->newResource($resourceConfig);
}
|
[
"public",
"function",
"resourceFor",
"(",
"$",
"resourceName",
")",
"{",
"$",
"resourceConfig",
"=",
"$",
"this",
"->",
"config",
"->",
"resourceConfigurationFor",
"(",
"$",
"resourceName",
")",
";",
"return",
"$",
"this",
"->",
"newResource",
"(",
"$",
"resourceConfig",
")",
";",
"}"
] |
Finds a ResourceConfiguration for given resource name.
@param string $resourceName
@return ResourceConfiguration
|
[
"Finds",
"a",
"ResourceConfiguration",
"for",
"given",
"resource",
"name",
"."
] |
3bbf66a85304070562e54a66c99145f58f32877e
|
https://github.com/jfortunato/fortune/blob/3bbf66a85304070562e54a66c99145f58f32877e/src/ResourceFactory.php#L133-L138
|
239,478
|
jfortunato/fortune
|
src/ResourceFactory.php
|
ResourceFactory.newRepository
|
protected function newRepository(ResourceConfiguration $config)
{
if ($this->database instanceof EntityManager) {
return $this->newDoctrineRepository($this->database, $config->getEntityClass(), $config->getParent());
} elseif ($this->database instanceof PDO) {
return $this->newPdoRepository($this->database, $config->getResource(), $config->getParent());
}
throw new \Exception("Couldn't determine database connection type.");
}
|
php
|
protected function newRepository(ResourceConfiguration $config)
{
if ($this->database instanceof EntityManager) {
return $this->newDoctrineRepository($this->database, $config->getEntityClass(), $config->getParent());
} elseif ($this->database instanceof PDO) {
return $this->newPdoRepository($this->database, $config->getResource(), $config->getParent());
}
throw new \Exception("Couldn't determine database connection type.");
}
|
[
"protected",
"function",
"newRepository",
"(",
"ResourceConfiguration",
"$",
"config",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"database",
"instanceof",
"EntityManager",
")",
"{",
"return",
"$",
"this",
"->",
"newDoctrineRepository",
"(",
"$",
"this",
"->",
"database",
",",
"$",
"config",
"->",
"getEntityClass",
"(",
")",
",",
"$",
"config",
"->",
"getParent",
"(",
")",
")",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"database",
"instanceof",
"PDO",
")",
"{",
"return",
"$",
"this",
"->",
"newPdoRepository",
"(",
"$",
"this",
"->",
"database",
",",
"$",
"config",
"->",
"getResource",
"(",
")",
",",
"$",
"config",
"->",
"getParent",
"(",
")",
")",
";",
"}",
"throw",
"new",
"\\",
"Exception",
"(",
"\"Couldn't determine database connection type.\"",
")",
";",
"}"
] |
Determines which repository to use based on the database connection
that was passed in.
@param string $entityClass
@return ResourceRepositoryInterface
|
[
"Determines",
"which",
"repository",
"to",
"use",
"based",
"on",
"the",
"database",
"connection",
"that",
"was",
"passed",
"in",
"."
] |
3bbf66a85304070562e54a66c99145f58f32877e
|
https://github.com/jfortunato/fortune/blob/3bbf66a85304070562e54a66c99145f58f32877e/src/ResourceFactory.php#L171-L180
|
239,479
|
jfortunato/fortune
|
src/ResourceFactory.php
|
ResourceFactory.newSerializer
|
protected function newSerializer(ResourceConfiguration $config)
{
return new JMSSerializer(
SerializerBuilder::create()->build(),
new SerializationContext,
new JMSPropertyExcluder($config->getExcludedProperties())
);
}
|
php
|
protected function newSerializer(ResourceConfiguration $config)
{
return new JMSSerializer(
SerializerBuilder::create()->build(),
new SerializationContext,
new JMSPropertyExcluder($config->getExcludedProperties())
);
}
|
[
"protected",
"function",
"newSerializer",
"(",
"ResourceConfiguration",
"$",
"config",
")",
"{",
"return",
"new",
"JMSSerializer",
"(",
"SerializerBuilder",
"::",
"create",
"(",
")",
"->",
"build",
"(",
")",
",",
"new",
"SerializationContext",
",",
"new",
"JMSPropertyExcluder",
"(",
"$",
"config",
"->",
"getExcludedProperties",
"(",
")",
")",
")",
";",
"}"
] |
Creates JMSSerializer instance.
@return JMSSerializer
|
[
"Creates",
"JMSSerializer",
"instance",
"."
] |
3bbf66a85304070562e54a66c99145f58f32877e
|
https://github.com/jfortunato/fortune/blob/3bbf66a85304070562e54a66c99145f58f32877e/src/ResourceFactory.php#L187-L194
|
239,480
|
jfortunato/fortune
|
src/ResourceFactory.php
|
ResourceFactory.newResource
|
protected function newResource(ResourceConfiguration $config)
{
return new Resource(
$this->newRepository($config),
$this->newValidator($config),
$this->newSecurity(),
$this,
$config
);
}
|
php
|
protected function newResource(ResourceConfiguration $config)
{
return new Resource(
$this->newRepository($config),
$this->newValidator($config),
$this->newSecurity(),
$this,
$config
);
}
|
[
"protected",
"function",
"newResource",
"(",
"ResourceConfiguration",
"$",
"config",
")",
"{",
"return",
"new",
"Resource",
"(",
"$",
"this",
"->",
"newRepository",
"(",
"$",
"config",
")",
",",
"$",
"this",
"->",
"newValidator",
"(",
"$",
"config",
")",
",",
"$",
"this",
"->",
"newSecurity",
"(",
")",
",",
"$",
"this",
",",
"$",
"config",
")",
";",
"}"
] |
Creates a new Resource based off its ResourceConfiguration
@param ResourceConfiguration $config
@return Resource
|
[
"Creates",
"a",
"new",
"Resource",
"based",
"off",
"its",
"ResourceConfiguration"
] |
3bbf66a85304070562e54a66c99145f58f32877e
|
https://github.com/jfortunato/fortune/blob/3bbf66a85304070562e54a66c99145f58f32877e/src/ResourceFactory.php#L202-L211
|
239,481
|
jfortunato/fortune
|
src/ResourceFactory.php
|
ResourceFactory.newValidator
|
protected function newValidator(ResourceConfiguration $config)
{
$class = $config->getValidatorClass();
return $config->isUsingYamlValidation() ?
new YamlResourceValidator($config->getYamlValidation()) : new $class();
}
|
php
|
protected function newValidator(ResourceConfiguration $config)
{
$class = $config->getValidatorClass();
return $config->isUsingYamlValidation() ?
new YamlResourceValidator($config->getYamlValidation()) : new $class();
}
|
[
"protected",
"function",
"newValidator",
"(",
"ResourceConfiguration",
"$",
"config",
")",
"{",
"$",
"class",
"=",
"$",
"config",
"->",
"getValidatorClass",
"(",
")",
";",
"return",
"$",
"config",
"->",
"isUsingYamlValidation",
"(",
")",
"?",
"new",
"YamlResourceValidator",
"(",
"$",
"config",
"->",
"getYamlValidation",
"(",
")",
")",
":",
"new",
"$",
"class",
"(",
")",
";",
"}"
] |
Checks the configuration to decide what validation class to use.
@param ResourceConfiguration $config
@return YamlResourceValidator|object
|
[
"Checks",
"the",
"configuration",
"to",
"decide",
"what",
"validation",
"class",
"to",
"use",
"."
] |
3bbf66a85304070562e54a66c99145f58f32877e
|
https://github.com/jfortunato/fortune/blob/3bbf66a85304070562e54a66c99145f58f32877e/src/ResourceFactory.php#L219-L225
|
239,482
|
jfortunato/fortune
|
src/ResourceFactory.php
|
ResourceFactory.newSecurity
|
protected function newSecurity()
{
$config = $this->config->getCurrentResourceConfiguration();
return new Security(
new SimpleAuthenticationBouncer($config),
new SimpleRoleBouncer($config),
new ParentBouncer($config)
);
}
|
php
|
protected function newSecurity()
{
$config = $this->config->getCurrentResourceConfiguration();
return new Security(
new SimpleAuthenticationBouncer($config),
new SimpleRoleBouncer($config),
new ParentBouncer($config)
);
}
|
[
"protected",
"function",
"newSecurity",
"(",
")",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"config",
"->",
"getCurrentResourceConfiguration",
"(",
")",
";",
"return",
"new",
"Security",
"(",
"new",
"SimpleAuthenticationBouncer",
"(",
"$",
"config",
")",
",",
"new",
"SimpleRoleBouncer",
"(",
"$",
"config",
")",
",",
"new",
"ParentBouncer",
"(",
"$",
"config",
")",
")",
";",
"}"
] |
Creates a Security gateway with all Bouncers
@return Security
|
[
"Creates",
"a",
"Security",
"gateway",
"with",
"all",
"Bouncers"
] |
3bbf66a85304070562e54a66c99145f58f32877e
|
https://github.com/jfortunato/fortune/blob/3bbf66a85304070562e54a66c99145f58f32877e/src/ResourceFactory.php#L232-L241
|
239,483
|
yoozoo/protoapiphp
|
src/httpClient.php
|
HttpClient.callApi
|
public function callApi(Message $req, $method, $uri, $handler)
{
// check handler, php before 5.4 doesn't support Type Hinting of callable
if (!is_callable($handler)) {
throw new GeneralException("Can not find response handler.");
}
$data = [
'json' => (object) $req->to_array(),
'http_errors' => false,
];
$response = $this->request($method, $uri, $data);
$rawContent = $response->getBody()->getContents();
$content = json_decode($rawContent, true);
if (!$content) {
throw new GeneralException("Response is not json data: " . $rawContent);
}
$statusCode = $response->getStatusCode();
switch ($statusCode) {
case 200:
// happy path
if (isset($content)) {
return $handler($content, "", "");
} else {
throw new GeneralException("Cannot find response body: " . $rawContent);
}
break;
case 400:
// biz error
if (isset($content)) {
return $handler("", $content, "");
}
throw new GeneralException("Cannot find Biz Error body: " . $rawContent);
break;
case 420:
// common error
if (isset($content)) {
return $handler("", "", $content);
}
throw new GeneralException("Cannot find Common Error body: " . $rawContent);
break;
case 500:
// internal error
throw new InternalServerErrorException("Internal server error: " . $rawContent);
break;
}
}
|
php
|
public function callApi(Message $req, $method, $uri, $handler)
{
// check handler, php before 5.4 doesn't support Type Hinting of callable
if (!is_callable($handler)) {
throw new GeneralException("Can not find response handler.");
}
$data = [
'json' => (object) $req->to_array(),
'http_errors' => false,
];
$response = $this->request($method, $uri, $data);
$rawContent = $response->getBody()->getContents();
$content = json_decode($rawContent, true);
if (!$content) {
throw new GeneralException("Response is not json data: " . $rawContent);
}
$statusCode = $response->getStatusCode();
switch ($statusCode) {
case 200:
// happy path
if (isset($content)) {
return $handler($content, "", "");
} else {
throw new GeneralException("Cannot find response body: " . $rawContent);
}
break;
case 400:
// biz error
if (isset($content)) {
return $handler("", $content, "");
}
throw new GeneralException("Cannot find Biz Error body: " . $rawContent);
break;
case 420:
// common error
if (isset($content)) {
return $handler("", "", $content);
}
throw new GeneralException("Cannot find Common Error body: " . $rawContent);
break;
case 500:
// internal error
throw new InternalServerErrorException("Internal server error: " . $rawContent);
break;
}
}
|
[
"public",
"function",
"callApi",
"(",
"Message",
"$",
"req",
",",
"$",
"method",
",",
"$",
"uri",
",",
"$",
"handler",
")",
"{",
"// check handler, php before 5.4 doesn't support Type Hinting of callable",
"if",
"(",
"!",
"is_callable",
"(",
"$",
"handler",
")",
")",
"{",
"throw",
"new",
"GeneralException",
"(",
"\"Can not find response handler.\"",
")",
";",
"}",
"$",
"data",
"=",
"[",
"'json'",
"=>",
"(",
"object",
")",
"$",
"req",
"->",
"to_array",
"(",
")",
",",
"'http_errors'",
"=>",
"false",
",",
"]",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"request",
"(",
"$",
"method",
",",
"$",
"uri",
",",
"$",
"data",
")",
";",
"$",
"rawContent",
"=",
"$",
"response",
"->",
"getBody",
"(",
")",
"->",
"getContents",
"(",
")",
";",
"$",
"content",
"=",
"json_decode",
"(",
"$",
"rawContent",
",",
"true",
")",
";",
"if",
"(",
"!",
"$",
"content",
")",
"{",
"throw",
"new",
"GeneralException",
"(",
"\"Response is not json data: \"",
".",
"$",
"rawContent",
")",
";",
"}",
"$",
"statusCode",
"=",
"$",
"response",
"->",
"getStatusCode",
"(",
")",
";",
"switch",
"(",
"$",
"statusCode",
")",
"{",
"case",
"200",
":",
"// happy path",
"if",
"(",
"isset",
"(",
"$",
"content",
")",
")",
"{",
"return",
"$",
"handler",
"(",
"$",
"content",
",",
"\"\"",
",",
"\"\"",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"GeneralException",
"(",
"\"Cannot find response body: \"",
".",
"$",
"rawContent",
")",
";",
"}",
"break",
";",
"case",
"400",
":",
"// biz error",
"if",
"(",
"isset",
"(",
"$",
"content",
")",
")",
"{",
"return",
"$",
"handler",
"(",
"\"\"",
",",
"$",
"content",
",",
"\"\"",
")",
";",
"}",
"throw",
"new",
"GeneralException",
"(",
"\"Cannot find Biz Error body: \"",
".",
"$",
"rawContent",
")",
";",
"break",
";",
"case",
"420",
":",
"// common error",
"if",
"(",
"isset",
"(",
"$",
"content",
")",
")",
"{",
"return",
"$",
"handler",
"(",
"\"\"",
",",
"\"\"",
",",
"$",
"content",
")",
";",
"}",
"throw",
"new",
"GeneralException",
"(",
"\"Cannot find Common Error body: \"",
".",
"$",
"rawContent",
")",
";",
"break",
";",
"case",
"500",
":",
"// internal error",
"throw",
"new",
"InternalServerErrorException",
"(",
"\"Internal server error: \"",
".",
"$",
"rawContent",
")",
";",
"break",
";",
"}",
"}"
] |
call api, handle error, return response
@param Message $req
@param String $method
@param String $uri
@param function $handler function($response, $bizerror, $common) create response oject or throw biz error exception
@return Message $result
|
[
"call",
"api",
"handle",
"error",
"return",
"response"
] |
524f7688e55a616f9edca8711b101c058a1ce6e5
|
https://github.com/yoozoo/protoapiphp/blob/524f7688e55a616f9edca8711b101c058a1ce6e5/src/httpClient.php#L23-L71
|
239,484
|
bytepark/lib-migration
|
src/Repository/AbstractRepository.php
|
AbstractRepository.diff
|
public function diff(Repository $otherRepository)
{
$diffRepository = new Memory();
foreach ($this->unitOfWorkStore as $unitOfWork) {
if (!$otherRepository->contains($unitOfWork)) {
$diffRepository->add($unitOfWork);
}
}
$diffRepository->sort();
return $diffRepository;
}
|
php
|
public function diff(Repository $otherRepository)
{
$diffRepository = new Memory();
foreach ($this->unitOfWorkStore as $unitOfWork) {
if (!$otherRepository->contains($unitOfWork)) {
$diffRepository->add($unitOfWork);
}
}
$diffRepository->sort();
return $diffRepository;
}
|
[
"public",
"function",
"diff",
"(",
"Repository",
"$",
"otherRepository",
")",
"{",
"$",
"diffRepository",
"=",
"new",
"Memory",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"unitOfWorkStore",
"as",
"$",
"unitOfWork",
")",
"{",
"if",
"(",
"!",
"$",
"otherRepository",
"->",
"contains",
"(",
"$",
"unitOfWork",
")",
")",
"{",
"$",
"diffRepository",
"->",
"add",
"(",
"$",
"unitOfWork",
")",
";",
"}",
"}",
"$",
"diffRepository",
"->",
"sort",
"(",
")",
";",
"return",
"$",
"diffRepository",
";",
"}"
] |
Calculates the diff to the given repository
The method returns a Repository including all Migrations present in this
instance but not the given other repository.
@param Repository $otherRepository The repository to diff to
@throws \Bytepark\Component\Migration\Exception\UnitIsAlreadyPresentException
@return Repository The diff
|
[
"Calculates",
"the",
"diff",
"to",
"the",
"given",
"repository"
] |
14d75f6978e257f456493c673175ca5d07b28c84
|
https://github.com/bytepark/lib-migration/blob/14d75f6978e257f456493c673175ca5d07b28c84/src/Repository/AbstractRepository.php#L59-L72
|
239,485
|
bytepark/lib-migration
|
src/Repository/AbstractRepository.php
|
AbstractRepository.find
|
public function find(Uid $uniqueId)
{
if (!array_key_exists((string) $uniqueId, $this->unitOfWorkStore)) {
throw new UnitNotFoundException();
}
return $this->unitOfWorkStore[(string) $uniqueId];
}
|
php
|
public function find(Uid $uniqueId)
{
if (!array_key_exists((string) $uniqueId, $this->unitOfWorkStore)) {
throw new UnitNotFoundException();
}
return $this->unitOfWorkStore[(string) $uniqueId];
}
|
[
"public",
"function",
"find",
"(",
"Uid",
"$",
"uniqueId",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"(",
"string",
")",
"$",
"uniqueId",
",",
"$",
"this",
"->",
"unitOfWorkStore",
")",
")",
"{",
"throw",
"new",
"UnitNotFoundException",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"unitOfWorkStore",
"[",
"(",
"string",
")",
"$",
"uniqueId",
"]",
";",
"}"
] |
Finds the unit with the given Uid
@param Uid $uniqueId The Uid of the unit to find
@throws UnitNotFoundException
@return UnitOfWork
|
[
"Finds",
"the",
"unit",
"with",
"the",
"given",
"Uid"
] |
14d75f6978e257f456493c673175ca5d07b28c84
|
https://github.com/bytepark/lib-migration/blob/14d75f6978e257f456493c673175ca5d07b28c84/src/Repository/AbstractRepository.php#L83-L90
|
239,486
|
bytepark/lib-migration
|
src/Repository/AbstractRepository.php
|
AbstractRepository.add
|
public function add(UnitOfWork $unitOfWork)
{
if ($this->contains($unitOfWork)) {
throw new UnitIsAlreadyPresentException();
}
$this->unitOfWorkStore[$unitOfWork->getUniqueId()] = $unitOfWork;
}
|
php
|
public function add(UnitOfWork $unitOfWork)
{
if ($this->contains($unitOfWork)) {
throw new UnitIsAlreadyPresentException();
}
$this->unitOfWorkStore[$unitOfWork->getUniqueId()] = $unitOfWork;
}
|
[
"public",
"function",
"add",
"(",
"UnitOfWork",
"$",
"unitOfWork",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"contains",
"(",
"$",
"unitOfWork",
")",
")",
"{",
"throw",
"new",
"UnitIsAlreadyPresentException",
"(",
")",
";",
"}",
"$",
"this",
"->",
"unitOfWorkStore",
"[",
"$",
"unitOfWork",
"->",
"getUniqueId",
"(",
")",
"]",
"=",
"$",
"unitOfWork",
";",
"}"
] |
Adds a UnitOfWork to the repository
@param UnitOfWork $unitOfWork The migration to add
@throws UnitIsAlreadyPresentException
@return void
|
[
"Adds",
"a",
"UnitOfWork",
"to",
"the",
"repository"
] |
14d75f6978e257f456493c673175ca5d07b28c84
|
https://github.com/bytepark/lib-migration/blob/14d75f6978e257f456493c673175ca5d07b28c84/src/Repository/AbstractRepository.php#L101-L108
|
239,487
|
bytepark/lib-migration
|
src/Repository/AbstractRepository.php
|
AbstractRepository.replace
|
public function replace(UnitOfWork $unitOfWork)
{
if (!$this->contains($unitOfWork)) {
throw new UnitNotPresentException;
}
$this->unitOfWorkStore[$unitOfWork->getUniqueId()] = $unitOfWork;
}
|
php
|
public function replace(UnitOfWork $unitOfWork)
{
if (!$this->contains($unitOfWork)) {
throw new UnitNotPresentException;
}
$this->unitOfWorkStore[$unitOfWork->getUniqueId()] = $unitOfWork;
}
|
[
"public",
"function",
"replace",
"(",
"UnitOfWork",
"$",
"unitOfWork",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"contains",
"(",
"$",
"unitOfWork",
")",
")",
"{",
"throw",
"new",
"UnitNotPresentException",
";",
"}",
"$",
"this",
"->",
"unitOfWorkStore",
"[",
"$",
"unitOfWork",
"->",
"getUniqueId",
"(",
")",
"]",
"=",
"$",
"unitOfWork",
";",
"}"
] |
Replaces with the given unit of work
@param UnitOfWork $unitOfWork The unit of work to replace with
@throws UnitNotPresentException
@return void
|
[
"Replaces",
"with",
"the",
"given",
"unit",
"of",
"work"
] |
14d75f6978e257f456493c673175ca5d07b28c84
|
https://github.com/bytepark/lib-migration/blob/14d75f6978e257f456493c673175ca5d07b28c84/src/Repository/AbstractRepository.php#L119-L126
|
239,488
|
silencedis/protected-members-accessor
|
src/ProtectedMembersAccessor.php
|
ProtectedMembersAccessor.getReflectionMethod
|
protected function getReflectionMethod($class, $method)
{
if (!isset($this->methodReflectors[$class])) {
$this->methodReflectors[$class] = [];
}
if (!isset($this->methodReflectors[$class][$method])) {
$this->methodReflectors[$class][$method] = new \ReflectionMethod($class, $method);
}
return $this->methodReflectors[$class][$method];
}
|
php
|
protected function getReflectionMethod($class, $method)
{
if (!isset($this->methodReflectors[$class])) {
$this->methodReflectors[$class] = [];
}
if (!isset($this->methodReflectors[$class][$method])) {
$this->methodReflectors[$class][$method] = new \ReflectionMethod($class, $method);
}
return $this->methodReflectors[$class][$method];
}
|
[
"protected",
"function",
"getReflectionMethod",
"(",
"$",
"class",
",",
"$",
"method",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"methodReflectors",
"[",
"$",
"class",
"]",
")",
")",
"{",
"$",
"this",
"->",
"methodReflectors",
"[",
"$",
"class",
"]",
"=",
"[",
"]",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"methodReflectors",
"[",
"$",
"class",
"]",
"[",
"$",
"method",
"]",
")",
")",
"{",
"$",
"this",
"->",
"methodReflectors",
"[",
"$",
"class",
"]",
"[",
"$",
"method",
"]",
"=",
"new",
"\\",
"ReflectionMethod",
"(",
"$",
"class",
",",
"$",
"method",
")",
";",
"}",
"return",
"$",
"this",
"->",
"methodReflectors",
"[",
"$",
"class",
"]",
"[",
"$",
"method",
"]",
";",
"}"
] |
Returns a method reflection
@param string $class
@param string $method
@return \ReflectionMethod
|
[
"Returns",
"a",
"method",
"reflection"
] |
0fcf525858a9555f3b4a90ad302549ea235678ff
|
https://github.com/silencedis/protected-members-accessor/blob/0fcf525858a9555f3b4a90ad302549ea235678ff/src/ProtectedMembersAccessor.php#L25-L35
|
239,489
|
silencedis/protected-members-accessor
|
src/ProtectedMembersAccessor.php
|
ProtectedMembersAccessor.getReflectionProperty
|
protected function getReflectionProperty($class, $property)
{
if (!isset($this->propertyReflectors[$class])) {
$this->propertyReflectors[$class] = [];
}
if (!isset($this->propertyReflectors[$class][$property])) {
$this->propertyReflectors[$class][$property] = new \ReflectionProperty($class, $property);
}
return $this->propertyReflectors[$class][$property];
}
|
php
|
protected function getReflectionProperty($class, $property)
{
if (!isset($this->propertyReflectors[$class])) {
$this->propertyReflectors[$class] = [];
}
if (!isset($this->propertyReflectors[$class][$property])) {
$this->propertyReflectors[$class][$property] = new \ReflectionProperty($class, $property);
}
return $this->propertyReflectors[$class][$property];
}
|
[
"protected",
"function",
"getReflectionProperty",
"(",
"$",
"class",
",",
"$",
"property",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"propertyReflectors",
"[",
"$",
"class",
"]",
")",
")",
"{",
"$",
"this",
"->",
"propertyReflectors",
"[",
"$",
"class",
"]",
"=",
"[",
"]",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"propertyReflectors",
"[",
"$",
"class",
"]",
"[",
"$",
"property",
"]",
")",
")",
"{",
"$",
"this",
"->",
"propertyReflectors",
"[",
"$",
"class",
"]",
"[",
"$",
"property",
"]",
"=",
"new",
"\\",
"ReflectionProperty",
"(",
"$",
"class",
",",
"$",
"property",
")",
";",
"}",
"return",
"$",
"this",
"->",
"propertyReflectors",
"[",
"$",
"class",
"]",
"[",
"$",
"property",
"]",
";",
"}"
] |
Returns a property reflection
@param string $class
@param string $property
@return \ReflectionProperty
|
[
"Returns",
"a",
"property",
"reflection"
] |
0fcf525858a9555f3b4a90ad302549ea235678ff
|
https://github.com/silencedis/protected-members-accessor/blob/0fcf525858a9555f3b4a90ad302549ea235678ff/src/ProtectedMembersAccessor.php#L45-L55
|
239,490
|
silencedis/protected-members-accessor
|
src/ProtectedMembersAccessor.php
|
ProtectedMembersAccessor.getProtectedMethod
|
public function getProtectedMethod(...$params)
{
if (is_string($params[0])) {
list($className, $object, $name) = $params;
} elseif (is_object($params[0])) {
list($object, $name) = $params;
$className = get_class($object);
}
/** @var string $className */
/** @var object $object */
/** @var string $name */
$this->checkOnObject($object);
$this->checkOnMemberName($name);
$reflector = $this->getReflectionMethod($className, $name);
return $reflector->getClosure($object);
}
|
php
|
public function getProtectedMethod(...$params)
{
if (is_string($params[0])) {
list($className, $object, $name) = $params;
} elseif (is_object($params[0])) {
list($object, $name) = $params;
$className = get_class($object);
}
/** @var string $className */
/** @var object $object */
/** @var string $name */
$this->checkOnObject($object);
$this->checkOnMemberName($name);
$reflector = $this->getReflectionMethod($className, $name);
return $reflector->getClosure($object);
}
|
[
"public",
"function",
"getProtectedMethod",
"(",
"...",
"$",
"params",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"params",
"[",
"0",
"]",
")",
")",
"{",
"list",
"(",
"$",
"className",
",",
"$",
"object",
",",
"$",
"name",
")",
"=",
"$",
"params",
";",
"}",
"elseif",
"(",
"is_object",
"(",
"$",
"params",
"[",
"0",
"]",
")",
")",
"{",
"list",
"(",
"$",
"object",
",",
"$",
"name",
")",
"=",
"$",
"params",
";",
"$",
"className",
"=",
"get_class",
"(",
"$",
"object",
")",
";",
"}",
"/** @var string $className */",
"/** @var object $object */",
"/** @var string $name */",
"$",
"this",
"->",
"checkOnObject",
"(",
"$",
"object",
")",
";",
"$",
"this",
"->",
"checkOnMemberName",
"(",
"$",
"name",
")",
";",
"$",
"reflector",
"=",
"$",
"this",
"->",
"getReflectionMethod",
"(",
"$",
"className",
",",
"$",
"name",
")",
";",
"return",
"$",
"reflector",
"->",
"getClosure",
"(",
"$",
"object",
")",
";",
"}"
] |
Returns a method as closure
@param array ...$params
@return \Closure
@throws ProtectedMembersAccessException
|
[
"Returns",
"a",
"method",
"as",
"closure"
] |
0fcf525858a9555f3b4a90ad302549ea235678ff
|
https://github.com/silencedis/protected-members-accessor/blob/0fcf525858a9555f3b4a90ad302549ea235678ff/src/ProtectedMembersAccessor.php#L91-L111
|
239,491
|
silencedis/protected-members-accessor
|
src/ProtectedMembersAccessor.php
|
ProtectedMembersAccessor.getProtectedProperty
|
public function getProtectedProperty(...$params)
{
if (is_string($params[0])) {
list($className, $object, $name) = $params;
} elseif (is_object($params[0])) {
list($object, $name) = $params;
$className = get_class($object);
}
/** @var string $className */
/** @var object $object */
/** @var string $name */
$this->checkOnObject($object);
$this->checkOnMemberName($name);
$reflector = new \ReflectionProperty($className, $name);
$isProtected = $reflector->isProtected() || $reflector->isPrivate();
if ($isProtected) {
$reflector->setAccessible(true);
}
$value = $reflector->getValue($object);
if ($isProtected) {
$reflector->setAccessible(false);
}
return $value;
}
|
php
|
public function getProtectedProperty(...$params)
{
if (is_string($params[0])) {
list($className, $object, $name) = $params;
} elseif (is_object($params[0])) {
list($object, $name) = $params;
$className = get_class($object);
}
/** @var string $className */
/** @var object $object */
/** @var string $name */
$this->checkOnObject($object);
$this->checkOnMemberName($name);
$reflector = new \ReflectionProperty($className, $name);
$isProtected = $reflector->isProtected() || $reflector->isPrivate();
if ($isProtected) {
$reflector->setAccessible(true);
}
$value = $reflector->getValue($object);
if ($isProtected) {
$reflector->setAccessible(false);
}
return $value;
}
|
[
"public",
"function",
"getProtectedProperty",
"(",
"...",
"$",
"params",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"params",
"[",
"0",
"]",
")",
")",
"{",
"list",
"(",
"$",
"className",
",",
"$",
"object",
",",
"$",
"name",
")",
"=",
"$",
"params",
";",
"}",
"elseif",
"(",
"is_object",
"(",
"$",
"params",
"[",
"0",
"]",
")",
")",
"{",
"list",
"(",
"$",
"object",
",",
"$",
"name",
")",
"=",
"$",
"params",
";",
"$",
"className",
"=",
"get_class",
"(",
"$",
"object",
")",
";",
"}",
"/** @var string $className */",
"/** @var object $object */",
"/** @var string $name */",
"$",
"this",
"->",
"checkOnObject",
"(",
"$",
"object",
")",
";",
"$",
"this",
"->",
"checkOnMemberName",
"(",
"$",
"name",
")",
";",
"$",
"reflector",
"=",
"new",
"\\",
"ReflectionProperty",
"(",
"$",
"className",
",",
"$",
"name",
")",
";",
"$",
"isProtected",
"=",
"$",
"reflector",
"->",
"isProtected",
"(",
")",
"||",
"$",
"reflector",
"->",
"isPrivate",
"(",
")",
";",
"if",
"(",
"$",
"isProtected",
")",
"{",
"$",
"reflector",
"->",
"setAccessible",
"(",
"true",
")",
";",
"}",
"$",
"value",
"=",
"$",
"reflector",
"->",
"getValue",
"(",
"$",
"object",
")",
";",
"if",
"(",
"$",
"isProtected",
")",
"{",
"$",
"reflector",
"->",
"setAccessible",
"(",
"false",
")",
";",
"}",
"return",
"$",
"value",
";",
"}"
] |
Returns a value of a protected property of the object
@param array ...$params
@return mixed
@throws ProtectedMembersAccessException
|
[
"Returns",
"a",
"value",
"of",
"a",
"protected",
"property",
"of",
"the",
"object"
] |
0fcf525858a9555f3b4a90ad302549ea235678ff
|
https://github.com/silencedis/protected-members-accessor/blob/0fcf525858a9555f3b4a90ad302549ea235678ff/src/ProtectedMembersAccessor.php#L121-L149
|
239,492
|
silencedis/protected-members-accessor
|
src/ProtectedMembersAccessor.php
|
ProtectedMembersAccessor.setProtectedProperty
|
public function setProtectedProperty(...$params)
{
if (is_string($params[0])) {
list($className, $object, $name, $value) = $params;
} elseif (is_object($params[0])) {
list($object, $name, $value) = $params;
$className = get_class($object);
}
/** @var string $className */
/** @var object $object */
/** @var string $name */
/** @var mixed $value */
$this->checkOnObject($object);
$this->checkOnMemberName($name);
$reflector = $this->getReflectionProperty($className, $name);
$isProtected = $reflector->isProtected() || $reflector->isPrivate();
if ($isProtected) {
$reflector->setAccessible(true);
}
$reflector->setValue($object, $value);
if ($isProtected) {
$reflector->setAccessible(false);
}
}
|
php
|
public function setProtectedProperty(...$params)
{
if (is_string($params[0])) {
list($className, $object, $name, $value) = $params;
} elseif (is_object($params[0])) {
list($object, $name, $value) = $params;
$className = get_class($object);
}
/** @var string $className */
/** @var object $object */
/** @var string $name */
/** @var mixed $value */
$this->checkOnObject($object);
$this->checkOnMemberName($name);
$reflector = $this->getReflectionProperty($className, $name);
$isProtected = $reflector->isProtected() || $reflector->isPrivate();
if ($isProtected) {
$reflector->setAccessible(true);
}
$reflector->setValue($object, $value);
if ($isProtected) {
$reflector->setAccessible(false);
}
}
|
[
"public",
"function",
"setProtectedProperty",
"(",
"...",
"$",
"params",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"params",
"[",
"0",
"]",
")",
")",
"{",
"list",
"(",
"$",
"className",
",",
"$",
"object",
",",
"$",
"name",
",",
"$",
"value",
")",
"=",
"$",
"params",
";",
"}",
"elseif",
"(",
"is_object",
"(",
"$",
"params",
"[",
"0",
"]",
")",
")",
"{",
"list",
"(",
"$",
"object",
",",
"$",
"name",
",",
"$",
"value",
")",
"=",
"$",
"params",
";",
"$",
"className",
"=",
"get_class",
"(",
"$",
"object",
")",
";",
"}",
"/** @var string $className */",
"/** @var object $object */",
"/** @var string $name */",
"/** @var mixed $value */",
"$",
"this",
"->",
"checkOnObject",
"(",
"$",
"object",
")",
";",
"$",
"this",
"->",
"checkOnMemberName",
"(",
"$",
"name",
")",
";",
"$",
"reflector",
"=",
"$",
"this",
"->",
"getReflectionProperty",
"(",
"$",
"className",
",",
"$",
"name",
")",
";",
"$",
"isProtected",
"=",
"$",
"reflector",
"->",
"isProtected",
"(",
")",
"||",
"$",
"reflector",
"->",
"isPrivate",
"(",
")",
";",
"if",
"(",
"$",
"isProtected",
")",
"{",
"$",
"reflector",
"->",
"setAccessible",
"(",
"true",
")",
";",
"}",
"$",
"reflector",
"->",
"setValue",
"(",
"$",
"object",
",",
"$",
"value",
")",
";",
"if",
"(",
"$",
"isProtected",
")",
"{",
"$",
"reflector",
"->",
"setAccessible",
"(",
"false",
")",
";",
"}",
"}"
] |
Sets a protected property for the object
@param array ...$params
@throws ProtectedMembersAccessException
|
[
"Sets",
"a",
"protected",
"property",
"for",
"the",
"object"
] |
0fcf525858a9555f3b4a90ad302549ea235678ff
|
https://github.com/silencedis/protected-members-accessor/blob/0fcf525858a9555f3b4a90ad302549ea235678ff/src/ProtectedMembersAccessor.php#L157-L184
|
239,493
|
flavorzyb/simple
|
src/Middleware/VerifyCsrfToken.php
|
VerifyCsrfToken.getTokenString
|
protected function getTokenString()
{
$result = Request::post('_token', '');
if ('' == $result) {
$result = Request::get('_token', '');
}
if ('' == $result) {
$result = isset($_SERVER['X-CSRF-TOKEN']) ? $_SERVER['X-CSRF-TOKEN'] : '';
}
return $result;
}
|
php
|
protected function getTokenString()
{
$result = Request::post('_token', '');
if ('' == $result) {
$result = Request::get('_token', '');
}
if ('' == $result) {
$result = isset($_SERVER['X-CSRF-TOKEN']) ? $_SERVER['X-CSRF-TOKEN'] : '';
}
return $result;
}
|
[
"protected",
"function",
"getTokenString",
"(",
")",
"{",
"$",
"result",
"=",
"Request",
"::",
"post",
"(",
"'_token'",
",",
"''",
")",
";",
"if",
"(",
"''",
"==",
"$",
"result",
")",
"{",
"$",
"result",
"=",
"Request",
"::",
"get",
"(",
"'_token'",
",",
"''",
")",
";",
"}",
"if",
"(",
"''",
"==",
"$",
"result",
")",
"{",
"$",
"result",
"=",
"isset",
"(",
"$",
"_SERVER",
"[",
"'X-CSRF-TOKEN'",
"]",
")",
"?",
"$",
"_SERVER",
"[",
"'X-CSRF-TOKEN'",
"]",
":",
"''",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
get token string
@return string
|
[
"get",
"token",
"string"
] |
8c4c539ae2057217b2637fc72c2a90ba266e8e6c
|
https://github.com/flavorzyb/simple/blob/8c4c539ae2057217b2637fc72c2a90ba266e8e6c/src/Middleware/VerifyCsrfToken.php#L40-L52
|
239,494
|
uthando-cms/uthando-common
|
src/UthandoCommon/Stdlib/ArrayUtils.php
|
ArrayUtils.removeKeysFromMultiArray
|
public static function removeKeysFromMultiArray(&$array, $keys)
{
foreach ($array as $key => &$value) {
if (is_array($value)) {
self::traverseArray($value, $keys);
} else {
if (in_array($key, $keys) || '' == $value) {
unset($array[$key]);
}
}
}
return $array;
}
|
php
|
public static function removeKeysFromMultiArray(&$array, $keys)
{
foreach ($array as $key => &$value) {
if (is_array($value)) {
self::traverseArray($value, $keys);
} else {
if (in_array($key, $keys) || '' == $value) {
unset($array[$key]);
}
}
}
return $array;
}
|
[
"public",
"static",
"function",
"removeKeysFromMultiArray",
"(",
"&",
"$",
"array",
",",
"$",
"keys",
")",
"{",
"foreach",
"(",
"$",
"array",
"as",
"$",
"key",
"=>",
"&",
"$",
"value",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"self",
"::",
"traverseArray",
"(",
"$",
"value",
",",
"$",
"keys",
")",
";",
"}",
"else",
"{",
"if",
"(",
"in_array",
"(",
"$",
"key",
",",
"$",
"keys",
")",
"||",
"''",
"==",
"$",
"value",
")",
"{",
"unset",
"(",
"$",
"array",
"[",
"$",
"key",
"]",
")",
";",
"}",
"}",
"}",
"return",
"$",
"array",
";",
"}"
] |
Traverse an array unsetting keys
@param array $array array to traverse
@param array $keys keys to remove
@return array
|
[
"Traverse",
"an",
"array",
"unsetting",
"keys"
] |
feb915da5d26b60f536282e1bc3ad5c22e53f485
|
https://github.com/uthando-cms/uthando-common/blob/feb915da5d26b60f536282e1bc3ad5c22e53f485/src/UthandoCommon/Stdlib/ArrayUtils.php#L28-L41
|
239,495
|
uthando-cms/uthando-common
|
src/UthandoCommon/Stdlib/ArrayUtils.php
|
ArrayUtils.listToMultiArray
|
public static function listToMultiArray($array)
{
$nested = [];
$depths = [];
foreach ($array as $key => $arr) {
if ($arr['depth'] == 0) {
$nested[$key] = $arr;
} else {
$parent =& $nested;
for ($i = 1; $i <= ($arr['depth']); $i++) {
$parent =& $parent[$depths[$i]];
}
$parent['pages'][$key] = $arr;
}
$depths[$arr['depth'] + 1] = $key;
}
return $nested;
}
|
php
|
public static function listToMultiArray($array)
{
$nested = [];
$depths = [];
foreach ($array as $key => $arr) {
if ($arr['depth'] == 0) {
$nested[$key] = $arr;
} else {
$parent =& $nested;
for ($i = 1; $i <= ($arr['depth']); $i++) {
$parent =& $parent[$depths[$i]];
}
$parent['pages'][$key] = $arr;
}
$depths[$arr['depth'] + 1] = $key;
}
return $nested;
}
|
[
"public",
"static",
"function",
"listToMultiArray",
"(",
"$",
"array",
")",
"{",
"$",
"nested",
"=",
"[",
"]",
";",
"$",
"depths",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"array",
"as",
"$",
"key",
"=>",
"$",
"arr",
")",
"{",
"if",
"(",
"$",
"arr",
"[",
"'depth'",
"]",
"==",
"0",
")",
"{",
"$",
"nested",
"[",
"$",
"key",
"]",
"=",
"$",
"arr",
";",
"}",
"else",
"{",
"$",
"parent",
"=",
"&",
"$",
"nested",
";",
"for",
"(",
"$",
"i",
"=",
"1",
";",
"$",
"i",
"<=",
"(",
"$",
"arr",
"[",
"'depth'",
"]",
")",
";",
"$",
"i",
"++",
")",
"{",
"$",
"parent",
"=",
"&",
"$",
"parent",
"[",
"$",
"depths",
"[",
"$",
"i",
"]",
"]",
";",
"}",
"$",
"parent",
"[",
"'pages'",
"]",
"[",
"$",
"key",
"]",
"=",
"$",
"arr",
";",
"}",
"$",
"depths",
"[",
"$",
"arr",
"[",
"'depth'",
"]",
"+",
"1",
"]",
"=",
"$",
"key",
";",
"}",
"return",
"$",
"nested",
";",
"}"
] |
transform a list into a multidimensional array
using a depth value
@param array $array
@return array
|
[
"transform",
"a",
"list",
"into",
"a",
"multidimensional",
"array",
"using",
"a",
"depth",
"value"
] |
feb915da5d26b60f536282e1bc3ad5c22e53f485
|
https://github.com/uthando-cms/uthando-common/blob/feb915da5d26b60f536282e1bc3ad5c22e53f485/src/UthandoCommon/Stdlib/ArrayUtils.php#L50-L73
|
239,496
|
keboola/debug-log-uploader
|
src/Keboola/DebugLogUploader/UploaderS3.php
|
UploaderS3.upload
|
public function upload($filePath, $contentType = 'text/plain')
{
$s3FileName = $this->getFilePathAndUniquePrefix() . basename($filePath);
list($bucket, $prefix) = explode('/', $this->s3path, 2);
$this->s3client->putObject([
'Bucket' => $bucket,
'Key' => (empty($prefix) ? '' : (trim($prefix, '/') . '/')) . $s3FileName,
'ContentType' => $contentType,
'ACL' => 'private',
'ServerSideEncryption' => 'AES256',
'SourceFile' => $filePath,
]);
return $this->withUrlPrefix($s3FileName);
}
|
php
|
public function upload($filePath, $contentType = 'text/plain')
{
$s3FileName = $this->getFilePathAndUniquePrefix() . basename($filePath);
list($bucket, $prefix) = explode('/', $this->s3path, 2);
$this->s3client->putObject([
'Bucket' => $bucket,
'Key' => (empty($prefix) ? '' : (trim($prefix, '/') . '/')) . $s3FileName,
'ContentType' => $contentType,
'ACL' => 'private',
'ServerSideEncryption' => 'AES256',
'SourceFile' => $filePath,
]);
return $this->withUrlPrefix($s3FileName);
}
|
[
"public",
"function",
"upload",
"(",
"$",
"filePath",
",",
"$",
"contentType",
"=",
"'text/plain'",
")",
"{",
"$",
"s3FileName",
"=",
"$",
"this",
"->",
"getFilePathAndUniquePrefix",
"(",
")",
".",
"basename",
"(",
"$",
"filePath",
")",
";",
"list",
"(",
"$",
"bucket",
",",
"$",
"prefix",
")",
"=",
"explode",
"(",
"'/'",
",",
"$",
"this",
"->",
"s3path",
",",
"2",
")",
";",
"$",
"this",
"->",
"s3client",
"->",
"putObject",
"(",
"[",
"'Bucket'",
"=>",
"$",
"bucket",
",",
"'Key'",
"=>",
"(",
"empty",
"(",
"$",
"prefix",
")",
"?",
"''",
":",
"(",
"trim",
"(",
"$",
"prefix",
",",
"'/'",
")",
".",
"'/'",
")",
")",
".",
"$",
"s3FileName",
",",
"'ContentType'",
"=>",
"$",
"contentType",
",",
"'ACL'",
"=>",
"'private'",
",",
"'ServerSideEncryption'",
"=>",
"'AES256'",
",",
"'SourceFile'",
"=>",
"$",
"filePath",
",",
"]",
")",
";",
"return",
"$",
"this",
"->",
"withUrlPrefix",
"(",
"$",
"s3FileName",
")",
";",
"}"
] |
Uploads file to s3
@param $filePath
@param string $contentType
@return string
|
[
"Uploads",
"file",
"to",
"s3"
] |
ea124d136e8c6d18ce1768da5dcc51994df8b764
|
https://github.com/keboola/debug-log-uploader/blob/ea124d136e8c6d18ce1768da5dcc51994df8b764/src/Keboola/DebugLogUploader/UploaderS3.php#L43-L58
|
239,497
|
keboola/debug-log-uploader
|
src/Keboola/DebugLogUploader/UploaderS3.php
|
UploaderS3.uploadString
|
public function uploadString($name, $content, $contentType = 'text/plain')
{
$s3FileName = $this->getFilePathAndUniquePrefix() . $name;
list($bucket, $prefix) = explode('/', $this->s3path, 2);
$this->s3client->putObject([
'Bucket' => $bucket,
'Key' => (empty($prefix) ? '' : (trim($prefix, '/') . '/')) . $s3FileName,
'ContentType' => $contentType,
'ACL' => 'private',
'ServerSideEncryption' => 'AES256',
'Body' => $content,
]);
return $this->withUrlPrefix($s3FileName);
}
|
php
|
public function uploadString($name, $content, $contentType = 'text/plain')
{
$s3FileName = $this->getFilePathAndUniquePrefix() . $name;
list($bucket, $prefix) = explode('/', $this->s3path, 2);
$this->s3client->putObject([
'Bucket' => $bucket,
'Key' => (empty($prefix) ? '' : (trim($prefix, '/') . '/')) . $s3FileName,
'ContentType' => $contentType,
'ACL' => 'private',
'ServerSideEncryption' => 'AES256',
'Body' => $content,
]);
return $this->withUrlPrefix($s3FileName);
}
|
[
"public",
"function",
"uploadString",
"(",
"$",
"name",
",",
"$",
"content",
",",
"$",
"contentType",
"=",
"'text/plain'",
")",
"{",
"$",
"s3FileName",
"=",
"$",
"this",
"->",
"getFilePathAndUniquePrefix",
"(",
")",
".",
"$",
"name",
";",
"list",
"(",
"$",
"bucket",
",",
"$",
"prefix",
")",
"=",
"explode",
"(",
"'/'",
",",
"$",
"this",
"->",
"s3path",
",",
"2",
")",
";",
"$",
"this",
"->",
"s3client",
"->",
"putObject",
"(",
"[",
"'Bucket'",
"=>",
"$",
"bucket",
",",
"'Key'",
"=>",
"(",
"empty",
"(",
"$",
"prefix",
")",
"?",
"''",
":",
"(",
"trim",
"(",
"$",
"prefix",
",",
"'/'",
")",
".",
"'/'",
")",
")",
".",
"$",
"s3FileName",
",",
"'ContentType'",
"=>",
"$",
"contentType",
",",
"'ACL'",
"=>",
"'private'",
",",
"'ServerSideEncryption'",
"=>",
"'AES256'",
",",
"'Body'",
"=>",
"$",
"content",
",",
"]",
")",
";",
"return",
"$",
"this",
"->",
"withUrlPrefix",
"(",
"$",
"s3FileName",
")",
";",
"}"
] |
Uploads string as file to s3
@param $name
@param $content
@param string $contentType
@return string
|
[
"Uploads",
"string",
"as",
"file",
"to",
"s3"
] |
ea124d136e8c6d18ce1768da5dcc51994df8b764
|
https://github.com/keboola/debug-log-uploader/blob/ea124d136e8c6d18ce1768da5dcc51994df8b764/src/Keboola/DebugLogUploader/UploaderS3.php#L67-L82
|
239,498
|
CableFramework/ServiceContainer
|
src/Cable/Component/Factory.php
|
Factory.create
|
public static function create(ProviderRepository $providerRepository = null)
{
$container = new Container(
$providerRepository
);
if (!$container->isProvided(AnnotationServiceProvider::class)) {
$container->addProvider(AnnotationServiceProvider::class);
}
$container->add(
Container::class,
function () use ($container) {
return $container;
}
)->alias(ContainerInterface::class);
return $container;
}
|
php
|
public static function create(ProviderRepository $providerRepository = null)
{
$container = new Container(
$providerRepository
);
if (!$container->isProvided(AnnotationServiceProvider::class)) {
$container->addProvider(AnnotationServiceProvider::class);
}
$container->add(
Container::class,
function () use ($container) {
return $container;
}
)->alias(ContainerInterface::class);
return $container;
}
|
[
"public",
"static",
"function",
"create",
"(",
"ProviderRepository",
"$",
"providerRepository",
"=",
"null",
")",
"{",
"$",
"container",
"=",
"new",
"Container",
"(",
"$",
"providerRepository",
")",
";",
"if",
"(",
"!",
"$",
"container",
"->",
"isProvided",
"(",
"AnnotationServiceProvider",
"::",
"class",
")",
")",
"{",
"$",
"container",
"->",
"addProvider",
"(",
"AnnotationServiceProvider",
"::",
"class",
")",
";",
"}",
"$",
"container",
"->",
"add",
"(",
"Container",
"::",
"class",
",",
"function",
"(",
")",
"use",
"(",
"$",
"container",
")",
"{",
"return",
"$",
"container",
";",
"}",
")",
"->",
"alias",
"(",
"ContainerInterface",
"::",
"class",
")",
";",
"return",
"$",
"container",
";",
"}"
] |
create a new container instance
@param ProviderRepository|null $providerRepository
@throws ProviderException
@return Container
|
[
"create",
"a",
"new",
"container",
"instance"
] |
0e48ad2e26de9b780d8fe336dd9ac48357285486
|
https://github.com/CableFramework/ServiceContainer/blob/0e48ad2e26de9b780d8fe336dd9ac48357285486/src/Cable/Component/Factory.php#L22-L41
|
239,499
|
carno-php/log
|
src/Outputter/TCP.php
|
TCP.connecting
|
private function connecting() : void
{
$this->connected = false;
$this->closing
? $this->closed()->resolve()
: $this->client = Socket::connect($this->endpoint, $this->events)
;
}
|
php
|
private function connecting() : void
{
$this->connected = false;
$this->closing
? $this->closed()->resolve()
: $this->client = Socket::connect($this->endpoint, $this->events)
;
}
|
[
"private",
"function",
"connecting",
"(",
")",
":",
"void",
"{",
"$",
"this",
"->",
"connected",
"=",
"false",
";",
"$",
"this",
"->",
"closing",
"?",
"$",
"this",
"->",
"closed",
"(",
")",
"->",
"resolve",
"(",
")",
":",
"$",
"this",
"->",
"client",
"=",
"Socket",
"::",
"connect",
"(",
"$",
"this",
"->",
"endpoint",
",",
"$",
"this",
"->",
"events",
")",
";",
"}"
] |
reconnect to server if conn closed or error
|
[
"reconnect",
"to",
"server",
"if",
"conn",
"closed",
"or",
"error"
] |
a96acf0a25e5ee0a8b763bac4f710f5350f2f70b
|
https://github.com/carno-php/log/blob/a96acf0a25e5ee0a8b763bac4f710f5350f2f70b/src/Outputter/TCP.php#L102-L109
|
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.