repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1 value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 | partition stringclasses 1 value |
|---|---|---|---|---|---|---|---|---|---|---|---|
pscheit/jparser | PLUG/time/Timer.php | Timer.is_running | function is_running(){
if( isset( $this->stopped ) ){
return false;
}
if( ! isset( $this->started ) ){
trigger_error("Timer has been stopped some how (".gettype($this->started).")'$this->started'", E_USER_WARNING);
return false;
}
return true;
} | php | function is_running(){
if( isset( $this->stopped ) ){
return false;
}
if( ! isset( $this->started ) ){
trigger_error("Timer has been stopped some how (".gettype($this->started).")'$this->started'", E_USER_WARNING);
return false;
}
return true;
} | [
"function",
"is_running",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"stopped",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"started",
")",
")",
"{",
"trigger_error",
"(",
"\"Timer ha... | Test whether timer is running
@return bool | [
"Test",
"whether",
"timer",
"is",
"running"
] | f9de77171c0d37d237e0e9a918ed7bff19e12095 | https://github.com/pscheit/jparser/blob/f9de77171c0d37d237e0e9a918ed7bff19e12095/PLUG/time/Timer.php#L88-L97 | train |
pscheit/jparser | PLUG/time/Timer.php | Timer.milliseconds | function milliseconds( $dp = null ){
if( $this->is_running() ){
$now = microtime( false );
}
else {
$now = $this->stopped;
}
$started = self::parse_microtime( $this->started );
$stopped = self::parse_microtime( $now );
$ms = $stopped - $started;
if( ! is_null($dp) ){
$mult = pow( 10, $dp );
$ms = round( $mult * $ms ) / $mult;
}
return $ms;
} | php | function milliseconds( $dp = null ){
if( $this->is_running() ){
$now = microtime( false );
}
else {
$now = $this->stopped;
}
$started = self::parse_microtime( $this->started );
$stopped = self::parse_microtime( $now );
$ms = $stopped - $started;
if( ! is_null($dp) ){
$mult = pow( 10, $dp );
$ms = round( $mult * $ms ) / $mult;
}
return $ms;
} | [
"function",
"milliseconds",
"(",
"$",
"dp",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"is_running",
"(",
")",
")",
"{",
"$",
"now",
"=",
"microtime",
"(",
"false",
")",
";",
"}",
"else",
"{",
"$",
"now",
"=",
"$",
"this",
"->",
"stop... | Get milliseconds since timer started.
@return float milliseconds | [
"Get",
"milliseconds",
"since",
"timer",
"started",
"."
] | f9de77171c0d37d237e0e9a918ed7bff19e12095 | https://github.com/pscheit/jparser/blob/f9de77171c0d37d237e0e9a918ed7bff19e12095/PLUG/time/Timer.php#L107-L122 | train |
pscheit/jparser | PLUG/time/Timer.php | Timer.seconds | function seconds( $dp = 2 ){
$secs = $this->milliseconds() / 1000;
if( ! is_null($dp) ){
$mult = pow( 10, $dp );
$secs = round( $mult * $secs ) / $mult;
}
return $secs;
} | php | function seconds( $dp = 2 ){
$secs = $this->milliseconds() / 1000;
if( ! is_null($dp) ){
$mult = pow( 10, $dp );
$secs = round( $mult * $secs ) / $mult;
}
return $secs;
} | [
"function",
"seconds",
"(",
"$",
"dp",
"=",
"2",
")",
"{",
"$",
"secs",
"=",
"$",
"this",
"->",
"milliseconds",
"(",
")",
"/",
"1000",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"dp",
")",
")",
"{",
"$",
"mult",
"=",
"pow",
"(",
"10",
",",
"... | Get seconds since timer started.
@param int precision; defaults to two decimal places
@return float seconds to specified precision | [
"Get",
"seconds",
"since",
"timer",
"started",
"."
] | f9de77171c0d37d237e0e9a918ed7bff19e12095 | https://github.com/pscheit/jparser/blob/f9de77171c0d37d237e0e9a918ed7bff19e12095/PLUG/time/Timer.php#L132-L139 | train |
pscheit/jparser | PLUG/time/Timer.php | Timer.parse_microtime | static function parse_microtime( $microtime ){
list($usec, $sec) = explode( ' ', $microtime );
$ms1 = (float) $usec * 1000;
$ms2 = (float) $sec * 1000;
return $ms1 + $ms2;
} | php | static function parse_microtime( $microtime ){
list($usec, $sec) = explode( ' ', $microtime );
$ms1 = (float) $usec * 1000;
$ms2 = (float) $sec * 1000;
return $ms1 + $ms2;
} | [
"static",
"function",
"parse_microtime",
"(",
"$",
"microtime",
")",
"{",
"list",
"(",
"$",
"usec",
",",
"$",
"sec",
")",
"=",
"explode",
"(",
"' '",
",",
"$",
"microtime",
")",
";",
"$",
"ms1",
"=",
"(",
"float",
")",
"$",
"usec",
"*",
"1000",
"... | Parses string microtime into milliseconds.
@param string microtime as returned by microtime( false )
@return float milliseconds | [
"Parses",
"string",
"microtime",
"into",
"milliseconds",
"."
] | f9de77171c0d37d237e0e9a918ed7bff19e12095 | https://github.com/pscheit/jparser/blob/f9de77171c0d37d237e0e9a918ed7bff19e12095/PLUG/time/Timer.php#L151-L156 | train |
fezfez/codeGenerator | src/CrudGenerator/Metadata/Sources/Doctrine2/Doctrine2MetaDataDAO.php | Doctrine2MetaDataDAO.getMetadataFor | public function getMetadataFor($entityName, array $parentName = array())
{
return $this->hydrateDataObject(
$this->entityManager->getMetadataFactory()->getMetadataFor($entityName),
$parentName
);
} | php | public function getMetadataFor($entityName, array $parentName = array())
{
return $this->hydrateDataObject(
$this->entityManager->getMetadataFactory()->getMetadataFor($entityName),
$parentName
);
} | [
"public",
"function",
"getMetadataFor",
"(",
"$",
"entityName",
",",
"array",
"$",
"parentName",
"=",
"array",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"hydrateDataObject",
"(",
"$",
"this",
"->",
"entityManager",
"->",
"getMetadataFactory",
"(",
")"... | Getting metadata for a particulary entity
@param string $entityName name of entity
@return MetadataDataObjectDoctrine2 | [
"Getting",
"metadata",
"for",
"a",
"particulary",
"entity"
] | 559f22bcc525c3157ecb17fe96818dd7b7ee58c2 | https://github.com/fezfez/codeGenerator/blob/559f22bcc525c3157ecb17fe96818dd7b7ee58c2/src/CrudGenerator/Metadata/Sources/Doctrine2/Doctrine2MetaDataDAO.php#L70-L76 | train |
pscheit/jparser | PLUG/core/PLUGCli.php | PLUGCli.init | static function init() {
switch( PHP_SAPI ) {
// Ideally we want to be runnning as CLI
case 'cli':
break;
// Special conditions to ensure CGI runs as CLI
case 'cgi':
// Ensure resource constants are defined
if( ! defined('STDERR') ){
define( 'STDERR', fopen('php://stderr', 'w') );
}
if( ! defined('STDOUT') ){
define( 'STDOUT', fopen('php://stdout', 'w') );
}
break;
default:
echo "Command line only\n";
exit(1);
}
// Default error logger function
PLUG::set_error_logger( array(__CLASS__,'format_logline') );
// parse command line arguments from argv global
global $argv, $argc;
// first cli arg is always current script. second arg will be script arg passed to shell wrapper
for( $i = 1; $i < $argc; $i++ ){
$arg = $argv[ $i ];
// Each command line argument may take following forms:
// 1. "Any single argument", no point parsing this unless it follows #2 below
// 2. "-aBCD", one or more switches, parse into 'a'=>true, 'B'=>true, and so on
// 3. "-a value", flag used with following value, parsed to 'a'=>'value'
// 4. "--longoption", GNU style long option, parse into 'longoption'=>true
// 5. "--longoption=value", as above, but parse into 'longoption'=>'value'
// 6."any variable name = any value"
$pair = explode( '=', $arg, 2 );
if( isset($pair[1]) ){
$name = trim( $pair[0] );
if( strpos($name,'--') === 0 ){
// #5. trimming "--" from option, tough luck if you only used one "-"
$name = trim( $name, '-' );
}
// else is #6, any pair
$name and self::$args[$name] = trim( $pair[1] );
}
else if( strpos($arg,'--') === 0 ){
// #4. long option, no value
$name = trim( $arg, "-\n\r\t " );
$name and self::$args[ $name ] = true;
}
else if( $arg && $arg{0} === '-' ){
$flags = preg_split('//', trim($arg,"-\n\r\t "), -1, PREG_SPLIT_NO_EMPTY );
foreach( $flags as $flag ){
self::$args[ $flag ] = true;
}
// leave $flag set incase a value follows.
continue;
}
// else is a standard argument. use as value only if it follows a flag, e.g "-a apple"
else if( isset($flag) ){
self::$args[ $flag ] = trim( $arg );
}
// dispose of last flag
unset( $flag );
// next arg
}
} | php | static function init() {
switch( PHP_SAPI ) {
// Ideally we want to be runnning as CLI
case 'cli':
break;
// Special conditions to ensure CGI runs as CLI
case 'cgi':
// Ensure resource constants are defined
if( ! defined('STDERR') ){
define( 'STDERR', fopen('php://stderr', 'w') );
}
if( ! defined('STDOUT') ){
define( 'STDOUT', fopen('php://stdout', 'w') );
}
break;
default:
echo "Command line only\n";
exit(1);
}
// Default error logger function
PLUG::set_error_logger( array(__CLASS__,'format_logline') );
// parse command line arguments from argv global
global $argv, $argc;
// first cli arg is always current script. second arg will be script arg passed to shell wrapper
for( $i = 1; $i < $argc; $i++ ){
$arg = $argv[ $i ];
// Each command line argument may take following forms:
// 1. "Any single argument", no point parsing this unless it follows #2 below
// 2. "-aBCD", one or more switches, parse into 'a'=>true, 'B'=>true, and so on
// 3. "-a value", flag used with following value, parsed to 'a'=>'value'
// 4. "--longoption", GNU style long option, parse into 'longoption'=>true
// 5. "--longoption=value", as above, but parse into 'longoption'=>'value'
// 6."any variable name = any value"
$pair = explode( '=', $arg, 2 );
if( isset($pair[1]) ){
$name = trim( $pair[0] );
if( strpos($name,'--') === 0 ){
// #5. trimming "--" from option, tough luck if you only used one "-"
$name = trim( $name, '-' );
}
// else is #6, any pair
$name and self::$args[$name] = trim( $pair[1] );
}
else if( strpos($arg,'--') === 0 ){
// #4. long option, no value
$name = trim( $arg, "-\n\r\t " );
$name and self::$args[ $name ] = true;
}
else if( $arg && $arg{0} === '-' ){
$flags = preg_split('//', trim($arg,"-\n\r\t "), -1, PREG_SPLIT_NO_EMPTY );
foreach( $flags as $flag ){
self::$args[ $flag ] = true;
}
// leave $flag set incase a value follows.
continue;
}
// else is a standard argument. use as value only if it follows a flag, e.g "-a apple"
else if( isset($flag) ){
self::$args[ $flag ] = trim( $arg );
}
// dispose of last flag
unset( $flag );
// next arg
}
} | [
"static",
"function",
"init",
"(",
")",
"{",
"switch",
"(",
"PHP_SAPI",
")",
"{",
"// Ideally we want to be runnning as CLI",
"case",
"'cli'",
":",
"break",
";",
"// Special conditions to ensure CGI runs as CLI",
"case",
"'cgi'",
":",
"// Ensure resource constants are defin... | Initialize PLUG CLI environment
@todo research CGI environment, differences to cli
@return Void | [
"Initialize",
"PLUG",
"CLI",
"environment"
] | f9de77171c0d37d237e0e9a918ed7bff19e12095 | https://github.com/pscheit/jparser/blob/f9de77171c0d37d237e0e9a918ed7bff19e12095/PLUG/core/PLUGCli.php#L44-L117 | train |
pscheit/jparser | PLUG/core/PLUGCli.php | PLUGCli.arg | final static function arg( $a, $default = null ){
if( is_int($a) ){
global $argv;
// note: arg(0) will always be the script path
return isset($argv[$a]) ? $argv[$a] : $default;
}
else {
return isset(self::$args[$a]) ? self::$args[$a] : $default;
}
} | php | final static function arg( $a, $default = null ){
if( is_int($a) ){
global $argv;
// note: arg(0) will always be the script path
return isset($argv[$a]) ? $argv[$a] : $default;
}
else {
return isset(self::$args[$a]) ? self::$args[$a] : $default;
}
} | [
"final",
"static",
"function",
"arg",
"(",
"$",
"a",
",",
"$",
"default",
"=",
"null",
")",
"{",
"if",
"(",
"is_int",
"(",
"$",
"a",
")",
")",
"{",
"global",
"$",
"argv",
";",
"// note: arg(0) will always be the script path",
"return",
"isset",
"(",
"$",... | Get command line argument
@param int|string argument name or index
@param string optional default argument to return if not present
@return string | [
"Get",
"command",
"line",
"argument"
] | f9de77171c0d37d237e0e9a918ed7bff19e12095 | https://github.com/pscheit/jparser/blob/f9de77171c0d37d237e0e9a918ed7bff19e12095/PLUG/core/PLUGCli.php#L128-L137 | train |
pscheit/jparser | PLUG/core/PLUGCli.php | PLUGCli.stderr | final static function stderr( $s ){
if( func_num_args() > 1 ){
$args = func_get_args();
$s = call_user_func_array( 'sprintf', $args );
}
fwrite( STDERR, $s );
} | php | final static function stderr( $s ){
if( func_num_args() > 1 ){
$args = func_get_args();
$s = call_user_func_array( 'sprintf', $args );
}
fwrite( STDERR, $s );
} | [
"final",
"static",
"function",
"stderr",
"(",
"$",
"s",
")",
"{",
"if",
"(",
"func_num_args",
"(",
")",
">",
"1",
")",
"{",
"$",
"args",
"=",
"func_get_args",
"(",
")",
";",
"$",
"s",
"=",
"call_user_func_array",
"(",
"'sprintf'",
",",
"$",
"args",
... | Print to stderr
@param string printf style formatter
@param ... arguments to printf
@return void | [
"Print",
"to",
"stderr"
] | f9de77171c0d37d237e0e9a918ed7bff19e12095 | https://github.com/pscheit/jparser/blob/f9de77171c0d37d237e0e9a918ed7bff19e12095/PLUG/core/PLUGCli.php#L147-L153 | train |
pscheit/jparser | PLUG/core/PLUGCli.php | PLUGCli.format_logline | static function format_logline( PLUGError $Err ){
if( PLUG::is_compiled() ){
return sprintf(
'%s: %s: %s',
basename(self::arg(0)),
$Err->getTypeString(),
$Err->getMessage()
);
}
else {
return sprintf(
'%s: %s: %s in %s#%u',
basename(self::arg(0)),
$Err->getTypeString(),
$Err->getMessage(),
basename($Err->getFile()),
$Err->getLine()
);
}
} | php | static function format_logline( PLUGError $Err ){
if( PLUG::is_compiled() ){
return sprintf(
'%s: %s: %s',
basename(self::arg(0)),
$Err->getTypeString(),
$Err->getMessage()
);
}
else {
return sprintf(
'%s: %s: %s in %s#%u',
basename(self::arg(0)),
$Err->getTypeString(),
$Err->getMessage(),
basename($Err->getFile()),
$Err->getLine()
);
}
} | [
"static",
"function",
"format_logline",
"(",
"PLUGError",
"$",
"Err",
")",
"{",
"if",
"(",
"PLUG",
"::",
"is_compiled",
"(",
")",
")",
"{",
"return",
"sprintf",
"(",
"'%s: %s: %s'",
",",
"basename",
"(",
"self",
"::",
"arg",
"(",
"0",
")",
")",
",",
... | Standard error logger printing to stderr with program name | [
"Standard",
"error",
"logger",
"printing",
"to",
"stderr",
"with",
"program",
"name"
] | f9de77171c0d37d237e0e9a918ed7bff19e12095 | https://github.com/pscheit/jparser/blob/f9de77171c0d37d237e0e9a918ed7bff19e12095/PLUG/core/PLUGCli.php#L160-L179 | train |
AXN-Informatique/laravel-glide | src/GlideServer.php | GlideServer.getLeagueGlideServer | public function getLeagueGlideServer()
{
if (null === $this->server) {
$config = $this->config + [
'response' => new LaravelResponseFactory($this->app['request'])
];
$this->server = ServerFactory::create($config);
}
return $this->server;
} | php | public function getLeagueGlideServer()
{
if (null === $this->server) {
$config = $this->config + [
'response' => new LaravelResponseFactory($this->app['request'])
];
$this->server = ServerFactory::create($config);
}
return $this->server;
} | [
"public",
"function",
"getLeagueGlideServer",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"server",
")",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"config",
"+",
"[",
"'response'",
"=>",
"new",
"LaravelResponseFactory",
"(",
"$",
"this"... | Return the league glide server instance for this glide server.
@return \League\Glide\Server | [
"Return",
"the",
"league",
"glide",
"server",
"instance",
"for",
"this",
"glide",
"server",
"."
] | 85fbf70dcc87c8aeda25411b86f26a1f5f55b2c2 | https://github.com/AXN-Informatique/laravel-glide/blob/85fbf70dcc87c8aeda25411b86f26a1f5f55b2c2/src/GlideServer.php#L64-L75 | train |
AXN-Informatique/laravel-glide | src/GlideServer.php | GlideServer.url | public function url($path, array $params = [])
{
$urlBuilder = UrlBuilderFactory::create($this->config['base_url'], $this->config['sign_key']);
return $urlBuilder->getUrl($path, $params);
} | php | public function url($path, array $params = [])
{
$urlBuilder = UrlBuilderFactory::create($this->config['base_url'], $this->config['sign_key']);
return $urlBuilder->getUrl($path, $params);
} | [
"public",
"function",
"url",
"(",
"$",
"path",
",",
"array",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"$",
"urlBuilder",
"=",
"UrlBuilderFactory",
"::",
"create",
"(",
"$",
"this",
"->",
"config",
"[",
"'base_url'",
"]",
",",
"$",
"this",
"->",
"confi... | Return image url.
@param string $path
@param array $params
@return string | [
"Return",
"image",
"url",
"."
] | 85fbf70dcc87c8aeda25411b86f26a1f5f55b2c2 | https://github.com/AXN-Informatique/laravel-glide/blob/85fbf70dcc87c8aeda25411b86f26a1f5f55b2c2/src/GlideServer.php#L148-L153 | train |
stanislav-web/Searcher | src/Searcher/Exceptions/InvalidLength.php | InvalidLength.rise | public function rise(array $params, $line, $filename)
{
$this->message = "The length of \"" . $params[0] . "\" is invalid! Must be " . $params[1] . " then " . $params[2] . ". File: " . $filename . " Line: " . $line;
return $this;
} | php | public function rise(array $params, $line, $filename)
{
$this->message = "The length of \"" . $params[0] . "\" is invalid! Must be " . $params[1] . " then " . $params[2] . ". File: " . $filename . " Line: " . $line;
return $this;
} | [
"public",
"function",
"rise",
"(",
"array",
"$",
"params",
",",
"$",
"line",
",",
"$",
"filename",
")",
"{",
"$",
"this",
"->",
"message",
"=",
"\"The length of \\\"\"",
".",
"$",
"params",
"[",
"0",
"]",
".",
"\"\\\" is invalid! Must be \"",
".",
"$",
"... | Rise error message for Length Exceptions
@param array $params message params
@param int $line error line
@param string $filename file error
@return \Searcher\Searcher\Exceptions\InvalidLength | [
"Rise",
"error",
"message",
"for",
"Length",
"Exceptions"
] | bf01156d1a2416ceddef0d238469563b74087d44 | https://github.com/stanislav-web/Searcher/blob/bf01156d1a2416ceddef0d238469563b74087d44/src/Searcher/Exceptions/InvalidLength.php#L34-L40 | train |
Lp-digital/github-event-parser | Entity/Issue.php | Issue.buildLabels | private function buildLabels($labels)
{
$collection = [];
foreach ($labels as $label) {
$collection[] = Label::createFromData($label);
}
return $collection;
} | php | private function buildLabels($labels)
{
$collection = [];
foreach ($labels as $label) {
$collection[] = Label::createFromData($label);
}
return $collection;
} | [
"private",
"function",
"buildLabels",
"(",
"$",
"labels",
")",
"{",
"$",
"collection",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"labels",
"as",
"$",
"label",
")",
"{",
"$",
"collection",
"[",
"]",
"=",
"Label",
"::",
"createFromData",
"(",
"$",
"labe... | Set the Label collection from an array.
@param array $labels an array of labels
@return Label[] the collection of labels | [
"Set",
"the",
"Label",
"collection",
"from",
"an",
"array",
"."
] | 2a57cd8ab1cf7e12fb680fd61afd1e9725db708c | https://github.com/Lp-digital/github-event-parser/blob/2a57cd8ab1cf7e12fb680fd61afd1e9725db708c/Entity/Issue.php#L279-L287 | train |
fezfez/codeGenerator | src/CrudGenerator/Metadata/Sources/Doctrine2/Doctrine2MetaDataDAOFactory.php | Doctrine2MetaDataDAOFactory.getInstance | public static function getInstance()
{
$fileManager = new FileManager();
$serviceManager = ZendFramework2Environnement::getDependence($fileManager);
$entityManager = $serviceManager->get('doctrine.entitymanager.orm_default');
if (($entityManager instanceof EntityManager) === false) {
throw new \Exception(
sprintf(
'Service manager return instanceof "%s" instead of "%s"',
is_object($entityManager) === true ? get_class($entityManager) : gettype($entityManager),
'Doctrine\ORM\EntityManager'
)
);
}
return new Doctrine2MetaDataDAO($entityManager);
} | php | public static function getInstance()
{
$fileManager = new FileManager();
$serviceManager = ZendFramework2Environnement::getDependence($fileManager);
$entityManager = $serviceManager->get('doctrine.entitymanager.orm_default');
if (($entityManager instanceof EntityManager) === false) {
throw new \Exception(
sprintf(
'Service manager return instanceof "%s" instead of "%s"',
is_object($entityManager) === true ? get_class($entityManager) : gettype($entityManager),
'Doctrine\ORM\EntityManager'
)
);
}
return new Doctrine2MetaDataDAO($entityManager);
} | [
"public",
"static",
"function",
"getInstance",
"(",
")",
"{",
"$",
"fileManager",
"=",
"new",
"FileManager",
"(",
")",
";",
"$",
"serviceManager",
"=",
"ZendFramework2Environnement",
"::",
"getDependence",
"(",
"$",
"fileManager",
")",
";",
"$",
"entityManager",... | Create Doctrine2MetaDataDAO instance
@return Doctrine2MetaDataDAO | [
"Create",
"Doctrine2MetaDataDAO",
"instance"
] | 559f22bcc525c3157ecb17fe96818dd7b7ee58c2 | https://github.com/fezfez/codeGenerator/blob/559f22bcc525c3157ecb17fe96818dd7b7ee58c2/src/CrudGenerator/Metadata/Sources/Doctrine2/Doctrine2MetaDataDAOFactory.php#L30-L47 | train |
manaphp/framework | Bos/Client.php | Client.getUploadResult | public function getUploadResult($token)
{
$jwt = new Jwt();
$claims = $jwt->decode($token, false);
if (!isset($claims['scope'])) {
throw new AuthenticationException('scope is not exists');
}
if ($claims['scope'] !== 'bos.object.create.response') {
throw new AuthenticationException(['`:scope` scope is not valid', 'scope' => $claims['scope']]);
}
if (!isset($claims['bucket'])) {
throw new AuthenticationException('bucket is not exists');
}
$bucket = $claims['bucket'];
$this->logger->info($token, 'bosClient.getUploadResult');
$jwt->verify($token, is_string($this->_access_key) ? $this->_access_key : $this->_access_key[$bucket]);
return array_except($claims, ['scope', 'iat', 'exp']);
} | php | public function getUploadResult($token)
{
$jwt = new Jwt();
$claims = $jwt->decode($token, false);
if (!isset($claims['scope'])) {
throw new AuthenticationException('scope is not exists');
}
if ($claims['scope'] !== 'bos.object.create.response') {
throw new AuthenticationException(['`:scope` scope is not valid', 'scope' => $claims['scope']]);
}
if (!isset($claims['bucket'])) {
throw new AuthenticationException('bucket is not exists');
}
$bucket = $claims['bucket'];
$this->logger->info($token, 'bosClient.getUploadResult');
$jwt->verify($token, is_string($this->_access_key) ? $this->_access_key : $this->_access_key[$bucket]);
return array_except($claims, ['scope', 'iat', 'exp']);
} | [
"public",
"function",
"getUploadResult",
"(",
"$",
"token",
")",
"{",
"$",
"jwt",
"=",
"new",
"Jwt",
"(",
")",
";",
"$",
"claims",
"=",
"$",
"jwt",
"->",
"decode",
"(",
"$",
"token",
",",
"false",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"c... | verify token of create object response
@param string $token
@return array | [
"verify",
"token",
"of",
"create",
"object",
"response"
] | b9a15c7f8f5d4770cacbea43f26914765bfcb248 | https://github.com/manaphp/framework/blob/b9a15c7f8f5d4770cacbea43f26914765bfcb248/Bos/Client.php#L147-L172 | train |
milejko/mmi-cms | src/CmsAdmin/Grid/GridExporter.php | GridExporter.passCsv | public function passCsv()
{
$csv = fopen('php://output', 'w');
//nagłówek CSV
fputcsv($csv, $this->_getHeader());
//iteracja po danych
foreach ($this->_getData() as $data) {
//zapis linii CSV
fputcsv($csv, $data);
}
fclose($csv);
} | php | public function passCsv()
{
$csv = fopen('php://output', 'w');
//nagłówek CSV
fputcsv($csv, $this->_getHeader());
//iteracja po danych
foreach ($this->_getData() as $data) {
//zapis linii CSV
fputcsv($csv, $data);
}
fclose($csv);
} | [
"public",
"function",
"passCsv",
"(",
")",
"{",
"$",
"csv",
"=",
"fopen",
"(",
"'php://output'",
",",
"'w'",
")",
";",
"//nagłówek CSV",
"fputcsv",
"(",
"$",
"csv",
",",
"$",
"this",
"->",
"_getHeader",
"(",
")",
")",
";",
"//iteracja po danych",
"foreac... | Parsuje dane do postaci CSV | [
"Parsuje",
"dane",
"do",
"postaci",
"CSV"
] | 95483b08f25136b8d6bcf787ec4ecc3e8bdffb38 | https://github.com/milejko/mmi-cms/blob/95483b08f25136b8d6bcf787ec4ecc3e8bdffb38/src/CmsAdmin/Grid/GridExporter.php#L38-L49 | train |
milejko/mmi-cms | src/CmsAdmin/Grid/GridExporter.php | GridExporter._getHeader | protected function _getHeader()
{
$header = [];
foreach ($this->_grid->getColumns() as $column) {
if ($column instanceof Column\IndexColumn || $column instanceof Column\OperationColumn) {
continue;
}
if ($column instanceof Column\CustomColumn && !$column->getExporting()) {
continue;
}
$header[] = $column->getLabel();
}
return $header;
} | php | protected function _getHeader()
{
$header = [];
foreach ($this->_grid->getColumns() as $column) {
if ($column instanceof Column\IndexColumn || $column instanceof Column\OperationColumn) {
continue;
}
if ($column instanceof Column\CustomColumn && !$column->getExporting()) {
continue;
}
$header[] = $column->getLabel();
}
return $header;
} | [
"protected",
"function",
"_getHeader",
"(",
")",
"{",
"$",
"header",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"_grid",
"->",
"getColumns",
"(",
")",
"as",
"$",
"column",
")",
"{",
"if",
"(",
"$",
"column",
"instanceof",
"Column",
"\\",
... | Wybiera etykiety kolumn CSV
@return array | [
"Wybiera",
"etykiety",
"kolumn",
"CSV"
] | 95483b08f25136b8d6bcf787ec4ecc3e8bdffb38 | https://github.com/milejko/mmi-cms/blob/95483b08f25136b8d6bcf787ec4ecc3e8bdffb38/src/CmsAdmin/Grid/GridExporter.php#L55-L68 | train |
webfactory/symfony-application-tests | src/Webfactory/Util/ApplicationServiceIterator.php | ApplicationServiceIterator.accept | public function accept()
{
/* @var $serviceId string|object */
$serviceId = $this->current();
if (in_array($serviceId, $this->getIdsOfServicesThatAreDefinedInApplication())) {
return true;
}
if ($this->startsWithPrefix($serviceId, $this->getPrefixesOfApplicationServices())) {
return true;
}
return false;
} | php | public function accept()
{
/* @var $serviceId string|object */
$serviceId = $this->current();
if (in_array($serviceId, $this->getIdsOfServicesThatAreDefinedInApplication())) {
return true;
}
if ($this->startsWithPrefix($serviceId, $this->getPrefixesOfApplicationServices())) {
return true;
}
return false;
} | [
"public",
"function",
"accept",
"(",
")",
"{",
"/* @var $serviceId string|object */",
"$",
"serviceId",
"=",
"$",
"this",
"->",
"current",
"(",
")",
";",
"if",
"(",
"in_array",
"(",
"$",
"serviceId",
",",
"$",
"this",
"->",
"getIdsOfServicesThatAreDefinedInAppli... | Checks if the current service ID is defined directly in the application.
@return boolean True if the current element is acceptable, otherwise false.
@link http://php.net/manual/en/filteriterator.accept.php | [
"Checks",
"if",
"the",
"current",
"service",
"ID",
"is",
"defined",
"directly",
"in",
"the",
"application",
"."
] | 971c0d45c46dc20323535940fc0d1cc7eafaf553 | https://github.com/webfactory/symfony-application-tests/blob/971c0d45c46dc20323535940fc0d1cc7eafaf553/src/Webfactory/Util/ApplicationServiceIterator.php#L77-L88 | train |
webfactory/symfony-application-tests | src/Webfactory/Util/ApplicationServiceIterator.php | ApplicationServiceIterator.getIdsOfServicesThatAreDefinedInApplication | protected function getIdsOfServicesThatAreDefinedInApplication()
{
if ($this->serviceIdWhitelist === null) {
$builder = $this->createContainerBuilder();
$this->applyToExtensions(function (ExtensionInterface $extension) use ($builder) {
$extension->load($builder->getExtensionConfig($extension->getAlias()), $builder);
});
$this->serviceIdWhitelist = $builder->getServiceIds();
}
return $this->serviceIdWhitelist;
} | php | protected function getIdsOfServicesThatAreDefinedInApplication()
{
if ($this->serviceIdWhitelist === null) {
$builder = $this->createContainerBuilder();
$this->applyToExtensions(function (ExtensionInterface $extension) use ($builder) {
$extension->load($builder->getExtensionConfig($extension->getAlias()), $builder);
});
$this->serviceIdWhitelist = $builder->getServiceIds();
}
return $this->serviceIdWhitelist;
} | [
"protected",
"function",
"getIdsOfServicesThatAreDefinedInApplication",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"serviceIdWhitelist",
"===",
"null",
")",
"{",
"$",
"builder",
"=",
"$",
"this",
"->",
"createContainerBuilder",
"(",
")",
";",
"$",
"this",
"-... | Returns all IDs of services that are clearly defined in the application bundles.
@return string[] | [
"Returns",
"all",
"IDs",
"of",
"services",
"that",
"are",
"clearly",
"defined",
"in",
"the",
"application",
"bundles",
"."
] | 971c0d45c46dc20323535940fc0d1cc7eafaf553 | https://github.com/webfactory/symfony-application-tests/blob/971c0d45c46dc20323535940fc0d1cc7eafaf553/src/Webfactory/Util/ApplicationServiceIterator.php#L95-L105 | train |
webfactory/symfony-application-tests | src/Webfactory/Util/ApplicationServiceIterator.php | ApplicationServiceIterator.getPrefixesOfApplicationServices | protected function getPrefixesOfApplicationServices()
{
if ($this->allowedServicePrefixes === null) {
$this->allowedServicePrefixes = $this->applyToExtensions(function (ExtensionInterface $extension) {
return $extension->getAlias() . '.';
});
}
return $this->allowedServicePrefixes;
} | php | protected function getPrefixesOfApplicationServices()
{
if ($this->allowedServicePrefixes === null) {
$this->allowedServicePrefixes = $this->applyToExtensions(function (ExtensionInterface $extension) {
return $extension->getAlias() . '.';
});
}
return $this->allowedServicePrefixes;
} | [
"protected",
"function",
"getPrefixesOfApplicationServices",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"allowedServicePrefixes",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"allowedServicePrefixes",
"=",
"$",
"this",
"->",
"applyToExtensions",
"(",
"function",
... | Returns the prefixes that should be used by services that are defined in application bundles.
@return string[] | [
"Returns",
"the",
"prefixes",
"that",
"should",
"be",
"used",
"by",
"services",
"that",
"are",
"defined",
"in",
"application",
"bundles",
"."
] | 971c0d45c46dc20323535940fc0d1cc7eafaf553 | https://github.com/webfactory/symfony-application-tests/blob/971c0d45c46dc20323535940fc0d1cc7eafaf553/src/Webfactory/Util/ApplicationServiceIterator.php#L112-L120 | train |
webfactory/symfony-application-tests | src/Webfactory/Util/ApplicationServiceIterator.php | ApplicationServiceIterator.applyToExtensions | protected function applyToExtensions($callback)
{
$results = array();
foreach (new ApplicationBundleIterator($this->kernel) as $bundle) {
/* @var $bundle BundleInterface */
$extension = $bundle->getContainerExtension();
if ($extension !== null) {
$results[] = call_user_func($callback, $extension);
}
}
return $results;
} | php | protected function applyToExtensions($callback)
{
$results = array();
foreach (new ApplicationBundleIterator($this->kernel) as $bundle) {
/* @var $bundle BundleInterface */
$extension = $bundle->getContainerExtension();
if ($extension !== null) {
$results[] = call_user_func($callback, $extension);
}
}
return $results;
} | [
"protected",
"function",
"applyToExtensions",
"(",
"$",
"callback",
")",
"{",
"$",
"results",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"new",
"ApplicationBundleIterator",
"(",
"$",
"this",
"->",
"kernel",
")",
"as",
"$",
"bundle",
")",
"{",
"/* @var $b... | Applies the given callback to all bundle extensions that are
defined in the application and returns an array with the results
of each call.
@param callable $callback
@return array(mixed) | [
"Applies",
"the",
"given",
"callback",
"to",
"all",
"bundle",
"extensions",
"that",
"are",
"defined",
"in",
"the",
"application",
"and",
"returns",
"an",
"array",
"with",
"the",
"results",
"of",
"each",
"call",
"."
] | 971c0d45c46dc20323535940fc0d1cc7eafaf553 | https://github.com/webfactory/symfony-application-tests/blob/971c0d45c46dc20323535940fc0d1cc7eafaf553/src/Webfactory/Util/ApplicationServiceIterator.php#L130-L141 | train |
webfactory/symfony-application-tests | src/Webfactory/Util/ApplicationServiceIterator.php | ApplicationServiceIterator.startsWithPrefix | protected function startsWithPrefix($serviceId, $allowedPrefixes)
{
foreach ($allowedPrefixes as $prefix) {
/* @var $prefix string */
if (strpos($serviceId, $prefix) === 0) {
return true;
}
}
return false;
} | php | protected function startsWithPrefix($serviceId, $allowedPrefixes)
{
foreach ($allowedPrefixes as $prefix) {
/* @var $prefix string */
if (strpos($serviceId, $prefix) === 0) {
return true;
}
}
return false;
} | [
"protected",
"function",
"startsWithPrefix",
"(",
"$",
"serviceId",
",",
"$",
"allowedPrefixes",
")",
"{",
"foreach",
"(",
"$",
"allowedPrefixes",
"as",
"$",
"prefix",
")",
"{",
"/* @var $prefix string */",
"if",
"(",
"strpos",
"(",
"$",
"serviceId",
",",
"$",... | Checks if the given service ID starts with any of the provided prefixes.
@param string $serviceId
@param string[] $allowedPrefixes
@return boolean | [
"Checks",
"if",
"the",
"given",
"service",
"ID",
"starts",
"with",
"any",
"of",
"the",
"provided",
"prefixes",
"."
] | 971c0d45c46dc20323535940fc0d1cc7eafaf553 | https://github.com/webfactory/symfony-application-tests/blob/971c0d45c46dc20323535940fc0d1cc7eafaf553/src/Webfactory/Util/ApplicationServiceIterator.php#L150-L159 | train |
webfactory/symfony-application-tests | src/Webfactory/Util/ApplicationServiceIterator.php | ApplicationServiceIterator.createContainerBuilder | protected function createContainerBuilder()
{
$builder = new ContainerBuilder();
$this->kernel->boot();
foreach ($this->kernel->getBundles() as $bundle) {
// Register all extensions, otherwise there might be config parts that cannot be processed.
$extension = $bundle->getContainerExtension();
if ($extension !== null) {
$builder->registerExtension($extension);
}
}
// Load the application configuration, which might affect the loaded services.
/* @var $locator FileLocatorInterface */
$locator = $this->kernel->getContainer()->get('file_locator');
$loaders = array(
new XmlFileLoader($builder, $locator),
new YamlFileLoader($builder, $locator),
new IniFileLoader($builder, $locator),
new PhpFileLoader($builder, $locator),
(class_exists(DirectoryLoader::class) ? new DirectoryLoader($builder, $locator) : null),
new ClosureLoader($builder),
);
$loaders = array_filter($loaders);
$resolver = new LoaderResolver($loaders);
$loader = new DelegatingLoader($resolver);
$this->kernel->registerContainerConfiguration($loader);
return $builder;
} | php | protected function createContainerBuilder()
{
$builder = new ContainerBuilder();
$this->kernel->boot();
foreach ($this->kernel->getBundles() as $bundle) {
// Register all extensions, otherwise there might be config parts that cannot be processed.
$extension = $bundle->getContainerExtension();
if ($extension !== null) {
$builder->registerExtension($extension);
}
}
// Load the application configuration, which might affect the loaded services.
/* @var $locator FileLocatorInterface */
$locator = $this->kernel->getContainer()->get('file_locator');
$loaders = array(
new XmlFileLoader($builder, $locator),
new YamlFileLoader($builder, $locator),
new IniFileLoader($builder, $locator),
new PhpFileLoader($builder, $locator),
(class_exists(DirectoryLoader::class) ? new DirectoryLoader($builder, $locator) : null),
new ClosureLoader($builder),
);
$loaders = array_filter($loaders);
$resolver = new LoaderResolver($loaders);
$loader = new DelegatingLoader($resolver);
$this->kernel->registerContainerConfiguration($loader);
return $builder;
} | [
"protected",
"function",
"createContainerBuilder",
"(",
")",
"{",
"$",
"builder",
"=",
"new",
"ContainerBuilder",
"(",
")",
";",
"$",
"this",
"->",
"kernel",
"->",
"boot",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"kernel",
"->",
"getBundles",
"(... | Creates a pre-configured container builder.
The builder contains all extensions and its configurations.
@return ContainerBuilder | [
"Creates",
"a",
"pre",
"-",
"configured",
"container",
"builder",
"."
] | 971c0d45c46dc20323535940fc0d1cc7eafaf553 | https://github.com/webfactory/symfony-application-tests/blob/971c0d45c46dc20323535940fc0d1cc7eafaf553/src/Webfactory/Util/ApplicationServiceIterator.php#L168-L195 | train |
Lp-digital/github-event-parser | Entity/PullRequest.php | PullRequest.getCommits | public function getCommits()
{
if ('' === ini_get('user_agent')) {
throw new UserAgentNotFoundException();
}
if (!ini_get('allow_url_fopen')) {
throw new AllowUrlFileOpenException();
}
$jsonResponse = $this->getFileContent($this->getCommitsUrl(), ini_get('user_agent'));
$response = json_decode($jsonResponse, true);
foreach ($response as $commitArray) {
$commit = Commit::createFromData($commitArray['commit'])
->setSha($commitArray['sha'])
;
$commits[] = $commit;
}
return $commits;
} | php | public function getCommits()
{
if ('' === ini_get('user_agent')) {
throw new UserAgentNotFoundException();
}
if (!ini_get('allow_url_fopen')) {
throw new AllowUrlFileOpenException();
}
$jsonResponse = $this->getFileContent($this->getCommitsUrl(), ini_get('user_agent'));
$response = json_decode($jsonResponse, true);
foreach ($response as $commitArray) {
$commit = Commit::createFromData($commitArray['commit'])
->setSha($commitArray['sha'])
;
$commits[] = $commit;
}
return $commits;
} | [
"public",
"function",
"getCommits",
"(",
")",
"{",
"if",
"(",
"''",
"===",
"ini_get",
"(",
"'user_agent'",
")",
")",
"{",
"throw",
"new",
"UserAgentNotFoundException",
"(",
")",
";",
"}",
"if",
"(",
"!",
"ini_get",
"(",
"'allow_url_fopen'",
")",
")",
"{"... | Get the commits.
@return Commit[] | [
"Get",
"the",
"commits",
"."
] | 2a57cd8ab1cf7e12fb680fd61afd1e9725db708c | https://github.com/Lp-digital/github-event-parser/blob/2a57cd8ab1cf7e12fb680fd61afd1e9725db708c/Entity/PullRequest.php#L902-L924 | train |
Lp-digital/github-event-parser | Entity/PullRequest.php | PullRequest.getFileContent | private function getFileContent($url, $userAgent)
{
$opts = [
'http' => [
'method' => 'GET',
'header' => [
'User-Agent: '. $userAgent
]
]
];
$context = stream_context_create($opts);
return file_get_contents($url, false, $context);
} | php | private function getFileContent($url, $userAgent)
{
$opts = [
'http' => [
'method' => 'GET',
'header' => [
'User-Agent: '. $userAgent
]
]
];
$context = stream_context_create($opts);
return file_get_contents($url, false, $context);
} | [
"private",
"function",
"getFileContent",
"(",
"$",
"url",
",",
"$",
"userAgent",
")",
"{",
"$",
"opts",
"=",
"[",
"'http'",
"=>",
"[",
"'method'",
"=>",
"'GET'",
",",
"'header'",
"=>",
"[",
"'User-Agent: '",
".",
"$",
"userAgent",
"]",
"]",
"]",
";",
... | A better file_get_contents | [
"A",
"better",
"file_get_contents"
] | 2a57cd8ab1cf7e12fb680fd61afd1e9725db708c | https://github.com/Lp-digital/github-event-parser/blob/2a57cd8ab1cf7e12fb680fd61afd1e9725db708c/Entity/PullRequest.php#L957-L971 | train |
xdan/jodit-connector-application | src/Helper.php | Helper.downloadRemoteFile | static function downloadRemoteFile($url, $destinationFilename) {
if (!ini_get('allow_url_fopen')) {
throw new \Exception('allow_url_fopen is disable', 501);
}
$message = "File was not loaded";
if (function_exists('curl_init')) {
try {
$raw = file_get_contents($url);
} catch (\Exception $e) {
throw new \Exception($message, Consts::ERROR_CODE_BAD_REQUEST);
}
} else {
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);// таймаут4
$response = parse_url($url);
curl_setopt($ch, CURLOPT_REFERER, $response['scheme'] . '://' . $response['host']);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_3) ' .
'AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.99 YaBrowser/19.1.1.907 Yowser/2.5 Safari/537.36');
$raw = curl_exec($ch);
if (!$raw) {
throw new \Exception($message, Consts::ERROR_CODE_BAD_REQUEST);
}
curl_close($ch);
}
if ($raw) {
file_put_contents($destinationFilename, $raw);
} else {
throw new \Exception($message, Consts::ERROR_CODE_BAD_REQUEST);
}
} | php | static function downloadRemoteFile($url, $destinationFilename) {
if (!ini_get('allow_url_fopen')) {
throw new \Exception('allow_url_fopen is disable', 501);
}
$message = "File was not loaded";
if (function_exists('curl_init')) {
try {
$raw = file_get_contents($url);
} catch (\Exception $e) {
throw new \Exception($message, Consts::ERROR_CODE_BAD_REQUEST);
}
} else {
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);// таймаут4
$response = parse_url($url);
curl_setopt($ch, CURLOPT_REFERER, $response['scheme'] . '://' . $response['host']);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_3) ' .
'AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.99 YaBrowser/19.1.1.907 Yowser/2.5 Safari/537.36');
$raw = curl_exec($ch);
if (!$raw) {
throw new \Exception($message, Consts::ERROR_CODE_BAD_REQUEST);
}
curl_close($ch);
}
if ($raw) {
file_put_contents($destinationFilename, $raw);
} else {
throw new \Exception($message, Consts::ERROR_CODE_BAD_REQUEST);
}
} | [
"static",
"function",
"downloadRemoteFile",
"(",
"$",
"url",
",",
"$",
"destinationFilename",
")",
"{",
"if",
"(",
"!",
"ini_get",
"(",
"'allow_url_fopen'",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'allow_url_fopen is disable'",
",",
"501",
")",... | Download remote file on server
@param string $url
@param string $destinationFilename
@throws \Exception | [
"Download",
"remote",
"file",
"on",
"server"
] | a1f8ebf2d605665fb25e737d60a62ea410358c62 | https://github.com/xdan/jodit-connector-application/blob/a1f8ebf2d605665fb25e737d60a62ea410358c62/src/Helper.php#L88-L131 | train |
pscheit/jparser | PLUG/parsing/LR/LRParseTable.php | LRParseTable.lookup | function lookup( $state, $la ){
if( ! isset($this->table[$state][$la]) ){
return null;
}
else {
return $this->table[$state][$la];
}
} | php | function lookup( $state, $la ){
if( ! isset($this->table[$state][$la]) ){
return null;
}
else {
return $this->table[$state][$la];
}
} | [
"function",
"lookup",
"(",
"$",
"state",
",",
"$",
"la",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"table",
"[",
"$",
"state",
"]",
"[",
"$",
"la",
"]",
")",
")",
"{",
"return",
"null",
";",
"}",
"else",
"{",
"return",
"$",
... | Lookup action by state and lookahead symbol
@param int odd-numbered state id
@param mixed look ahead symbol
@return int either an even-numbered rule id, or an odd-numbered state id, or null | [
"Lookup",
"action",
"by",
"state",
"and",
"lookahead",
"symbol"
] | f9de77171c0d37d237e0e9a918ed7bff19e12095 | https://github.com/pscheit/jparser/blob/f9de77171c0d37d237e0e9a918ed7bff19e12095/PLUG/parsing/LR/LRParseTable.php#L53-L60 | train |
milejko/mmi-cms | src/CmsAdmin/Grid/GridState.php | GridState._applyFilters | private function _applyFilters(\Mmi\Orm\Query $query)
{
//iteracja po filtrach
foreach ($this->getFilters() as $filter) {
//filtr nie jest prawidłowy
if (!($filter instanceof GridStateFilter)) {
throw new GridException('Invalid state filter object');
}
//operator równości
if ($filter->getMethod() == 'equals') {
$query->andField($filter->getField(), $filter->getTableName())->equals($filter->getValue());
continue;
}
//podobieństwo
if ($filter->getMethod() == 'like') {
$query->andField($filter->getField(), $filter->getTableName())->like($filter->getValue() . '%');
continue;
}
//większość
if ($filter->getMethod() == 'null') {
if ($filter->getValue()) {
$query->andField($filter->getField(), $filter->getTableName())->notEquals(null);
continue;
}
$query->andField($filter->getField(), $filter->getTableName())->equals(null);
continue;
}
if ($filter->getMethod() == 'between') {
$range = explode(';', $filter->getValue());
//zdefiniowane od
if (!empty($range[0])) {
$query->andField($filter->getField(), $filter->getTableName())->greaterOrEquals($range[0]);
}
//zdefiniowane do
if (isset($range[1]) && !empty($range[1])) {
$query->andField($filter->getField(), $filter->getTableName())->lessOrEquals($range[1]);
}
continue;
}
//domyślnie - wyszukanie
$query->andField($filter->getField(), $filter->getTableName())->like('%' . $filter->getValue() . '%');
}
return $this;
} | php | private function _applyFilters(\Mmi\Orm\Query $query)
{
//iteracja po filtrach
foreach ($this->getFilters() as $filter) {
//filtr nie jest prawidłowy
if (!($filter instanceof GridStateFilter)) {
throw new GridException('Invalid state filter object');
}
//operator równości
if ($filter->getMethod() == 'equals') {
$query->andField($filter->getField(), $filter->getTableName())->equals($filter->getValue());
continue;
}
//podobieństwo
if ($filter->getMethod() == 'like') {
$query->andField($filter->getField(), $filter->getTableName())->like($filter->getValue() . '%');
continue;
}
//większość
if ($filter->getMethod() == 'null') {
if ($filter->getValue()) {
$query->andField($filter->getField(), $filter->getTableName())->notEquals(null);
continue;
}
$query->andField($filter->getField(), $filter->getTableName())->equals(null);
continue;
}
if ($filter->getMethod() == 'between') {
$range = explode(';', $filter->getValue());
//zdefiniowane od
if (!empty($range[0])) {
$query->andField($filter->getField(), $filter->getTableName())->greaterOrEquals($range[0]);
}
//zdefiniowane do
if (isset($range[1]) && !empty($range[1])) {
$query->andField($filter->getField(), $filter->getTableName())->lessOrEquals($range[1]);
}
continue;
}
//domyślnie - wyszukanie
$query->andField($filter->getField(), $filter->getTableName())->like('%' . $filter->getValue() . '%');
}
return $this;
} | [
"private",
"function",
"_applyFilters",
"(",
"\\",
"Mmi",
"\\",
"Orm",
"\\",
"Query",
"$",
"query",
")",
"{",
"//iteracja po filtrach",
"foreach",
"(",
"$",
"this",
"->",
"getFilters",
"(",
")",
"as",
"$",
"filter",
")",
"{",
"//filtr nie jest prawidłowy",
"... | Stosuje filtry na zapytaniu
@param \Mmi\Orm\Query $query
@return GridState
@throws GridException | [
"Stosuje",
"filtry",
"na",
"zapytaniu"
] | 95483b08f25136b8d6bcf787ec4ecc3e8bdffb38 | https://github.com/milejko/mmi-cms/blob/95483b08f25136b8d6bcf787ec4ecc3e8bdffb38/src/CmsAdmin/Grid/GridState.php#L183-L226 | train |
milejko/mmi-cms | src/CmsAdmin/Grid/GridState.php | GridState._applyOrder | private function _applyOrder(\Mmi\Orm\Query $query)
{
$orders = $this->getOrder();
//resetowanie domyślnego orderu jeśli podany
if (!empty($orders)) {
$query->resetOrder();
}
//iteracja po orderze
foreach ($orders as $order) {
//order nie jest obiektem sortowania
if (!($order instanceof GridStateOrder)) {
throw new GridException('Invalid state order object');
}
//aplikacja na querę
$query->{$order->getMethod()}($order->getField(), $order->getTableName());
}
return $this;
} | php | private function _applyOrder(\Mmi\Orm\Query $query)
{
$orders = $this->getOrder();
//resetowanie domyślnego orderu jeśli podany
if (!empty($orders)) {
$query->resetOrder();
}
//iteracja po orderze
foreach ($orders as $order) {
//order nie jest obiektem sortowania
if (!($order instanceof GridStateOrder)) {
throw new GridException('Invalid state order object');
}
//aplikacja na querę
$query->{$order->getMethod()}($order->getField(), $order->getTableName());
}
return $this;
} | [
"private",
"function",
"_applyOrder",
"(",
"\\",
"Mmi",
"\\",
"Orm",
"\\",
"Query",
"$",
"query",
")",
"{",
"$",
"orders",
"=",
"$",
"this",
"->",
"getOrder",
"(",
")",
";",
"//resetowanie domyślnego orderu jeśli podany",
"if",
"(",
"!",
"empty",
"(",
"$",... | Stosuje sortowania na zapytaniu
@param \Mmi\Orm\Query $query
@return GridState
@throws GridException | [
"Stosuje",
"sortowania",
"na",
"zapytaniu"
] | 95483b08f25136b8d6bcf787ec4ecc3e8bdffb38 | https://github.com/milejko/mmi-cms/blob/95483b08f25136b8d6bcf787ec4ecc3e8bdffb38/src/CmsAdmin/Grid/GridState.php#L234-L251 | train |
xdan/jodit-connector-application | src/File.php | File.isGoodFile | public function isGoodFile(Config $source) {
$info = pathinfo($this->path);
if (!isset($info['extension']) or (!in_array(strtolower($info['extension']), $source->extensions))) {
return false;
}
if (in_array(strtolower($info['extension']), $source->imageExtensions) and !$this->isImage()) {
return false;
}
return true;
} | php | public function isGoodFile(Config $source) {
$info = pathinfo($this->path);
if (!isset($info['extension']) or (!in_array(strtolower($info['extension']), $source->extensions))) {
return false;
}
if (in_array(strtolower($info['extension']), $source->imageExtensions) and !$this->isImage()) {
return false;
}
return true;
} | [
"public",
"function",
"isGoodFile",
"(",
"Config",
"$",
"source",
")",
"{",
"$",
"info",
"=",
"pathinfo",
"(",
"$",
"this",
"->",
"path",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"info",
"[",
"'extension'",
"]",
")",
"or",
"(",
"!",
"in_array",... | Check file extension
@param {Source} $source
@return bool | [
"Check",
"file",
"extension"
] | a1f8ebf2d605665fb25e737d60a62ea410358c62 | https://github.com/xdan/jodit-connector-application/blob/a1f8ebf2d605665fb25e737d60a62ea410358c62/src/File.php#L38-L50 | train |
xdan/jodit-connector-application | src/File.php | File.isImage | public function isImage() {
try {
if (!function_exists('exif_imagetype') && !function_exists('Jodit\exif_imagetype')) {
function exif_imagetype($filename) {
if ((list(, , $type) = getimagesize($filename)) !== false) {
return $type;
}
return false;
}
}
return in_array(exif_imagetype($this->getPath()), [IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG, IMAGETYPE_BMP]);
} catch (\Exception $e) {
return false;
}
} | php | public function isImage() {
try {
if (!function_exists('exif_imagetype') && !function_exists('Jodit\exif_imagetype')) {
function exif_imagetype($filename) {
if ((list(, , $type) = getimagesize($filename)) !== false) {
return $type;
}
return false;
}
}
return in_array(exif_imagetype($this->getPath()), [IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG, IMAGETYPE_BMP]);
} catch (\Exception $e) {
return false;
}
} | [
"public",
"function",
"isImage",
"(",
")",
"{",
"try",
"{",
"if",
"(",
"!",
"function_exists",
"(",
"'exif_imagetype'",
")",
"&&",
"!",
"function_exists",
"(",
"'Jodit\\exif_imagetype'",
")",
")",
"{",
"function",
"exif_imagetype",
"(",
"$",
"filename",
")",
... | Check by mimetype what file is image
@return bool | [
"Check",
"by",
"mimetype",
"what",
"file",
"is",
"image"
] | a1f8ebf2d605665fb25e737d60a62ea410358c62 | https://github.com/xdan/jodit-connector-application/blob/a1f8ebf2d605665fb25e737d60a62ea410358c62/src/File.php#L124-L140 | train |
manaphp/framework | Cli/Controllers/DbController.php | DbController.listCommand | public function listCommand($services = [], $table_pattern = '')
{
foreach ($services ?: $this->_getDbServices() as $service) {
/** @var \ManaPHP\DbInterface $db */
$db = $this->_di->getShared($service);
$this->console->writeLn(['service: `:service`', 'service' => $service], Console::FC_CYAN);
foreach ($this->_getTables($service, $table_pattern) as $row => $table) {
$columns = (array)$db->getMetadata($table)[Db::METADATA_ATTRIBUTES];
$primaryKey = $db->getMetadata($table)[Db::METADATA_PRIMARY_KEY];
foreach ($columns as $i => $column) {
if (in_array($column, $primaryKey, true)) {
$columns[$i] = $this->console->colorize($column, Console::FC_RED);
}
}
$this->console->writeLn([' :row :table(:columns)',
'row' => sprintf('%2d ', $row + 1),
'table' => $this->console->colorize($table, Console::FC_GREEN),
'columns' => implode(', ', $columns)]);
}
}
} | php | public function listCommand($services = [], $table_pattern = '')
{
foreach ($services ?: $this->_getDbServices() as $service) {
/** @var \ManaPHP\DbInterface $db */
$db = $this->_di->getShared($service);
$this->console->writeLn(['service: `:service`', 'service' => $service], Console::FC_CYAN);
foreach ($this->_getTables($service, $table_pattern) as $row => $table) {
$columns = (array)$db->getMetadata($table)[Db::METADATA_ATTRIBUTES];
$primaryKey = $db->getMetadata($table)[Db::METADATA_PRIMARY_KEY];
foreach ($columns as $i => $column) {
if (in_array($column, $primaryKey, true)) {
$columns[$i] = $this->console->colorize($column, Console::FC_RED);
}
}
$this->console->writeLn([' :row :table(:columns)',
'row' => sprintf('%2d ', $row + 1),
'table' => $this->console->colorize($table, Console::FC_GREEN),
'columns' => implode(', ', $columns)]);
}
}
} | [
"public",
"function",
"listCommand",
"(",
"$",
"services",
"=",
"[",
"]",
",",
"$",
"table_pattern",
"=",
"''",
")",
"{",
"foreach",
"(",
"$",
"services",
"?",
":",
"$",
"this",
"->",
"_getDbServices",
"(",
")",
"as",
"$",
"service",
")",
"{",
"/** @... | list databases and tables
@param array $services services name list
@param string $table_pattern match table against a pattern | [
"list",
"databases",
"and",
"tables"
] | b9a15c7f8f5d4770cacbea43f26914765bfcb248 | https://github.com/manaphp/framework/blob/b9a15c7f8f5d4770cacbea43f26914765bfcb248/Cli/Controllers/DbController.php#L203-L225 | train |
manaphp/framework | Cli/Controllers/DbController.php | DbController.modelCommand | public function modelCommand($table, $service = '', $namespace = 'App\Models', $optimized = false)
{
if (strpos($namespace, '\\') === false) {
$namespace = 'App\\' . ucfirst($namespace) . '\\Models';
}
/** @var \ManaPHP\DbInterface $db */
if ($service) {
$db = $this->_di->getShared($service);
if (!in_array($table, $db->getTables(), true)) {
throw new Exception(['`:table` is not exists', 'table' => $table]);
}
} else {
foreach ($this->_getDbServices() as $s) {
$db = $this->_di->getShared($s);
if (in_array($table, $db->getTables(), true)) {
$service = $s;
break;
}
}
if (!$service) {
throw new Exception(['`:table` is not found in services`', 'table' => $table]);
}
}
$this->console->progress(['`:table` processing...', 'table' => $table], '');
$plainClass = Text::camelize($table);
$fileName = "@tmp/db_model/$plainClass.php";
$model_str = $this->_renderModel($service, $table, $namespace, $optimized);
$this->filesystem->filePut($fileName, $model_str);
$this->console->progress(['`:table` table saved to `:file`', 'table' => $table, 'file' => $fileName]);
} | php | public function modelCommand($table, $service = '', $namespace = 'App\Models', $optimized = false)
{
if (strpos($namespace, '\\') === false) {
$namespace = 'App\\' . ucfirst($namespace) . '\\Models';
}
/** @var \ManaPHP\DbInterface $db */
if ($service) {
$db = $this->_di->getShared($service);
if (!in_array($table, $db->getTables(), true)) {
throw new Exception(['`:table` is not exists', 'table' => $table]);
}
} else {
foreach ($this->_getDbServices() as $s) {
$db = $this->_di->getShared($s);
if (in_array($table, $db->getTables(), true)) {
$service = $s;
break;
}
}
if (!$service) {
throw new Exception(['`:table` is not found in services`', 'table' => $table]);
}
}
$this->console->progress(['`:table` processing...', 'table' => $table], '');
$plainClass = Text::camelize($table);
$fileName = "@tmp/db_model/$plainClass.php";
$model_str = $this->_renderModel($service, $table, $namespace, $optimized);
$this->filesystem->filePut($fileName, $model_str);
$this->console->progress(['`:table` table saved to `:file`', 'table' => $table, 'file' => $fileName]);
} | [
"public",
"function",
"modelCommand",
"(",
"$",
"table",
",",
"$",
"service",
"=",
"''",
",",
"$",
"namespace",
"=",
"'App\\Models'",
",",
"$",
"optimized",
"=",
"false",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"namespace",
",",
"'\\\\'",
")",
"===",
... | generate model file in online
@param string $table table name
@param string $service service name
@param string $namespace
@param bool $optimized output as more methods as possible
@throws \ManaPHP\Cli\Controllers\Exception | [
"generate",
"model",
"file",
"in",
"online"
] | b9a15c7f8f5d4770cacbea43f26914765bfcb248 | https://github.com/manaphp/framework/blob/b9a15c7f8f5d4770cacbea43f26914765bfcb248/Cli/Controllers/DbController.php#L237-L270 | train |
manaphp/framework | Cli/Controllers/DbController.php | DbController.modelsCommand | public function modelsCommand($services = [], $table_pattern = '', $namespace = 'App\Models', $optimized = false)
{
if (strpos($namespace, '\\') === false) {
$namespace = 'App\\' . ucfirst($namespace) . '\\Models';
}
foreach ($services ?: $this->_getDbServices() as $service) {
foreach ($this->_getTables($service, $table_pattern) as $table) {
$this->console->progress(['`:table` processing...', 'table' => $table], '');
$plainClass = Text::camelize($table);
$fileName = "@tmp/db_models/$plainClass.php";
$model_str = $this->_renderModel($service, $table, $namespace, $optimized);
$this->filesystem->filePut($fileName, $model_str);
$this->console->progress([' `:table` table saved to `:file`', 'table' => $table, 'file' => $fileName]);
}
}
} | php | public function modelsCommand($services = [], $table_pattern = '', $namespace = 'App\Models', $optimized = false)
{
if (strpos($namespace, '\\') === false) {
$namespace = 'App\\' . ucfirst($namespace) . '\\Models';
}
foreach ($services ?: $this->_getDbServices() as $service) {
foreach ($this->_getTables($service, $table_pattern) as $table) {
$this->console->progress(['`:table` processing...', 'table' => $table], '');
$plainClass = Text::camelize($table);
$fileName = "@tmp/db_models/$plainClass.php";
$model_str = $this->_renderModel($service, $table, $namespace, $optimized);
$this->filesystem->filePut($fileName, $model_str);
$this->console->progress([' `:table` table saved to `:file`', 'table' => $table, 'file' => $fileName]);
}
}
} | [
"public",
"function",
"modelsCommand",
"(",
"$",
"services",
"=",
"[",
"]",
",",
"$",
"table_pattern",
"=",
"''",
",",
"$",
"namespace",
"=",
"'App\\Models'",
",",
"$",
"optimized",
"=",
"false",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"namespace",
",... | generate models file in online
@param array $services services name list
@param string $table_pattern match table against a pattern
@param string $namespace namespace of models
@param bool $optimized output as more methods as possible | [
"generate",
"models",
"file",
"in",
"online"
] | b9a15c7f8f5d4770cacbea43f26914765bfcb248 | https://github.com/manaphp/framework/blob/b9a15c7f8f5d4770cacbea43f26914765bfcb248/Cli/Controllers/DbController.php#L280-L298 | train |
Ma27/Ma27ApiKeyAuthenticationBundle | Service/Mapping/Driver/AnnotationDriver.php | AnnotationDriver.isMetadataFullyLoaded | private function isMetadataFullyLoaded(array $metadata)
{
return $metadata[ClassMetadata::LOGIN_PROPERTY]
&& $metadata[ClassMetadata::PASSWORD_PROPERTY]
&& $metadata[ClassMetadata::API_KEY_PROPERTY]
&& $metadata[ClassMetadata::LAST_ACTION_PROPERTY];
} | php | private function isMetadataFullyLoaded(array $metadata)
{
return $metadata[ClassMetadata::LOGIN_PROPERTY]
&& $metadata[ClassMetadata::PASSWORD_PROPERTY]
&& $metadata[ClassMetadata::API_KEY_PROPERTY]
&& $metadata[ClassMetadata::LAST_ACTION_PROPERTY];
} | [
"private",
"function",
"isMetadataFullyLoaded",
"(",
"array",
"$",
"metadata",
")",
"{",
"return",
"$",
"metadata",
"[",
"ClassMetadata",
"::",
"LOGIN_PROPERTY",
"]",
"&&",
"$",
"metadata",
"[",
"ClassMetadata",
"::",
"PASSWORD_PROPERTY",
"]",
"&&",
"$",
"metada... | Method which checks if all metadata annotations were loaded already.
@param object[] $metadata
@return bool | [
"Method",
"which",
"checks",
"if",
"all",
"metadata",
"annotations",
"were",
"loaded",
"already",
"."
] | 3f1e2ea6eacefac0db41b2ad964c8ef262f0e408 | https://github.com/Ma27/Ma27ApiKeyAuthenticationBundle/blob/3f1e2ea6eacefac0db41b2ad964c8ef262f0e408/Service/Mapping/Driver/AnnotationDriver.php#L127-L133 | train |
milejko/mmi-cms | src/Cms/Model/Navigation.php | Navigation.decorateConfiguration | public function decorateConfiguration(\Mmi\Navigation\NavigationConfig $config)
{
$objectArray = (new CmsCategoryQuery)
->lang()
->andFieldStatus()->equals(\Cms\Orm\CmsCategoryRecord::STATUS_ACTIVE)
->orderAscParentId()
->orderAscOrder()
->find()
->toObjectArray();
foreach ($objectArray as $key => $record) {/* @var $record CmsCategoryRecord */
if ($record->parentId != 0) {
continue;
}
$element = new \Mmi\Navigation\NavigationConfigElement($record->uri);
$this->_setNavigationElementFromRecord($record, $element);
$config->addElement($element);
unset($objectArray[$key]);
$this->_buildChildren($record, $element, $objectArray);
}
} | php | public function decorateConfiguration(\Mmi\Navigation\NavigationConfig $config)
{
$objectArray = (new CmsCategoryQuery)
->lang()
->andFieldStatus()->equals(\Cms\Orm\CmsCategoryRecord::STATUS_ACTIVE)
->orderAscParentId()
->orderAscOrder()
->find()
->toObjectArray();
foreach ($objectArray as $key => $record) {/* @var $record CmsCategoryRecord */
if ($record->parentId != 0) {
continue;
}
$element = new \Mmi\Navigation\NavigationConfigElement($record->uri);
$this->_setNavigationElementFromRecord($record, $element);
$config->addElement($element);
unset($objectArray[$key]);
$this->_buildChildren($record, $element, $objectArray);
}
} | [
"public",
"function",
"decorateConfiguration",
"(",
"\\",
"Mmi",
"\\",
"Navigation",
"\\",
"NavigationConfig",
"$",
"config",
")",
"{",
"$",
"objectArray",
"=",
"(",
"new",
"CmsCategoryQuery",
")",
"->",
"lang",
"(",
")",
"->",
"andFieldStatus",
"(",
")",
"-... | Dodaje do konfiguracji dane z bazy danych
@param \Mmi\Navigation\NavigationConfig $config | [
"Dodaje",
"do",
"konfiguracji",
"dane",
"z",
"bazy",
"danych"
] | 95483b08f25136b8d6bcf787ec4ecc3e8bdffb38 | https://github.com/milejko/mmi-cms/blob/95483b08f25136b8d6bcf787ec4ecc3e8bdffb38/src/Cms/Model/Navigation.php#L45-L64 | train |
milejko/mmi-cms | src/Cms/Model/Navigation.php | Navigation._setNavigationElementFromRecord | protected function _setNavigationElementFromRecord(CmsCategoryRecord $record, \Mmi\Navigation\NavigationConfigElement $element)
{
$params = [];
parse_str($record->mvcParams, $params);
$params['uri'] = $record->customUri ? $record->customUri : $record->uri;
$config = $record->getConfig();
$config->typeId = $record->cmsCategoryTypeId;
$config->categoryId = $record->id;
$element
->setModule('cms')
->setController('category')
->setAction('dispatch')
->setParams($params)
->setBlank($record->blank ? true : false)
->setDisabled($record->active ? false : true)
->setHttps($record->https)
->setUri($record->redirectUri ? : null)
->setLabel($record->name)
->setLang($record->lang)
->setFollow($record->follow ? true : false)
->setConfig($config)
->setDateStart($record->dateStart)
->setDateEnd($record->dateEnd);
if ($record->title) {
$element->setTitle($record->title);
}
if ($record->description) {
$element->setDescription($record->description);
}
return $this->_setNavigationElementRoles($record, $element);
} | php | protected function _setNavigationElementFromRecord(CmsCategoryRecord $record, \Mmi\Navigation\NavigationConfigElement $element)
{
$params = [];
parse_str($record->mvcParams, $params);
$params['uri'] = $record->customUri ? $record->customUri : $record->uri;
$config = $record->getConfig();
$config->typeId = $record->cmsCategoryTypeId;
$config->categoryId = $record->id;
$element
->setModule('cms')
->setController('category')
->setAction('dispatch')
->setParams($params)
->setBlank($record->blank ? true : false)
->setDisabled($record->active ? false : true)
->setHttps($record->https)
->setUri($record->redirectUri ? : null)
->setLabel($record->name)
->setLang($record->lang)
->setFollow($record->follow ? true : false)
->setConfig($config)
->setDateStart($record->dateStart)
->setDateEnd($record->dateEnd);
if ($record->title) {
$element->setTitle($record->title);
}
if ($record->description) {
$element->setDescription($record->description);
}
return $this->_setNavigationElementRoles($record, $element);
} | [
"protected",
"function",
"_setNavigationElementFromRecord",
"(",
"CmsCategoryRecord",
"$",
"record",
",",
"\\",
"Mmi",
"\\",
"Navigation",
"\\",
"NavigationConfigElement",
"$",
"element",
")",
"{",
"$",
"params",
"=",
"[",
"]",
";",
"parse_str",
"(",
"$",
"recor... | Ustawia dane elementu nawigacji na podstawie rekordu kategorii
@param \Cms\Orm\CmsCategoryRecord $record
@param \Mmi\Navigation\NavigationConfigElement $element
@return \Mmi\Navigation\NavigationConfigElement | [
"Ustawia",
"dane",
"elementu",
"nawigacji",
"na",
"podstawie",
"rekordu",
"kategorii"
] | 95483b08f25136b8d6bcf787ec4ecc3e8bdffb38 | https://github.com/milejko/mmi-cms/blob/95483b08f25136b8d6bcf787ec4ecc3e8bdffb38/src/Cms/Model/Navigation.php#L112-L142 | train |
GromNaN/TubeLink | src/TubeLink/Tube.php | Tube.render | public function render(array $options = array())
{
$url = $this->service->generateEmbedUrl($this);
$options = array_replace(array(
'width' => 560,
'height' => 315,
'frameborder' => 0,
'allowfullscreen' => ''
), $options);
$html = <<<HTML
<iframe src="$url" width="{$options['width']}" height="{$options['height']}" frameborder="{$options['frameborder']}" {$options['allowfullscreen']}></iframe>
HTML;
return $html;
} | php | public function render(array $options = array())
{
$url = $this->service->generateEmbedUrl($this);
$options = array_replace(array(
'width' => 560,
'height' => 315,
'frameborder' => 0,
'allowfullscreen' => ''
), $options);
$html = <<<HTML
<iframe src="$url" width="{$options['width']}" height="{$options['height']}" frameborder="{$options['frameborder']}" {$options['allowfullscreen']}></iframe>
HTML;
return $html;
} | [
"public",
"function",
"render",
"(",
"array",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"service",
"->",
"generateEmbedUrl",
"(",
"$",
"this",
")",
";",
"$",
"options",
"=",
"array_replace",
"(",
"array",
"... | Render the HTML for the embedded video player
@return string | [
"Render",
"the",
"HTML",
"for",
"the",
"embedded",
"video",
"player"
] | a1d9bdd0c92b043d297b95e8069a5b30ceaded9a | https://github.com/GromNaN/TubeLink/blob/a1d9bdd0c92b043d297b95e8069a5b30ceaded9a/src/TubeLink/Tube.php#L42-L56 | train |
milejko/mmi-cms | src/Cms/Model/Cron.php | Cron.run | public static function run()
{
foreach (Orm\CmsCronQuery::active()->find() as $cron) {
if (!self::_getToExecute($cron)) {
continue;
}
$output = '';
try {
$start = microtime(true);
$output = \Mmi\Mvc\ActionHelper::getInstance()->action(new \Mmi\Http\Request(['module' => $cron->module, 'controller' => $cron->controller, 'action' => $cron->action]));
$elapsed = round(microtime(true) - $start, 2);
} catch (\Exception $e) {
//error logging
\Mmi\App\FrontController::getInstance()->getLogger()->error('CRON failed: @' . gethostname() . $cron->name . ' ' . $e->getMessage());
return;
}
//zmień datę ostatniego wywołania
$cron->dateLastExecute = date('Y-m-d H:i:s');
//ponowne łączenie
\App\Registry::$db->connect();
//zapis do bazy bez modyfikowania daty ostatniej modyfikacji
$cron->saveWithoutLastDateModify();
//logowanie uruchomienia
\Mmi\App\FrontController::getInstance()->getLogger()->info('CRON done: @' . gethostname() . ' ' . $cron->name . ' ' . $output . ' in ' . $elapsed . 's');
}
} | php | public static function run()
{
foreach (Orm\CmsCronQuery::active()->find() as $cron) {
if (!self::_getToExecute($cron)) {
continue;
}
$output = '';
try {
$start = microtime(true);
$output = \Mmi\Mvc\ActionHelper::getInstance()->action(new \Mmi\Http\Request(['module' => $cron->module, 'controller' => $cron->controller, 'action' => $cron->action]));
$elapsed = round(microtime(true) - $start, 2);
} catch (\Exception $e) {
//error logging
\Mmi\App\FrontController::getInstance()->getLogger()->error('CRON failed: @' . gethostname() . $cron->name . ' ' . $e->getMessage());
return;
}
//zmień datę ostatniego wywołania
$cron->dateLastExecute = date('Y-m-d H:i:s');
//ponowne łączenie
\App\Registry::$db->connect();
//zapis do bazy bez modyfikowania daty ostatniej modyfikacji
$cron->saveWithoutLastDateModify();
//logowanie uruchomienia
\Mmi\App\FrontController::getInstance()->getLogger()->info('CRON done: @' . gethostname() . ' ' . $cron->name . ' ' . $output . ' in ' . $elapsed . 's');
}
} | [
"public",
"static",
"function",
"run",
"(",
")",
"{",
"foreach",
"(",
"Orm",
"\\",
"CmsCronQuery",
"::",
"active",
"(",
")",
"->",
"find",
"(",
")",
"as",
"$",
"cron",
")",
"{",
"if",
"(",
"!",
"self",
"::",
"_getToExecute",
"(",
"$",
"cron",
")",
... | Pobiera zadania crona | [
"Pobiera",
"zadania",
"crona"
] | 95483b08f25136b8d6bcf787ec4ecc3e8bdffb38 | https://github.com/milejko/mmi-cms/blob/95483b08f25136b8d6bcf787ec4ecc3e8bdffb38/src/Cms/Model/Cron.php#L21-L46 | train |
milejko/mmi-cms | src/Cms/Model/Cron.php | Cron._getToExecute | protected static function _getToExecute($record)
{
return self::_valueMatch(date('i'), $record->minute) &&
self::_valueMatch(date('H'), $record->hour) &&
self::_valueMatch(date('d'), $record->dayOfMonth) &&
self::_valueMatch(date('m'), $record->month) &&
self::_valueMatch(date('N'), $record->dayOfWeek);
} | php | protected static function _getToExecute($record)
{
return self::_valueMatch(date('i'), $record->minute) &&
self::_valueMatch(date('H'), $record->hour) &&
self::_valueMatch(date('d'), $record->dayOfMonth) &&
self::_valueMatch(date('m'), $record->month) &&
self::_valueMatch(date('N'), $record->dayOfWeek);
} | [
"protected",
"static",
"function",
"_getToExecute",
"(",
"$",
"record",
")",
"{",
"return",
"self",
"::",
"_valueMatch",
"(",
"date",
"(",
"'i'",
")",
",",
"$",
"record",
"->",
"minute",
")",
"&&",
"self",
"::",
"_valueMatch",
"(",
"date",
"(",
"'H'",
... | Sprawdza czy dane zadanie jest do wykonania
@param \Cms\Orm\CmsCronRecord $record | [
"Sprawdza",
"czy",
"dane",
"zadanie",
"jest",
"do",
"wykonania"
] | 95483b08f25136b8d6bcf787ec4ecc3e8bdffb38 | https://github.com/milejko/mmi-cms/blob/95483b08f25136b8d6bcf787ec4ecc3e8bdffb38/src/Cms/Model/Cron.php#L52-L59 | train |
mapbender/fom | src/FOM/UserBundle/Controller/GroupController.php | GroupController.indexAction | public function indexAction() {
$oid = new ObjectIdentity('class', 'FOM\UserBundle\Entity\Group');
$query = $this->getDoctrine()->getManager()->createQuery('SELECT g FROM FOMUserBundle:Group g');
$groups = $query->getResult();
$allowed_groups = array();
// ACL access check
foreach($groups as $index => $group) {
if($this->get('security.authorization_checker')->isGranted('VIEW', $group)) {
$allowed_groups[] = $group;
}
}
return array(
'groups' => $allowed_groups,
'create_permission' => $this->get('security.authorization_checker')->isGranted('CREATE', $oid)
);
} | php | public function indexAction() {
$oid = new ObjectIdentity('class', 'FOM\UserBundle\Entity\Group');
$query = $this->getDoctrine()->getManager()->createQuery('SELECT g FROM FOMUserBundle:Group g');
$groups = $query->getResult();
$allowed_groups = array();
// ACL access check
foreach($groups as $index => $group) {
if($this->get('security.authorization_checker')->isGranted('VIEW', $group)) {
$allowed_groups[] = $group;
}
}
return array(
'groups' => $allowed_groups,
'create_permission' => $this->get('security.authorization_checker')->isGranted('CREATE', $oid)
);
} | [
"public",
"function",
"indexAction",
"(",
")",
"{",
"$",
"oid",
"=",
"new",
"ObjectIdentity",
"(",
"'class'",
",",
"'FOM\\UserBundle\\Entity\\Group'",
")",
";",
"$",
"query",
"=",
"$",
"this",
"->",
"getDoctrine",
"(",
")",
"->",
"getManager",
"(",
")",
"-... | Renders group list.
@Route("/group")
@Method({ "GET" })
@Template | [
"Renders",
"group",
"list",
"."
] | 6dea943121f3c3f9b1b4b14dc2a8e8640a120675 | https://github.com/mapbender/fom/blob/6dea943121f3c3f9b1b4b14dc2a8e8640a120675/src/FOM/UserBundle/Controller/GroupController.php#L31-L48 | train |
fezfez/codeGenerator | src/CrudGenerator/Metadata/Sources/Oracle/OracleMetaDataDAOFactory.php | OracleMetaDataDAOFactory.getInstance | public static function getInstance(DriverConfig $config)
{
$pdoDriver = PdoDriverFactory::getInstance();
return new OracleMetaDataDAO(
$pdoDriver->getConnection($config)
);
} | php | public static function getInstance(DriverConfig $config)
{
$pdoDriver = PdoDriverFactory::getInstance();
return new OracleMetaDataDAO(
$pdoDriver->getConnection($config)
);
} | [
"public",
"static",
"function",
"getInstance",
"(",
"DriverConfig",
"$",
"config",
")",
"{",
"$",
"pdoDriver",
"=",
"PdoDriverFactory",
"::",
"getInstance",
"(",
")",
";",
"return",
"new",
"OracleMetaDataDAO",
"(",
"$",
"pdoDriver",
"->",
"getConnection",
"(",
... | Create PDO Metadata DAO instance
@param DriverConfig $config
@return OracleMetaDataDAO | [
"Create",
"PDO",
"Metadata",
"DAO",
"instance"
] | 559f22bcc525c3157ecb17fe96818dd7b7ee58c2 | https://github.com/fezfez/codeGenerator/blob/559f22bcc525c3157ecb17fe96818dd7b7ee58c2/src/CrudGenerator/Metadata/Sources/Oracle/OracleMetaDataDAOFactory.php#L30-L37 | train |
xdan/jodit-connector-application | src/Config.php | Config.getSource | public function getSource($sourceName = null) {
if ($sourceName === 'default') {
$sourceName = null;
}
foreach ($this->sources as $key => $item) {
if ((!$sourceName || $sourceName === $key)) {
return $item;
}
$source = $item !== $this ? $item->getSource($sourceName) : null;
if ($source) {
return $source;
}
}
if ($sourceName) {
return null;
}
return $this;
} | php | public function getSource($sourceName = null) {
if ($sourceName === 'default') {
$sourceName = null;
}
foreach ($this->sources as $key => $item) {
if ((!$sourceName || $sourceName === $key)) {
return $item;
}
$source = $item !== $this ? $item->getSource($sourceName) : null;
if ($source) {
return $source;
}
}
if ($sourceName) {
return null;
}
return $this;
} | [
"public",
"function",
"getSource",
"(",
"$",
"sourceName",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"sourceName",
"===",
"'default'",
")",
"{",
"$",
"sourceName",
"=",
"null",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"sources",
"as",
"$",
"key",
"=... | Get source by name
@param string $sourceName
@return \Jodit\Config | null | [
"Get",
"source",
"by",
"name"
] | a1f8ebf2d605665fb25e737d60a62ea410358c62 | https://github.com/xdan/jodit-connector-application/blob/a1f8ebf2d605665fb25e737d60a62ea410358c62/src/Config.php#L170-L192 | train |
brightnucleus/boilerplate | _scripts/SetupHelper.php | SetupHelper.getRootFolder | public static function getRootFolder()
{
$filesystem = new Filesystem();
$folder = $filesystem->normalizePath(__DIR__ . '/../');
if (! is_dir($folder)) {
throw new RuntimeException(
sprintf(
'Could not find a matching folder for folder name "%1$s".',
$folder
)
);
}
return $folder;
} | php | public static function getRootFolder()
{
$filesystem = new Filesystem();
$folder = $filesystem->normalizePath(__DIR__ . '/../');
if (! is_dir($folder)) {
throw new RuntimeException(
sprintf(
'Could not find a matching folder for folder name "%1$s".',
$folder
)
);
}
return $folder;
} | [
"public",
"static",
"function",
"getRootFolder",
"(",
")",
"{",
"$",
"filesystem",
"=",
"new",
"Filesystem",
"(",
")",
";",
"$",
"folder",
"=",
"$",
"filesystem",
"->",
"normalizePath",
"(",
"__DIR__",
".",
"'/../'",
")",
";",
"if",
"(",
"!",
"is_dir",
... | Get the path to the package's root folder.
@since 0.1.0
@return string Complete path to the root folder.
@throws RuntimeException If the folder could not be matched. | [
"Get",
"the",
"path",
"to",
"the",
"package",
"s",
"root",
"folder",
"."
] | 27092790349481e1bece8f79eaccaa15cc35d845 | https://github.com/brightnucleus/boilerplate/blob/27092790349481e1bece8f79eaccaa15cc35d845/_scripts/SetupHelper.php#L107-L122 | train |
brightnucleus/boilerplate | _scripts/SetupHelper.php | SetupHelper.getFile | public static function getFile($fileName)
{
$filesystem = new Filesystem();
$file = $filesystem->normalizePath(__DIR__ . '/../' . $fileName);
if (! file_exists($file)) {
throw new RuntimeException(
sprintf(
'Could not find a matching file for file name "%1$s".',
$fileName
)
);
}
return $file;
} | php | public static function getFile($fileName)
{
$filesystem = new Filesystem();
$file = $filesystem->normalizePath(__DIR__ . '/../' . $fileName);
if (! file_exists($file)) {
throw new RuntimeException(
sprintf(
'Could not find a matching file for file name "%1$s".',
$fileName
)
);
}
return $file;
} | [
"public",
"static",
"function",
"getFile",
"(",
"$",
"fileName",
")",
"{",
"$",
"filesystem",
"=",
"new",
"Filesystem",
"(",
")",
";",
"$",
"file",
"=",
"$",
"filesystem",
"->",
"normalizePath",
"(",
"__DIR__",
".",
"'/../'",
".",
"$",
"fileName",
")",
... | Get a file path from a project-root-relative file name.
@since 0.1.0
@param string $fileName Project-root-relative file name to get the path of.
@return string Complete path to the requested file.
@throws RuntimeException If the file could not be matched. | [
"Get",
"a",
"file",
"path",
"from",
"a",
"project",
"-",
"root",
"-",
"relative",
"file",
"name",
"."
] | 27092790349481e1bece8f79eaccaa15cc35d845 | https://github.com/brightnucleus/boilerplate/blob/27092790349481e1bece8f79eaccaa15cc35d845/_scripts/SetupHelper.php#L134-L149 | train |
webfactory/symfony-application-tests | src/Webfactory/Util/ServiceCreator.php | ServiceCreator.create | public function create($serviceId)
{
try {
return $this->container->get($serviceId, Container::NULL_ON_INVALID_REFERENCE);
} catch (\Exception $e) {
if ($this->isCausedBySyntheticServiceRequest($e)) {
// Ignore errors that are caused by synthetic services. It is simply not
// possible to create them in a reliable way.
return null;
}
throw new CannotInstantiateServiceException($serviceId, 0, $e);
}
} | php | public function create($serviceId)
{
try {
return $this->container->get($serviceId, Container::NULL_ON_INVALID_REFERENCE);
} catch (\Exception $e) {
if ($this->isCausedBySyntheticServiceRequest($e)) {
// Ignore errors that are caused by synthetic services. It is simply not
// possible to create them in a reliable way.
return null;
}
throw new CannotInstantiateServiceException($serviceId, 0, $e);
}
} | [
"public",
"function",
"create",
"(",
"$",
"serviceId",
")",
"{",
"try",
"{",
"return",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"$",
"serviceId",
",",
"Container",
"::",
"NULL_ON_INVALID_REFERENCE",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
... | Creates the service with the given ID.
@param string $serviceId
@return object|null The service object or null if it cannot be created (for comprehensible reasons).
@throws CannotInstantiateServiceException If it is not possible to create the service. | [
"Creates",
"the",
"service",
"with",
"the",
"given",
"ID",
"."
] | 971c0d45c46dc20323535940fc0d1cc7eafaf553 | https://github.com/webfactory/symfony-application-tests/blob/971c0d45c46dc20323535940fc0d1cc7eafaf553/src/Webfactory/Util/ServiceCreator.php#L40-L52 | train |
webfactory/symfony-application-tests | src/Webfactory/Util/ServiceCreator.php | ServiceCreator.isCausedBySyntheticServiceRequest | protected function isCausedBySyntheticServiceRequest(\Exception $exception)
{
if (!($exception instanceof RuntimeException)) {
return false;
}
return strpos($exception->getMessage(), 'requested a synthetic service') !== false;
} | php | protected function isCausedBySyntheticServiceRequest(\Exception $exception)
{
if (!($exception instanceof RuntimeException)) {
return false;
}
return strpos($exception->getMessage(), 'requested a synthetic service') !== false;
} | [
"protected",
"function",
"isCausedBySyntheticServiceRequest",
"(",
"\\",
"Exception",
"$",
"exception",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"exception",
"instanceof",
"RuntimeException",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"strpos",
"(",
"$",... | Checks if a request for a synthetic service caused the provided exception.
@param \Exception $exception
@return boolean | [
"Checks",
"if",
"a",
"request",
"for",
"a",
"synthetic",
"service",
"caused",
"the",
"provided",
"exception",
"."
] | 971c0d45c46dc20323535940fc0d1cc7eafaf553 | https://github.com/webfactory/symfony-application-tests/blob/971c0d45c46dc20323535940fc0d1cc7eafaf553/src/Webfactory/Util/ServiceCreator.php#L60-L66 | train |
manaphp/framework | Router.php | Router._addRoute | protected function _addRoute($pattern, $paths = null, $method = null)
{
$route = new Route($pattern, $paths, $method);
if ($method !== 'REST' && strpos($pattern, '{') === false) {
$this->_simple_routes[$method][$pattern] = $route;
} else {
$this->_regex_routes[] = $route;
}
return $route;
} | php | protected function _addRoute($pattern, $paths = null, $method = null)
{
$route = new Route($pattern, $paths, $method);
if ($method !== 'REST' && strpos($pattern, '{') === false) {
$this->_simple_routes[$method][$pattern] = $route;
} else {
$this->_regex_routes[] = $route;
}
return $route;
} | [
"protected",
"function",
"_addRoute",
"(",
"$",
"pattern",
",",
"$",
"paths",
"=",
"null",
",",
"$",
"method",
"=",
"null",
")",
"{",
"$",
"route",
"=",
"new",
"Route",
"(",
"$",
"pattern",
",",
"$",
"paths",
",",
"$",
"method",
")",
";",
"if",
"... | Adds a route applying the common attributes
@param string $pattern
@param string|array $paths
@param string $method
@return \ManaPHP\Router\RouteInterface | [
"Adds",
"a",
"route",
"applying",
"the",
"common",
"attributes"
] | b9a15c7f8f5d4770cacbea43f26914765bfcb248 | https://github.com/manaphp/framework/blob/b9a15c7f8f5d4770cacbea43f26914765bfcb248/Router.php#L147-L157 | train |
manaphp/framework | Router.php | Router.add | public function add($pattern, $paths = null, $method = null)
{
return $this->_addRoute($pattern, $paths, $method);
} | php | public function add($pattern, $paths = null, $method = null)
{
return $this->_addRoute($pattern, $paths, $method);
} | [
"public",
"function",
"add",
"(",
"$",
"pattern",
",",
"$",
"paths",
"=",
"null",
",",
"$",
"method",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"_addRoute",
"(",
"$",
"pattern",
",",
"$",
"paths",
",",
"$",
"method",
")",
";",
"}"
] | Adds a route to the router on any HTTP method
@param string $pattern
@param string|array $paths
@param string|array $method
@return \ManaPHP\Router\RouteInterface | [
"Adds",
"a",
"route",
"to",
"the",
"router",
"on",
"any",
"HTTP",
"method"
] | b9a15c7f8f5d4770cacbea43f26914765bfcb248 | https://github.com/manaphp/framework/blob/b9a15c7f8f5d4770cacbea43f26914765bfcb248/Router.php#L168-L171 | train |
Ma27/Ma27ApiKeyAuthenticationBundle | Security/ApiKeyAuthenticator.php | ApiKeyAuthenticator.authenticateToken | public function authenticateToken(TokenInterface $token, UserProviderInterface $userProvider, $providerKey)
{
$apiKey = $token->getCredentials();
$user = $this
->om
->getRepository($this->modelName)
->findOneBy(array($this->metadata->getPropertyName(ClassMetadata::API_KEY_PROPERTY) => (string) $apiKey));
if (!$user) {
$this->dispatcher->dispatch(Ma27ApiKeyAuthenticationEvents::FIREWALL_FAILURE, new OnFirewallFailureEvent());
throw new AuthenticationException(
sprintf('API key %s does not exist!', $apiKey)
);
}
$token = new PreAuthenticatedToken(
$user,
$apiKey,
$providerKey,
$user->getRoles() ?: array()
);
$firewallEvent = new OnFirewallAuthenticationEvent($user);
$firewallEvent->setToken($token);
$this->dispatcher->dispatch(Ma27ApiKeyAuthenticationEvents::FIREWALL_LOGIN, $firewallEvent);
return $token;
} | php | public function authenticateToken(TokenInterface $token, UserProviderInterface $userProvider, $providerKey)
{
$apiKey = $token->getCredentials();
$user = $this
->om
->getRepository($this->modelName)
->findOneBy(array($this->metadata->getPropertyName(ClassMetadata::API_KEY_PROPERTY) => (string) $apiKey));
if (!$user) {
$this->dispatcher->dispatch(Ma27ApiKeyAuthenticationEvents::FIREWALL_FAILURE, new OnFirewallFailureEvent());
throw new AuthenticationException(
sprintf('API key %s does not exist!', $apiKey)
);
}
$token = new PreAuthenticatedToken(
$user,
$apiKey,
$providerKey,
$user->getRoles() ?: array()
);
$firewallEvent = new OnFirewallAuthenticationEvent($user);
$firewallEvent->setToken($token);
$this->dispatcher->dispatch(Ma27ApiKeyAuthenticationEvents::FIREWALL_LOGIN, $firewallEvent);
return $token;
} | [
"public",
"function",
"authenticateToken",
"(",
"TokenInterface",
"$",
"token",
",",
"UserProviderInterface",
"$",
"userProvider",
",",
"$",
"providerKey",
")",
"{",
"$",
"apiKey",
"=",
"$",
"token",
"->",
"getCredentials",
"(",
")",
";",
"$",
"user",
"=",
"... | Returns an authenticated token.
@param TokenInterface $token
@param UserProviderInterface $userProvider
@param string $providerKey
@throws AuthenticationException If the api key does not exist or is invalid
@throws \RuntimeException If $userProvider is not an instance of AdvancedUserProviderInterface
@return PreAuthenticatedToken | [
"Returns",
"an",
"authenticated",
"token",
"."
] | 3f1e2ea6eacefac0db41b2ad964c8ef262f0e408 | https://github.com/Ma27/Ma27ApiKeyAuthenticationBundle/blob/3f1e2ea6eacefac0db41b2ad964c8ef262f0e408/Security/ApiKeyAuthenticator.php#L89-L119 | train |
Ma27/Ma27ApiKeyAuthenticationBundle | Security/ApiKeyAuthenticator.php | ApiKeyAuthenticator.createToken | public function createToken(Request $request, $providerKey)
{
$apiKey = $request->headers->get($this->header);
if (!$apiKey) {
throw new BadCredentialsException('No ApiKey found in request!');
}
return new PreAuthenticatedToken(
'unauthorized',
$apiKey,
$providerKey
);
} | php | public function createToken(Request $request, $providerKey)
{
$apiKey = $request->headers->get($this->header);
if (!$apiKey) {
throw new BadCredentialsException('No ApiKey found in request!');
}
return new PreAuthenticatedToken(
'unauthorized',
$apiKey,
$providerKey
);
} | [
"public",
"function",
"createToken",
"(",
"Request",
"$",
"request",
",",
"$",
"providerKey",
")",
"{",
"$",
"apiKey",
"=",
"$",
"request",
"->",
"headers",
"->",
"get",
"(",
"$",
"this",
"->",
"header",
")",
";",
"if",
"(",
"!",
"$",
"apiKey",
")",
... | Creates an api key by the http request.
@param Request $request
@param string $providerKey
@throws BadCredentialsException If the request token cannot be found
@return PreAuthenticatedToken | [
"Creates",
"an",
"api",
"key",
"by",
"the",
"http",
"request",
"."
] | 3f1e2ea6eacefac0db41b2ad964c8ef262f0e408 | https://github.com/Ma27/Ma27ApiKeyAuthenticationBundle/blob/3f1e2ea6eacefac0db41b2ad964c8ef262f0e408/Security/ApiKeyAuthenticator.php#L144-L157 | train |
fezfez/codeGenerator | src/CrudGenerator/View/ViewFactory.php | ViewFactory.getInstance | public static function getInstance()
{
$classAwake = new ClassAwake();
$viewHelpers = $classAwake->wakeByInterfaces(
array(
__DIR__,
),
'CrudGenerator\View\ViewHelperFactoryInterface'
);
return new View(new ViewRenderer($viewHelpers));
} | php | public static function getInstance()
{
$classAwake = new ClassAwake();
$viewHelpers = $classAwake->wakeByInterfaces(
array(
__DIR__,
),
'CrudGenerator\View\ViewHelperFactoryInterface'
);
return new View(new ViewRenderer($viewHelpers));
} | [
"public",
"static",
"function",
"getInstance",
"(",
")",
"{",
"$",
"classAwake",
"=",
"new",
"ClassAwake",
"(",
")",
";",
"$",
"viewHelpers",
"=",
"$",
"classAwake",
"->",
"wakeByInterfaces",
"(",
"array",
"(",
"__DIR__",
",",
")",
",",
"'CrudGenerator\\View... | Build a View manager
@return View | [
"Build",
"a",
"View",
"manager"
] | 559f22bcc525c3157ecb17fe96818dd7b7ee58c2 | https://github.com/fezfez/codeGenerator/blob/559f22bcc525c3157ecb17fe96818dd7b7ee58c2/src/CrudGenerator/View/ViewFactory.php#L26-L37 | train |
milejko/mmi-cms | src/CmsAdmin/AttributeController.php | AttributeController.deleteAttributeRelationAction | public function deleteAttributeRelationAction()
{
//wyszukiwanie rekordu relacji
$record = (new \Cms\Orm\CmsAttributeRelationQuery)
->whereObjectId()->equals($this->id)
->findPk($this->relationId);
//jeśli znaleziono rekord
if ($record && $record->delete()) {
//wyszukiwanie stron w zmienionym szablonie
foreach ((new \Cms\Orm\CmsCategoryQuery)->whereCmsCategoryTypeId()
->equals($this->id)
->findPairs('id', 'id') as $categoryId) {
//usuwanie wartości usuniętych atrybutów
(new \Cms\Model\AttributeValueRelationModel('category', $categoryId))
->deleteAttributeValueRelationsByAttributeId($record->cmsAttributeId);
}
$this->getMessenger()->addMessage('messenger.attribute.attributeRelation.deleted', true);
}
} | php | public function deleteAttributeRelationAction()
{
//wyszukiwanie rekordu relacji
$record = (new \Cms\Orm\CmsAttributeRelationQuery)
->whereObjectId()->equals($this->id)
->findPk($this->relationId);
//jeśli znaleziono rekord
if ($record && $record->delete()) {
//wyszukiwanie stron w zmienionym szablonie
foreach ((new \Cms\Orm\CmsCategoryQuery)->whereCmsCategoryTypeId()
->equals($this->id)
->findPairs('id', 'id') as $categoryId) {
//usuwanie wartości usuniętych atrybutów
(new \Cms\Model\AttributeValueRelationModel('category', $categoryId))
->deleteAttributeValueRelationsByAttributeId($record->cmsAttributeId);
}
$this->getMessenger()->addMessage('messenger.attribute.attributeRelation.deleted', true);
}
} | [
"public",
"function",
"deleteAttributeRelationAction",
"(",
")",
"{",
"//wyszukiwanie rekordu relacji",
"$",
"record",
"=",
"(",
"new",
"\\",
"Cms",
"\\",
"Orm",
"\\",
"CmsAttributeRelationQuery",
")",
"->",
"whereObjectId",
"(",
")",
"->",
"equals",
"(",
"$",
"... | Usuwanie relacji szablon atrybut | [
"Usuwanie",
"relacji",
"szablon",
"atrybut"
] | 95483b08f25136b8d6bcf787ec4ecc3e8bdffb38 | https://github.com/milejko/mmi-cms/blob/95483b08f25136b8d6bcf787ec4ecc3e8bdffb38/src/CmsAdmin/AttributeController.php#L75-L93 | train |
stanislav-web/Searcher | src/Searcher/Validator.php | Validator.verify | public function verify($data, array $callbacks = [], $cast = '')
{
if (empty($callbacks) === true) {
return $this->fields[$cast] = $data;
}
// Create a Closure
$isValid = function ($data) use ($callbacks, $cast) {
if (empty($cast) === false) {
$this->cast = $cast;
}
foreach ($callbacks as $callback) {
$this->{$callback}($data);
}
};
// return boolean as such
return $isValid($data);
} | php | public function verify($data, array $callbacks = [], $cast = '')
{
if (empty($callbacks) === true) {
return $this->fields[$cast] = $data;
}
// Create a Closure
$isValid = function ($data) use ($callbacks, $cast) {
if (empty($cast) === false) {
$this->cast = $cast;
}
foreach ($callbacks as $callback) {
$this->{$callback}($data);
}
};
// return boolean as such
return $isValid($data);
} | [
"public",
"function",
"verify",
"(",
"$",
"data",
",",
"array",
"$",
"callbacks",
"=",
"[",
"]",
",",
"$",
"cast",
"=",
"''",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"callbacks",
")",
"===",
"true",
")",
"{",
"return",
"$",
"this",
"->",
"fields"... | Verify transferred according to the rules
@param mixed $data
@param array $callbacks
@param string $cast
@return mixed | [
"Verify",
"transferred",
"according",
"to",
"the",
"rules"
] | bf01156d1a2416ceddef0d238469563b74087d44 | https://github.com/stanislav-web/Searcher/blob/bf01156d1a2416ceddef0d238469563b74087d44/src/Searcher/Validator.php#L83-L104 | train |
stanislav-web/Searcher | src/Searcher/Validator.php | Validator.setLength | public function setLength(array $condition)
{
if (is_array($condition) === true) {
$this->{key($condition)} = (int) current($condition);
}
return $this;
} | php | public function setLength(array $condition)
{
if (is_array($condition) === true) {
$this->{key($condition)} = (int) current($condition);
}
return $this;
} | [
"public",
"function",
"setLength",
"(",
"array",
"$",
"condition",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"condition",
")",
"===",
"true",
")",
"{",
"$",
"this",
"->",
"{",
"key",
"(",
"$",
"condition",
")",
"}",
"=",
"(",
"int",
")",
"current"... | Set value length for the search min and max
@param array $condition value
@return Validator | [
"Set",
"value",
"length",
"for",
"the",
"search",
"min",
"and",
"max"
] | bf01156d1a2416ceddef0d238469563b74087d44 | https://github.com/stanislav-web/Searcher/blob/bf01156d1a2416ceddef0d238469563b74087d44/src/Searcher/Validator.php#L112-L119 | train |
stanislav-web/Searcher | src/Searcher/Validator.php | Validator.isNotNull | protected function isNotNull($value)
{
if (is_null($value) === true || empty($value) === true) {
throw new ExceptionFactory('DataType', [$value, 'string']);
}
return true;
} | php | protected function isNotNull($value)
{
if (is_null($value) === true || empty($value) === true) {
throw new ExceptionFactory('DataType', [$value, 'string']);
}
return true;
} | [
"protected",
"function",
"isNotNull",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"value",
")",
"===",
"true",
"||",
"empty",
"(",
"$",
"value",
")",
"===",
"true",
")",
"{",
"throw",
"new",
"ExceptionFactory",
"(",
"'DataType'",
",",
... | Verify by not null
@param string $value
@throws ExceptionFactory
@return boolean | [
"Verify",
"by",
"not",
"null"
] | bf01156d1a2416ceddef0d238469563b74087d44 | https://github.com/stanislav-web/Searcher/blob/bf01156d1a2416ceddef0d238469563b74087d44/src/Searcher/Validator.php#L128-L135 | train |
stanislav-web/Searcher | src/Searcher/Validator.php | Validator.isAcceptLength | protected function isAcceptLength($value)
{
$value = strlen(utf8_decode($value));
if ($value < $this->min) {
throw new ExceptionFactory('InvalidLength', [$value, 'greater', $this->min]);
}
else if ($value > $this->max) {
throw new ExceptionFactory('InvalidLength', [$value, 'less', $this->max]);
}
return true;
} | php | protected function isAcceptLength($value)
{
$value = strlen(utf8_decode($value));
if ($value < $this->min) {
throw new ExceptionFactory('InvalidLength', [$value, 'greater', $this->min]);
}
else if ($value > $this->max) {
throw new ExceptionFactory('InvalidLength', [$value, 'less', $this->max]);
}
return true;
} | [
"protected",
"function",
"isAcceptLength",
"(",
"$",
"value",
")",
"{",
"$",
"value",
"=",
"strlen",
"(",
"utf8_decode",
"(",
"$",
"value",
")",
")",
";",
"if",
"(",
"$",
"value",
"<",
"$",
"this",
"->",
"min",
")",
"{",
"throw",
"new",
"ExceptionFac... | Verify by length
@param string $value
@throws ExceptionFactory
@return boolean | [
"Verify",
"by",
"length"
] | bf01156d1a2416ceddef0d238469563b74087d44 | https://github.com/stanislav-web/Searcher/blob/bf01156d1a2416ceddef0d238469563b74087d44/src/Searcher/Validator.php#L178-L190 | train |
stanislav-web/Searcher | src/Searcher/Validator.php | Validator.isExists | protected function isExists(array $value)
{
// validate fields by exist in tables
foreach ($value as $table => $fields) {
// load model metaData
if ($this->isModel($table) === true) {
$model = (new Manager())->load($table, new $table);
// check fields of table
$this->validColumns($model->getModelsMetaData(), $fields, $table, $model);
// setup clear used tables
$columnDefines = (new $table)->getReadConnection()->describeColumns($model->getSource());
// add using tables with model alias
$this->fields['tables'][$model->getSource()] = $table;
// checking columns & fields
foreach ($columnDefines as $column) {
if (in_array($column->getName(), $fields) === true) {
$this->validTypes($column);
// add column to table collection
$this->fields[$this->cast][$model->getSource()][$column->getName()] = $column->getType();
}
}
}
}
return true;
} | php | protected function isExists(array $value)
{
// validate fields by exist in tables
foreach ($value as $table => $fields) {
// load model metaData
if ($this->isModel($table) === true) {
$model = (new Manager())->load($table, new $table);
// check fields of table
$this->validColumns($model->getModelsMetaData(), $fields, $table, $model);
// setup clear used tables
$columnDefines = (new $table)->getReadConnection()->describeColumns($model->getSource());
// add using tables with model alias
$this->fields['tables'][$model->getSource()] = $table;
// checking columns & fields
foreach ($columnDefines as $column) {
if (in_array($column->getName(), $fields) === true) {
$this->validTypes($column);
// add column to table collection
$this->fields[$this->cast][$model->getSource()][$column->getName()] = $column->getType();
}
}
}
}
return true;
} | [
"protected",
"function",
"isExists",
"(",
"array",
"$",
"value",
")",
"{",
"// validate fields by exist in tables",
"foreach",
"(",
"$",
"value",
"as",
"$",
"table",
"=>",
"$",
"fields",
")",
"{",
"// load model metaData",
"if",
"(",
"$",
"this",
"->",
"isMode... | Check if field exist in table
@param array $value
@throws ExceptionFactory
@return boolean | [
"Check",
"if",
"field",
"exist",
"in",
"table"
] | bf01156d1a2416ceddef0d238469563b74087d44 | https://github.com/stanislav-web/Searcher/blob/bf01156d1a2416ceddef0d238469563b74087d44/src/Searcher/Validator.php#L216-L253 | train |
stanislav-web/Searcher | src/Searcher/Validator.php | Validator.isOrdered | protected function isOrdered(array $ordered)
{
// validate fields by exist in tables
foreach ($ordered as $table => $sort) {
// load model metaData
if ($this->isModel($table) === true) {
$model = (new Manager())->load($table, new $table);
// check fields of table
$this->validColumns($model->getModelsMetaData(), array_keys($sort), $table, $model);
// check sort clause
$sort = array_map('strtolower', $sort);
if (empty($diff = array_diff(array_values($sort), $this->sort)) === false) {
throw new ExceptionFactory('Column', ['ORDER_TYPES_DOES_NOT_EXISTS', $diff]);
}
if (empty($diff = array_diff($sort, $this->sort)) === false) {
throw new ExceptionFactory('Column', ['ORDER_TYPES_DOES_NOT_EXISTS', $diff]);
}
$this->fields[$this->cast][$model->getSource()] = $sort;
}
}
return true;
} | php | protected function isOrdered(array $ordered)
{
// validate fields by exist in tables
foreach ($ordered as $table => $sort) {
// load model metaData
if ($this->isModel($table) === true) {
$model = (new Manager())->load($table, new $table);
// check fields of table
$this->validColumns($model->getModelsMetaData(), array_keys($sort), $table, $model);
// check sort clause
$sort = array_map('strtolower', $sort);
if (empty($diff = array_diff(array_values($sort), $this->sort)) === false) {
throw new ExceptionFactory('Column', ['ORDER_TYPES_DOES_NOT_EXISTS', $diff]);
}
if (empty($diff = array_diff($sort, $this->sort)) === false) {
throw new ExceptionFactory('Column', ['ORDER_TYPES_DOES_NOT_EXISTS', $diff]);
}
$this->fields[$this->cast][$model->getSource()] = $sort;
}
}
return true;
} | [
"protected",
"function",
"isOrdered",
"(",
"array",
"$",
"ordered",
")",
"{",
"// validate fields by exist in tables",
"foreach",
"(",
"$",
"ordered",
"as",
"$",
"table",
"=>",
"$",
"sort",
")",
"{",
"// load model metaData",
"if",
"(",
"$",
"this",
"->",
"isM... | Check ordered fields
@param array $ordered
@throws ExceptionFactory
@return boolean | [
"Check",
"ordered",
"fields"
] | bf01156d1a2416ceddef0d238469563b74087d44 | https://github.com/stanislav-web/Searcher/blob/bf01156d1a2416ceddef0d238469563b74087d44/src/Searcher/Validator.php#L262-L295 | train |
stanislav-web/Searcher | src/Searcher/Validator.php | Validator.validTypes | protected function validTypes(Column $column)
{
if (in_array($column->getType(), $this->columns) === false) {
throw new ExceptionFactory('Column', ['COLUMN_DOES_NOT_SUPPORT', $column->getType(), $column->getName()]);
}
return true;
} | php | protected function validTypes(Column $column)
{
if (in_array($column->getType(), $this->columns) === false) {
throw new ExceptionFactory('Column', ['COLUMN_DOES_NOT_SUPPORT', $column->getType(), $column->getName()]);
}
return true;
} | [
"protected",
"function",
"validTypes",
"(",
"Column",
"$",
"column",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"column",
"->",
"getType",
"(",
")",
",",
"$",
"this",
"->",
"columns",
")",
"===",
"false",
")",
"{",
"throw",
"new",
"ExceptionFactory",
"... | Check if field type support in table
@throws ExceptionFactory
@return boolean | [
"Check",
"if",
"field",
"type",
"support",
"in",
"table"
] | bf01156d1a2416ceddef0d238469563b74087d44 | https://github.com/stanislav-web/Searcher/blob/bf01156d1a2416ceddef0d238469563b74087d44/src/Searcher/Validator.php#L303-L311 | train |
stanislav-web/Searcher | src/Searcher/Validator.php | Validator.validColumns | protected function validColumns(Memory $meta, array $columns, $table, $model)
{
if (empty($not = array_diff($columns, $meta->getAttributes($model))) === false) {
throw new ExceptionFactory('Column', ['COLUMN_DOES_NOT_EXISTS', $not, $table, $meta->getAttributes($model)]);
}
return true;
} | php | protected function validColumns(Memory $meta, array $columns, $table, $model)
{
if (empty($not = array_diff($columns, $meta->getAttributes($model))) === false) {
throw new ExceptionFactory('Column', ['COLUMN_DOES_NOT_EXISTS', $not, $table, $meta->getAttributes($model)]);
}
return true;
} | [
"protected",
"function",
"validColumns",
"(",
"Memory",
"$",
"meta",
",",
"array",
"$",
"columns",
",",
"$",
"table",
",",
"$",
"model",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"not",
"=",
"array_diff",
"(",
"$",
"columns",
",",
"$",
"meta",
"->",
... | Validate table columns
@param Memory $meta column info
@param array $columns
@param string $table
@param mixed $model selected model
@throws ExceptionFactory
@return boolean | [
"Validate",
"table",
"columns"
] | bf01156d1a2416ceddef0d238469563b74087d44 | https://github.com/stanislav-web/Searcher/blob/bf01156d1a2416ceddef0d238469563b74087d44/src/Searcher/Validator.php#L323-L331 | train |
fezfez/codeGenerator | src/CrudGenerator/History/HistoryManager.php | HistoryManager.findAll | public function findAll()
{
if ($this->fileManager->isDir(Installer::BASE_PATH . self::HISTORY_PATH) === false) {
throw new EnvironnementResolverException(
sprintf(
'Unable to locate "%d"',
Installer::BASE_PATH . self::HISTORY_PATH
)
);
}
$historyCollection = new HistoryCollection();
$searchPath = Installer::BASE_PATH . self::HISTORY_PATH . '*' . self::FILE_EXTENSION;
foreach ($this->fileManager->glob($searchPath) as $file) {
$content = $this->fileManager->fileGetContent($file);
try {
$historyCollection->append($this->historyHydrator->jsonToDTO($content));
} catch (InvalidHistoryException $e) {
continue;
}
}
return $historyCollection;
} | php | public function findAll()
{
if ($this->fileManager->isDir(Installer::BASE_PATH . self::HISTORY_PATH) === false) {
throw new EnvironnementResolverException(
sprintf(
'Unable to locate "%d"',
Installer::BASE_PATH . self::HISTORY_PATH
)
);
}
$historyCollection = new HistoryCollection();
$searchPath = Installer::BASE_PATH . self::HISTORY_PATH . '*' . self::FILE_EXTENSION;
foreach ($this->fileManager->glob($searchPath) as $file) {
$content = $this->fileManager->fileGetContent($file);
try {
$historyCollection->append($this->historyHydrator->jsonToDTO($content));
} catch (InvalidHistoryException $e) {
continue;
}
}
return $historyCollection;
} | [
"public",
"function",
"findAll",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"fileManager",
"->",
"isDir",
"(",
"Installer",
"::",
"BASE_PATH",
".",
"self",
"::",
"HISTORY_PATH",
")",
"===",
"false",
")",
"{",
"throw",
"new",
"EnvironnementResolverException... | Retrieve all history
@throws EnvironnementResolverException
@return HistoryCollection | [
"Retrieve",
"all",
"history"
] | 559f22bcc525c3157ecb17fe96818dd7b7ee58c2 | https://github.com/fezfez/codeGenerator/blob/559f22bcc525c3157ecb17fe96818dd7b7ee58c2/src/CrudGenerator/History/HistoryManager.php#L86-L111 | train |
mapbender/fom | src/FOM/UserBundle/Controller/UserController.php | UserController.indexAction | public function indexAction()
{
$allowed_users = array();
$users = $this->getDoctrine()->getManager()->createQuery('SELECT r FROM FOMUserBundle:User r')->getResult();
// ACL access check
foreach ($users as $index => $user) {
if ($this->isGranted('VIEW', $user)) {
$allowed_users[] = $user;
}
}
$oid = new ObjectIdentity('class', 'FOM\UserBundle\Entity\User');
return array(
'users' => $allowed_users,
'create_permission' => $this->isGranted('CREATE', $oid)
);
} | php | public function indexAction()
{
$allowed_users = array();
$users = $this->getDoctrine()->getManager()->createQuery('SELECT r FROM FOMUserBundle:User r')->getResult();
// ACL access check
foreach ($users as $index => $user) {
if ($this->isGranted('VIEW', $user)) {
$allowed_users[] = $user;
}
}
$oid = new ObjectIdentity('class', 'FOM\UserBundle\Entity\User');
return array(
'users' => $allowed_users,
'create_permission' => $this->isGranted('CREATE', $oid)
);
} | [
"public",
"function",
"indexAction",
"(",
")",
"{",
"$",
"allowed_users",
"=",
"array",
"(",
")",
";",
"$",
"users",
"=",
"$",
"this",
"->",
"getDoctrine",
"(",
")",
"->",
"getManager",
"(",
")",
"->",
"createQuery",
"(",
"'SELECT r FROM FOMUserBundle:User r... | Renders user list.
@ManagerRoute("/user")
@Method({ "GET" })
@Template | [
"Renders",
"user",
"list",
"."
] | 6dea943121f3c3f9b1b4b14dc2a8e8640a120675 | https://github.com/mapbender/fom/blob/6dea943121f3c3f9b1b4b14dc2a8e8640a120675/src/FOM/UserBundle/Controller/UserController.php#L30-L48 | train |
stevenmaguire/middleware-csp-php | src/EnforceContentSecurity.php | EnforceContentSecurity.addPolicyHeader | protected function addPolicyHeader(ResponseInterface $response)
{
$this->loadDefaultProfiles();
$currentHeader = $response->getHeader($this->header);
$initialConfig = [];
if (count($currentHeader)) {
$initialConfig = $this->decodeConfiguration($currentHeader[0]);
}
$initialDirectives = $this->encodeConfiguration($initialConfig);
$this->mergeProfileWithConfig($initialConfig);
$newDirectives = $this->encodeConfiguration($this->config);
if ($newDirectives != $initialDirectives) {
$response = $response->withHeader($this->header, $newDirectives);
}
return $response;
} | php | protected function addPolicyHeader(ResponseInterface $response)
{
$this->loadDefaultProfiles();
$currentHeader = $response->getHeader($this->header);
$initialConfig = [];
if (count($currentHeader)) {
$initialConfig = $this->decodeConfiguration($currentHeader[0]);
}
$initialDirectives = $this->encodeConfiguration($initialConfig);
$this->mergeProfileWithConfig($initialConfig);
$newDirectives = $this->encodeConfiguration($this->config);
if ($newDirectives != $initialDirectives) {
$response = $response->withHeader($this->header, $newDirectives);
}
return $response;
} | [
"protected",
"function",
"addPolicyHeader",
"(",
"ResponseInterface",
"$",
"response",
")",
"{",
"$",
"this",
"->",
"loadDefaultProfiles",
"(",
")",
";",
"$",
"currentHeader",
"=",
"$",
"response",
"->",
"getHeader",
"(",
"$",
"this",
"->",
"header",
")",
";... | Add content security policy header to response
@param ResponseInterface $response
@return ResponseInterface | [
"Add",
"content",
"security",
"policy",
"header",
"to",
"response"
] | ec27694254dee2762c50e640272db17f9a704c48 | https://github.com/stevenmaguire/middleware-csp-php/blob/ec27694254dee2762c50e640272db17f9a704c48/src/EnforceContentSecurity.php#L52-L74 | train |
stevenmaguire/middleware-csp-php | src/EnforceContentSecurity.php | EnforceContentSecurity.decodeConfiguration | protected function decodeConfiguration($string)
{
$config = [];
$directives = explode($this->directiveSeparator, $string);
foreach ($directives as $directive) {
$parts = array_filter(explode($this->sourceSeparator, $directive));
$key = trim(array_shift($parts));
$config[$key] = $parts;
}
return $config;
} | php | protected function decodeConfiguration($string)
{
$config = [];
$directives = explode($this->directiveSeparator, $string);
foreach ($directives as $directive) {
$parts = array_filter(explode($this->sourceSeparator, $directive));
$key = trim(array_shift($parts));
$config[$key] = $parts;
}
return $config;
} | [
"protected",
"function",
"decodeConfiguration",
"(",
"$",
"string",
")",
"{",
"$",
"config",
"=",
"[",
"]",
";",
"$",
"directives",
"=",
"explode",
"(",
"$",
"this",
"->",
"directiveSeparator",
",",
"$",
"string",
")",
";",
"foreach",
"(",
"$",
"directiv... | Decode a given string into configuration
@param string $string
@return array | [
"Decode",
"a",
"given",
"string",
"into",
"configuration"
] | ec27694254dee2762c50e640272db17f9a704c48 | https://github.com/stevenmaguire/middleware-csp-php/blob/ec27694254dee2762c50e640272db17f9a704c48/src/EnforceContentSecurity.php#L83-L94 | train |
stevenmaguire/middleware-csp-php | src/EnforceContentSecurity.php | EnforceContentSecurity.encodeConfiguration | protected function encodeConfiguration($config = [])
{
$value = [];
ksort($config);
foreach ($config as $directive => $values) {
$values = array_unique($values);
sort($values);
array_unshift($values, $directive);
$string = implode($this->sourceSeparator, $values);
if ($string) {
$value[] = $string;
}
}
return implode($this->directiveSeparator . ' ', $value);
} | php | protected function encodeConfiguration($config = [])
{
$value = [];
ksort($config);
foreach ($config as $directive => $values) {
$values = array_unique($values);
sort($values);
array_unshift($values, $directive);
$string = implode($this->sourceSeparator, $values);
if ($string) {
$value[] = $string;
}
}
return implode($this->directiveSeparator . ' ', $value);
} | [
"protected",
"function",
"encodeConfiguration",
"(",
"$",
"config",
"=",
"[",
"]",
")",
"{",
"$",
"value",
"=",
"[",
"]",
";",
"ksort",
"(",
"$",
"config",
")",
";",
"foreach",
"(",
"$",
"config",
"as",
"$",
"directive",
"=>",
"$",
"values",
")",
"... | Encode the current configuration as string
@param array $config
@return string | [
"Encode",
"the",
"current",
"configuration",
"as",
"string"
] | ec27694254dee2762c50e640272db17f9a704c48 | https://github.com/stevenmaguire/middleware-csp-php/blob/ec27694254dee2762c50e640272db17f9a704c48/src/EnforceContentSecurity.php#L103-L119 | train |
stevenmaguire/middleware-csp-php | src/EnforceContentSecurity.php | EnforceContentSecurity.getArrayFromValue | protected function getArrayFromValue($value, $separator = ',')
{
if (!is_array($value)) {
$value = explode($separator, $value);
}
return $value;
} | php | protected function getArrayFromValue($value, $separator = ',')
{
if (!is_array($value)) {
$value = explode($separator, $value);
}
return $value;
} | [
"protected",
"function",
"getArrayFromValue",
"(",
"$",
"value",
",",
"$",
"separator",
"=",
"','",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"explode",
"(",
"$",
"separator",
",",
"$",
"value",
")",
... | Create array from value
@param mixed $value
@return array | [
"Create",
"array",
"from",
"value"
] | ec27694254dee2762c50e640272db17f9a704c48 | https://github.com/stevenmaguire/middleware-csp-php/blob/ec27694254dee2762c50e640272db17f9a704c48/src/EnforceContentSecurity.php#L129-L136 | train |
stevenmaguire/middleware-csp-php | src/EnforceContentSecurity.php | EnforceContentSecurity.loadDefaultProfiles | protected function loadDefaultProfiles()
{
$defaultProfiles = [];
if (isset($this->profiles['default'])) {
$defaultProfiles = $this->getArrayFromValue(
$this->profiles['default']
);
}
array_map([$this, 'loadProfileByKey'], $defaultProfiles);
} | php | protected function loadDefaultProfiles()
{
$defaultProfiles = [];
if (isset($this->profiles['default'])) {
$defaultProfiles = $this->getArrayFromValue(
$this->profiles['default']
);
}
array_map([$this, 'loadProfileByKey'], $defaultProfiles);
} | [
"protected",
"function",
"loadDefaultProfiles",
"(",
")",
"{",
"$",
"defaultProfiles",
"=",
"[",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"profiles",
"[",
"'default'",
"]",
")",
")",
"{",
"$",
"defaultProfiles",
"=",
"$",
"this",
"->",
"ge... | Load default profiles
@return void | [
"Load",
"default",
"profiles"
] | ec27694254dee2762c50e640272db17f9a704c48 | https://github.com/stevenmaguire/middleware-csp-php/blob/ec27694254dee2762c50e640272db17f9a704c48/src/EnforceContentSecurity.php#L168-L179 | train |
stevenmaguire/middleware-csp-php | src/EnforceContentSecurity.php | EnforceContentSecurity.loadProfileByKey | protected function loadProfileByKey($key)
{
if (isset($this->profiles['profiles'][$key])) {
$profile = $this->profiles['profiles'][$key];
if (is_array($profile)) {
$this->mergeProfileWithConfig($profile);
}
}
} | php | protected function loadProfileByKey($key)
{
if (isset($this->profiles['profiles'][$key])) {
$profile = $this->profiles['profiles'][$key];
if (is_array($profile)) {
$this->mergeProfileWithConfig($profile);
}
}
} | [
"protected",
"function",
"loadProfileByKey",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"profiles",
"[",
"'profiles'",
"]",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"profile",
"=",
"$",
"this",
"->",
"profiles",
"[",
"'... | Load a specific profile
@param string $key
@return void | [
"Load",
"a",
"specific",
"profile"
] | ec27694254dee2762c50e640272db17f9a704c48 | https://github.com/stevenmaguire/middleware-csp-php/blob/ec27694254dee2762c50e640272db17f9a704c48/src/EnforceContentSecurity.php#L188-L197 | train |
stevenmaguire/middleware-csp-php | src/EnforceContentSecurity.php | EnforceContentSecurity.mergeProfileWithConfig | protected function mergeProfileWithConfig(array $profile)
{
foreach ($profile as $directive => $values) {
if (!isset($this->config[$directive])) {
$this->config[$directive] = [];
}
$values = $this->getArrayFromValue($values);
$this->config[$directive] = array_merge($this->config[$directive], $values);
}
} | php | protected function mergeProfileWithConfig(array $profile)
{
foreach ($profile as $directive => $values) {
if (!isset($this->config[$directive])) {
$this->config[$directive] = [];
}
$values = $this->getArrayFromValue($values);
$this->config[$directive] = array_merge($this->config[$directive], $values);
}
} | [
"protected",
"function",
"mergeProfileWithConfig",
"(",
"array",
"$",
"profile",
")",
"{",
"foreach",
"(",
"$",
"profile",
"as",
"$",
"directive",
"=>",
"$",
"values",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"config",
"[",
"$",
"dire... | Merge a given profile with current configuration
@param array $profile
@return void | [
"Merge",
"a",
"given",
"profile",
"with",
"current",
"configuration"
] | ec27694254dee2762c50e640272db17f9a704c48 | https://github.com/stevenmaguire/middleware-csp-php/blob/ec27694254dee2762c50e640272db17f9a704c48/src/EnforceContentSecurity.php#L206-L217 | train |
milejko/mmi-cms | src/Cms/Form/Element/Tags.php | Tags.getValue | public function getValue()
{
$arr = [];
if (!is_array($this->_options['value'])) {
return [];
}
foreach ($this->_options['value'] as $key) {
$arr[$key] = $key;
}
return $arr;
} | php | public function getValue()
{
$arr = [];
if (!is_array($this->_options['value'])) {
return [];
}
foreach ($this->_options['value'] as $key) {
$arr[$key] = $key;
}
return $arr;
} | [
"public",
"function",
"getValue",
"(",
")",
"{",
"$",
"arr",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"this",
"->",
"_options",
"[",
"'value'",
"]",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
"foreach",
"(",
"$",
"this",
"->"... | przerobienie tablicy + klucz
@return array | [
"przerobienie",
"tablicy",
"+",
"klucz"
] | 95483b08f25136b8d6bcf787ec4ecc3e8bdffb38 | https://github.com/milejko/mmi-cms/blob/95483b08f25136b8d6bcf787ec4ecc3e8bdffb38/src/Cms/Form/Element/Tags.php#L191-L201 | train |
manaphp/framework | Http/Request/File.php | File.moveTo | public function moveTo($dst, $allowedExtensions = 'jpg,jpeg,png,gif,doc,xls,pdf,zip', $overwrite = false)
{
if ($allowedExtensions !== '*') {
$extension = pathinfo($dst, PATHINFO_EXTENSION);
if (!$extension || preg_match("#\b$extension\b#", $allowedExtensions) !== 1) {
throw new FileException(['`:extension` file type is not allowed upload', 'extension' => $extension]);
}
}
if ($this->_file['error'] !== UPLOAD_ERR_OK) {
throw new FileException(['error code of upload file is not UPLOAD_ERR_OK: :error', 'error' => $this->_file['error']]);
}
if ($this->filesystem->fileExists($dst)) {
if ($overwrite) {
$this->filesystem->fileDelete($dst);
} else {
throw new FileException(['`:file` file already exists', 'file' => $dst]);
}
}
$this->filesystem->dirCreate(dirname($dst));
if (!move_uploaded_file($this->_file['tmp_name'], $this->alias->resolve($dst))) {
throw new FileException(['move_uploaded_file to `:dst` failed: :last_error_message', 'dst' => $dst]);
}
if (!chmod($this->alias->resolve($dst), 0644)) {
throw new FileException(['chmod `:dst` destination failed: :last_error_message', 'dst' => $dst]);
}
} | php | public function moveTo($dst, $allowedExtensions = 'jpg,jpeg,png,gif,doc,xls,pdf,zip', $overwrite = false)
{
if ($allowedExtensions !== '*') {
$extension = pathinfo($dst, PATHINFO_EXTENSION);
if (!$extension || preg_match("#\b$extension\b#", $allowedExtensions) !== 1) {
throw new FileException(['`:extension` file type is not allowed upload', 'extension' => $extension]);
}
}
if ($this->_file['error'] !== UPLOAD_ERR_OK) {
throw new FileException(['error code of upload file is not UPLOAD_ERR_OK: :error', 'error' => $this->_file['error']]);
}
if ($this->filesystem->fileExists($dst)) {
if ($overwrite) {
$this->filesystem->fileDelete($dst);
} else {
throw new FileException(['`:file` file already exists', 'file' => $dst]);
}
}
$this->filesystem->dirCreate(dirname($dst));
if (!move_uploaded_file($this->_file['tmp_name'], $this->alias->resolve($dst))) {
throw new FileException(['move_uploaded_file to `:dst` failed: :last_error_message', 'dst' => $dst]);
}
if (!chmod($this->alias->resolve($dst), 0644)) {
throw new FileException(['chmod `:dst` destination failed: :last_error_message', 'dst' => $dst]);
}
} | [
"public",
"function",
"moveTo",
"(",
"$",
"dst",
",",
"$",
"allowedExtensions",
"=",
"'jpg,jpeg,png,gif,doc,xls,pdf,zip'",
",",
"$",
"overwrite",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"allowedExtensions",
"!==",
"'*'",
")",
"{",
"$",
"extension",
"=",
"pat... | Moves the temporary file to a destination within the application
@param string $dst
@param string $allowedExtensions
@param bool $overwrite
@throws \ManaPHP\Http\Request\File\Exception | [
"Moves",
"the",
"temporary",
"file",
"to",
"a",
"destination",
"within",
"the",
"application"
] | b9a15c7f8f5d4770cacbea43f26914765bfcb248 | https://github.com/manaphp/framework/blob/b9a15c7f8f5d4770cacbea43f26914765bfcb248/Http/Request/File.php#L120-L150 | train |
manaphp/framework | Http/Request/File.php | File.getExtension | public function getExtension()
{
$name = $this->_file['name'];
return ($extension = pathinfo($name, PATHINFO_EXTENSION)) === $name ? '' : $extension;
} | php | public function getExtension()
{
$name = $this->_file['name'];
return ($extension = pathinfo($name, PATHINFO_EXTENSION)) === $name ? '' : $extension;
} | [
"public",
"function",
"getExtension",
"(",
")",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"_file",
"[",
"'name'",
"]",
";",
"return",
"(",
"$",
"extension",
"=",
"pathinfo",
"(",
"$",
"name",
",",
"PATHINFO_EXTENSION",
")",
")",
"===",
"$",
"name",
"... | Returns the file extension
@return string | [
"Returns",
"the",
"file",
"extension"
] | b9a15c7f8f5d4770cacbea43f26914765bfcb248 | https://github.com/manaphp/framework/blob/b9a15c7f8f5d4770cacbea43f26914765bfcb248/Http/Request/File.php#L157-L161 | train |
swoft-cloud/swoft-service-governance | src/ProviderSelector.php | ProviderSelector.select | public function select(string $type = null)
{
if (empty($type)) {
$type = $this->provider;
}
$providers = $this->mergeProviders();
if (!isset($providers[$type])) {
throw new InvalidArgumentException(sprintf('Provider %s does not exist', $type));
}
$providerBeanName = $providers[$type];
return App::getBean($providerBeanName);
} | php | public function select(string $type = null)
{
if (empty($type)) {
$type = $this->provider;
}
$providers = $this->mergeProviders();
if (!isset($providers[$type])) {
throw new InvalidArgumentException(sprintf('Provider %s does not exist', $type));
}
$providerBeanName = $providers[$type];
return App::getBean($providerBeanName);
} | [
"public",
"function",
"select",
"(",
"string",
"$",
"type",
"=",
"null",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"type",
")",
")",
"{",
"$",
"type",
"=",
"$",
"this",
"->",
"provider",
";",
"}",
"$",
"providers",
"=",
"$",
"this",
"->",
"mergePro... | Select a provider by Selector
@param string $type
@return ProviderInterface
@throws \Swoft\Exception\InvalidArgumentException | [
"Select",
"a",
"provider",
"by",
"Selector"
] | c7591dd1de20fc0333b7d1e3e8d11c5488a216cd | https://github.com/swoft-cloud/swoft-service-governance/blob/c7591dd1de20fc0333b7d1e3e8d11c5488a216cd/src/ProviderSelector.php#L42-L56 | train |
fezfez/codeGenerator | src/CrudGenerator/Utils/PhpStringParser.php | PhpStringParser.staticPhp | public function staticPhp($text)
{
$textExplode = explode('->', $text);
$variableName = str_replace('$', '', array_shift($textExplode));
$variableVariable = $this->variables;
if (isset($variableVariable[$variableName]) === false) {
throw new \InvalidArgumentException(
sprintf('variable %s does not exist', $variableName)
);
}
$textExplode = array_map(
function ($value) {
return str_replace('()', '', $value);
},
$textExplode
);
$instance = $variableVariable[$variableName];
$keys = array_values($textExplode);
$lastKey = array_pop($keys);
foreach ($textExplode as $key => $method) {
if ($instance === null && $lastKey !== $key) {
throw new \InvalidArgumentException(sprintf('method %s return null', $method));
} elseif (false === method_exists($instance, $method)) {
throw new \InvalidArgumentException(sprintf('method %s does not exist on %s', $method, $text));
} else {
$instance = $instance->$method();
}
}
return $instance;
} | php | public function staticPhp($text)
{
$textExplode = explode('->', $text);
$variableName = str_replace('$', '', array_shift($textExplode));
$variableVariable = $this->variables;
if (isset($variableVariable[$variableName]) === false) {
throw new \InvalidArgumentException(
sprintf('variable %s does not exist', $variableName)
);
}
$textExplode = array_map(
function ($value) {
return str_replace('()', '', $value);
},
$textExplode
);
$instance = $variableVariable[$variableName];
$keys = array_values($textExplode);
$lastKey = array_pop($keys);
foreach ($textExplode as $key => $method) {
if ($instance === null && $lastKey !== $key) {
throw new \InvalidArgumentException(sprintf('method %s return null', $method));
} elseif (false === method_exists($instance, $method)) {
throw new \InvalidArgumentException(sprintf('method %s does not exist on %s', $method, $text));
} else {
$instance = $instance->$method();
}
}
return $instance;
} | [
"public",
"function",
"staticPhp",
"(",
"$",
"text",
")",
"{",
"$",
"textExplode",
"=",
"explode",
"(",
"'->'",
",",
"$",
"text",
")",
";",
"$",
"variableName",
"=",
"str_replace",
"(",
"'$'",
",",
"''",
",",
"array_shift",
"(",
"$",
"textExplode",
")"... | Interpret a php plain text
@param string $text A php call as plain text example : $foo->bar()->baz()
@throws \InvalidArgumentException
@return mixed | [
"Interpret",
"a",
"php",
"plain",
"text"
] | 559f22bcc525c3157ecb17fe96818dd7b7ee58c2 | https://github.com/fezfez/codeGenerator/blob/559f22bcc525c3157ecb17fe96818dd7b7ee58c2/src/CrudGenerator/Utils/PhpStringParser.php#L71-L105 | train |
AXN-Informatique/laravel-glide | src/Console/Commands/GlideKeyGenerate.php | GlideKeyGenerate.setKeyInEnvironmentFile | protected function setKeyInEnvironmentFile($key)
{
$currentContent = file_get_contents(base_path('.env'));
$currentValue = '';
if (preg_match('/^GLIDE_SIGN_KEY=(.*)$/m', $currentContent, $matches) && isset($matches[1])) {
$currentValue = $matches[1];
}
file_put_contents(base_path('.env'), str_replace(
'GLIDE_SIGN_KEY='.$currentValue,
'GLIDE_SIGN_KEY='.$key,
$currentContent
));
} | php | protected function setKeyInEnvironmentFile($key)
{
$currentContent = file_get_contents(base_path('.env'));
$currentValue = '';
if (preg_match('/^GLIDE_SIGN_KEY=(.*)$/m', $currentContent, $matches) && isset($matches[1])) {
$currentValue = $matches[1];
}
file_put_contents(base_path('.env'), str_replace(
'GLIDE_SIGN_KEY='.$currentValue,
'GLIDE_SIGN_KEY='.$key,
$currentContent
));
} | [
"protected",
"function",
"setKeyInEnvironmentFile",
"(",
"$",
"key",
")",
"{",
"$",
"currentContent",
"=",
"file_get_contents",
"(",
"base_path",
"(",
"'.env'",
")",
")",
";",
"$",
"currentValue",
"=",
"''",
";",
"if",
"(",
"preg_match",
"(",
"'/^GLIDE_SIGN_KE... | Set the key in the environment file.
@param string $key
@return void | [
"Set",
"the",
"key",
"in",
"the",
"environment",
"file",
"."
] | 85fbf70dcc87c8aeda25411b86f26a1f5f55b2c2 | https://github.com/AXN-Informatique/laravel-glide/blob/85fbf70dcc87c8aeda25411b86f26a1f5f55b2c2/src/Console/Commands/GlideKeyGenerate.php#L49-L64 | train |
manaphp/framework | Cli/Controllers/ServeController.php | ServeController.defaultCommand | public function defaultCommand($ip = '127.0.0.1', $port = 1983)
{
$router_str = <<<'STR'
<?php
$_SERVER['SERVER_ADDR'] = ':ip';
$_SERVER['SERVER_PORT'] = ':port';
$_SERVER['REQUEST_SCHEME'] = 'http';
chdir('public');
$uri = urldecode(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH));
if ($uri !== '/') {
if (file_exists('public/' . $uri)
|| preg_match('#\.(?:css|js|gif|png|jpg|jpeg|ttf|woff|ico)$#', $uri) === 1
) {
return false;
}
}
$_GET['_url'] = $uri;
$_REQUEST['_url'] = $uri;
require_once 'index.php';
STR;
if ($value = $this->arguments->getValue(0)) {
if (strpos($value, ':')) {
list($ip, $port) = explode(':', $value, 2);
} elseif (is_numeric($value)) {
$port = (int)$value;
} else {
$ip = $value;
}
}
$router = 'builtin_server_router.php';
$this->filesystem->filePut("@tmp/$router", strtr($router_str, [':ip' => $ip, ':port' => $port]));
echo "server listen on: $ip:$port", PHP_EOL;
$prefix = $this->router->getPrefix();
if (DIRECTORY_SEPARATOR === '\\') {
shell_exec("explorer.exe http://$ip:$port" . $prefix);
}
shell_exec("php -S $ip:$port -t public tmp/$router");
} | php | public function defaultCommand($ip = '127.0.0.1', $port = 1983)
{
$router_str = <<<'STR'
<?php
$_SERVER['SERVER_ADDR'] = ':ip';
$_SERVER['SERVER_PORT'] = ':port';
$_SERVER['REQUEST_SCHEME'] = 'http';
chdir('public');
$uri = urldecode(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH));
if ($uri !== '/') {
if (file_exists('public/' . $uri)
|| preg_match('#\.(?:css|js|gif|png|jpg|jpeg|ttf|woff|ico)$#', $uri) === 1
) {
return false;
}
}
$_GET['_url'] = $uri;
$_REQUEST['_url'] = $uri;
require_once 'index.php';
STR;
if ($value = $this->arguments->getValue(0)) {
if (strpos($value, ':')) {
list($ip, $port) = explode(':', $value, 2);
} elseif (is_numeric($value)) {
$port = (int)$value;
} else {
$ip = $value;
}
}
$router = 'builtin_server_router.php';
$this->filesystem->filePut("@tmp/$router", strtr($router_str, [':ip' => $ip, ':port' => $port]));
echo "server listen on: $ip:$port", PHP_EOL;
$prefix = $this->router->getPrefix();
if (DIRECTORY_SEPARATOR === '\\') {
shell_exec("explorer.exe http://$ip:$port" . $prefix);
}
shell_exec("php -S $ip:$port -t public tmp/$router");
} | [
"public",
"function",
"defaultCommand",
"(",
"$",
"ip",
"=",
"'127.0.0.1'",
",",
"$",
"port",
"=",
"1983",
")",
"{",
"$",
"router_str",
"=",
" <<<'STR'\n<?php\n$_SERVER['SERVER_ADDR'] = ':ip';\n$_SERVER['SERVER_PORT'] = ':port';\n$_SERVER['REQUEST_SCHEME'] = 'http';\nchdir('publi... | start with php builtin server
@param string $ip
@param int $port | [
"start",
"with",
"php",
"builtin",
"server"
] | b9a15c7f8f5d4770cacbea43f26914765bfcb248 | https://github.com/manaphp/framework/blob/b9a15c7f8f5d4770cacbea43f26914765bfcb248/Cli/Controllers/ServeController.php#L20-L62 | train |
webfactory/symfony-application-tests | src/Webfactory/Util/TwigTemplateIterator.php | TwigTemplateIterator.getIterator | public function getIterator()
{
$this->kernel->boot();
$viewDirectories = $this->getPossibleViewDirectories();
$viewDirectories = $this->removeNotExistingDirectories($viewDirectories);
$templates = $this->getTwigTemplatesIn($viewDirectories);
return new \ArrayIterator($templates);
} | php | public function getIterator()
{
$this->kernel->boot();
$viewDirectories = $this->getPossibleViewDirectories();
$viewDirectories = $this->removeNotExistingDirectories($viewDirectories);
$templates = $this->getTwigTemplatesIn($viewDirectories);
return new \ArrayIterator($templates);
} | [
"public",
"function",
"getIterator",
"(",
")",
"{",
"$",
"this",
"->",
"kernel",
"->",
"boot",
"(",
")",
";",
"$",
"viewDirectories",
"=",
"$",
"this",
"->",
"getPossibleViewDirectories",
"(",
")",
";",
"$",
"viewDirectories",
"=",
"$",
"this",
"->",
"re... | Returns an iterator that provides Twig template paths.
@return \Traversable | [
"Returns",
"an",
"iterator",
"that",
"provides",
"Twig",
"template",
"paths",
"."
] | 971c0d45c46dc20323535940fc0d1cc7eafaf553 | https://github.com/webfactory/symfony-application-tests/blob/971c0d45c46dc20323535940fc0d1cc7eafaf553/src/Webfactory/Util/TwigTemplateIterator.php#L38-L45 | train |
webfactory/symfony-application-tests | src/Webfactory/Util/TwigTemplateIterator.php | TwigTemplateIterator.getTwigTemplatesIn | protected function getTwigTemplatesIn($directories)
{
if (count($directories) === 0) {
return array();
}
$templates = Finder::create()->in($directories)->files()->name('*.*.twig');
$templates = iterator_to_array($templates, false);
$templates = array_map(function (SplFileInfo $file) {
return $file->getRealPath();
}, $templates);
return $templates;
} | php | protected function getTwigTemplatesIn($directories)
{
if (count($directories) === 0) {
return array();
}
$templates = Finder::create()->in($directories)->files()->name('*.*.twig');
$templates = iterator_to_array($templates, false);
$templates = array_map(function (SplFileInfo $file) {
return $file->getRealPath();
}, $templates);
return $templates;
} | [
"protected",
"function",
"getTwigTemplatesIn",
"(",
"$",
"directories",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"directories",
")",
"===",
"0",
")",
"{",
"return",
"array",
"(",
")",
";",
"}",
"$",
"templates",
"=",
"Finder",
"::",
"create",
"(",
")",
... | Returns the paths to all Twig templates in the given directories.
@param string[] $directories
@return string[] | [
"Returns",
"the",
"paths",
"to",
"all",
"Twig",
"templates",
"in",
"the",
"given",
"directories",
"."
] | 971c0d45c46dc20323535940fc0d1cc7eafaf553 | https://github.com/webfactory/symfony-application-tests/blob/971c0d45c46dc20323535940fc0d1cc7eafaf553/src/Webfactory/Util/TwigTemplateIterator.php#L87-L98 | train |
milejko/mmi-cms | src/Cms/Model/CategoryWidgetModel.php | CategoryWidgetModel.findWidgetRelationById | public function findWidgetRelationById($id)
{
//iteracja po relacjach
foreach ($this->_widgetCollection as $widgetRelationRecord) {
//relacja odnaleziona
if ($widgetRelationRecord->id == $id) {
return $widgetRelationRecord;
}
}
} | php | public function findWidgetRelationById($id)
{
//iteracja po relacjach
foreach ($this->_widgetCollection as $widgetRelationRecord) {
//relacja odnaleziona
if ($widgetRelationRecord->id == $id) {
return $widgetRelationRecord;
}
}
} | [
"public",
"function",
"findWidgetRelationById",
"(",
"$",
"id",
")",
"{",
"//iteracja po relacjach",
"foreach",
"(",
"$",
"this",
"->",
"_widgetCollection",
"as",
"$",
"widgetRelationRecord",
")",
"{",
"//relacja odnaleziona",
"if",
"(",
"$",
"widgetRelationRecord",
... | Pobiera rekord konfiguracji widgeta
@param integer $id
@return \Cms\Orm\CmsCategoryWidgetCategoryRecord | [
"Pobiera",
"rekord",
"konfiguracji",
"widgeta"
] | 95483b08f25136b8d6bcf787ec4ecc3e8bdffb38 | https://github.com/milejko/mmi-cms/blob/95483b08f25136b8d6bcf787ec4ecc3e8bdffb38/src/Cms/Model/CategoryWidgetModel.php#L59-L68 | train |
pscheit/jparser | PLUG/core/PLUGObject.php | PLUGObject.trigger_error | protected function trigger_error( $code, $message, $type = E_USER_NOTICE ){
$trace = debug_backtrace();
$Err = PLUG::raise_error( $code, $message, $type, $trace );
$this->on_trigger_error( $Err );
} | php | protected function trigger_error( $code, $message, $type = E_USER_NOTICE ){
$trace = debug_backtrace();
$Err = PLUG::raise_error( $code, $message, $type, $trace );
$this->on_trigger_error( $Err );
} | [
"protected",
"function",
"trigger_error",
"(",
"$",
"code",
",",
"$",
"message",
",",
"$",
"type",
"=",
"E_USER_NOTICE",
")",
"{",
"$",
"trace",
"=",
"debug_backtrace",
"(",
")",
";",
"$",
"Err",
"=",
"PLUG",
"::",
"raise_error",
"(",
"$",
"code",
",",... | Raise a PLUGError originating from this instance.
@param int error code.
@param string error message text
@param int error type constant
@return void | [
"Raise",
"a",
"PLUGError",
"originating",
"from",
"this",
"instance",
"."
] | f9de77171c0d37d237e0e9a918ed7bff19e12095 | https://github.com/pscheit/jparser/blob/f9de77171c0d37d237e0e9a918ed7bff19e12095/PLUG/core/PLUGObject.php#L40-L44 | train |
pscheit/jparser | PLUG/core/PLUGObject.php | PLUGObject.get_error_level | function get_error_level() {
// calculate level in case global errors have been cleared
$e = 0;
foreach( $this->err_stack as $t => $ids ) {
foreach( $ids as $id ){
$Err = PLUGError::get_reference( $t, $id );
if( is_object($Err) ){
$e |= $t;
break;
}
}
}
return $e;
} | php | function get_error_level() {
// calculate level in case global errors have been cleared
$e = 0;
foreach( $this->err_stack as $t => $ids ) {
foreach( $ids as $id ){
$Err = PLUGError::get_reference( $t, $id );
if( is_object($Err) ){
$e |= $t;
break;
}
}
}
return $e;
} | [
"function",
"get_error_level",
"(",
")",
"{",
"// calculate level in case global errors have been cleared",
"$",
"e",
"=",
"0",
";",
"foreach",
"(",
"$",
"this",
"->",
"err_stack",
"as",
"$",
"t",
"=>",
"$",
"ids",
")",
"{",
"foreach",
"(",
"$",
"ids",
"as",... | Get current level of errors raised in this object.
@return int | [
"Get",
"current",
"level",
"of",
"errors",
"raised",
"in",
"this",
"object",
"."
] | f9de77171c0d37d237e0e9a918ed7bff19e12095 | https://github.com/pscheit/jparser/blob/f9de77171c0d37d237e0e9a918ed7bff19e12095/PLUG/core/PLUGObject.php#L67-L80 | train |
pscheit/jparser | PLUG/core/PLUGObject.php | PLUGObject.get_errors | function get_errors( $emask = null ) {
$errs = array();
foreach( $this->err_stack as $t => $ids ) {
if( $emask !== NULL && ( $emask & $t ) == 0 ) {
// ignore this error
continue;
}
// collect these errors
foreach( $ids as $id ){
$Err = PLUGError::get_reference( $t, $id );
if( is_object($Err) ){
$errs[] = $Err;
}
}
}
return $errs;
} | php | function get_errors( $emask = null ) {
$errs = array();
foreach( $this->err_stack as $t => $ids ) {
if( $emask !== NULL && ( $emask & $t ) == 0 ) {
// ignore this error
continue;
}
// collect these errors
foreach( $ids as $id ){
$Err = PLUGError::get_reference( $t, $id );
if( is_object($Err) ){
$errs[] = $Err;
}
}
}
return $errs;
} | [
"function",
"get_errors",
"(",
"$",
"emask",
"=",
"null",
")",
"{",
"$",
"errs",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"err_stack",
"as",
"$",
"t",
"=>",
"$",
"ids",
")",
"{",
"if",
"(",
"$",
"emask",
"!==",
"NULL",
"&... | Get errors raised in this object.
@param int php error level constant
@return array | [
"Get",
"errors",
"raised",
"in",
"this",
"object",
"."
] | f9de77171c0d37d237e0e9a918ed7bff19e12095 | https://github.com/pscheit/jparser/blob/f9de77171c0d37d237e0e9a918ed7bff19e12095/PLUG/core/PLUGObject.php#L90-L106 | train |
pscheit/jparser | PLUG/core/PLUGObject.php | PLUGObject.clear_errors | function clear_errors( $emask = null ) {
foreach( $this->err_stack as $t => $ids ) {
if( $emask !== NULL && ( $emask & $t ) == 0 ) {
// ignore this error
continue;
}
// clear these errors
foreach( $ids as $id ){
$Err = PLUGError::get_reference( $t, $id );
$Err->clear();
}
unset( $this->err_stack[$t] );
}
} | php | function clear_errors( $emask = null ) {
foreach( $this->err_stack as $t => $ids ) {
if( $emask !== NULL && ( $emask & $t ) == 0 ) {
// ignore this error
continue;
}
// clear these errors
foreach( $ids as $id ){
$Err = PLUGError::get_reference( $t, $id );
$Err->clear();
}
unset( $this->err_stack[$t] );
}
} | [
"function",
"clear_errors",
"(",
"$",
"emask",
"=",
"null",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"err_stack",
"as",
"$",
"t",
"=>",
"$",
"ids",
")",
"{",
"if",
"(",
"$",
"emask",
"!==",
"NULL",
"&&",
"(",
"$",
"emask",
"&",
"$",
"t",
")... | Clear errors raised in this object.
@param int php error level constant
@return array | [
"Clear",
"errors",
"raised",
"in",
"this",
"object",
"."
] | f9de77171c0d37d237e0e9a918ed7bff19e12095 | https://github.com/pscheit/jparser/blob/f9de77171c0d37d237e0e9a918ed7bff19e12095/PLUG/core/PLUGObject.php#L116-L129 | train |
pscheit/jparser | PLUG/core/PLUGObject.php | PLUGObject.dump_errors | function dump_errors( $emask = null ) {
foreach( $this->err_stack as $t => $ids ) {
if( $emask !== NULL && ( $emask & $t ) == 0 ) {
// ignore this error
continue;
}
// dump these errors
foreach( $ids as $id ){
$Err = PLUGError::get_reference( $t, $id );
echo (string) $Err;
echo $Err->getTraceAsString(), "\n";
}
}
} | php | function dump_errors( $emask = null ) {
foreach( $this->err_stack as $t => $ids ) {
if( $emask !== NULL && ( $emask & $t ) == 0 ) {
// ignore this error
continue;
}
// dump these errors
foreach( $ids as $id ){
$Err = PLUGError::get_reference( $t, $id );
echo (string) $Err;
echo $Err->getTraceAsString(), "\n";
}
}
} | [
"function",
"dump_errors",
"(",
"$",
"emask",
"=",
"null",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"err_stack",
"as",
"$",
"t",
"=>",
"$",
"ids",
")",
"{",
"if",
"(",
"$",
"emask",
"!==",
"NULL",
"&&",
"(",
"$",
"emask",
"&",
"$",
"t",
")"... | Dump errors raised in this object.
@param int php error level constant
@return array | [
"Dump",
"errors",
"raised",
"in",
"this",
"object",
"."
] | f9de77171c0d37d237e0e9a918ed7bff19e12095 | https://github.com/pscheit/jparser/blob/f9de77171c0d37d237e0e9a918ed7bff19e12095/PLUG/core/PLUGObject.php#L139-L152 | train |
pscheit/jparser | PLUG/core/PLUGObject.php | PLUGObject.is_error | function is_error( $emask = null ) {
$e = $this->get_error_level();
if( $emask === null ){
return (bool) $e;
}
else {
return (bool) ( $e & $emask );
}
} | php | function is_error( $emask = null ) {
$e = $this->get_error_level();
if( $emask === null ){
return (bool) $e;
}
else {
return (bool) ( $e & $emask );
}
} | [
"function",
"is_error",
"(",
"$",
"emask",
"=",
"null",
")",
"{",
"$",
"e",
"=",
"$",
"this",
"->",
"get_error_level",
"(",
")",
";",
"if",
"(",
"$",
"emask",
"===",
"null",
")",
"{",
"return",
"(",
"bool",
")",
"$",
"e",
";",
"}",
"else",
"{",... | Test whether this object is in a state of error
@param int php error level constant
@return bool | [
"Test",
"whether",
"this",
"object",
"is",
"in",
"a",
"state",
"of",
"error"
] | f9de77171c0d37d237e0e9a918ed7bff19e12095 | https://github.com/pscheit/jparser/blob/f9de77171c0d37d237e0e9a918ed7bff19e12095/PLUG/core/PLUGObject.php#L162-L170 | train |
fezfez/codeGenerator | src/CrudGenerator/Metadata/Sources/MetaDataDAOCache.php | MetaDataDAOCache.getAllMetadata | public function getAllMetadata()
{
$configName = ($this->config !== null) ? $this->config->getUniqueName() : '';
$cacheFilename = Installer::BASE_PATH . Installer::CACHE_PATH . DIRECTORY_SEPARATOR;
$cacheFilename .= md5('all_metadata' . get_class($this->metadataDAO) . $configName);
if ($this->fileManager->isFile($cacheFilename) === true && $this->noCache === false) {
$data = unserialize($this->fileManager->fileGetContent($cacheFilename));
} else {
$data = $this->metadataDAO->getAllMetadata();
$this->fileManager->filePutsContent($cacheFilename, serialize($data));
}
return $data;
} | php | public function getAllMetadata()
{
$configName = ($this->config !== null) ? $this->config->getUniqueName() : '';
$cacheFilename = Installer::BASE_PATH . Installer::CACHE_PATH . DIRECTORY_SEPARATOR;
$cacheFilename .= md5('all_metadata' . get_class($this->metadataDAO) . $configName);
if ($this->fileManager->isFile($cacheFilename) === true && $this->noCache === false) {
$data = unserialize($this->fileManager->fileGetContent($cacheFilename));
} else {
$data = $this->metadataDAO->getAllMetadata();
$this->fileManager->filePutsContent($cacheFilename, serialize($data));
}
return $data;
} | [
"public",
"function",
"getAllMetadata",
"(",
")",
"{",
"$",
"configName",
"=",
"(",
"$",
"this",
"->",
"config",
"!==",
"null",
")",
"?",
"$",
"this",
"->",
"config",
"->",
"getUniqueName",
"(",
")",
":",
"''",
";",
"$",
"cacheFilename",
"=",
"Installe... | Get all metadata from the concrete metadata DAO
@return \CrudGenerator\Metadata\DataObject\MetaDataCollection | [
"Get",
"all",
"metadata",
"from",
"the",
"concrete",
"metadata",
"DAO"
] | 559f22bcc525c3157ecb17fe96818dd7b7ee58c2 | https://github.com/fezfez/codeGenerator/blob/559f22bcc525c3157ecb17fe96818dd7b7ee58c2/src/CrudGenerator/Metadata/Sources/MetaDataDAOCache.php#L62-L76 | train |
pscheit/jparser | PLUG/parsing/Lex.php | Lex.defined | function defined( $c ){
if( isset($this->literals[$c]) ){
return true;
}
if( ! defined($c) ){
return false;
}
$i = constant( $c );
return isset( $this->names[$i] ) && $this->names[$i] === $c;
} | php | function defined( $c ){
if( isset($this->literals[$c]) ){
return true;
}
if( ! defined($c) ){
return false;
}
$i = constant( $c );
return isset( $this->names[$i] ) && $this->names[$i] === $c;
} | [
"function",
"defined",
"(",
"$",
"c",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"literals",
"[",
"$",
"c",
"]",
")",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"!",
"defined",
"(",
"$",
"c",
")",
")",
"{",
"return",
"false",... | Test if symbol is defined in this Lex
@param string
@return bool | [
"Test",
"if",
"symbol",
"is",
"defined",
"in",
"this",
"Lex"
] | f9de77171c0d37d237e0e9a918ed7bff19e12095 | https://github.com/pscheit/jparser/blob/f9de77171c0d37d237e0e9a918ed7bff19e12095/PLUG/parsing/Lex.php#L111-L120 | train |
pscheit/jparser | PLUG/parsing/Lex.php | Lex.name | function name( $i ){
if( is_int($i) ){
if( ! isset($this->names[$i]) ){
trigger_error("symbol ".var_export($i,1)." is unknown in ".get_class($this), E_USER_NOTICE );
return 'UNKNOWN';
}
else {
return $this->names[$i];
}
}
else if ( ! isset($this->literals[$i]) ){
trigger_error("literal symbol ".var_export($i,1)." is unknown in ".get_class($this), E_USER_NOTICE );
}
return $i;
} | php | function name( $i ){
if( is_int($i) ){
if( ! isset($this->names[$i]) ){
trigger_error("symbol ".var_export($i,1)." is unknown in ".get_class($this), E_USER_NOTICE );
return 'UNKNOWN';
}
else {
return $this->names[$i];
}
}
else if ( ! isset($this->literals[$i]) ){
trigger_error("literal symbol ".var_export($i,1)." is unknown in ".get_class($this), E_USER_NOTICE );
}
return $i;
} | [
"function",
"name",
"(",
"$",
"i",
")",
"{",
"if",
"(",
"is_int",
"(",
"$",
"i",
")",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"names",
"[",
"$",
"i",
"]",
")",
")",
"{",
"trigger_error",
"(",
"\"symbol \"",
".",
"var_export",... | Get internal name from constant symbol value
@param int
@return string | [
"Get",
"internal",
"name",
"from",
"constant",
"symbol",
"value"
] | f9de77171c0d37d237e0e9a918ed7bff19e12095 | https://github.com/pscheit/jparser/blob/f9de77171c0d37d237e0e9a918ed7bff19e12095/PLUG/parsing/Lex.php#L129-L143 | train |
pscheit/jparser | PLUG/parsing/LR/LRNDA.php | LRNDA.export | function export(){
$RootSet = $this->resolve();
$table = array();
$RootSet->export( $table, $this->Grammar );
return new LRParseTableBuilder( $table );
} | php | function export(){
$RootSet = $this->resolve();
$table = array();
$RootSet->export( $table, $this->Grammar );
return new LRParseTableBuilder( $table );
} | [
"function",
"export",
"(",
")",
"{",
"$",
"RootSet",
"=",
"$",
"this",
"->",
"resolve",
"(",
")",
";",
"$",
"table",
"=",
"array",
"(",
")",
";",
"$",
"RootSet",
"->",
"export",
"(",
"$",
"table",
",",
"$",
"this",
"->",
"Grammar",
")",
";",
"r... | Export to determinsitic parse table.
@return LRParseTable | [
"Export",
"to",
"determinsitic",
"parse",
"table",
"."
] | f9de77171c0d37d237e0e9a918ed7bff19e12095 | https://github.com/pscheit/jparser/blob/f9de77171c0d37d237e0e9a918ed7bff19e12095/PLUG/parsing/LR/LRNDA.php#L57-L62 | train |
pscheit/jparser | PLUG/parsing/LR/LRNDA.php | LRNDA.resolve | function resolve(){
LRState::clear_index();
LRStation::clear_index();
// create Root Set
// we SHOULD have a single etransition to an intial state
return LRStateSet::init( $this->etransitions[0], $this->Grammar );
} | php | function resolve(){
LRState::clear_index();
LRStation::clear_index();
// create Root Set
// we SHOULD have a single etransition to an intial state
return LRStateSet::init( $this->etransitions[0], $this->Grammar );
} | [
"function",
"resolve",
"(",
")",
"{",
"LRState",
"::",
"clear_index",
"(",
")",
";",
"LRStation",
"::",
"clear_index",
"(",
")",
";",
"// create Root Set",
"// we SHOULD have a single etransition to an intial state",
"return",
"LRStateSet",
"::",
"init",
"(",
"$",
"... | Resolve non-deterministic automaton into a deterministic state tree
@return LRStateSet | [
"Resolve",
"non",
"-",
"deterministic",
"automaton",
"into",
"a",
"deterministic",
"state",
"tree"
] | f9de77171c0d37d237e0e9a918ed7bff19e12095 | https://github.com/pscheit/jparser/blob/f9de77171c0d37d237e0e9a918ed7bff19e12095/PLUG/parsing/LR/LRNDA.php#L70-L76 | train |
fezfez/codeGenerator | src/CrudGenerator/Metadata/MetaDataSourceFinder.php | MetaDataSourceFinder.getAllAdapters | public function getAllAdapters()
{
$classCollection = $this->classAwake->wakeByInterfaces(
array(
__DIR__ . '/Sources/',
),
'CrudGenerator\Metadata\Sources\MetaDataDAOFactoryInterface'
);
$adapterCollection = new MetaDataSourceCollection();
foreach ($classCollection as $className) {
$adapterCollection->append(
$this->metaDataSourceHydrator->adapterNameToMetaDataSource(
$className
)
);
}
return $adapterCollection;
} | php | public function getAllAdapters()
{
$classCollection = $this->classAwake->wakeByInterfaces(
array(
__DIR__ . '/Sources/',
),
'CrudGenerator\Metadata\Sources\MetaDataDAOFactoryInterface'
);
$adapterCollection = new MetaDataSourceCollection();
foreach ($classCollection as $className) {
$adapterCollection->append(
$this->metaDataSourceHydrator->adapterNameToMetaDataSource(
$className
)
);
}
return $adapterCollection;
} | [
"public",
"function",
"getAllAdapters",
"(",
")",
"{",
"$",
"classCollection",
"=",
"$",
"this",
"->",
"classAwake",
"->",
"wakeByInterfaces",
"(",
"array",
"(",
"__DIR__",
".",
"'/Sources/'",
",",
")",
",",
"'CrudGenerator\\Metadata\\Sources\\MetaDataDAOFactoryInterf... | Find all adpater in the projects
@return MetaDataSourceCollection | [
"Find",
"all",
"adpater",
"in",
"the",
"projects"
] | 559f22bcc525c3157ecb17fe96818dd7b7ee58c2 | https://github.com/fezfez/codeGenerator/blob/559f22bcc525c3157ecb17fe96818dd7b7ee58c2/src/CrudGenerator/Metadata/MetaDataSourceFinder.php#L46-L66 | train |
manaphp/framework | Amqp.php | Amqp.purgeQueue | public function purgeQueue($name)
{
if (!isset($this->_queues[$name])) {
throw new InvalidKeyException(['purge `:queue` queue failed: it is NOT exists', 'queue' => $name]);
}
try {
$this->_queues[$name]->purge();
} catch (\Exception $e) {
throw new AmqpException(['purge `:queue` queue failed: error', 'queue' => $name, 'error' => $e->getMessage()]);
}
return $this;
} | php | public function purgeQueue($name)
{
if (!isset($this->_queues[$name])) {
throw new InvalidKeyException(['purge `:queue` queue failed: it is NOT exists', 'queue' => $name]);
}
try {
$this->_queues[$name]->purge();
} catch (\Exception $e) {
throw new AmqpException(['purge `:queue` queue failed: error', 'queue' => $name, 'error' => $e->getMessage()]);
}
return $this;
} | [
"public",
"function",
"purgeQueue",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_queues",
"[",
"$",
"name",
"]",
")",
")",
"{",
"throw",
"new",
"InvalidKeyException",
"(",
"[",
"'purge `:queue` queue failed: it is NOT exists... | Purge the contents of a queue
@param string $name
@return static | [
"Purge",
"the",
"contents",
"of",
"a",
"queue"
] | b9a15c7f8f5d4770cacbea43f26914765bfcb248 | https://github.com/manaphp/framework/blob/b9a15c7f8f5d4770cacbea43f26914765bfcb248/Amqp.php#L298-L311 | train |
manaphp/framework | Mongodb/Model.php | Model.getFieldTypes | public function getFieldTypes()
{
static $cached = [];
$class = static::class;
if (!isset($cached[$class])) {
if (!$doc = static::sample()) {
if (!$docs = $this->getConnection()->fetchAll($this->getSource(), [], ['limit' => 1])) {
throw new RuntimeException(['`:collection` collection has none record', 'collection' => $this->getSource()]);
}
$doc = $docs[0];
}
$types = [];
foreach ($doc as $field => $value) {
$type = gettype($value);
if ($type === 'integer') {
$types[$field] = 'int';
} elseif ($type === 'string') {
$types[$field] = 'string';
} elseif ($type === 'double') {
$types[$field] = 'float';
} elseif ($type === 'boolean') {
$types[$field] = 'bool';
} elseif ($type === 'array') {
$types[$field] = 'array';
} elseif ($value instanceof ObjectID) {
if ($field === '_id') {
continue;
}
$types[$field] = 'objectid';
} else {
throw new RuntimeException(['`:field` field value type can not be infered.', 'field' => $field]);
}
}
$cached[$class] = $types;
}
return $cached[$class];
} | php | public function getFieldTypes()
{
static $cached = [];
$class = static::class;
if (!isset($cached[$class])) {
if (!$doc = static::sample()) {
if (!$docs = $this->getConnection()->fetchAll($this->getSource(), [], ['limit' => 1])) {
throw new RuntimeException(['`:collection` collection has none record', 'collection' => $this->getSource()]);
}
$doc = $docs[0];
}
$types = [];
foreach ($doc as $field => $value) {
$type = gettype($value);
if ($type === 'integer') {
$types[$field] = 'int';
} elseif ($type === 'string') {
$types[$field] = 'string';
} elseif ($type === 'double') {
$types[$field] = 'float';
} elseif ($type === 'boolean') {
$types[$field] = 'bool';
} elseif ($type === 'array') {
$types[$field] = 'array';
} elseif ($value instanceof ObjectID) {
if ($field === '_id') {
continue;
}
$types[$field] = 'objectid';
} else {
throw new RuntimeException(['`:field` field value type can not be infered.', 'field' => $field]);
}
}
$cached[$class] = $types;
}
return $cached[$class];
} | [
"public",
"function",
"getFieldTypes",
"(",
")",
"{",
"static",
"$",
"cached",
"=",
"[",
"]",
";",
"$",
"class",
"=",
"static",
"::",
"class",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"cached",
"[",
"$",
"class",
"]",
")",
")",
"{",
"if",
"(",
"... | bool, int, float, string, array, objectid
@return array | [
"bool",
"int",
"float",
"string",
"array",
"objectid"
] | b9a15c7f8f5d4770cacbea43f26914765bfcb248 | https://github.com/manaphp/framework/blob/b9a15c7f8f5d4770cacbea43f26914765bfcb248/Mongodb/Model.php#L153-L195 | train |
manaphp/framework | Loader.php | Loader.registerNamespaces | public function registerNamespaces($namespaces, $merge = true)
{
foreach ($namespaces as $namespace => $path) {
$path = rtrim($path, '\\/');
if (DIRECTORY_SEPARATOR === '\\') {
$namespaces[$namespace] = strtr($path, '\\', '/');
}
}
$this->_namespaces = $merge ? array_merge($this->_namespaces, $namespaces) : $namespaces;
return $this;
} | php | public function registerNamespaces($namespaces, $merge = true)
{
foreach ($namespaces as $namespace => $path) {
$path = rtrim($path, '\\/');
if (DIRECTORY_SEPARATOR === '\\') {
$namespaces[$namespace] = strtr($path, '\\', '/');
}
}
$this->_namespaces = $merge ? array_merge($this->_namespaces, $namespaces) : $namespaces;
return $this;
} | [
"public",
"function",
"registerNamespaces",
"(",
"$",
"namespaces",
",",
"$",
"merge",
"=",
"true",
")",
"{",
"foreach",
"(",
"$",
"namespaces",
"as",
"$",
"namespace",
"=>",
"$",
"path",
")",
"{",
"$",
"path",
"=",
"rtrim",
"(",
"$",
"path",
",",
"'... | Register namespaces and their related directories
@param array $namespaces
@param bool $merge
@return static | [
"Register",
"namespaces",
"and",
"their",
"related",
"directories"
] | b9a15c7f8f5d4770cacbea43f26914765bfcb248 | https://github.com/manaphp/framework/blob/b9a15c7f8f5d4770cacbea43f26914765bfcb248/Loader.php#L44-L56 | train |
manaphp/framework | Loader.php | Loader.registerClasses | public function registerClasses($classes, $merge = true)
{
if (DIRECTORY_SEPARATOR === '\\') {
foreach ($classes as $key => $path) {
$classes[$key] = strtr($path, '\\', '/');
}
}
$this->_classes = $merge ? array_merge($this->_classes, $classes) : $classes;
return $this;
} | php | public function registerClasses($classes, $merge = true)
{
if (DIRECTORY_SEPARATOR === '\\') {
foreach ($classes as $key => $path) {
$classes[$key] = strtr($path, '\\', '/');
}
}
$this->_classes = $merge ? array_merge($this->_classes, $classes) : $classes;
return $this;
} | [
"public",
"function",
"registerClasses",
"(",
"$",
"classes",
",",
"$",
"merge",
"=",
"true",
")",
"{",
"if",
"(",
"DIRECTORY_SEPARATOR",
"===",
"'\\\\'",
")",
"{",
"foreach",
"(",
"$",
"classes",
"as",
"$",
"key",
"=>",
"$",
"path",
")",
"{",
"$",
"... | Register classes and their locations
@param array $classes
@param bool $merge
@return static | [
"Register",
"classes",
"and",
"their",
"locations"
] | b9a15c7f8f5d4770cacbea43f26914765bfcb248 | https://github.com/manaphp/framework/blob/b9a15c7f8f5d4770cacbea43f26914765bfcb248/Loader.php#L74-L85 | train |
manaphp/framework | Loader.php | Loader.requireFile | public function requireFile($file)
{
if (PHP_EOL !== "\n" && strpos($file, 'phar://') !== 0) {
$realPath = strtr(realpath($file), '\\', '/');
if ($realPath !== $file) {
trigger_error("File name ($realPath) case mismatch for .$file", E_USER_ERROR);
}
}
/** @noinspection PhpIncludeInspection */
require $file;
} | php | public function requireFile($file)
{
if (PHP_EOL !== "\n" && strpos($file, 'phar://') !== 0) {
$realPath = strtr(realpath($file), '\\', '/');
if ($realPath !== $file) {
trigger_error("File name ($realPath) case mismatch for .$file", E_USER_ERROR);
}
}
/** @noinspection PhpIncludeInspection */
require $file;
} | [
"public",
"function",
"requireFile",
"(",
"$",
"file",
")",
"{",
"if",
"(",
"PHP_EOL",
"!==",
"\"\\n\"",
"&&",
"strpos",
"(",
"$",
"file",
",",
"'phar://'",
")",
"!==",
"0",
")",
"{",
"$",
"realPath",
"=",
"strtr",
"(",
"realpath",
"(",
"$",
"file",
... | If a file exists, require it from the file system.
@param string $file The file to require.
@return void | [
"If",
"a",
"file",
"exists",
"require",
"it",
"from",
"the",
"file",
"system",
"."
] | b9a15c7f8f5d4770cacbea43f26914765bfcb248 | https://github.com/manaphp/framework/blob/b9a15c7f8f5d4770cacbea43f26914765bfcb248/Loader.php#L118-L128 | train |
manaphp/framework | Loader.php | Loader.load | public function load($className)
{
if (isset($this->_classes[$className])) {
$file = $this->_classes[$className];
if (!is_file($file)) {
trigger_error(strtr('load `:class` class failed: `:file` is not exists.', [':class' => $className, ':file' => $file]), E_USER_ERROR);
}
//either linux or phar://
if (PHP_EOL === "\n" || $file[0] === 'p') {
/** @noinspection PhpIncludeInspection */
require $file;
} else {
$this->requireFile($file);
}
return true;
}
/** @noinspection LoopWhichDoesNotLoopInspection */
foreach ($this->_namespaces as $namespace => $path) {
if (strpos($className, $namespace) !== 0) {
continue;
}
$file = $path . strtr(substr($className, strlen($namespace)), '\\', '/') . '.php';
if (is_file($file)) {
//either linux or phar://
if (PHP_EOL === "\n" || $file[0] === 'p') {
/** @noinspection PhpIncludeInspection */
require $file;
} else {
$this->requireFile($file);
}
return true;
}
}
return false;
} | php | public function load($className)
{
if (isset($this->_classes[$className])) {
$file = $this->_classes[$className];
if (!is_file($file)) {
trigger_error(strtr('load `:class` class failed: `:file` is not exists.', [':class' => $className, ':file' => $file]), E_USER_ERROR);
}
//either linux or phar://
if (PHP_EOL === "\n" || $file[0] === 'p') {
/** @noinspection PhpIncludeInspection */
require $file;
} else {
$this->requireFile($file);
}
return true;
}
/** @noinspection LoopWhichDoesNotLoopInspection */
foreach ($this->_namespaces as $namespace => $path) {
if (strpos($className, $namespace) !== 0) {
continue;
}
$file = $path . strtr(substr($className, strlen($namespace)), '\\', '/') . '.php';
if (is_file($file)) {
//either linux or phar://
if (PHP_EOL === "\n" || $file[0] === 'p') {
/** @noinspection PhpIncludeInspection */
require $file;
} else {
$this->requireFile($file);
}
return true;
}
}
return false;
} | [
"public",
"function",
"load",
"(",
"$",
"className",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_classes",
"[",
"$",
"className",
"]",
")",
")",
"{",
"$",
"file",
"=",
"$",
"this",
"->",
"_classes",
"[",
"$",
"className",
"]",
";",
"i... | Makes the work of autoload registered classes
@param string $className
@return bool | [
"Makes",
"the",
"work",
"of",
"autoload",
"registered",
"classes"
] | b9a15c7f8f5d4770cacbea43f26914765bfcb248 | https://github.com/manaphp/framework/blob/b9a15c7f8f5d4770cacbea43f26914765bfcb248/Loader.php#L137-L177 | train |
mapbender/fom | src/FOM/UserBundle/Form/DataTransformer/ACEDataTransformer.php | ACEDataTransformer.transform | public function transform($ace)
{
$sid = null;
$mask = null;
$sidPrefix = '';
$sidName = '';
$permissions = array();
if($ace instanceof Entry) {
$sid = $ace->getSecurityIdentity();
$mask = $ace->getMask();
} elseif(is_array($ace)) {
$sid = $ace['sid'];
$mask = $ace['mask'];
}
$sidString = '';
if($sid instanceof RoleSecurityIdentity) {
$sidPrefix = 'r';
$sidName = $sid->getRole();
$sidString = sprintf('%s:%s', $sidPrefix, $sidName);
} elseif($sid instanceof UserSecurityIdentity) {
$sidPrefix = 'u';
$sidName = $sid->getUsername();
$sidClass = $sid->getClass();
$sidString = sprintf('%s:%s:%s', $sidPrefix, $sidName, $sidClass);
}
for($i = 1; $i <= 30; $i++) {
$key = 1 << ($i-1);
if($mask & $key) {
$permissions[$i] = true;
} else {
$permissions[$i] = false;
}
}
return array(
'sid' => $sidString,
'permissions' => $permissions);
} | php | public function transform($ace)
{
$sid = null;
$mask = null;
$sidPrefix = '';
$sidName = '';
$permissions = array();
if($ace instanceof Entry) {
$sid = $ace->getSecurityIdentity();
$mask = $ace->getMask();
} elseif(is_array($ace)) {
$sid = $ace['sid'];
$mask = $ace['mask'];
}
$sidString = '';
if($sid instanceof RoleSecurityIdentity) {
$sidPrefix = 'r';
$sidName = $sid->getRole();
$sidString = sprintf('%s:%s', $sidPrefix, $sidName);
} elseif($sid instanceof UserSecurityIdentity) {
$sidPrefix = 'u';
$sidName = $sid->getUsername();
$sidClass = $sid->getClass();
$sidString = sprintf('%s:%s:%s', $sidPrefix, $sidName, $sidClass);
}
for($i = 1; $i <= 30; $i++) {
$key = 1 << ($i-1);
if($mask & $key) {
$permissions[$i] = true;
} else {
$permissions[$i] = false;
}
}
return array(
'sid' => $sidString,
'permissions' => $permissions);
} | [
"public",
"function",
"transform",
"(",
"$",
"ace",
")",
"{",
"$",
"sid",
"=",
"null",
";",
"$",
"mask",
"=",
"null",
";",
"$",
"sidPrefix",
"=",
"''",
";",
"$",
"sidName",
"=",
"''",
";",
"$",
"permissions",
"=",
"array",
"(",
")",
";",
"if",
... | Transforms an single ACE to an object suitable for ACEType
@param ace $ace
@return object | [
"Transforms",
"an",
"single",
"ACE",
"to",
"an",
"object",
"suitable",
"for",
"ACEType"
] | 6dea943121f3c3f9b1b4b14dc2a8e8640a120675 | https://github.com/mapbender/fom/blob/6dea943121f3c3f9b1b4b14dc2a8e8640a120675/src/FOM/UserBundle/Form/DataTransformer/ACEDataTransformer.php#L26-L67 | train |
mapbender/fom | src/FOM/UserBundle/Form/DataTransformer/ACEDataTransformer.php | ACEDataTransformer.reverseTransform | public function reverseTransform($data)
{
$sidParts = explode(':', $data['sid']);
if(strtoupper($sidParts[0]) == 'R') {
/* is rolebased */
$sid = new RoleSecurityIdentity($sidParts[1]);
} else {
if(3 == count($sidParts)) {
/* has 3 sidParts */
$class = $sidParts[2];
} else {
if($this->isLdapUser($sidParts[1])) {
/* is LDAP user*/
$class = 'Mapbender\LdapIntegrationBundle\Entity\LdapUser';
} else {
/* is not a LDAP user*/
$class = 'FOM\UserBundle\Entity\User';
}
}
$sid = new UserSecurityIdentity($sidParts[1], $class);
}
$maskBuilder = new MaskBuilder();
foreach($data['permissions'] as $bit => $permission) {
if(true === $permission) {
$maskBuilder->add(1 << ($bit - 1));
}
}
return array(
'sid' => $sid,
'mask' => $maskBuilder->get());
} | php | public function reverseTransform($data)
{
$sidParts = explode(':', $data['sid']);
if(strtoupper($sidParts[0]) == 'R') {
/* is rolebased */
$sid = new RoleSecurityIdentity($sidParts[1]);
} else {
if(3 == count($sidParts)) {
/* has 3 sidParts */
$class = $sidParts[2];
} else {
if($this->isLdapUser($sidParts[1])) {
/* is LDAP user*/
$class = 'Mapbender\LdapIntegrationBundle\Entity\LdapUser';
} else {
/* is not a LDAP user*/
$class = 'FOM\UserBundle\Entity\User';
}
}
$sid = new UserSecurityIdentity($sidParts[1], $class);
}
$maskBuilder = new MaskBuilder();
foreach($data['permissions'] as $bit => $permission) {
if(true === $permission) {
$maskBuilder->add(1 << ($bit - 1));
}
}
return array(
'sid' => $sid,
'mask' => $maskBuilder->get());
} | [
"public",
"function",
"reverseTransform",
"(",
"$",
"data",
")",
"{",
"$",
"sidParts",
"=",
"explode",
"(",
"':'",
",",
"$",
"data",
"[",
"'sid'",
"]",
")",
";",
"if",
"(",
"strtoupper",
"(",
"$",
"sidParts",
"[",
"0",
"]",
")",
"==",
"'R'",
")",
... | Transforms an ACEType result into an ACE
@param object $data
@return ace | [
"Transforms",
"an",
"ACEType",
"result",
"into",
"an",
"ACE"
] | 6dea943121f3c3f9b1b4b14dc2a8e8640a120675 | https://github.com/mapbender/fom/blob/6dea943121f3c3f9b1b4b14dc2a8e8640a120675/src/FOM/UserBundle/Form/DataTransformer/ACEDataTransformer.php#L75-L107 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.