id
int32 0
241k
| repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
list | docstring
stringlengths 3
47.2k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 91
247
|
|---|---|---|---|---|---|---|---|---|---|---|---|
229,000
|
slickframework/slick
|
src/Slick/Mvc/Application.php
|
Application.getDispatcher
|
public function getDispatcher()
{
if (is_null($this->_dispatcher)) {
$this->setDispatcher(new Dispatcher(['application' => $this]));
}
return $this->_dispatcher;
}
|
php
|
public function getDispatcher()
{
if (is_null($this->_dispatcher)) {
$this->setDispatcher(new Dispatcher(['application' => $this]));
}
return $this->_dispatcher;
}
|
[
"public",
"function",
"getDispatcher",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"_dispatcher",
")",
")",
"{",
"$",
"this",
"->",
"setDispatcher",
"(",
"new",
"Dispatcher",
"(",
"[",
"'application'",
"=>",
"$",
"this",
"]",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_dispatcher",
";",
"}"
] |
Returns the request dispatcher
@return Dispatcher
|
[
"Returns",
"the",
"request",
"dispatcher"
] |
77f56b81020ce8c10f25f7d918661ccd9a918a37
|
https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Mvc/Application.php#L299-L305
|
229,001
|
slickframework/slick
|
src/Slick/Mvc/Application.php
|
Application._startErrorHandler
|
protected function _startErrorHandler()
{
$this->_whoops = new Run();
$environment = $this->getConfiguration()
->get('environment', 'production');
switch ($environment) {
case 'production':
$handler = new Production();
$handler->setApplication($this);
break;
default:
$handler = new PrettyPageHandler();
}
$this->_whoops->pushHandler($handler);
$this->_whoops->register();
return $this;
}
|
php
|
protected function _startErrorHandler()
{
$this->_whoops = new Run();
$environment = $this->getConfiguration()
->get('environment', 'production');
switch ($environment) {
case 'production':
$handler = new Production();
$handler->setApplication($this);
break;
default:
$handler = new PrettyPageHandler();
}
$this->_whoops->pushHandler($handler);
$this->_whoops->register();
return $this;
}
|
[
"protected",
"function",
"_startErrorHandler",
"(",
")",
"{",
"$",
"this",
"->",
"_whoops",
"=",
"new",
"Run",
"(",
")",
";",
"$",
"environment",
"=",
"$",
"this",
"->",
"getConfiguration",
"(",
")",
"->",
"get",
"(",
"'environment'",
",",
"'production'",
")",
";",
"switch",
"(",
"$",
"environment",
")",
"{",
"case",
"'production'",
":",
"$",
"handler",
"=",
"new",
"Production",
"(",
")",
";",
"$",
"handler",
"->",
"setApplication",
"(",
"$",
"this",
")",
";",
"break",
";",
"default",
":",
"$",
"handler",
"=",
"new",
"PrettyPageHandler",
"(",
")",
";",
"}",
"$",
"this",
"->",
"_whoops",
"->",
"pushHandler",
"(",
"$",
"handler",
")",
";",
"$",
"this",
"->",
"_whoops",
"->",
"register",
"(",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Starts and registers the error handler
@return self
|
[
"Starts",
"and",
"registers",
"the",
"error",
"handler"
] |
77f56b81020ce8c10f25f7d918661ccd9a918a37
|
https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Mvc/Application.php#L323-L343
|
229,002
|
slickframework/slick
|
src/Slick/Utility/Text.php
|
Text.singular
|
public static function singular($string)
{
$result = $string;
foreach (self::$_singular as $rule => $replacement) {
$rule = self::_normalize($rule);
if (preg_match($rule, $string)) {
$result = preg_replace($rule, $replacement, $string);
break;
}
}
return $result;
}
|
php
|
public static function singular($string)
{
$result = $string;
foreach (self::$_singular as $rule => $replacement) {
$rule = self::_normalize($rule);
if (preg_match($rule, $string)) {
$result = preg_replace($rule, $replacement, $string);
break;
}
}
return $result;
}
|
[
"public",
"static",
"function",
"singular",
"(",
"$",
"string",
")",
"{",
"$",
"result",
"=",
"$",
"string",
";",
"foreach",
"(",
"self",
"::",
"$",
"_singular",
"as",
"$",
"rule",
"=>",
"$",
"replacement",
")",
"{",
"$",
"rule",
"=",
"self",
"::",
"_normalize",
"(",
"$",
"rule",
")",
";",
"if",
"(",
"preg_match",
"(",
"$",
"rule",
",",
"$",
"string",
")",
")",
"{",
"$",
"result",
"=",
"preg_replace",
"(",
"$",
"rule",
",",
"$",
"replacement",
",",
"$",
"string",
")",
";",
"break",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] |
Returns the singular version of the given string.
@param string $string Singular string to evaluate.
@return string The singular version of the provided string.
|
[
"Returns",
"the",
"singular",
"version",
"of",
"the",
"given",
"string",
"."
] |
77f56b81020ce8c10f25f7d918661ccd9a918a37
|
https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Utility/Text.php#L122-L133
|
229,003
|
slickframework/slick
|
src/Slick/Utility/Text.php
|
Text.plural
|
public static function plural($string)
{
$result = $string;
foreach (self::$_plural as $rule => $replacement) {
$rule = self::_normalize($rule);
if (preg_match($rule, $string)) {
$result = preg_replace($rule, $replacement, $string);
break;
}
}
return $result;
}
|
php
|
public static function plural($string)
{
$result = $string;
foreach (self::$_plural as $rule => $replacement) {
$rule = self::_normalize($rule);
if (preg_match($rule, $string)) {
$result = preg_replace($rule, $replacement, $string);
break;
}
}
return $result;
}
|
[
"public",
"static",
"function",
"plural",
"(",
"$",
"string",
")",
"{",
"$",
"result",
"=",
"$",
"string",
";",
"foreach",
"(",
"self",
"::",
"$",
"_plural",
"as",
"$",
"rule",
"=>",
"$",
"replacement",
")",
"{",
"$",
"rule",
"=",
"self",
"::",
"_normalize",
"(",
"$",
"rule",
")",
";",
"if",
"(",
"preg_match",
"(",
"$",
"rule",
",",
"$",
"string",
")",
")",
"{",
"$",
"result",
"=",
"preg_replace",
"(",
"$",
"rule",
",",
"$",
"replacement",
",",
"$",
"string",
")",
";",
"break",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] |
Returns the plural version of the given string.
@param string $string Plural string to evaluate.
@return string The plural version of the provided string.
|
[
"Returns",
"the",
"plural",
"version",
"of",
"the",
"given",
"string",
"."
] |
77f56b81020ce8c10f25f7d918661ccd9a918a37
|
https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Utility/Text.php#L142-L153
|
229,004
|
slickframework/slick
|
src/Slick/Utility/Text.php
|
Text.split
|
public static function split($string, $pattern, $limit = null)
{
$flags = PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE;
return preg_split(self::_normalize($pattern), $string, $limit, $flags);
}
|
php
|
public static function split($string, $pattern, $limit = null)
{
$flags = PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE;
return preg_split(self::_normalize($pattern), $string, $limit, $flags);
}
|
[
"public",
"static",
"function",
"split",
"(",
"$",
"string",
",",
"$",
"pattern",
",",
"$",
"limit",
"=",
"null",
")",
"{",
"$",
"flags",
"=",
"PREG_SPLIT_NO_EMPTY",
"|",
"PREG_SPLIT_DELIM_CAPTURE",
";",
"return",
"preg_split",
"(",
"self",
"::",
"_normalize",
"(",
"$",
"pattern",
")",
",",
"$",
"string",
",",
"$",
"limit",
",",
"$",
"flags",
")",
";",
"}"
] |
Split string by a regular expression.
This is a less formal method then the PHP preg_split() function.
@param string $string The string to split.
@param string $pattern The regular expression for split operation.
@param integer $limit If specified, then only substring up to limit
are returned with the rest of the string being placed in the
last substring.
@return array Returns an array containing substring of subject
split along boundaries matched by pattern.
|
[
"Split",
"string",
"by",
"a",
"regular",
"expression",
"."
] |
77f56b81020ce8c10f25f7d918661ccd9a918a37
|
https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Utility/Text.php#L198-L202
|
229,005
|
slickframework/slick
|
src/Slick/Utility/Text.php
|
Text._normalize
|
private static function _normalize($pattern)
{
return self::$_delimiter . trim($pattern, self::$_delimiter)
. self::$_delimiter;
}
|
php
|
private static function _normalize($pattern)
{
return self::$_delimiter . trim($pattern, self::$_delimiter)
. self::$_delimiter;
}
|
[
"private",
"static",
"function",
"_normalize",
"(",
"$",
"pattern",
")",
"{",
"return",
"self",
"::",
"$",
"_delimiter",
".",
"trim",
"(",
"$",
"pattern",
",",
"self",
"::",
"$",
"_delimiter",
")",
".",
"self",
"::",
"$",
"_delimiter",
";",
"}"
] |
Normalize the given pattern
This allows the remaining methods can operate on a pattern without
first having to check it or normalize it.
@param string $pattern The pattern string to normalize.
@return string A normalized pattern string.
|
[
"Normalize",
"the",
"given",
"pattern"
] |
77f56b81020ce8c10f25f7d918661ccd9a918a37
|
https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Utility/Text.php#L259-L263
|
229,006
|
jameshalsall/licenser
|
src/Container/ServiceContainer.php
|
ServiceContainer.setup
|
private function setup()
{
$this['licenser'] = function () {
return new Licenser(new Finder());
};
$this['command.licenser'] = function ($c) {
return new LicenserCommand($c['licenser'], $c['license_header_factory']);
};
$this['command.check'] = function ($c) {
return new CheckCommand($c['licenser'], $c['license_header_factory']);
};
$this['twig.templating'] = function () {
$loader = new \Twig_Loader_Filesystem(__DIR__ . '/../../licenses');
return new \Twig_Environment($loader);
};
$this['license_header_factory'] = function ($c) {
return new LicenseHeaderFactory($c['twig.templating']);
};
}
|
php
|
private function setup()
{
$this['licenser'] = function () {
return new Licenser(new Finder());
};
$this['command.licenser'] = function ($c) {
return new LicenserCommand($c['licenser'], $c['license_header_factory']);
};
$this['command.check'] = function ($c) {
return new CheckCommand($c['licenser'], $c['license_header_factory']);
};
$this['twig.templating'] = function () {
$loader = new \Twig_Loader_Filesystem(__DIR__ . '/../../licenses');
return new \Twig_Environment($loader);
};
$this['license_header_factory'] = function ($c) {
return new LicenseHeaderFactory($c['twig.templating']);
};
}
|
[
"private",
"function",
"setup",
"(",
")",
"{",
"$",
"this",
"[",
"'licenser'",
"]",
"=",
"function",
"(",
")",
"{",
"return",
"new",
"Licenser",
"(",
"new",
"Finder",
"(",
")",
")",
";",
"}",
";",
"$",
"this",
"[",
"'command.licenser'",
"]",
"=",
"function",
"(",
"$",
"c",
")",
"{",
"return",
"new",
"LicenserCommand",
"(",
"$",
"c",
"[",
"'licenser'",
"]",
",",
"$",
"c",
"[",
"'license_header_factory'",
"]",
")",
";",
"}",
";",
"$",
"this",
"[",
"'command.check'",
"]",
"=",
"function",
"(",
"$",
"c",
")",
"{",
"return",
"new",
"CheckCommand",
"(",
"$",
"c",
"[",
"'licenser'",
"]",
",",
"$",
"c",
"[",
"'license_header_factory'",
"]",
")",
";",
"}",
";",
"$",
"this",
"[",
"'twig.templating'",
"]",
"=",
"function",
"(",
")",
"{",
"$",
"loader",
"=",
"new",
"\\",
"Twig_Loader_Filesystem",
"(",
"__DIR__",
".",
"'/../../licenses'",
")",
";",
"return",
"new",
"\\",
"Twig_Environment",
"(",
"$",
"loader",
")",
";",
"}",
";",
"$",
"this",
"[",
"'license_header_factory'",
"]",
"=",
"function",
"(",
"$",
"c",
")",
"{",
"return",
"new",
"LicenseHeaderFactory",
"(",
"$",
"c",
"[",
"'twig.templating'",
"]",
")",
";",
"}",
";",
"}"
] |
Setup service configuration.
|
[
"Setup",
"service",
"configuration",
"."
] |
41fce6a66bf42e0045bd479397f788c83f7d78af
|
https://github.com/jameshalsall/licenser/blob/41fce6a66bf42e0045bd479397f788c83f7d78af/src/Container/ServiceContainer.php#L57-L79
|
229,007
|
slickframework/slick
|
src/Slick/Database/Sql/Insert.php
|
Insert.getQueryString
|
public function getQueryString()
{
$dialect = Dialect::create($this->_adapter->getDialect(), $this);
return $dialect->getSqlStatement();
}
|
php
|
public function getQueryString()
{
$dialect = Dialect::create($this->_adapter->getDialect(), $this);
return $dialect->getSqlStatement();
}
|
[
"public",
"function",
"getQueryString",
"(",
")",
"{",
"$",
"dialect",
"=",
"Dialect",
"::",
"create",
"(",
"$",
"this",
"->",
"_adapter",
"->",
"getDialect",
"(",
")",
",",
"$",
"this",
")",
";",
"return",
"$",
"dialect",
"->",
"getSqlStatement",
"(",
")",
";",
"}"
] |
Returns the string version of this query
@return string
|
[
"Returns",
"the",
"string",
"version",
"of",
"this",
"query"
] |
77f56b81020ce8c10f25f7d918661ccd9a918a37
|
https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Database/Sql/Insert.php#L51-L55
|
229,008
|
slickframework/slick
|
src/Slick/Cache/Driver/File.php
|
File.getFolder
|
public function getFolder()
{
if (is_null($this->_folder)) {
$this->_folder = new Folder(
array(
'name' => "{$this->_path}/{$this->_dirName}",
'autoCreate' => true
)
);
}
return $this->_folder;
}
|
php
|
public function getFolder()
{
if (is_null($this->_folder)) {
$this->_folder = new Folder(
array(
'name' => "{$this->_path}/{$this->_dirName}",
'autoCreate' => true
)
);
}
return $this->_folder;
}
|
[
"public",
"function",
"getFolder",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"_folder",
")",
")",
"{",
"$",
"this",
"->",
"_folder",
"=",
"new",
"Folder",
"(",
"array",
"(",
"'name'",
"=>",
"\"{$this->_path}/{$this->_dirName}\"",
",",
"'autoCreate'",
"=>",
"true",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_folder",
";",
"}"
] |
Lazy loading of folder property
@return Folder
|
[
"Lazy",
"loading",
"of",
"folder",
"property"
] |
77f56b81020ce8c10f25f7d918661ccd9a918a37
|
https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Cache/Driver/File.php#L53-L64
|
229,009
|
slickframework/slick
|
src/Slick/Cache/Driver/File.php
|
File.flush
|
public function flush()
{
/** @var Node $node */
foreach ($this->getFolder()->getNodes() as $node) {
if ($node->details->isFile()) {
$node->delete();
}
}
return $this;
}
|
php
|
public function flush()
{
/** @var Node $node */
foreach ($this->getFolder()->getNodes() as $node) {
if ($node->details->isFile()) {
$node->delete();
}
}
return $this;
}
|
[
"public",
"function",
"flush",
"(",
")",
"{",
"/** @var Node $node */",
"foreach",
"(",
"$",
"this",
"->",
"getFolder",
"(",
")",
"->",
"getNodes",
"(",
")",
"as",
"$",
"node",
")",
"{",
"if",
"(",
"$",
"node",
"->",
"details",
"->",
"isFile",
"(",
")",
")",
"{",
"$",
"node",
"->",
"delete",
"(",
")",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] |
Flushes all values controlled by this cache driver
@return File A self instance for chaining method calls.
|
[
"Flushes",
"all",
"values",
"controlled",
"by",
"this",
"cache",
"driver"
] |
77f56b81020ce8c10f25f7d918661ccd9a918a37
|
https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Cache/Driver/File.php#L148-L158
|
229,010
|
slickframework/slick
|
src/Slick/Form/Element/Checkbox.php
|
Checkbox.getHtmlAttributes
|
public function getHtmlAttributes()
{
if ( $this->getValue()) {
$this->_attributes['checked'] = 'checked';
}
$text = parent::getHtmlAttributes();
$text = str_replace('form-control', '', $text);
return $text;
}
|
php
|
public function getHtmlAttributes()
{
if ( $this->getValue()) {
$this->_attributes['checked'] = 'checked';
}
$text = parent::getHtmlAttributes();
$text = str_replace('form-control', '', $text);
return $text;
}
|
[
"public",
"function",
"getHtmlAttributes",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getValue",
"(",
")",
")",
"{",
"$",
"this",
"->",
"_attributes",
"[",
"'checked'",
"]",
"=",
"'checked'",
";",
"}",
"$",
"text",
"=",
"parent",
"::",
"getHtmlAttributes",
"(",
")",
";",
"$",
"text",
"=",
"str_replace",
"(",
"'form-control'",
",",
"''",
",",
"$",
"text",
")",
";",
"return",
"$",
"text",
";",
"}"
] |
Overrides the default method to remove the class form-control
@return string|void
|
[
"Overrides",
"the",
"default",
"method",
"to",
"remove",
"the",
"class",
"form",
"-",
"control"
] |
77f56b81020ce8c10f25f7d918661ccd9a918a37
|
https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Form/Element/Checkbox.php#L53-L61
|
229,011
|
slickframework/slick
|
src/Slick/Di/ContainerBuilder.php
|
ContainerBuilder.buildContainer
|
public static function buildContainer(array $definitions)
{
/** @var ContainerBuilder $builder */
$builder = new static();
$container = Container::getContainer();
$manager = $builder->_createManager($definitions);
if (!$container) {
$container = new Container($manager);
} else {
$builder->_merge($container->getDefinitionManager(), $manager);
}
return $container;
}
|
php
|
public static function buildContainer(array $definitions)
{
/** @var ContainerBuilder $builder */
$builder = new static();
$container = Container::getContainer();
$manager = $builder->_createManager($definitions);
if (!$container) {
$container = new Container($manager);
} else {
$builder->_merge($container->getDefinitionManager(), $manager);
}
return $container;
}
|
[
"public",
"static",
"function",
"buildContainer",
"(",
"array",
"$",
"definitions",
")",
"{",
"/** @var ContainerBuilder $builder */",
"$",
"builder",
"=",
"new",
"static",
"(",
")",
";",
"$",
"container",
"=",
"Container",
"::",
"getContainer",
"(",
")",
";",
"$",
"manager",
"=",
"$",
"builder",
"->",
"_createManager",
"(",
"$",
"definitions",
")",
";",
"if",
"(",
"!",
"$",
"container",
")",
"{",
"$",
"container",
"=",
"new",
"Container",
"(",
"$",
"manager",
")",
";",
"}",
"else",
"{",
"$",
"builder",
"->",
"_merge",
"(",
"$",
"container",
"->",
"getDefinitionManager",
"(",
")",
",",
"$",
"manager",
")",
";",
"}",
"return",
"$",
"container",
";",
"}"
] |
Builds a dependency container with provided definitions
@param array $definitions
@return Container
|
[
"Builds",
"a",
"dependency",
"container",
"with",
"provided",
"definitions"
] |
77f56b81020ce8c10f25f7d918661ccd9a918a37
|
https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Di/ContainerBuilder.php#L37-L49
|
229,012
|
slickframework/slick
|
src/Slick/Di/ContainerBuilder.php
|
ContainerBuilder._createManager
|
protected function _createManager(array $definitions)
{
$manager = new DefinitionManager();
foreach ($definitions as $name => $definition)
{
if ($definition instanceof DefinitionHelperInterface) {
/** @var DefinitionHelperInterface $definition */
$manager->add($definition->getDefinition($name));
} else if ($definition instanceof EntryReference) {
/** @var EntryReference $definition */
$manager->add(new AliasDefinition($name, $definition->getName()));
} else {
$manager->add(new ValueDefinition($name, $definition));
}
}
return $manager;
}
|
php
|
protected function _createManager(array $definitions)
{
$manager = new DefinitionManager();
foreach ($definitions as $name => $definition)
{
if ($definition instanceof DefinitionHelperInterface) {
/** @var DefinitionHelperInterface $definition */
$manager->add($definition->getDefinition($name));
} else if ($definition instanceof EntryReference) {
/** @var EntryReference $definition */
$manager->add(new AliasDefinition($name, $definition->getName()));
} else {
$manager->add(new ValueDefinition($name, $definition));
}
}
return $manager;
}
|
[
"protected",
"function",
"_createManager",
"(",
"array",
"$",
"definitions",
")",
"{",
"$",
"manager",
"=",
"new",
"DefinitionManager",
"(",
")",
";",
"foreach",
"(",
"$",
"definitions",
"as",
"$",
"name",
"=>",
"$",
"definition",
")",
"{",
"if",
"(",
"$",
"definition",
"instanceof",
"DefinitionHelperInterface",
")",
"{",
"/** @var DefinitionHelperInterface $definition */",
"$",
"manager",
"->",
"add",
"(",
"$",
"definition",
"->",
"getDefinition",
"(",
"$",
"name",
")",
")",
";",
"}",
"else",
"if",
"(",
"$",
"definition",
"instanceof",
"EntryReference",
")",
"{",
"/** @var EntryReference $definition */",
"$",
"manager",
"->",
"add",
"(",
"new",
"AliasDefinition",
"(",
"$",
"name",
",",
"$",
"definition",
"->",
"getName",
"(",
")",
")",
")",
";",
"}",
"else",
"{",
"$",
"manager",
"->",
"add",
"(",
"new",
"ValueDefinition",
"(",
"$",
"name",
",",
"$",
"definition",
")",
")",
";",
"}",
"}",
"return",
"$",
"manager",
";",
"}"
] |
Creates a definition manager for provided definitions
@param array $definitions
@return DefinitionManager
|
[
"Creates",
"a",
"definition",
"manager",
"for",
"provided",
"definitions"
] |
77f56b81020ce8c10f25f7d918661ccd9a918a37
|
https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Di/ContainerBuilder.php#L58-L75
|
229,013
|
slickframework/slick
|
src/Slick/Di/ContainerBuilder.php
|
ContainerBuilder._merge
|
protected function _merge(DefinitionManager $current, DefinitionManager $new)
{
/** @var DefinitionInterface $definition */
foreach ($new as $definition) {
if (!$current->has($definition->getName())) {
$current->add($definition);
}
}
}
|
php
|
protected function _merge(DefinitionManager $current, DefinitionManager $new)
{
/** @var DefinitionInterface $definition */
foreach ($new as $definition) {
if (!$current->has($definition->getName())) {
$current->add($definition);
}
}
}
|
[
"protected",
"function",
"_merge",
"(",
"DefinitionManager",
"$",
"current",
",",
"DefinitionManager",
"$",
"new",
")",
"{",
"/** @var DefinitionInterface $definition */",
"foreach",
"(",
"$",
"new",
"as",
"$",
"definition",
")",
"{",
"if",
"(",
"!",
"$",
"current",
"->",
"has",
"(",
"$",
"definition",
"->",
"getName",
"(",
")",
")",
")",
"{",
"$",
"current",
"->",
"add",
"(",
"$",
"definition",
")",
";",
"}",
"}",
"}"
] |
Adds new definitions to the current definitions manager
@param DefinitionManager $current
@param DefinitionManager $new
|
[
"Adds",
"new",
"definitions",
"to",
"the",
"current",
"definitions",
"manager"
] |
77f56b81020ce8c10f25f7d918661ccd9a918a37
|
https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Di/ContainerBuilder.php#L83-L91
|
229,014
|
slickframework/slick
|
src/Slick/Di/Container.php
|
Container.make
|
public function make($name, array $parameters = [])
{
if (! is_string($name)) {
throw new InvalidArgumentException(sprintf(
'The name parameter must be of type string, %s given',
is_object($name) ? get_class($name) : gettype($name)
));
}
$definition = $this->_definitionManager->get($name);
if (! $definition) {
throw new NotFoundException("No entry or class found for '$name'");
}
return $this->_resolveDefinition($definition, $parameters);
}
|
php
|
public function make($name, array $parameters = [])
{
if (! is_string($name)) {
throw new InvalidArgumentException(sprintf(
'The name parameter must be of type string, %s given',
is_object($name) ? get_class($name) : gettype($name)
));
}
$definition = $this->_definitionManager->get($name);
if (! $definition) {
throw new NotFoundException("No entry or class found for '$name'");
}
return $this->_resolveDefinition($definition, $parameters);
}
|
[
"public",
"function",
"make",
"(",
"$",
"name",
",",
"array",
"$",
"parameters",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"name",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'The name parameter must be of type string, %s given'",
",",
"is_object",
"(",
"$",
"name",
")",
"?",
"get_class",
"(",
"$",
"name",
")",
":",
"gettype",
"(",
"$",
"name",
")",
")",
")",
";",
"}",
"$",
"definition",
"=",
"$",
"this",
"->",
"_definitionManager",
"->",
"get",
"(",
"$",
"name",
")",
";",
"if",
"(",
"!",
"$",
"definition",
")",
"{",
"throw",
"new",
"NotFoundException",
"(",
"\"No entry or class found for '$name'\"",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_resolveDefinition",
"(",
"$",
"definition",
",",
"$",
"parameters",
")",
";",
"}"
] |
Build an entry of the container by its name.
This method behave like get() except it forces the scope to "prototype",
which means the definition of the entry will be re-evaluated each time.
For example, if the entry is a class, then a new instance will be
created each time.
This method makes the container behave like a factory.
@param string $name Entry name or a class name.
@param array $parameters Optional parameters to use to build the entry.
Use this to force specific parameters
to specific values. Parameters not defined in
this array will be resolved using
the container.
@throws InvalidArgumentException Name parameter must be of type string.
@throws DependencyException Error while resolving the entry.
@throws NotFoundException No entry found for the given name.
@return mixed
|
[
"Build",
"an",
"entry",
"of",
"the",
"container",
"by",
"its",
"name",
"."
] |
77f56b81020ce8c10f25f7d918661ccd9a918a37
|
https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Di/Container.php#L193-L209
|
229,015
|
slickframework/slick
|
src/Slick/Di/Container.php
|
Container.addResolver
|
public function addResolver($className, ResolverInterface $resolver)
{
if (! class_exists($className)) {
throw new InvalidArgumentException(
"The cass '{$className} was not found."
);
}
$this->_definitionResolvers[$className] = $resolver;
return $this;
}
|
php
|
public function addResolver($className, ResolverInterface $resolver)
{
if (! class_exists($className)) {
throw new InvalidArgumentException(
"The cass '{$className} was not found."
);
}
$this->_definitionResolvers[$className] = $resolver;
return $this;
}
|
[
"public",
"function",
"addResolver",
"(",
"$",
"className",
",",
"ResolverInterface",
"$",
"resolver",
")",
"{",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"className",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"The cass '{$className} was not found.\"",
")",
";",
"}",
"$",
"this",
"->",
"_definitionResolvers",
"[",
"$",
"className",
"]",
"=",
"$",
"resolver",
";",
"return",
"$",
"this",
";",
"}"
] |
Add a definition resolver to the list of resolvers
@param string $className
@param ResolverInterface $resolver
@return Container
@throws Exception\InvalidArgumentException Class name does not exists
|
[
"Add",
"a",
"definition",
"resolver",
"to",
"the",
"list",
"of",
"resolvers"
] |
77f56b81020ce8c10f25f7d918661ccd9a918a37
|
https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Di/Container.php#L220-L230
|
229,016
|
slickframework/slick
|
src/Slick/Di/Container.php
|
Container._resolveDefinition
|
protected function _resolveDefinition(
DefinitionInterface $definition, array $parameters = [])
{
$entryName = $definition->getName();
$definitionResolver = $this->_getDefinitionResolver($definition);
try {
$value = $definitionResolver->resolve($definition, $parameters);
} catch (\Exception $exception) {
throw new DependencyException(
"An error occurred while resolving " .
"entry '{$entryName}': " . $exception->getMessage(),
0,
$exception
);
}
return $value;
}
|
php
|
protected function _resolveDefinition(
DefinitionInterface $definition, array $parameters = [])
{
$entryName = $definition->getName();
$definitionResolver = $this->_getDefinitionResolver($definition);
try {
$value = $definitionResolver->resolve($definition, $parameters);
} catch (\Exception $exception) {
throw new DependencyException(
"An error occurred while resolving " .
"entry '{$entryName}': " . $exception->getMessage(),
0,
$exception
);
}
return $value;
}
|
[
"protected",
"function",
"_resolveDefinition",
"(",
"DefinitionInterface",
"$",
"definition",
",",
"array",
"$",
"parameters",
"=",
"[",
"]",
")",
"{",
"$",
"entryName",
"=",
"$",
"definition",
"->",
"getName",
"(",
")",
";",
"$",
"definitionResolver",
"=",
"$",
"this",
"->",
"_getDefinitionResolver",
"(",
"$",
"definition",
")",
";",
"try",
"{",
"$",
"value",
"=",
"$",
"definitionResolver",
"->",
"resolve",
"(",
"$",
"definition",
",",
"$",
"parameters",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"exception",
")",
"{",
"throw",
"new",
"DependencyException",
"(",
"\"An error occurred while resolving \"",
".",
"\"entry '{$entryName}': \"",
".",
"$",
"exception",
"->",
"getMessage",
"(",
")",
",",
"0",
",",
"$",
"exception",
")",
";",
"}",
"return",
"$",
"value",
";",
"}"
] |
Resolves a definition.
Checks for circular dependencies while resolving the definition.
@param DefinitionInterface $definition
@param array $parameters
@throws DependencyException Error while resolving the entry.
@return mixed
|
[
"Resolves",
"a",
"definition",
"."
] |
77f56b81020ce8c10f25f7d918661ccd9a918a37
|
https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Di/Container.php#L243-L261
|
229,017
|
slickframework/slick
|
src/Slick/Di/Container.php
|
Container._getDefinitionResolver
|
protected function _getDefinitionResolver(DefinitionInterface $definition)
{
$definitionType = get_class($definition);
if (! isset($this->_definitionResolvers[$definitionType])) {
throw new NotFoundException(
"No definition resolver was configured for definition " .
"of type $definitionType"
);
}
return $this->_definitionResolvers[$definitionType];
}
|
php
|
protected function _getDefinitionResolver(DefinitionInterface $definition)
{
$definitionType = get_class($definition);
if (! isset($this->_definitionResolvers[$definitionType])) {
throw new NotFoundException(
"No definition resolver was configured for definition " .
"of type $definitionType"
);
}
return $this->_definitionResolvers[$definitionType];
}
|
[
"protected",
"function",
"_getDefinitionResolver",
"(",
"DefinitionInterface",
"$",
"definition",
")",
"{",
"$",
"definitionType",
"=",
"get_class",
"(",
"$",
"definition",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_definitionResolvers",
"[",
"$",
"definitionType",
"]",
")",
")",
"{",
"throw",
"new",
"NotFoundException",
"(",
"\"No definition resolver was configured for definition \"",
".",
"\"of type $definitionType\"",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_definitionResolvers",
"[",
"$",
"definitionType",
"]",
";",
"}"
] |
Returns a resolver capable of handling the given definition.
@param DefinitionInterface $definition
@throws NotFoundException No definition resolver was found for
this type of definition.
@return ResolverInterface
|
[
"Returns",
"a",
"resolver",
"capable",
"of",
"handling",
"the",
"given",
"definition",
"."
] |
77f56b81020ce8c10f25f7d918661ccd9a918a37
|
https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Di/Container.php#L272-L284
|
229,018
|
silverstripe/silverstripe-mobile
|
code/MobileSiteConfigExtension.php
|
MobileSiteConfigExtension.getMobileSiteType
|
public function getMobileSiteType() {
$defaults = $this->owner->stat('defaults');
$value = $this->owner->getField('MobileSiteType');
if(!$value) $value = $defaults['MobileSiteType'];
return $value;
}
|
php
|
public function getMobileSiteType() {
$defaults = $this->owner->stat('defaults');
$value = $this->owner->getField('MobileSiteType');
if(!$value) $value = $defaults['MobileSiteType'];
return $value;
}
|
[
"public",
"function",
"getMobileSiteType",
"(",
")",
"{",
"$",
"defaults",
"=",
"$",
"this",
"->",
"owner",
"->",
"stat",
"(",
"'defaults'",
")",
";",
"$",
"value",
"=",
"$",
"this",
"->",
"owner",
"->",
"getField",
"(",
"'MobileSiteType'",
")",
";",
"if",
"(",
"!",
"$",
"value",
")",
"$",
"value",
"=",
"$",
"defaults",
"[",
"'MobileSiteType'",
"]",
";",
"return",
"$",
"value",
";",
"}"
] |
Provide a default if MobileSiteType is not set.
@return string
|
[
"Provide",
"a",
"default",
"if",
"MobileSiteType",
"is",
"not",
"set",
"."
] |
27822812aa7d178e4e9d1e7e1b63c2836b4deb21
|
https://github.com/silverstripe/silverstripe-mobile/blob/27822812aa7d178e4e9d1e7e1b63c2836b4deb21/code/MobileSiteConfigExtension.php#L85-L90
|
229,019
|
silverstripe/silverstripe-mobile
|
code/MobileSiteConfigExtension.php
|
MobileSiteConfigExtension.augmentDatabase
|
public function augmentDatabase() {
$defaultThemes = array('blackcandymobile', 'jquerymobile');
$currentTheme = $this->owner->getField('MobileTheme');
if(!$currentTheme || in_array($currentTheme, $defaultThemes)) {
$this->copyDefaultTheme($currentTheme);
}
}
|
php
|
public function augmentDatabase() {
$defaultThemes = array('blackcandymobile', 'jquerymobile');
$currentTheme = $this->owner->getField('MobileTheme');
if(!$currentTheme || in_array($currentTheme, $defaultThemes)) {
$this->copyDefaultTheme($currentTheme);
}
}
|
[
"public",
"function",
"augmentDatabase",
"(",
")",
"{",
"$",
"defaultThemes",
"=",
"array",
"(",
"'blackcandymobile'",
",",
"'jquerymobile'",
")",
";",
"$",
"currentTheme",
"=",
"$",
"this",
"->",
"owner",
"->",
"getField",
"(",
"'MobileTheme'",
")",
";",
"if",
"(",
"!",
"$",
"currentTheme",
"||",
"in_array",
"(",
"$",
"currentTheme",
",",
"$",
"defaultThemes",
")",
")",
"{",
"$",
"this",
"->",
"copyDefaultTheme",
"(",
"$",
"currentTheme",
")",
";",
"}",
"}"
] |
The default theme is "blackcandymobile". If this is still set
as a field on SiteConfig, then make sure that it's copied
into the themes directory from the mobile module.
|
[
"The",
"default",
"theme",
"is",
"blackcandymobile",
".",
"If",
"this",
"is",
"still",
"set",
"as",
"a",
"field",
"on",
"SiteConfig",
"then",
"make",
"sure",
"that",
"it",
"s",
"copied",
"into",
"the",
"themes",
"directory",
"from",
"the",
"mobile",
"module",
"."
] |
27822812aa7d178e4e9d1e7e1b63c2836b4deb21
|
https://github.com/silverstripe/silverstripe-mobile/blob/27822812aa7d178e4e9d1e7e1b63c2836b4deb21/code/MobileSiteConfigExtension.php#L110-L116
|
229,020
|
silverstripe/silverstripe-mobile
|
code/MobileSiteConfigExtension.php
|
MobileSiteConfigExtension.updateCMSFields
|
public function updateCMSFields(FieldList $fields) {
$fields->addFieldsToTab(
'Root.Mobile',
array(
OptionsetField::create('MobileSiteType', _t('MobileSiteConfig.MOBILESITEBEHAVIOUR', 'Mobile site behaviour'), $this->getMobileSiteTypes()),
TextField::create('MobileDomain', _t('MobileSiteConfig.MOBILEDOMAIN', 'Mobile domain <small>(e.g. m.mysite.com, needs to be different from "Full site domain")</small>')),
TextField::create('FullSiteDomain', _t('MobileSiteConfig.FULLSITEDOMAIN', 'Full site domain <small>(e.g. mysite.com, usually doesn\'t need to be changed)</small>')),
DropdownField::create('MobileTheme', _t('MobileSiteConfig.MOBILETHEME', 'Mobile theme'), $this->owner->getAvailableThemes())
->setEmptyString(_t('SiteConfig.DEFAULTTHEME', '(Use default theme)'))
)
);
}
|
php
|
public function updateCMSFields(FieldList $fields) {
$fields->addFieldsToTab(
'Root.Mobile',
array(
OptionsetField::create('MobileSiteType', _t('MobileSiteConfig.MOBILESITEBEHAVIOUR', 'Mobile site behaviour'), $this->getMobileSiteTypes()),
TextField::create('MobileDomain', _t('MobileSiteConfig.MOBILEDOMAIN', 'Mobile domain <small>(e.g. m.mysite.com, needs to be different from "Full site domain")</small>')),
TextField::create('FullSiteDomain', _t('MobileSiteConfig.FULLSITEDOMAIN', 'Full site domain <small>(e.g. mysite.com, usually doesn\'t need to be changed)</small>')),
DropdownField::create('MobileTheme', _t('MobileSiteConfig.MOBILETHEME', 'Mobile theme'), $this->owner->getAvailableThemes())
->setEmptyString(_t('SiteConfig.DEFAULTTHEME', '(Use default theme)'))
)
);
}
|
[
"public",
"function",
"updateCMSFields",
"(",
"FieldList",
"$",
"fields",
")",
"{",
"$",
"fields",
"->",
"addFieldsToTab",
"(",
"'Root.Mobile'",
",",
"array",
"(",
"OptionsetField",
"::",
"create",
"(",
"'MobileSiteType'",
",",
"_t",
"(",
"'MobileSiteConfig.MOBILESITEBEHAVIOUR'",
",",
"'Mobile site behaviour'",
")",
",",
"$",
"this",
"->",
"getMobileSiteTypes",
"(",
")",
")",
",",
"TextField",
"::",
"create",
"(",
"'MobileDomain'",
",",
"_t",
"(",
"'MobileSiteConfig.MOBILEDOMAIN'",
",",
"'Mobile domain <small>(e.g. m.mysite.com, needs to be different from \"Full site domain\")</small>'",
")",
")",
",",
"TextField",
"::",
"create",
"(",
"'FullSiteDomain'",
",",
"_t",
"(",
"'MobileSiteConfig.FULLSITEDOMAIN'",
",",
"'Full site domain <small>(e.g. mysite.com, usually doesn\\'t need to be changed)</small>'",
")",
")",
",",
"DropdownField",
"::",
"create",
"(",
"'MobileTheme'",
",",
"_t",
"(",
"'MobileSiteConfig.MOBILETHEME'",
",",
"'Mobile theme'",
")",
",",
"$",
"this",
"->",
"owner",
"->",
"getAvailableThemes",
"(",
")",
")",
"->",
"setEmptyString",
"(",
"_t",
"(",
"'SiteConfig.DEFAULTTHEME'",
",",
"'(Use default theme)'",
")",
")",
")",
")",
";",
"}"
] |
Append extra fields to the new Mobile tab in the cms.
|
[
"Append",
"extra",
"fields",
"to",
"the",
"new",
"Mobile",
"tab",
"in",
"the",
"cms",
"."
] |
27822812aa7d178e4e9d1e7e1b63c2836b4deb21
|
https://github.com/silverstripe/silverstripe-mobile/blob/27822812aa7d178e4e9d1e7e1b63c2836b4deb21/code/MobileSiteConfigExtension.php#L156-L167
|
229,021
|
slickframework/slick
|
src/Slick/Mvc/Controller.php
|
Controller.redirect
|
public function redirect($url)
{
$location = $this->_request->getBasePath();
$location = str_replace('//', '/', "{$location}/{$url}");
$this->_response->setStatusCode(302);
$header = new GenericHeader('Location', $location);
$this->_response->getHeaders()->addHeader($header);
return $this->disableRendering();
}
|
php
|
public function redirect($url)
{
$location = $this->_request->getBasePath();
$location = str_replace('//', '/', "{$location}/{$url}");
$this->_response->setStatusCode(302);
$header = new GenericHeader('Location', $location);
$this->_response->getHeaders()->addHeader($header);
return $this->disableRendering();
}
|
[
"public",
"function",
"redirect",
"(",
"$",
"url",
")",
"{",
"$",
"location",
"=",
"$",
"this",
"->",
"_request",
"->",
"getBasePath",
"(",
")",
";",
"$",
"location",
"=",
"str_replace",
"(",
"'//'",
",",
"'/'",
",",
"\"{$location}/{$url}\"",
")",
";",
"$",
"this",
"->",
"_response",
"->",
"setStatusCode",
"(",
"302",
")",
";",
"$",
"header",
"=",
"new",
"GenericHeader",
"(",
"'Location'",
",",
"$",
"location",
")",
";",
"$",
"this",
"->",
"_response",
"->",
"getHeaders",
"(",
")",
"->",
"addHeader",
"(",
"$",
"header",
")",
";",
"return",
"$",
"this",
"->",
"disableRendering",
"(",
")",
";",
"}"
] |
Sends a redirection header and exits execution.
@param array|string $url The url to redirect to.
@return self
|
[
"Sends",
"a",
"redirection",
"header",
"and",
"exits",
"execution",
"."
] |
77f56b81020ce8c10f25f7d918661ccd9a918a37
|
https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Mvc/Controller.php#L126-L134
|
229,022
|
slickframework/slick
|
src/Slick/Mvc/Controller.php
|
Controller.set
|
public function set($key, $value = null)
{
if (is_array($key)) {
foreach ($key as $_key => $value) {
$this->_set($_key, $value);
}
return $this;
}
$this->_set($key, $value);
return $this;
}
|
php
|
public function set($key, $value = null)
{
if (is_array($key)) {
foreach ($key as $_key => $value) {
$this->_set($_key, $value);
}
return $this;
}
$this->_set($key, $value);
return $this;
}
|
[
"public",
"function",
"set",
"(",
"$",
"key",
",",
"$",
"value",
"=",
"null",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"key",
")",
")",
"{",
"foreach",
"(",
"$",
"key",
"as",
"$",
"_key",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"_set",
"(",
"$",
"_key",
",",
"$",
"value",
")",
";",
"}",
"return",
"$",
"this",
";",
"}",
"$",
"this",
"->",
"_set",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Sets a value or an array of values to the data that will be rendered.
@param string|array $key The key used to set the data value. If an
array is given it will iterate through all the elements and set the
values of the array.
@param mixed $value The value to add to set.
@return self A self instance for chain method calls.
|
[
"Sets",
"a",
"value",
"or",
"an",
"array",
"of",
"values",
"to",
"the",
"data",
"that",
"will",
"be",
"rendered",
"."
] |
77f56b81020ce8c10f25f7d918661ccd9a918a37
|
https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Mvc/Controller.php#L174-L184
|
229,023
|
slickframework/slick
|
src/Slick/Mvc/Scaffold/Form.php
|
Form._setup
|
protected function _setup()
{
foreach ($this->_properties as $property) {
$element = $this->_createElement($property);
if ($element) {
$this->addElement($element['name'], $element);
}
}
$this->add(
new Submit(
['value' => 'Save']
)
);
}
|
php
|
protected function _setup()
{
foreach ($this->_properties as $property) {
$element = $this->_createElement($property);
if ($element) {
$this->addElement($element['name'], $element);
}
}
$this->add(
new Submit(
['value' => 'Save']
)
);
}
|
[
"protected",
"function",
"_setup",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"_properties",
"as",
"$",
"property",
")",
"{",
"$",
"element",
"=",
"$",
"this",
"->",
"_createElement",
"(",
"$",
"property",
")",
";",
"if",
"(",
"$",
"element",
")",
"{",
"$",
"this",
"->",
"addElement",
"(",
"$",
"element",
"[",
"'name'",
"]",
",",
"$",
"element",
")",
";",
"}",
"}",
"$",
"this",
"->",
"add",
"(",
"new",
"Submit",
"(",
"[",
"'value'",
"=>",
"'Save'",
"]",
")",
")",
";",
"}"
] |
Callback for form setup
|
[
"Callback",
"for",
"form",
"setup"
] |
77f56b81020ce8c10f25f7d918661ccd9a918a37
|
https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Mvc/Scaffold/Form.php#L97-L110
|
229,024
|
AOEpeople/StackFormation
|
src/AwsInspector/Model/Ec2/Instance.php
|
Instance.getSshConnection
|
public function getSshConnection($multiplex=null)
{
$jumpHost = $this->getJumpHost();
return new Connection(
$this->getDefaultUsername(),
$jumpHost ? $this->getPrivateIpAddress() : $this->getConnectionIp(),
$this->getPrivateKey(),
$jumpHost,
!is_null($multiplex) ? $multiplex : $this->multiplexSshConnection
);
}
|
php
|
public function getSshConnection($multiplex=null)
{
$jumpHost = $this->getJumpHost();
return new Connection(
$this->getDefaultUsername(),
$jumpHost ? $this->getPrivateIpAddress() : $this->getConnectionIp(),
$this->getPrivateKey(),
$jumpHost,
!is_null($multiplex) ? $multiplex : $this->multiplexSshConnection
);
}
|
[
"public",
"function",
"getSshConnection",
"(",
"$",
"multiplex",
"=",
"null",
")",
"{",
"$",
"jumpHost",
"=",
"$",
"this",
"->",
"getJumpHost",
"(",
")",
";",
"return",
"new",
"Connection",
"(",
"$",
"this",
"->",
"getDefaultUsername",
"(",
")",
",",
"$",
"jumpHost",
"?",
"$",
"this",
"->",
"getPrivateIpAddress",
"(",
")",
":",
"$",
"this",
"->",
"getConnectionIp",
"(",
")",
",",
"$",
"this",
"->",
"getPrivateKey",
"(",
")",
",",
"$",
"jumpHost",
",",
"!",
"is_null",
"(",
"$",
"multiplex",
")",
"?",
"$",
"multiplex",
":",
"$",
"this",
"->",
"multiplexSshConnection",
")",
";",
"}"
] |
Get SSH connection
@return Connection
@throws \Exception
|
[
"Get",
"SSH",
"connection"
] |
5332dbbe54653e50d610cbaf75fb865c68aa2f1e
|
https://github.com/AOEpeople/StackFormation/blob/5332dbbe54653e50d610cbaf75fb865c68aa2f1e/src/AwsInspector/Model/Ec2/Instance.php#L142-L152
|
229,025
|
slickframework/slick
|
src/Slick/Configuration/Configuration.php
|
Configuration.get
|
public static function get($file, $class='php')
{
foreach (self::$_paths as $path) {
$fileName = "{$path}/{$file}.{$class}";
if (is_file($fileName)) {
$cfg = new Configuration(
[
'class' => $class,
'options' => [
'file' => $fileName
]
]
);
return $cfg->initialize();
}
}
throw new Exception\FileNotFoundException(
"The file {$file}.{$class} was not found in the configuration " .
"directories list. Search on the following directories:" .
implode(', ', self::$_paths) . "."
);
}
|
php
|
public static function get($file, $class='php')
{
foreach (self::$_paths as $path) {
$fileName = "{$path}/{$file}.{$class}";
if (is_file($fileName)) {
$cfg = new Configuration(
[
'class' => $class,
'options' => [
'file' => $fileName
]
]
);
return $cfg->initialize();
}
}
throw new Exception\FileNotFoundException(
"The file {$file}.{$class} was not found in the configuration " .
"directories list. Search on the following directories:" .
implode(', ', self::$_paths) . "."
);
}
|
[
"public",
"static",
"function",
"get",
"(",
"$",
"file",
",",
"$",
"class",
"=",
"'php'",
")",
"{",
"foreach",
"(",
"self",
"::",
"$",
"_paths",
"as",
"$",
"path",
")",
"{",
"$",
"fileName",
"=",
"\"{$path}/{$file}.{$class}\"",
";",
"if",
"(",
"is_file",
"(",
"$",
"fileName",
")",
")",
"{",
"$",
"cfg",
"=",
"new",
"Configuration",
"(",
"[",
"'class'",
"=>",
"$",
"class",
",",
"'options'",
"=>",
"[",
"'file'",
"=>",
"$",
"fileName",
"]",
"]",
")",
";",
"return",
"$",
"cfg",
"->",
"initialize",
"(",
")",
";",
"}",
"}",
"throw",
"new",
"Exception",
"\\",
"FileNotFoundException",
"(",
"\"The file {$file}.{$class} was not found in the configuration \"",
".",
"\"directories list. Search on the following directories:\"",
".",
"implode",
"(",
"', '",
",",
"self",
"::",
"$",
"_paths",
")",
".",
"\".\"",
")",
";",
"}"
] |
Factory method to search and parse the provided name
@param string $file the file name
@param string $class parser class
@throws Exception\FileNotFoundException if the given file was not found
in any of the paths defined in Configuration::$_paths static property
@return DriverInterface
|
[
"Factory",
"method",
"to",
"search",
"and",
"parse",
"the",
"provided",
"name"
] |
77f56b81020ce8c10f25f7d918661ccd9a918a37
|
https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Configuration/Configuration.php#L64-L87
|
229,026
|
slickframework/slick
|
src/Slick/Configuration/Configuration.php
|
Configuration.initialize
|
public function initialize()
{
$class = $this->class;
$driver = null;
if (empty($class)) {
throw new Exception\InvalidArgumentException(
"The configuration driver is invalid."
);
}
// Load user defined driver
if (class_exists($class)) {
$driver = new $class($this->_options);
if (is_a($driver, '\Slick\Configuration\Driver\DriverInterface')) {
return $driver;
} else {
throw new Exception\InvalidArgumentException(
"The configuration type '{$class}' doesn't inherited from "
."Slick\Configuration\Driver\DriverInterface."
);
}
}
switch ($class) {
case 'ini':
$driver = new Driver\Ini($this->_options);
break;
case 'php':
$driver = new Driver\Php($this->_options);
break;
default:
throw new Exception\InvalidArgumentException(
"The configuration driver is unknown."
);
}
return $driver;
}
|
php
|
public function initialize()
{
$class = $this->class;
$driver = null;
if (empty($class)) {
throw new Exception\InvalidArgumentException(
"The configuration driver is invalid."
);
}
// Load user defined driver
if (class_exists($class)) {
$driver = new $class($this->_options);
if (is_a($driver, '\Slick\Configuration\Driver\DriverInterface')) {
return $driver;
} else {
throw new Exception\InvalidArgumentException(
"The configuration type '{$class}' doesn't inherited from "
."Slick\Configuration\Driver\DriverInterface."
);
}
}
switch ($class) {
case 'ini':
$driver = new Driver\Ini($this->_options);
break;
case 'php':
$driver = new Driver\Php($this->_options);
break;
default:
throw new Exception\InvalidArgumentException(
"The configuration driver is unknown."
);
}
return $driver;
}
|
[
"public",
"function",
"initialize",
"(",
")",
"{",
"$",
"class",
"=",
"$",
"this",
"->",
"class",
";",
"$",
"driver",
"=",
"null",
";",
"if",
"(",
"empty",
"(",
"$",
"class",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"InvalidArgumentException",
"(",
"\"The configuration driver is invalid.\"",
")",
";",
"}",
"// Load user defined driver",
"if",
"(",
"class_exists",
"(",
"$",
"class",
")",
")",
"{",
"$",
"driver",
"=",
"new",
"$",
"class",
"(",
"$",
"this",
"->",
"_options",
")",
";",
"if",
"(",
"is_a",
"(",
"$",
"driver",
",",
"'\\Slick\\Configuration\\Driver\\DriverInterface'",
")",
")",
"{",
"return",
"$",
"driver",
";",
"}",
"else",
"{",
"throw",
"new",
"Exception",
"\\",
"InvalidArgumentException",
"(",
"\"The configuration type '{$class}' doesn't inherited from \"",
".",
"\"Slick\\Configuration\\Driver\\DriverInterface.\"",
")",
";",
"}",
"}",
"switch",
"(",
"$",
"class",
")",
"{",
"case",
"'ini'",
":",
"$",
"driver",
"=",
"new",
"Driver",
"\\",
"Ini",
"(",
"$",
"this",
"->",
"_options",
")",
";",
"break",
";",
"case",
"'php'",
":",
"$",
"driver",
"=",
"new",
"Driver",
"\\",
"Php",
"(",
"$",
"this",
"->",
"_options",
")",
";",
"break",
";",
"default",
":",
"throw",
"new",
"Exception",
"\\",
"InvalidArgumentException",
"(",
"\"The configuration driver is unknown.\"",
")",
";",
"}",
"return",
"$",
"driver",
";",
"}"
] |
Initializes the driver specified by class using the provided options.
@return DriverInterface
@throws Exception\InvalidArgumentException If the class provided is not
known, is not defined or if an existing class is provided it does not
implements the {@see \Slick\Configuration\Driver\DriverInterface}
interface
|
[
"Initializes",
"the",
"driver",
"specified",
"by",
"class",
"using",
"the",
"provided",
"options",
"."
] |
77f56b81020ce8c10f25f7d918661ccd9a918a37
|
https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Configuration/Configuration.php#L122-L162
|
229,027
|
mbilbille/jpnforphp
|
src/JpnForPhp/Analyzer/Analyzer.php
|
Analyzer.inspect
|
public static function inspect($str)
{
$result = array(
'length' => 0,
'kanji' => 0,
'hiragana' => 0,
'katakana' => 0,
);
$result['length'] = self::length($str);
$result['kanji'] = self::countKanji($str);
$result['hiragana'] = self::countHiragana($str);
$result['katakana'] = self::countKatakana($str);
return $result;
}
|
php
|
public static function inspect($str)
{
$result = array(
'length' => 0,
'kanji' => 0,
'hiragana' => 0,
'katakana' => 0,
);
$result['length'] = self::length($str);
$result['kanji'] = self::countKanji($str);
$result['hiragana'] = self::countHiragana($str);
$result['katakana'] = self::countKatakana($str);
return $result;
}
|
[
"public",
"static",
"function",
"inspect",
"(",
"$",
"str",
")",
"{",
"$",
"result",
"=",
"array",
"(",
"'length'",
"=>",
"0",
",",
"'kanji'",
"=>",
"0",
",",
"'hiragana'",
"=>",
"0",
",",
"'katakana'",
"=>",
"0",
",",
")",
";",
"$",
"result",
"[",
"'length'",
"]",
"=",
"self",
"::",
"length",
"(",
"$",
"str",
")",
";",
"$",
"result",
"[",
"'kanji'",
"]",
"=",
"self",
"::",
"countKanji",
"(",
"$",
"str",
")",
";",
"$",
"result",
"[",
"'hiragana'",
"]",
"=",
"self",
"::",
"countHiragana",
"(",
"$",
"str",
")",
";",
"$",
"result",
"[",
"'katakana'",
"]",
"=",
"self",
"::",
"countKatakana",
"(",
"$",
"str",
")",
";",
"return",
"$",
"result",
";",
"}"
] |
Inspects a given string and returns useful details about it.
@param string $str The string to be inspected.
@return array An associative array containing the following items:
- "length" : string length.
- "kanji" : number of kanji within this string.
- "hiragana" : number of hiragana within this string.
- "katakana" : number of katakana within this string.
@see length()
@see countKanji()
@see countHiragana()
@see countKatakana()
|
[
"Inspects",
"a",
"given",
"string",
"and",
"returns",
"useful",
"details",
"about",
"it",
"."
] |
5623468503cc2941f4656b0ee1a58b939d263453
|
https://github.com/mbilbille/jpnforphp/blob/5623468503cc2941f4656b0ee1a58b939d263453/src/JpnForPhp/Analyzer/Analyzer.php#L55-L70
|
229,028
|
mbilbille/jpnforphp
|
src/JpnForPhp/Analyzer/Analyzer.php
|
Analyzer.countKanji
|
public static function countKanji($str, $extended = false)
{
$matches = array();
if ($extended) {
return preg_match_all(Helper::PREG_PATTERN_KANJI_EXTENDED, $str, $matches);
} else {
return preg_match_all(Helper::PREG_PATTERN_KANJI, $str, $matches);
}
}
|
php
|
public static function countKanji($str, $extended = false)
{
$matches = array();
if ($extended) {
return preg_match_all(Helper::PREG_PATTERN_KANJI_EXTENDED, $str, $matches);
} else {
return preg_match_all(Helper::PREG_PATTERN_KANJI, $str, $matches);
}
}
|
[
"public",
"static",
"function",
"countKanji",
"(",
"$",
"str",
",",
"$",
"extended",
"=",
"false",
")",
"{",
"$",
"matches",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"extended",
")",
"{",
"return",
"preg_match_all",
"(",
"Helper",
"::",
"PREG_PATTERN_KANJI_EXTENDED",
",",
"$",
"str",
",",
"$",
"matches",
")",
";",
"}",
"else",
"{",
"return",
"preg_match_all",
"(",
"Helper",
"::",
"PREG_PATTERN_KANJI",
",",
"$",
"str",
",",
"$",
"matches",
")",
";",
"}",
"}"
] |
Count number of kanji within the specified string.
@param string $str The input string.
@param bool $extended Determines whether to use the extended kanji set
@return integer Returns the number of kanji.
|
[
"Count",
"number",
"of",
"kanji",
"within",
"the",
"specified",
"string",
"."
] |
5623468503cc2941f4656b0ee1a58b939d263453
|
https://github.com/mbilbille/jpnforphp/blob/5623468503cc2941f4656b0ee1a58b939d263453/src/JpnForPhp/Analyzer/Analyzer.php#L80-L89
|
229,029
|
mbilbille/jpnforphp
|
src/JpnForPhp/Analyzer/Analyzer.php
|
Analyzer.hasKanji
|
public static function hasKanji($str, $extended = false)
{
if ($extended) {
return preg_match(Helper::PREG_PATTERN_KANJI_EXTENDED, $str, $matches) > 0;
} else {
return preg_match(Helper::PREG_PATTERN_KANJI, $str, $matches) > 0;
}
}
|
php
|
public static function hasKanji($str, $extended = false)
{
if ($extended) {
return preg_match(Helper::PREG_PATTERN_KANJI_EXTENDED, $str, $matches) > 0;
} else {
return preg_match(Helper::PREG_PATTERN_KANJI, $str, $matches) > 0;
}
}
|
[
"public",
"static",
"function",
"hasKanji",
"(",
"$",
"str",
",",
"$",
"extended",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"extended",
")",
"{",
"return",
"preg_match",
"(",
"Helper",
"::",
"PREG_PATTERN_KANJI_EXTENDED",
",",
"$",
"str",
",",
"$",
"matches",
")",
">",
"0",
";",
"}",
"else",
"{",
"return",
"preg_match",
"(",
"Helper",
"::",
"PREG_PATTERN_KANJI",
",",
"$",
"str",
",",
"$",
"matches",
")",
">",
"0",
";",
"}",
"}"
] |
Determines whether the given string contains kanji characters.
@param string $str The string to inspect.
@param bool $extended Determines whether to use the extended kanji set
@return bool TRUE if it contains at least one kanji, otherwise FALSE.
|
[
"Determines",
"whether",
"the",
"given",
"string",
"contains",
"kanji",
"characters",
"."
] |
5623468503cc2941f4656b0ee1a58b939d263453
|
https://github.com/mbilbille/jpnforphp/blob/5623468503cc2941f4656b0ee1a58b939d263453/src/JpnForPhp/Analyzer/Analyzer.php#L128-L135
|
229,030
|
mbilbille/jpnforphp
|
src/JpnForPhp/Inflector/InflectorUtils.php
|
InflectorUtils.getEntriesFromDatabase
|
public static function getEntriesFromDatabase($verb)
{
if (!Analyzer::hasJapaneseLetters($verb)) {
$verb = (new Transliterator())->transliterate($verb, new System\Hiragana());
}
$sql = 'SELECT kanji, kana, type FROM verbs WHERE kanji = :kanji OR kana = :kana';
$uri = 'sqlite:' . __DIR__ . DIRECTORY_SEPARATOR . 'verbs.db';
$connection = new PDO($uri);
$connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$connection->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER);
$statement = $connection->prepare($sql);
$statement->execute(array(':kanji' => $verb, ':kana' => $verb));
$results = $statement->fetchAll(PDO::FETCH_CLASS, __NAMESPACE__ . '\\Entry');
return $results;
}
|
php
|
public static function getEntriesFromDatabase($verb)
{
if (!Analyzer::hasJapaneseLetters($verb)) {
$verb = (new Transliterator())->transliterate($verb, new System\Hiragana());
}
$sql = 'SELECT kanji, kana, type FROM verbs WHERE kanji = :kanji OR kana = :kana';
$uri = 'sqlite:' . __DIR__ . DIRECTORY_SEPARATOR . 'verbs.db';
$connection = new PDO($uri);
$connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$connection->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER);
$statement = $connection->prepare($sql);
$statement->execute(array(':kanji' => $verb, ':kana' => $verb));
$results = $statement->fetchAll(PDO::FETCH_CLASS, __NAMESPACE__ . '\\Entry');
return $results;
}
|
[
"public",
"static",
"function",
"getEntriesFromDatabase",
"(",
"$",
"verb",
")",
"{",
"if",
"(",
"!",
"Analyzer",
"::",
"hasJapaneseLetters",
"(",
"$",
"verb",
")",
")",
"{",
"$",
"verb",
"=",
"(",
"new",
"Transliterator",
"(",
")",
")",
"->",
"transliterate",
"(",
"$",
"verb",
",",
"new",
"System",
"\\",
"Hiragana",
"(",
")",
")",
";",
"}",
"$",
"sql",
"=",
"'SELECT kanji, kana, type FROM verbs WHERE kanji = :kanji OR kana = :kana'",
";",
"$",
"uri",
"=",
"'sqlite:'",
".",
"__DIR__",
".",
"DIRECTORY_SEPARATOR",
".",
"'verbs.db'",
";",
"$",
"connection",
"=",
"new",
"PDO",
"(",
"$",
"uri",
")",
";",
"$",
"connection",
"->",
"setAttribute",
"(",
"PDO",
"::",
"ATTR_ERRMODE",
",",
"PDO",
"::",
"ERRMODE_EXCEPTION",
")",
";",
"$",
"connection",
"->",
"setAttribute",
"(",
"PDO",
"::",
"ATTR_CASE",
",",
"PDO",
"::",
"CASE_LOWER",
")",
";",
"$",
"statement",
"=",
"$",
"connection",
"->",
"prepare",
"(",
"$",
"sql",
")",
";",
"$",
"statement",
"->",
"execute",
"(",
"array",
"(",
"':kanji'",
"=>",
"$",
"verb",
",",
"':kana'",
"=>",
"$",
"verb",
")",
")",
";",
"$",
"results",
"=",
"$",
"statement",
"->",
"fetchAll",
"(",
"PDO",
"::",
"FETCH_CLASS",
",",
"__NAMESPACE__",
".",
"'\\\\Entry'",
")",
";",
"return",
"$",
"results",
";",
"}"
] |
Gets a verb entries from the database using either Kanji, Hiragana or Romaji
@param $verb A String value
@return array Array of Entry instances
|
[
"Gets",
"a",
"verb",
"entries",
"from",
"the",
"database",
"using",
"either",
"Kanji",
"Hiragana",
"or",
"Romaji"
] |
5623468503cc2941f4656b0ee1a58b939d263453
|
https://github.com/mbilbille/jpnforphp/blob/5623468503cc2941f4656b0ee1a58b939d263453/src/JpnForPhp/Inflector/InflectorUtils.php#L71-L86
|
229,031
|
silverstripe/silverstripe-mobile
|
code/MobileBrowserDetector.php
|
MobileBrowserDetector.is_tablet
|
public static function is_tablet($agent = null) {
if(!$agent) $agent = $_SERVER['HTTP_USER_AGENT'];
// Check if user agent is a Tablet
if(
(preg_match('/iP(a|ro)d/i', $agent))
|| (preg_match('/tablet/i', $agent)) && (!preg_match('/RX-34/i', $agent)) || (preg_match('/FOLIO/i', $agent))
) {
return true;
}
// Check if user agent is an Android Tablet
else if (
(preg_match('/Linux/i', $agent))
&& (preg_match('/Android/i', $agent))
&& (!preg_match('/Fennec|mobi|HTC.Magic|HTCX06HT|Nexus.One|SC-02B|fone.945/i', $agent))
&& (!preg_match('/Mobile/i', $agent))
) {
// see http://googlewebmastercentral.blogspot.de/2011/03/mo-better-to-also-detect-mobile-user.html
// see http://googlewebmastercentral.blogspot.de/2012/11/giving-tablet-users-full-sized-web.html
return true;
}
// Check if user agent is a Kindle or Kindle Fire
else if (
(preg_match('/Kindle/i', $agent))
|| (preg_match('/Mac.OS/i', $agent))
&& (preg_match('/Silk/i', $agent))
) {
return true;
}
// Check if user agent is a pre Android 3.0 Tablet
else if (
(preg_match('/GT-P10|SC-01C|SHW-M180S|SGH-T849|SCH-I800|SHW-M180L|SPH-P100|SGH-I987|zt180|HTC(.Flyer|\_Flyer)|Sprint.ATP51|ViewPad7|pandigital(sprnova|nova)|Ideos.S7|Dell.Streak.7|Advent.Vega|A101IT|A70BHT|MID7015|Next2|nook/i', $agent))
|| (preg_match('/MB511/i', $agent))
&& (preg_match('/RUTEM/i', $agent))
) {
return true;
}
// Browser is either a mobile handset or desktop.
else {
return false;
}
}
|
php
|
public static function is_tablet($agent = null) {
if(!$agent) $agent = $_SERVER['HTTP_USER_AGENT'];
// Check if user agent is a Tablet
if(
(preg_match('/iP(a|ro)d/i', $agent))
|| (preg_match('/tablet/i', $agent)) && (!preg_match('/RX-34/i', $agent)) || (preg_match('/FOLIO/i', $agent))
) {
return true;
}
// Check if user agent is an Android Tablet
else if (
(preg_match('/Linux/i', $agent))
&& (preg_match('/Android/i', $agent))
&& (!preg_match('/Fennec|mobi|HTC.Magic|HTCX06HT|Nexus.One|SC-02B|fone.945/i', $agent))
&& (!preg_match('/Mobile/i', $agent))
) {
// see http://googlewebmastercentral.blogspot.de/2011/03/mo-better-to-also-detect-mobile-user.html
// see http://googlewebmastercentral.blogspot.de/2012/11/giving-tablet-users-full-sized-web.html
return true;
}
// Check if user agent is a Kindle or Kindle Fire
else if (
(preg_match('/Kindle/i', $agent))
|| (preg_match('/Mac.OS/i', $agent))
&& (preg_match('/Silk/i', $agent))
) {
return true;
}
// Check if user agent is a pre Android 3.0 Tablet
else if (
(preg_match('/GT-P10|SC-01C|SHW-M180S|SGH-T849|SCH-I800|SHW-M180L|SPH-P100|SGH-I987|zt180|HTC(.Flyer|\_Flyer)|Sprint.ATP51|ViewPad7|pandigital(sprnova|nova)|Ideos.S7|Dell.Streak.7|Advent.Vega|A101IT|A70BHT|MID7015|Next2|nook/i', $agent))
|| (preg_match('/MB511/i', $agent))
&& (preg_match('/RUTEM/i', $agent))
) {
return true;
}
// Browser is either a mobile handset or desktop.
else {
return false;
}
}
|
[
"public",
"static",
"function",
"is_tablet",
"(",
"$",
"agent",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"agent",
")",
"$",
"agent",
"=",
"$",
"_SERVER",
"[",
"'HTTP_USER_AGENT'",
"]",
";",
"// Check if user agent is a Tablet",
"if",
"(",
"(",
"preg_match",
"(",
"'/iP(a|ro)d/i'",
",",
"$",
"agent",
")",
")",
"||",
"(",
"preg_match",
"(",
"'/tablet/i'",
",",
"$",
"agent",
")",
")",
"&&",
"(",
"!",
"preg_match",
"(",
"'/RX-34/i'",
",",
"$",
"agent",
")",
")",
"||",
"(",
"preg_match",
"(",
"'/FOLIO/i'",
",",
"$",
"agent",
")",
")",
")",
"{",
"return",
"true",
";",
"}",
"// Check if user agent is an Android Tablet",
"else",
"if",
"(",
"(",
"preg_match",
"(",
"'/Linux/i'",
",",
"$",
"agent",
")",
")",
"&&",
"(",
"preg_match",
"(",
"'/Android/i'",
",",
"$",
"agent",
")",
")",
"&&",
"(",
"!",
"preg_match",
"(",
"'/Fennec|mobi|HTC.Magic|HTCX06HT|Nexus.One|SC-02B|fone.945/i'",
",",
"$",
"agent",
")",
")",
"&&",
"(",
"!",
"preg_match",
"(",
"'/Mobile/i'",
",",
"$",
"agent",
")",
")",
")",
"{",
"// see http://googlewebmastercentral.blogspot.de/2011/03/mo-better-to-also-detect-mobile-user.html\t\t",
"// see http://googlewebmastercentral.blogspot.de/2012/11/giving-tablet-users-full-sized-web.html",
"return",
"true",
";",
"}",
"// Check if user agent is a Kindle or Kindle Fire",
"else",
"if",
"(",
"(",
"preg_match",
"(",
"'/Kindle/i'",
",",
"$",
"agent",
")",
")",
"||",
"(",
"preg_match",
"(",
"'/Mac.OS/i'",
",",
"$",
"agent",
")",
")",
"&&",
"(",
"preg_match",
"(",
"'/Silk/i'",
",",
"$",
"agent",
")",
")",
")",
"{",
"return",
"true",
";",
"}",
"// Check if user agent is a pre Android 3.0 Tablet",
"else",
"if",
"(",
"(",
"preg_match",
"(",
"'/GT-P10|SC-01C|SHW-M180S|SGH-T849|SCH-I800|SHW-M180L|SPH-P100|SGH-I987|zt180|HTC(.Flyer|\\_Flyer)|Sprint.ATP51|ViewPad7|pandigital(sprnova|nova)|Ideos.S7|Dell.Streak.7|Advent.Vega|A101IT|A70BHT|MID7015|Next2|nook/i'",
",",
"$",
"agent",
")",
")",
"||",
"(",
"preg_match",
"(",
"'/MB511/i'",
",",
"$",
"agent",
")",
")",
"&&",
"(",
"preg_match",
"(",
"'/RUTEM/i'",
",",
"$",
"agent",
")",
")",
")",
"{",
"return",
"true",
";",
"}",
"// Browser is either a mobile handset or desktop.",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] |
Rough detection of "tablet" user agents, based on their user agent string.
CAUTION: Does NOT detect Windows 8 tablets, since there's no user-agent distinction between
tablets and desktops in Windows 8.
Loosely based off the (now discontinued) Categorizr library:
http://www.brettjankord.com/2012/01/16/categorizr-a-modern-device-detection-script/
@param String User agent (defaults to $_SERVER)
@return boolean
|
[
"Rough",
"detection",
"of",
"tablet",
"user",
"agents",
"based",
"on",
"their",
"user",
"agent",
"string",
"."
] |
27822812aa7d178e4e9d1e7e1b63c2836b4deb21
|
https://github.com/silverstripe/silverstripe-mobile/blob/27822812aa7d178e4e9d1e7e1b63c2836b4deb21/code/MobileBrowserDetector.php#L125-L166
|
229,032
|
jameshalsall/licenser
|
src/Command/AbstractLicenserCommand.php
|
AbstractLicenserCommand.initializeLicenser
|
protected function initializeLicenser(InputInterface $input, OutputInterface $output)
{
$license = $input->getArgument('license');
try {
$licenseHeader = $this->licenseHeaderFactory->createFromLicenseName(
$license,
['owners' => $input->getOption('owners')]
);
} catch (\InvalidArgumentException $e) {
$licenseHeader = file_get_contents($license);
}
$this->licenser->setLicenseHeader($licenseHeader);
$this->licenser->setOutputStream($output);
}
|
php
|
protected function initializeLicenser(InputInterface $input, OutputInterface $output)
{
$license = $input->getArgument('license');
try {
$licenseHeader = $this->licenseHeaderFactory->createFromLicenseName(
$license,
['owners' => $input->getOption('owners')]
);
} catch (\InvalidArgumentException $e) {
$licenseHeader = file_get_contents($license);
}
$this->licenser->setLicenseHeader($licenseHeader);
$this->licenser->setOutputStream($output);
}
|
[
"protected",
"function",
"initializeLicenser",
"(",
"InputInterface",
"$",
"input",
",",
"OutputInterface",
"$",
"output",
")",
"{",
"$",
"license",
"=",
"$",
"input",
"->",
"getArgument",
"(",
"'license'",
")",
";",
"try",
"{",
"$",
"licenseHeader",
"=",
"$",
"this",
"->",
"licenseHeaderFactory",
"->",
"createFromLicenseName",
"(",
"$",
"license",
",",
"[",
"'owners'",
"=>",
"$",
"input",
"->",
"getOption",
"(",
"'owners'",
")",
"]",
")",
";",
"}",
"catch",
"(",
"\\",
"InvalidArgumentException",
"$",
"e",
")",
"{",
"$",
"licenseHeader",
"=",
"file_get_contents",
"(",
"$",
"license",
")",
";",
"}",
"$",
"this",
"->",
"licenser",
"->",
"setLicenseHeader",
"(",
"$",
"licenseHeader",
")",
";",
"$",
"this",
"->",
"licenser",
"->",
"setOutputStream",
"(",
"$",
"output",
")",
";",
"}"
] |
Initializes the Licenser instance with license information
@param InputInterface $input An input stream
@param OutputInterface $output An output stream
|
[
"Initializes",
"the",
"Licenser",
"instance",
"with",
"license",
"information"
] |
41fce6a66bf42e0045bd479397f788c83f7d78af
|
https://github.com/jameshalsall/licenser/blob/41fce6a66bf42e0045bd479397f788c83f7d78af/src/Command/AbstractLicenserCommand.php#L107-L122
|
229,033
|
laravelcity/laravel-categories
|
src/Lib/Repository.php
|
Repository.newCollection
|
public function newCollection ($model , $extClass = null)
{
$this->modelType = $model;
if ($extClass)
$this->category = new $extClass;
$this->category->setModelType($model);
return $this;
}
|
php
|
public function newCollection ($model , $extClass = null)
{
$this->modelType = $model;
if ($extClass)
$this->category = new $extClass;
$this->category->setModelType($model);
return $this;
}
|
[
"public",
"function",
"newCollection",
"(",
"$",
"model",
",",
"$",
"extClass",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"modelType",
"=",
"$",
"model",
";",
"if",
"(",
"$",
"extClass",
")",
"$",
"this",
"->",
"category",
"=",
"new",
"$",
"extClass",
";",
"$",
"this",
"->",
"category",
"->",
"setModelType",
"(",
"$",
"model",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
create category with model_type
@params $modelType => string
@return $this
|
[
"create",
"category",
"with",
"model_type"
] |
b5c1baf8cbb51377fef090fc9ddaa0946bf42a68
|
https://github.com/laravelcity/laravel-categories/blob/b5c1baf8cbb51377fef090fc9ddaa0946bf42a68/src/Lib/Repository.php#L27-L35
|
229,034
|
laravelcity/laravel-categories
|
src/Lib/Repository.php
|
Repository.htmlSelectList
|
public function htmlSelectList ($attributes = null , $value = null , $select = true)
{
return $this->category->getOptionListCategories($value , $attributes , $select);
}
|
php
|
public function htmlSelectList ($attributes = null , $value = null , $select = true)
{
return $this->category->getOptionListCategories($value , $attributes , $select);
}
|
[
"public",
"function",
"htmlSelectList",
"(",
"$",
"attributes",
"=",
"null",
",",
"$",
"value",
"=",
"null",
",",
"$",
"select",
"=",
"true",
")",
"{",
"return",
"$",
"this",
"->",
"category",
"->",
"getOptionListCategories",
"(",
"$",
"value",
",",
"$",
"attributes",
",",
"$",
"select",
")",
";",
"}"
] |
get html select of categories
@param $attributes => array
@param $select => boolean
|
[
"get",
"html",
"select",
"of",
"categories"
] |
b5c1baf8cbb51377fef090fc9ddaa0946bf42a68
|
https://github.com/laravelcity/laravel-categories/blob/b5c1baf8cbb51377fef090fc9ddaa0946bf42a68/src/Lib/Repository.php#L190-L193
|
229,035
|
laravelcity/laravel-categories
|
src/Lib/Repository.php
|
Repository.htmlUlList
|
public function htmlUlList ($attributes = null , $ul = true)
{
return $this->category->getUlListCategories($attributes , $ul);
}
|
php
|
public function htmlUlList ($attributes = null , $ul = true)
{
return $this->category->getUlListCategories($attributes , $ul);
}
|
[
"public",
"function",
"htmlUlList",
"(",
"$",
"attributes",
"=",
"null",
",",
"$",
"ul",
"=",
"true",
")",
"{",
"return",
"$",
"this",
"->",
"category",
"->",
"getUlListCategories",
"(",
"$",
"attributes",
",",
"$",
"ul",
")",
";",
"}"
] |
get html ul of categories
@param $attributes => array
@param $select => boolean
@return string
|
[
"get",
"html",
"ul",
"of",
"categories"
] |
b5c1baf8cbb51377fef090fc9ddaa0946bf42a68
|
https://github.com/laravelcity/laravel-categories/blob/b5c1baf8cbb51377fef090fc9ddaa0946bf42a68/src/Lib/Repository.php#L201-L204
|
229,036
|
laravelcity/laravel-categories
|
src/Lib/Repository.php
|
Repository.beforeLineTitle
|
function beforeLineTitle ($category , $lineStyle = ' __ ')
{
return $this->category->makeLineForDepth($this->depth($category) , $lineStyle);
}
|
php
|
function beforeLineTitle ($category , $lineStyle = ' __ ')
{
return $this->category->makeLineForDepth($this->depth($category) , $lineStyle);
}
|
[
"function",
"beforeLineTitle",
"(",
"$",
"category",
",",
"$",
"lineStyle",
"=",
"' __ '",
")",
"{",
"return",
"$",
"this",
"->",
"category",
"->",
"makeLineForDepth",
"(",
"$",
"this",
"->",
"depth",
"(",
"$",
"category",
")",
",",
"$",
"lineStyle",
")",
";",
"}"
] |
make line for category show depth
@param $category => collect
@param $lineStyle => string
@return string
|
[
"make",
"line",
"for",
"category",
"show",
"depth"
] |
b5c1baf8cbb51377fef090fc9ddaa0946bf42a68
|
https://github.com/laravelcity/laravel-categories/blob/b5c1baf8cbb51377fef090fc9ddaa0946bf42a68/src/Lib/Repository.php#L231-L234
|
229,037
|
Danzabar/phalcon-cli
|
src/Format/FormatCollection.php
|
FormatCollection.textToCode
|
public function textToCode(array $details)
{
$formatted = array();
if (isset($details['foreground'])) {
$formatted['foreground'] = $this->color->getForeground($details['foreground']);
}
if (isset($details['background'])) {
$formatted['background'] = $this->color->getBackground($details['background']);
}
return $formatted;
}
|
php
|
public function textToCode(array $details)
{
$formatted = array();
if (isset($details['foreground'])) {
$formatted['foreground'] = $this->color->getForeground($details['foreground']);
}
if (isset($details['background'])) {
$formatted['background'] = $this->color->getBackground($details['background']);
}
return $formatted;
}
|
[
"public",
"function",
"textToCode",
"(",
"array",
"$",
"details",
")",
"{",
"$",
"formatted",
"=",
"array",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"details",
"[",
"'foreground'",
"]",
")",
")",
"{",
"$",
"formatted",
"[",
"'foreground'",
"]",
"=",
"$",
"this",
"->",
"color",
"->",
"getForeground",
"(",
"$",
"details",
"[",
"'foreground'",
"]",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"details",
"[",
"'background'",
"]",
")",
")",
"{",
"$",
"formatted",
"[",
"'background'",
"]",
"=",
"$",
"this",
"->",
"color",
"->",
"getBackground",
"(",
"$",
"details",
"[",
"'background'",
"]",
")",
";",
"}",
"return",
"$",
"formatted",
";",
"}"
] |
Turns a text color ie "Blue" into a color code.
@return void
|
[
"Turns",
"a",
"text",
"color",
"ie",
"Blue",
"into",
"a",
"color",
"code",
"."
] |
0d6293d5d899158705f8e3a31886d176e595ee38
|
https://github.com/Danzabar/phalcon-cli/blob/0d6293d5d899158705f8e3a31886d176e595ee38/src/Format/FormatCollection.php#L60-L73
|
229,038
|
Danzabar/phalcon-cli
|
src/Format/FormatCollection.php
|
FormatCollection.get
|
public function get($name = null)
{
if (!is_null($name)) {
if (array_key_exists($name, $this->formats)) {
return $this->formats[$name];
}
return false;
} else {
return $this->formats;
}
}
|
php
|
public function get($name = null)
{
if (!is_null($name)) {
if (array_key_exists($name, $this->formats)) {
return $this->formats[$name];
}
return false;
} else {
return $this->formats;
}
}
|
[
"public",
"function",
"get",
"(",
"$",
"name",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"name",
")",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"formats",
")",
")",
"{",
"return",
"$",
"this",
"->",
"formats",
"[",
"$",
"name",
"]",
";",
"}",
"return",
"false",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"formats",
";",
"}",
"}"
] |
Gets either a single or all formats depending on the var that is passed
@return void
|
[
"Gets",
"either",
"a",
"single",
"or",
"all",
"formats",
"depending",
"on",
"the",
"var",
"that",
"is",
"passed"
] |
0d6293d5d899158705f8e3a31886d176e595ee38
|
https://github.com/Danzabar/phalcon-cli/blob/0d6293d5d899158705f8e3a31886d176e595ee38/src/Format/FormatCollection.php#L80-L92
|
229,039
|
slickframework/slick
|
src/Slick/Form/AbstractFieldset.php
|
AbstractFieldset.remove
|
public function remove($name)
{
$removed = false;
if ($this->has($name)) {
$this->elements->rewind();
while($this->elements->valid()) {
if ($this->elements->current()->getName() == $name) {
$this->elements->remove();
$removed = true;
break;
}
$this->elements->next();
}
}
return $removed;
}
|
php
|
public function remove($name)
{
$removed = false;
if ($this->has($name)) {
$this->elements->rewind();
while($this->elements->valid()) {
if ($this->elements->current()->getName() == $name) {
$this->elements->remove();
$removed = true;
break;
}
$this->elements->next();
}
}
return $removed;
}
|
[
"public",
"function",
"remove",
"(",
"$",
"name",
")",
"{",
"$",
"removed",
"=",
"false",
";",
"if",
"(",
"$",
"this",
"->",
"has",
"(",
"$",
"name",
")",
")",
"{",
"$",
"this",
"->",
"elements",
"->",
"rewind",
"(",
")",
";",
"while",
"(",
"$",
"this",
"->",
"elements",
"->",
"valid",
"(",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"elements",
"->",
"current",
"(",
")",
"->",
"getName",
"(",
")",
"==",
"$",
"name",
")",
"{",
"$",
"this",
"->",
"elements",
"->",
"remove",
"(",
")",
";",
"$",
"removed",
"=",
"true",
";",
"break",
";",
"}",
"$",
"this",
"->",
"elements",
"->",
"next",
"(",
")",
";",
"}",
"}",
"return",
"$",
"removed",
";",
"}"
] |
Removes the element with the provided name
@param $name Element name to search
@return boolean True if the element was found and removed
and false if not found
|
[
"Removes",
"the",
"element",
"with",
"the",
"provided",
"name"
] |
77f56b81020ce8c10f25f7d918661ccd9a918a37
|
https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Form/AbstractFieldset.php#L61-L77
|
229,040
|
slickframework/slick
|
src/Slick/Form/AbstractFieldset.php
|
AbstractFieldset.get
|
public function get($name)
{
$found = null;
/** @var ElementInterface $element */
foreach ($this->elements as $element) {
if ($element->getName() == $name) {
$found = $element;
}
}
return $found;
}
|
php
|
public function get($name)
{
$found = null;
/** @var ElementInterface $element */
foreach ($this->elements as $element) {
if ($element->getName() == $name) {
$found = $element;
}
}
return $found;
}
|
[
"public",
"function",
"get",
"(",
"$",
"name",
")",
"{",
"$",
"found",
"=",
"null",
";",
"/** @var ElementInterface $element */",
"foreach",
"(",
"$",
"this",
"->",
"elements",
"as",
"$",
"element",
")",
"{",
"if",
"(",
"$",
"element",
"->",
"getName",
"(",
")",
"==",
"$",
"name",
")",
"{",
"$",
"found",
"=",
"$",
"element",
";",
"}",
"}",
"return",
"$",
"found",
";",
"}"
] |
Returns the element with the provided name
@param string $name Element name to search
@return ElementInterface
|
[
"Returns",
"the",
"element",
"with",
"the",
"provided",
"name"
] |
77f56b81020ce8c10f25f7d918661ccd9a918a37
|
https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Form/AbstractFieldset.php#L86-L96
|
229,041
|
slickframework/slick
|
src/Slick/Form/AbstractFieldset.php
|
AbstractFieldset.has
|
public function has($name)
{
$found = false;
$this->elements->rewind();
/** @var ElementInterface $element*/
foreach ($this->elements as $element) {
if ($element->getName() == $name) {
$found = true;
break;
}
}
return $found;
}
|
php
|
public function has($name)
{
$found = false;
$this->elements->rewind();
/** @var ElementInterface $element*/
foreach ($this->elements as $element) {
if ($element->getName() == $name) {
$found = true;
break;
}
}
return $found;
}
|
[
"public",
"function",
"has",
"(",
"$",
"name",
")",
"{",
"$",
"found",
"=",
"false",
";",
"$",
"this",
"->",
"elements",
"->",
"rewind",
"(",
")",
";",
"/** @var ElementInterface $element*/",
"foreach",
"(",
"$",
"this",
"->",
"elements",
"as",
"$",
"element",
")",
"{",
"if",
"(",
"$",
"element",
"->",
"getName",
"(",
")",
"==",
"$",
"name",
")",
"{",
"$",
"found",
"=",
"true",
";",
"break",
";",
"}",
"}",
"return",
"$",
"found",
";",
"}"
] |
Check if an element with a given name exists
@param $name Element name to search
@return boolean True if element exists or false if not
|
[
"Check",
"if",
"an",
"element",
"with",
"a",
"given",
"name",
"exists"
] |
77f56b81020ce8c10f25f7d918661ccd9a918a37
|
https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Form/AbstractFieldset.php#L105-L118
|
229,042
|
slickframework/slick
|
src/Slick/Form/AbstractFieldset.php
|
AbstractFieldset.populateValues
|
public function populateValues($data)
{
/** @var FieldsetInterface|ElementInterface $element*/
foreach ($this->elements as $element) {
if (is_a($element, '\Slick\Form\FieldsetInterface')) {
$element->populateValues($data);
} else {
foreach ($data as $name => $value) {
if ($element->getName() == $name) {
$element->setValue($value);
}
}
}
}
}
|
php
|
public function populateValues($data)
{
/** @var FieldsetInterface|ElementInterface $element*/
foreach ($this->elements as $element) {
if (is_a($element, '\Slick\Form\FieldsetInterface')) {
$element->populateValues($data);
} else {
foreach ($data as $name => $value) {
if ($element->getName() == $name) {
$element->setValue($value);
}
}
}
}
}
|
[
"public",
"function",
"populateValues",
"(",
"$",
"data",
")",
"{",
"/** @var FieldsetInterface|ElementInterface $element*/",
"foreach",
"(",
"$",
"this",
"->",
"elements",
"as",
"$",
"element",
")",
"{",
"if",
"(",
"is_a",
"(",
"$",
"element",
",",
"'\\Slick\\Form\\FieldsetInterface'",
")",
")",
"{",
"$",
"element",
"->",
"populateValues",
"(",
"$",
"data",
")",
";",
"}",
"else",
"{",
"foreach",
"(",
"$",
"data",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"element",
"->",
"getName",
"(",
")",
"==",
"$",
"name",
")",
"{",
"$",
"element",
"->",
"setValue",
"(",
"$",
"value",
")",
";",
"}",
"}",
"}",
"}",
"}"
] |
Recursively populate value attributes of elements
@param $data
|
[
"Recursively",
"populate",
"value",
"attributes",
"of",
"elements"
] |
77f56b81020ce8c10f25f7d918661ccd9a918a37
|
https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Form/AbstractFieldset.php#L125-L140
|
229,043
|
slickframework/slick
|
src/Slick/Orm/Relation/BelongsTo.php
|
BelongsTo.beforeSave
|
public function beforeSave(Save $event)
{
$entity = $event->getTarget();
$property = $this->getPropertyName();
$field = $this->getForeignKey();
$data = $event->data;
if (isset($entity->$property) && !is_null($entity->$property)) {
/** @var Entity $object */
$object = $entity->$property;
$data[$field] = $object;
$class = $this->getRelatedEntity();
if ($object instanceof $class) {
$pmk = $object->getPrimaryKey();
$data[$field] = $object->$pmk;
}
$event->data = $data;
}
}
|
php
|
public function beforeSave(Save $event)
{
$entity = $event->getTarget();
$property = $this->getPropertyName();
$field = $this->getForeignKey();
$data = $event->data;
if (isset($entity->$property) && !is_null($entity->$property)) {
/** @var Entity $object */
$object = $entity->$property;
$data[$field] = $object;
$class = $this->getRelatedEntity();
if ($object instanceof $class) {
$pmk = $object->getPrimaryKey();
$data[$field] = $object->$pmk;
}
$event->data = $data;
}
}
|
[
"public",
"function",
"beforeSave",
"(",
"Save",
"$",
"event",
")",
"{",
"$",
"entity",
"=",
"$",
"event",
"->",
"getTarget",
"(",
")",
";",
"$",
"property",
"=",
"$",
"this",
"->",
"getPropertyName",
"(",
")",
";",
"$",
"field",
"=",
"$",
"this",
"->",
"getForeignKey",
"(",
")",
";",
"$",
"data",
"=",
"$",
"event",
"->",
"data",
";",
"if",
"(",
"isset",
"(",
"$",
"entity",
"->",
"$",
"property",
")",
"&&",
"!",
"is_null",
"(",
"$",
"entity",
"->",
"$",
"property",
")",
")",
"{",
"/** @var Entity $object */",
"$",
"object",
"=",
"$",
"entity",
"->",
"$",
"property",
";",
"$",
"data",
"[",
"$",
"field",
"]",
"=",
"$",
"object",
";",
"$",
"class",
"=",
"$",
"this",
"->",
"getRelatedEntity",
"(",
")",
";",
"if",
"(",
"$",
"object",
"instanceof",
"$",
"class",
")",
"{",
"$",
"pmk",
"=",
"$",
"object",
"->",
"getPrimaryKey",
"(",
")",
";",
"$",
"data",
"[",
"$",
"field",
"]",
"=",
"$",
"object",
"->",
"$",
"pmk",
";",
"}",
"$",
"event",
"->",
"data",
"=",
"$",
"data",
";",
"}",
"}"
] |
Runs before save to set the relation data to be saved
@param Save $event
|
[
"Runs",
"before",
"save",
"to",
"set",
"the",
"relation",
"data",
"to",
"be",
"saved"
] |
77f56b81020ce8c10f25f7d918661ccd9a918a37
|
https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Orm/Relation/BelongsTo.php#L84-L101
|
229,044
|
slickframework/slick
|
src/Slick/Orm/Relation/BelongsTo.php
|
BelongsTo.beforeSelect
|
public function beforeSelect(\Slick\Orm\Events\Select $event)
{
if ($this->lazyLoad) {
return;
}
$related = Entity\Manager::getInstance()
->get($this->getRelatedEntity());
$relatedTable = $related->getEntity()->getTableName();
$sql = $event->sqlQuery;
$columns = $related->getColumns();
$fields = [];
foreach (array_keys($columns) as $column) {
$name = trim($column, '_');
$fields[] = "{$name} AS {$relatedTable}_{$name}";
}
$pmk = $related->getEntity()->getPrimaryKey();
$ent = $this->getEntity()->getTableName();
$clause = "{$relatedTable}.{$pmk} = {$ent}.{$this->getForeignKey()}";
$sql->join($relatedTable, $clause, $fields);
$event->sqlQuery = $sql;
}
|
php
|
public function beforeSelect(\Slick\Orm\Events\Select $event)
{
if ($this->lazyLoad) {
return;
}
$related = Entity\Manager::getInstance()
->get($this->getRelatedEntity());
$relatedTable = $related->getEntity()->getTableName();
$sql = $event->sqlQuery;
$columns = $related->getColumns();
$fields = [];
foreach (array_keys($columns) as $column) {
$name = trim($column, '_');
$fields[] = "{$name} AS {$relatedTable}_{$name}";
}
$pmk = $related->getEntity()->getPrimaryKey();
$ent = $this->getEntity()->getTableName();
$clause = "{$relatedTable}.{$pmk} = {$ent}.{$this->getForeignKey()}";
$sql->join($relatedTable, $clause, $fields);
$event->sqlQuery = $sql;
}
|
[
"public",
"function",
"beforeSelect",
"(",
"\\",
"Slick",
"\\",
"Orm",
"\\",
"Events",
"\\",
"Select",
"$",
"event",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"lazyLoad",
")",
"{",
"return",
";",
"}",
"$",
"related",
"=",
"Entity",
"\\",
"Manager",
"::",
"getInstance",
"(",
")",
"->",
"get",
"(",
"$",
"this",
"->",
"getRelatedEntity",
"(",
")",
")",
";",
"$",
"relatedTable",
"=",
"$",
"related",
"->",
"getEntity",
"(",
")",
"->",
"getTableName",
"(",
")",
";",
"$",
"sql",
"=",
"$",
"event",
"->",
"sqlQuery",
";",
"$",
"columns",
"=",
"$",
"related",
"->",
"getColumns",
"(",
")",
";",
"$",
"fields",
"=",
"[",
"]",
";",
"foreach",
"(",
"array_keys",
"(",
"$",
"columns",
")",
"as",
"$",
"column",
")",
"{",
"$",
"name",
"=",
"trim",
"(",
"$",
"column",
",",
"'_'",
")",
";",
"$",
"fields",
"[",
"]",
"=",
"\"{$name} AS {$relatedTable}_{$name}\"",
";",
"}",
"$",
"pmk",
"=",
"$",
"related",
"->",
"getEntity",
"(",
")",
"->",
"getPrimaryKey",
"(",
")",
";",
"$",
"ent",
"=",
"$",
"this",
"->",
"getEntity",
"(",
")",
"->",
"getTableName",
"(",
")",
";",
"$",
"clause",
"=",
"\"{$relatedTable}.{$pmk} = {$ent}.{$this->getForeignKey()}\"",
";",
"$",
"sql",
"->",
"join",
"(",
"$",
"relatedTable",
",",
"$",
"clause",
",",
"$",
"fields",
")",
";",
"$",
"event",
"->",
"sqlQuery",
"=",
"$",
"sql",
";",
"}"
] |
Sets the join information on the select query when lazy load is false
@param \Slick\Orm\Events\Select $event
|
[
"Sets",
"the",
"join",
"information",
"on",
"the",
"select",
"query",
"when",
"lazy",
"load",
"is",
"false"
] |
77f56b81020ce8c10f25f7d918661ccd9a918a37
|
https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Orm/Relation/BelongsTo.php#L108-L128
|
229,045
|
lekoala/silverstripe-form-extras
|
code/fields/TableFieldCommon.php
|
TableFieldCommon.autosetColumns
|
public function autosetColumns()
{
$value = $this->value;
if (empty($this->columns)) {
$dataValue = $value;
if (count($dataValue)) {
$firstValue = (array) $dataValue[0];
foreach (array_keys($firstValue) as $header) {
$this->addColumn($header);
}
}
}
}
|
php
|
public function autosetColumns()
{
$value = $this->value;
if (empty($this->columns)) {
$dataValue = $value;
if (count($dataValue)) {
$firstValue = (array) $dataValue[0];
foreach (array_keys($firstValue) as $header) {
$this->addColumn($header);
}
}
}
}
|
[
"public",
"function",
"autosetColumns",
"(",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"value",
";",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"columns",
")",
")",
"{",
"$",
"dataValue",
"=",
"$",
"value",
";",
"if",
"(",
"count",
"(",
"$",
"dataValue",
")",
")",
"{",
"$",
"firstValue",
"=",
"(",
"array",
")",
"$",
"dataValue",
"[",
"0",
"]",
";",
"foreach",
"(",
"array_keys",
"(",
"$",
"firstValue",
")",
"as",
"$",
"header",
")",
"{",
"$",
"this",
"->",
"addColumn",
"(",
"$",
"header",
")",
";",
"}",
"}",
"}",
"}"
] |
Autoset columns for simple structures based on current data
|
[
"Autoset",
"columns",
"for",
"simple",
"structures",
"based",
"on",
"current",
"data"
] |
e0c1200792af8e6cea916e1999c73cf8408c6dd2
|
https://github.com/lekoala/silverstripe-form-extras/blob/e0c1200792af8e6cea916e1999c73cf8408c6dd2/code/fields/TableFieldCommon.php#L80-L92
|
229,046
|
lekoala/silverstripe-form-extras
|
code/fields/TableFieldCommon.php
|
TableFieldCommon.addTotalRow
|
public function addTotalRow($field, $name = null, $label = null)
{
if ($name === null) {
$name = $field;
}
if ($label === null) {
$label = $name;
$name = $field;
}
$this->totalRow[$field] = array('Field' => $field, 'Name' => $name, 'Label' => $label);
}
|
php
|
public function addTotalRow($field, $name = null, $label = null)
{
if ($name === null) {
$name = $field;
}
if ($label === null) {
$label = $name;
$name = $field;
}
$this->totalRow[$field] = array('Field' => $field, 'Name' => $name, 'Label' => $label);
}
|
[
"public",
"function",
"addTotalRow",
"(",
"$",
"field",
",",
"$",
"name",
"=",
"null",
",",
"$",
"label",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"name",
"===",
"null",
")",
"{",
"$",
"name",
"=",
"$",
"field",
";",
"}",
"if",
"(",
"$",
"label",
"===",
"null",
")",
"{",
"$",
"label",
"=",
"$",
"name",
";",
"$",
"name",
"=",
"$",
"field",
";",
"}",
"$",
"this",
"->",
"totalRow",
"[",
"$",
"field",
"]",
"=",
"array",
"(",
"'Field'",
"=>",
"$",
"field",
",",
"'Name'",
"=>",
"$",
"name",
",",
"'Label'",
"=>",
"$",
"label",
")",
";",
"}"
] |
Add a total row at the end of the table.
@param string $field Field to compute (must be of type currency)
@param string $name Name of the html input
@param string $label Label of the total
|
[
"Add",
"a",
"total",
"row",
"at",
"the",
"end",
"of",
"the",
"table",
"."
] |
e0c1200792af8e6cea916e1999c73cf8408c6dd2
|
https://github.com/lekoala/silverstripe-form-extras/blob/e0c1200792af8e6cea916e1999c73cf8408c6dd2/code/fields/TableFieldCommon.php#L166-L176
|
229,047
|
lekoala/silverstripe-form-extras
|
code/fields/TableFieldCommon.php
|
TableFieldCommon.getProperty
|
public function getProperty($property)
{
$values = array();
foreach ($this->columns as $key => $col) {
if (isset($col[$property])) {
$values[$key] = $col[$property];
} else {
$values[$key] = null;
}
}
}
|
php
|
public function getProperty($property)
{
$values = array();
foreach ($this->columns as $key => $col) {
if (isset($col[$property])) {
$values[$key] = $col[$property];
} else {
$values[$key] = null;
}
}
}
|
[
"public",
"function",
"getProperty",
"(",
"$",
"property",
")",
"{",
"$",
"values",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"columns",
"as",
"$",
"key",
"=>",
"$",
"col",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"col",
"[",
"$",
"property",
"]",
")",
")",
"{",
"$",
"values",
"[",
"$",
"key",
"]",
"=",
"$",
"col",
"[",
"$",
"property",
"]",
";",
"}",
"else",
"{",
"$",
"values",
"[",
"$",
"key",
"]",
"=",
"null",
";",
"}",
"}",
"}"
] |
Get a property from all columns
@param string $property
|
[
"Get",
"a",
"property",
"from",
"all",
"columns"
] |
e0c1200792af8e6cea916e1999c73cf8408c6dd2
|
https://github.com/lekoala/silverstripe-form-extras/blob/e0c1200792af8e6cea916e1999c73cf8408c6dd2/code/fields/TableFieldCommon.php#L393-L403
|
229,048
|
lekoala/silverstripe-form-extras
|
code/fields/TableFieldCommon.php
|
TableFieldCommon.setProperty
|
public function setProperty($property, $arr)
{
if (!ArrayLib::is_associative($arr)) {
$arr = array_combine($arr, $arr);
}
// Make sure all columns exists
foreach ($arr as $colName => $value) {
if (!isset($this->columns[$colName])) {
$this->columns[$colName] = array();
}
}
// Assign values to columns
foreach ($this->columns as $colName => $colData) {
if (isset($arr[$colName])) {
$colData[$property] = $arr[$colName];
$this->columns[$colName] = $colData;
}
}
return $this;
}
|
php
|
public function setProperty($property, $arr)
{
if (!ArrayLib::is_associative($arr)) {
$arr = array_combine($arr, $arr);
}
// Make sure all columns exists
foreach ($arr as $colName => $value) {
if (!isset($this->columns[$colName])) {
$this->columns[$colName] = array();
}
}
// Assign values to columns
foreach ($this->columns as $colName => $colData) {
if (isset($arr[$colName])) {
$colData[$property] = $arr[$colName];
$this->columns[$colName] = $colData;
}
}
return $this;
}
|
[
"public",
"function",
"setProperty",
"(",
"$",
"property",
",",
"$",
"arr",
")",
"{",
"if",
"(",
"!",
"ArrayLib",
"::",
"is_associative",
"(",
"$",
"arr",
")",
")",
"{",
"$",
"arr",
"=",
"array_combine",
"(",
"$",
"arr",
",",
"$",
"arr",
")",
";",
"}",
"// Make sure all columns exists",
"foreach",
"(",
"$",
"arr",
"as",
"$",
"colName",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"columns",
"[",
"$",
"colName",
"]",
")",
")",
"{",
"$",
"this",
"->",
"columns",
"[",
"$",
"colName",
"]",
"=",
"array",
"(",
")",
";",
"}",
"}",
"// Assign values to columns",
"foreach",
"(",
"$",
"this",
"->",
"columns",
"as",
"$",
"colName",
"=>",
"$",
"colData",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"arr",
"[",
"$",
"colName",
"]",
")",
")",
"{",
"$",
"colData",
"[",
"$",
"property",
"]",
"=",
"$",
"arr",
"[",
"$",
"colName",
"]",
";",
"$",
"this",
"->",
"columns",
"[",
"$",
"colName",
"]",
"=",
"$",
"colData",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] |
Set a property on all columns
@param string $property
@param array $arr
@return \TableFieldCommon
|
[
"Set",
"a",
"property",
"on",
"all",
"columns"
] |
e0c1200792af8e6cea916e1999c73cf8408c6dd2
|
https://github.com/lekoala/silverstripe-form-extras/blob/e0c1200792af8e6cea916e1999c73cf8408c6dd2/code/fields/TableFieldCommon.php#L411-L430
|
229,049
|
lekoala/silverstripe-form-extras
|
code/fields/TableFieldCommon.php
|
TableFieldCommon.getColumnProperty
|
public function getColumnProperty($column, $property, $default = null)
{
if (!isset($this->columns[$column])) {
return $default;
}
if (!isset($this->columns[$column][$property])) {
return $default;
}
return $this->columns[$column][$property];
}
|
php
|
public function getColumnProperty($column, $property, $default = null)
{
if (!isset($this->columns[$column])) {
return $default;
}
if (!isset($this->columns[$column][$property])) {
return $default;
}
return $this->columns[$column][$property];
}
|
[
"public",
"function",
"getColumnProperty",
"(",
"$",
"column",
",",
"$",
"property",
",",
"$",
"default",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"columns",
"[",
"$",
"column",
"]",
")",
")",
"{",
"return",
"$",
"default",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"columns",
"[",
"$",
"column",
"]",
"[",
"$",
"property",
"]",
")",
")",
"{",
"return",
"$",
"default",
";",
"}",
"return",
"$",
"this",
"->",
"columns",
"[",
"$",
"column",
"]",
"[",
"$",
"property",
"]",
";",
"}"
] |
Get property from a column
@param string $column
@param string $property
@param mixed $default
@return mixed
|
[
"Get",
"property",
"from",
"a",
"column"
] |
e0c1200792af8e6cea916e1999c73cf8408c6dd2
|
https://github.com/lekoala/silverstripe-form-extras/blob/e0c1200792af8e6cea916e1999c73cf8408c6dd2/code/fields/TableFieldCommon.php#L439-L448
|
229,050
|
lekoala/silverstripe-form-extras
|
code/fields/TableFieldCommon.php
|
TableFieldCommon.setColumnProperty
|
public function setColumnProperty($column, $property, $value)
{
if (!isset($this->columns[$column])) {
$this->columns[$column] = array();
}
$this->columns[$column][$property] = $value;
return $this;
}
|
php
|
public function setColumnProperty($column, $property, $value)
{
if (!isset($this->columns[$column])) {
$this->columns[$column] = array();
}
$this->columns[$column][$property] = $value;
return $this;
}
|
[
"public",
"function",
"setColumnProperty",
"(",
"$",
"column",
",",
"$",
"property",
",",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"columns",
"[",
"$",
"column",
"]",
")",
")",
"{",
"$",
"this",
"->",
"columns",
"[",
"$",
"column",
"]",
"=",
"array",
"(",
")",
";",
"}",
"$",
"this",
"->",
"columns",
"[",
"$",
"column",
"]",
"[",
"$",
"property",
"]",
"=",
"$",
"value",
";",
"return",
"$",
"this",
";",
"}"
] |
Set property of a column
@param string $column
@param string $property
@param mixed $value
@return \TableFieldCommon
|
[
"Set",
"property",
"of",
"a",
"column"
] |
e0c1200792af8e6cea916e1999c73cf8408c6dd2
|
https://github.com/lekoala/silverstripe-form-extras/blob/e0c1200792af8e6cea916e1999c73cf8408c6dd2/code/fields/TableFieldCommon.php#L457-L464
|
229,051
|
slickframework/slick
|
src/Slick/Session/Session.php
|
Session.get
|
public static function get($config = null)
{
/** @var Session $session */
$session = new static();
if (is_null($config)) {
$config = Configuration::get('config');
}
$class = $config->get('session.type', 'server');
$options = $config->get('session', array());
if ($config->get('session.type', false)) {
unset ($options['type']);
}
$session->class = $class;
$session->options = $options;
return $session->initialize();
}
|
php
|
public static function get($config = null)
{
/** @var Session $session */
$session = new static();
if (is_null($config)) {
$config = Configuration::get('config');
}
$class = $config->get('session.type', 'server');
$options = $config->get('session', array());
if ($config->get('session.type', false)) {
unset ($options['type']);
}
$session->class = $class;
$session->options = $options;
return $session->initialize();
}
|
[
"public",
"static",
"function",
"get",
"(",
"$",
"config",
"=",
"null",
")",
"{",
"/** @var Session $session */",
"$",
"session",
"=",
"new",
"static",
"(",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"config",
")",
")",
"{",
"$",
"config",
"=",
"Configuration",
"::",
"get",
"(",
"'config'",
")",
";",
"}",
"$",
"class",
"=",
"$",
"config",
"->",
"get",
"(",
"'session.type'",
",",
"'server'",
")",
";",
"$",
"options",
"=",
"$",
"config",
"->",
"get",
"(",
"'session'",
",",
"array",
"(",
")",
")",
";",
"if",
"(",
"$",
"config",
"->",
"get",
"(",
"'session.type'",
",",
"false",
")",
")",
"{",
"unset",
"(",
"$",
"options",
"[",
"'type'",
"]",
")",
";",
"}",
"$",
"session",
"->",
"class",
"=",
"$",
"class",
";",
"$",
"session",
"->",
"options",
"=",
"$",
"options",
";",
"return",
"$",
"session",
"->",
"initialize",
"(",
")",
";",
"}"
] |
Factory method to retrieve a session object
@param \Slick\Configuration\Driver\DriverInterface $config
@return Driver\DriverInterface
|
[
"Factory",
"method",
"to",
"retrieve",
"a",
"session",
"object"
] |
77f56b81020ce8c10f25f7d918661ccd9a918a37
|
https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Session/Session.php#L47-L64
|
229,052
|
slickframework/slick
|
src/Slick/Session/Session.php
|
Session.initialize
|
public function initialize()
{
$driver = $this->_class;
if (empty($driver)) {
throw new Exception\InvalidArgumentException(
"The session driver is invalid."
);
}
// Load user defined driver
if (class_exists($driver)) {
$driverObj = new $driver($this->_options);
if (is_a($driverObj, '\Slick\Session\Driver\DriverInterface')) {
return $driverObj;
} else {
throw new Exception\InvalidArgumentException(
"The session type '{$driver}' doesn't inherited from "
."Slick\Session\Driver\DriverInterface."
);
}
}
// Load module predefined drivers
switch ($driver) {
case 'server':
$driverObj = new Driver\Server($this->_options);
break;
default:
throw new Exception\InvalidArgumentException(
"The session type '{$driver}' isn't implemented."
);
}
return $driverObj;
}
|
php
|
public function initialize()
{
$driver = $this->_class;
if (empty($driver)) {
throw new Exception\InvalidArgumentException(
"The session driver is invalid."
);
}
// Load user defined driver
if (class_exists($driver)) {
$driverObj = new $driver($this->_options);
if (is_a($driverObj, '\Slick\Session\Driver\DriverInterface')) {
return $driverObj;
} else {
throw new Exception\InvalidArgumentException(
"The session type '{$driver}' doesn't inherited from "
."Slick\Session\Driver\DriverInterface."
);
}
}
// Load module predefined drivers
switch ($driver) {
case 'server':
$driverObj = new Driver\Server($this->_options);
break;
default:
throw new Exception\InvalidArgumentException(
"The session type '{$driver}' isn't implemented."
);
}
return $driverObj;
}
|
[
"public",
"function",
"initialize",
"(",
")",
"{",
"$",
"driver",
"=",
"$",
"this",
"->",
"_class",
";",
"if",
"(",
"empty",
"(",
"$",
"driver",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"InvalidArgumentException",
"(",
"\"The session driver is invalid.\"",
")",
";",
"}",
"// Load user defined driver",
"if",
"(",
"class_exists",
"(",
"$",
"driver",
")",
")",
"{",
"$",
"driverObj",
"=",
"new",
"$",
"driver",
"(",
"$",
"this",
"->",
"_options",
")",
";",
"if",
"(",
"is_a",
"(",
"$",
"driverObj",
",",
"'\\Slick\\Session\\Driver\\DriverInterface'",
")",
")",
"{",
"return",
"$",
"driverObj",
";",
"}",
"else",
"{",
"throw",
"new",
"Exception",
"\\",
"InvalidArgumentException",
"(",
"\"The session type '{$driver}' doesn't inherited from \"",
".",
"\"Slick\\Session\\Driver\\DriverInterface.\"",
")",
";",
"}",
"}",
"// Load module predefined drivers",
"switch",
"(",
"$",
"driver",
")",
"{",
"case",
"'server'",
":",
"$",
"driverObj",
"=",
"new",
"Driver",
"\\",
"Server",
"(",
"$",
"this",
"->",
"_options",
")",
";",
"break",
";",
"default",
":",
"throw",
"new",
"Exception",
"\\",
"InvalidArgumentException",
"(",
"\"The session type '{$driver}' isn't implemented.\"",
")",
";",
"}",
"return",
"$",
"driverObj",
";",
"}"
] |
Returns a new session driver based on the class property.
@throws Exception\InvalidArgumentException
@return Driver\DriverInterface A new Session driver based on class.
|
[
"Returns",
"a",
"new",
"session",
"driver",
"based",
"on",
"the",
"class",
"property",
"."
] |
77f56b81020ce8c10f25f7d918661ccd9a918a37
|
https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Session/Session.php#L72-L108
|
229,053
|
slickframework/slick
|
src/Slick/Database/Adapter.php
|
Adapter.initialize
|
public function initialize()
{
$adapter = null;
if (is_null($this->_driver)) {
// No name given for driver initialization
throw new InvalidArgumentException(
"Trying to initialize an invalid database adapter."
);
}
if (class_exists($this->_driver)) {
// Class name given, check if it is an adapter
$reflection = new ReflectionClass($this->_driver);
if (
!$reflection->implementsInterface(
'Slick\Database\Adapter\AdapterInterface'
)
) {
throw new InvalidArgumentException(
"The adapter class name {$this->_driver} does not " .
"implement Slick\Database\Adapter\AdapterInterface " .
"interface."
);
}
return $reflection->newInstanceArgs([$this->_options]);
}
switch (strtolower($this->_driver)) {
case 'mysql':
$adapter = $this->_createAdapter('mysql');
break;
case 'sqlite':
$adapter = $this->_createAdapter('sqlite');
break;
default:
throw new InvalidArgumentException(
"Trying to initialize an unknown database adapter."
);
}
return $adapter;
}
|
php
|
public function initialize()
{
$adapter = null;
if (is_null($this->_driver)) {
// No name given for driver initialization
throw new InvalidArgumentException(
"Trying to initialize an invalid database adapter."
);
}
if (class_exists($this->_driver)) {
// Class name given, check if it is an adapter
$reflection = new ReflectionClass($this->_driver);
if (
!$reflection->implementsInterface(
'Slick\Database\Adapter\AdapterInterface'
)
) {
throw new InvalidArgumentException(
"The adapter class name {$this->_driver} does not " .
"implement Slick\Database\Adapter\AdapterInterface " .
"interface."
);
}
return $reflection->newInstanceArgs([$this->_options]);
}
switch (strtolower($this->_driver)) {
case 'mysql':
$adapter = $this->_createAdapter('mysql');
break;
case 'sqlite':
$adapter = $this->_createAdapter('sqlite');
break;
default:
throw new InvalidArgumentException(
"Trying to initialize an unknown database adapter."
);
}
return $adapter;
}
|
[
"public",
"function",
"initialize",
"(",
")",
"{",
"$",
"adapter",
"=",
"null",
";",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"_driver",
")",
")",
"{",
"// No name given for driver initialization",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"Trying to initialize an invalid database adapter.\"",
")",
";",
"}",
"if",
"(",
"class_exists",
"(",
"$",
"this",
"->",
"_driver",
")",
")",
"{",
"// Class name given, check if it is an adapter",
"$",
"reflection",
"=",
"new",
"ReflectionClass",
"(",
"$",
"this",
"->",
"_driver",
")",
";",
"if",
"(",
"!",
"$",
"reflection",
"->",
"implementsInterface",
"(",
"'Slick\\Database\\Adapter\\AdapterInterface'",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"The adapter class name {$this->_driver} does not \"",
".",
"\"implement Slick\\Database\\Adapter\\AdapterInterface \"",
".",
"\"interface.\"",
")",
";",
"}",
"return",
"$",
"reflection",
"->",
"newInstanceArgs",
"(",
"[",
"$",
"this",
"->",
"_options",
"]",
")",
";",
"}",
"switch",
"(",
"strtolower",
"(",
"$",
"this",
"->",
"_driver",
")",
")",
"{",
"case",
"'mysql'",
":",
"$",
"adapter",
"=",
"$",
"this",
"->",
"_createAdapter",
"(",
"'mysql'",
")",
";",
"break",
";",
"case",
"'sqlite'",
":",
"$",
"adapter",
"=",
"$",
"this",
"->",
"_createAdapter",
"(",
"'sqlite'",
")",
";",
"break",
";",
"default",
":",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"Trying to initialize an unknown database adapter.\"",
")",
";",
"}",
"return",
"$",
"adapter",
";",
"}"
] |
Initializes an adapter with provided options
@throws Exception\InvalidArgumentException If the driver is null,
unknown or if the adapter class name provided as driver does not
implements the Slick\Database\Adapter\AdapterInterface interface.
@return AdapterInterface
|
[
"Initializes",
"an",
"adapter",
"with",
"provided",
"options"
] |
77f56b81020ce8c10f25f7d918661ccd9a918a37
|
https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Database/Adapter.php#L68-L112
|
229,054
|
wolfguarder/yii2-video-gallery
|
models/VideoGalleryItem.php
|
VideoGalleryItem.getVideoImage
|
public function getVideoImage($version = 'default'){
if (strpos($this->url, 'youtu') !== false) {
switch($version){
case 'max':
return 'https://img.youtube.com/vi/'.$this->getVideoCode().'/maxresdefault.jpg';
break;
case 'hq':
return 'https://img.youtube.com/vi/'.$this->getVideoCode().'/hqdefault.jpg';
break;
case 'mq':
return 'https://img.youtube.com/vi/'.$this->getVideoCode().'/mqdefault.jpg';
break;
case 'sd':
return 'https://img.youtube.com/vi/'.$this->getVideoCode().'/sddefault.jpg';
break;
default:
return 'https://img.youtube.com/vi/'.$this->getVideoCode().'/default.jpg';
}
}
return '';
}
|
php
|
public function getVideoImage($version = 'default'){
if (strpos($this->url, 'youtu') !== false) {
switch($version){
case 'max':
return 'https://img.youtube.com/vi/'.$this->getVideoCode().'/maxresdefault.jpg';
break;
case 'hq':
return 'https://img.youtube.com/vi/'.$this->getVideoCode().'/hqdefault.jpg';
break;
case 'mq':
return 'https://img.youtube.com/vi/'.$this->getVideoCode().'/mqdefault.jpg';
break;
case 'sd':
return 'https://img.youtube.com/vi/'.$this->getVideoCode().'/sddefault.jpg';
break;
default:
return 'https://img.youtube.com/vi/'.$this->getVideoCode().'/default.jpg';
}
}
return '';
}
|
[
"public",
"function",
"getVideoImage",
"(",
"$",
"version",
"=",
"'default'",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"this",
"->",
"url",
",",
"'youtu'",
")",
"!==",
"false",
")",
"{",
"switch",
"(",
"$",
"version",
")",
"{",
"case",
"'max'",
":",
"return",
"'https://img.youtube.com/vi/'",
".",
"$",
"this",
"->",
"getVideoCode",
"(",
")",
".",
"'/maxresdefault.jpg'",
";",
"break",
";",
"case",
"'hq'",
":",
"return",
"'https://img.youtube.com/vi/'",
".",
"$",
"this",
"->",
"getVideoCode",
"(",
")",
".",
"'/hqdefault.jpg'",
";",
"break",
";",
"case",
"'mq'",
":",
"return",
"'https://img.youtube.com/vi/'",
".",
"$",
"this",
"->",
"getVideoCode",
"(",
")",
".",
"'/mqdefault.jpg'",
";",
"break",
";",
"case",
"'sd'",
":",
"return",
"'https://img.youtube.com/vi/'",
".",
"$",
"this",
"->",
"getVideoCode",
"(",
")",
".",
"'/sddefault.jpg'",
";",
"break",
";",
"default",
":",
"return",
"'https://img.youtube.com/vi/'",
".",
"$",
"this",
"->",
"getVideoCode",
"(",
")",
".",
"'/default.jpg'",
";",
"}",
"}",
"return",
"''",
";",
"}"
] |
Gets video thumbnail from outside server
@param string $version (max, hq, mq, sd or default)
@return string Url to image
|
[
"Gets",
"video",
"thumbnail",
"from",
"outside",
"server"
] |
e2c4a06e469a674e1b75dbc841714f2d5a9505bf
|
https://github.com/wolfguarder/yii2-video-gallery/blob/e2c4a06e469a674e1b75dbc841714f2d5a9505bf/models/VideoGalleryItem.php#L138-L163
|
229,055
|
denisyukphp/tmpfile
|
src/tmpfile.php
|
tmpfile.create
|
private function create()
{
$filename = tempnam(null === $this->tempDir ? sys_get_temp_dir() : $this->tempDir, 'php');
if (!$filename) {
throw new \Error('The function tempnam() could not create a file in temporary directory.');
}
return $filename;
}
|
php
|
private function create()
{
$filename = tempnam(null === $this->tempDir ? sys_get_temp_dir() : $this->tempDir, 'php');
if (!$filename) {
throw new \Error('The function tempnam() could not create a file in temporary directory.');
}
return $filename;
}
|
[
"private",
"function",
"create",
"(",
")",
"{",
"$",
"filename",
"=",
"tempnam",
"(",
"null",
"===",
"$",
"this",
"->",
"tempDir",
"?",
"sys_get_temp_dir",
"(",
")",
":",
"$",
"this",
"->",
"tempDir",
",",
"'php'",
")",
";",
"if",
"(",
"!",
"$",
"filename",
")",
"{",
"throw",
"new",
"\\",
"Error",
"(",
"'The function tempnam() could not create a file in temporary directory.'",
")",
";",
"}",
"return",
"$",
"filename",
";",
"}"
] |
Create file with unique name in temp directory
@throws \Error
@return string
|
[
"Create",
"file",
"with",
"unique",
"name",
"in",
"temp",
"directory"
] |
6b8a26deae0d8767af8bcd82390980292ee23436
|
https://github.com/denisyukphp/tmpfile/blob/6b8a26deae0d8767af8bcd82390980292ee23436/src/tmpfile.php#L45-L54
|
229,056
|
denisyukphp/tmpfile
|
src/tmpfile.php
|
tmpfile.read
|
public function read()
{
$args = array_merge(
[$this->filename],
[false, null],
func_get_args()
);
return file_get_contents(...$args);
}
|
php
|
public function read()
{
$args = array_merge(
[$this->filename],
[false, null],
func_get_args()
);
return file_get_contents(...$args);
}
|
[
"public",
"function",
"read",
"(",
")",
"{",
"$",
"args",
"=",
"array_merge",
"(",
"[",
"$",
"this",
"->",
"filename",
"]",
",",
"[",
"false",
",",
"null",
"]",
",",
"func_get_args",
"(",
")",
")",
";",
"return",
"file_get_contents",
"(",
"...",
"$",
"args",
")",
";",
"}"
] |
Read entire file or chunk into a string
@param int $offset
@param int $maxlen
@return string|false
|
[
"Read",
"entire",
"file",
"or",
"chunk",
"into",
"a",
"string"
] |
6b8a26deae0d8767af8bcd82390980292ee23436
|
https://github.com/denisyukphp/tmpfile/blob/6b8a26deae0d8767af8bcd82390980292ee23436/src/tmpfile.php#L89-L98
|
229,057
|
Danzabar/phalcon-cli
|
src/Tasks/Helpers/Table.php
|
Table.draw
|
public function draw(array $data)
{
$lengths = $this->calcLength($data);
$this->writeHeaders($lengths);
$this->writeData($data, $lengths);
$this->writeFooter($lengths);
}
|
php
|
public function draw(array $data)
{
$lengths = $this->calcLength($data);
$this->writeHeaders($lengths);
$this->writeData($data, $lengths);
$this->writeFooter($lengths);
}
|
[
"public",
"function",
"draw",
"(",
"array",
"$",
"data",
")",
"{",
"$",
"lengths",
"=",
"$",
"this",
"->",
"calcLength",
"(",
"$",
"data",
")",
";",
"$",
"this",
"->",
"writeHeaders",
"(",
"$",
"lengths",
")",
";",
"$",
"this",
"->",
"writeData",
"(",
"$",
"data",
",",
"$",
"lengths",
")",
";",
"$",
"this",
"->",
"writeFooter",
"(",
"$",
"lengths",
")",
";",
"}"
] |
Draws a table from the array passed to it.
@return void
|
[
"Draws",
"a",
"table",
"from",
"the",
"array",
"passed",
"to",
"it",
"."
] |
0d6293d5d899158705f8e3a31886d176e595ee38
|
https://github.com/Danzabar/phalcon-cli/blob/0d6293d5d899158705f8e3a31886d176e595ee38/src/Tasks/Helpers/Table.php#L56-L65
|
229,058
|
Danzabar/phalcon-cli
|
src/Tasks/Helpers/Table.php
|
Table.writeData
|
public function writeData(array $data, array $lengths)
{
foreach ($data as $row) {
$rowOutput = $this->table_headerPart;
foreach ($row as $key => $value) {
$rowOutput .= ' '.str_pad($value, $lengths[$key], ' ', STR_PAD_RIGHT).' '.$this->table_headerPart;
}
$this->output->writeln($rowOutput);
}
}
|
php
|
public function writeData(array $data, array $lengths)
{
foreach ($data as $row) {
$rowOutput = $this->table_headerPart;
foreach ($row as $key => $value) {
$rowOutput .= ' '.str_pad($value, $lengths[$key], ' ', STR_PAD_RIGHT).' '.$this->table_headerPart;
}
$this->output->writeln($rowOutput);
}
}
|
[
"public",
"function",
"writeData",
"(",
"array",
"$",
"data",
",",
"array",
"$",
"lengths",
")",
"{",
"foreach",
"(",
"$",
"data",
"as",
"$",
"row",
")",
"{",
"$",
"rowOutput",
"=",
"$",
"this",
"->",
"table_headerPart",
";",
"foreach",
"(",
"$",
"row",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"rowOutput",
".=",
"' '",
".",
"str_pad",
"(",
"$",
"value",
",",
"$",
"lengths",
"[",
"$",
"key",
"]",
",",
"' '",
",",
"STR_PAD_RIGHT",
")",
".",
"' '",
".",
"$",
"this",
"->",
"table_headerPart",
";",
"}",
"$",
"this",
"->",
"output",
"->",
"writeln",
"(",
"$",
"rowOutput",
")",
";",
"}",
"}"
] |
Writes the table
@return void
|
[
"Writes",
"the",
"table"
] |
0d6293d5d899158705f8e3a31886d176e595ee38
|
https://github.com/Danzabar/phalcon-cli/blob/0d6293d5d899158705f8e3a31886d176e595ee38/src/Tasks/Helpers/Table.php#L72-L83
|
229,059
|
Danzabar/phalcon-cli
|
src/Tasks/Helpers/Table.php
|
Table.writeFooter
|
public function writeFooter(array $headers)
{
$bar = $this->table_connectorLeft;
foreach ($headers as $name => $length) {
$bar .= str_pad('', $length + 2, $this->table_barFiller).''.$this->table_connectorRight;
}
$this->output->writeln($bar);
}
|
php
|
public function writeFooter(array $headers)
{
$bar = $this->table_connectorLeft;
foreach ($headers as $name => $length) {
$bar .= str_pad('', $length + 2, $this->table_barFiller).''.$this->table_connectorRight;
}
$this->output->writeln($bar);
}
|
[
"public",
"function",
"writeFooter",
"(",
"array",
"$",
"headers",
")",
"{",
"$",
"bar",
"=",
"$",
"this",
"->",
"table_connectorLeft",
";",
"foreach",
"(",
"$",
"headers",
"as",
"$",
"name",
"=>",
"$",
"length",
")",
"{",
"$",
"bar",
".=",
"str_pad",
"(",
"''",
",",
"$",
"length",
"+",
"2",
",",
"$",
"this",
"->",
"table_barFiller",
")",
".",
"''",
".",
"$",
"this",
"->",
"table_connectorRight",
";",
"}",
"$",
"this",
"->",
"output",
"->",
"writeln",
"(",
"$",
"bar",
")",
";",
"}"
] |
Writes a decorative footer
@return void
|
[
"Writes",
"a",
"decorative",
"footer"
] |
0d6293d5d899158705f8e3a31886d176e595ee38
|
https://github.com/Danzabar/phalcon-cli/blob/0d6293d5d899158705f8e3a31886d176e595ee38/src/Tasks/Helpers/Table.php#L90-L99
|
229,060
|
Danzabar/phalcon-cli
|
src/Tasks/Helpers/Table.php
|
Table.writeHeaders
|
public function writeHeaders(array $headers)
{
$bar = $this->table_connectorHeader;
$header = $this->table_headerPart;
foreach ($headers as $name => $length) {
$bar .= str_pad('', $length + 2, $this->table_barFiller).$this->table_connectorHeader;
$header .= ' '.str_pad($name, $length, ' ', STR_PAD_RIGHT).' '.$this->table_headerPart;
}
$this->output->writeln($bar);
$this->output->writeln($header);
$this->output->writeln($bar);
}
|
php
|
public function writeHeaders(array $headers)
{
$bar = $this->table_connectorHeader;
$header = $this->table_headerPart;
foreach ($headers as $name => $length) {
$bar .= str_pad('', $length + 2, $this->table_barFiller).$this->table_connectorHeader;
$header .= ' '.str_pad($name, $length, ' ', STR_PAD_RIGHT).' '.$this->table_headerPart;
}
$this->output->writeln($bar);
$this->output->writeln($header);
$this->output->writeln($bar);
}
|
[
"public",
"function",
"writeHeaders",
"(",
"array",
"$",
"headers",
")",
"{",
"$",
"bar",
"=",
"$",
"this",
"->",
"table_connectorHeader",
";",
"$",
"header",
"=",
"$",
"this",
"->",
"table_headerPart",
";",
"foreach",
"(",
"$",
"headers",
"as",
"$",
"name",
"=>",
"$",
"length",
")",
"{",
"$",
"bar",
".=",
"str_pad",
"(",
"''",
",",
"$",
"length",
"+",
"2",
",",
"$",
"this",
"->",
"table_barFiller",
")",
".",
"$",
"this",
"->",
"table_connectorHeader",
";",
"$",
"header",
".=",
"' '",
".",
"str_pad",
"(",
"$",
"name",
",",
"$",
"length",
",",
"' '",
",",
"STR_PAD_RIGHT",
")",
".",
"' '",
".",
"$",
"this",
"->",
"table_headerPart",
";",
"}",
"$",
"this",
"->",
"output",
"->",
"writeln",
"(",
"$",
"bar",
")",
";",
"$",
"this",
"->",
"output",
"->",
"writeln",
"(",
"$",
"header",
")",
";",
"$",
"this",
"->",
"output",
"->",
"writeln",
"(",
"$",
"bar",
")",
";",
"}"
] |
Outputs the headers with padding previously calculated
@return void
|
[
"Outputs",
"the",
"headers",
"with",
"padding",
"previously",
"calculated"
] |
0d6293d5d899158705f8e3a31886d176e595ee38
|
https://github.com/Danzabar/phalcon-cli/blob/0d6293d5d899158705f8e3a31886d176e595ee38/src/Tasks/Helpers/Table.php#L106-L120
|
229,061
|
Danzabar/phalcon-cli
|
src/Tasks/Helpers/Table.php
|
Table.calcLength
|
public function calcLength(array $data)
{
$lengths = array();
foreach ($data as $table) {
foreach ($table as $key => $value) {
$len = strlen($value);
if (!isset($lengths[$key]) || $len > $lengths[$key]) {
$lengths[$key] = $len;
}
if (isset($lengths[$key]) && strlen($key) > $lengths[$key]) {
$lengths[$key] = strlen($key);
}
}
}
return $lengths;
}
|
php
|
public function calcLength(array $data)
{
$lengths = array();
foreach ($data as $table) {
foreach ($table as $key => $value) {
$len = strlen($value);
if (!isset($lengths[$key]) || $len > $lengths[$key]) {
$lengths[$key] = $len;
}
if (isset($lengths[$key]) && strlen($key) > $lengths[$key]) {
$lengths[$key] = strlen($key);
}
}
}
return $lengths;
}
|
[
"public",
"function",
"calcLength",
"(",
"array",
"$",
"data",
")",
"{",
"$",
"lengths",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"table",
")",
"{",
"foreach",
"(",
"$",
"table",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"len",
"=",
"strlen",
"(",
"$",
"value",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"lengths",
"[",
"$",
"key",
"]",
")",
"||",
"$",
"len",
">",
"$",
"lengths",
"[",
"$",
"key",
"]",
")",
"{",
"$",
"lengths",
"[",
"$",
"key",
"]",
"=",
"$",
"len",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"lengths",
"[",
"$",
"key",
"]",
")",
"&&",
"strlen",
"(",
"$",
"key",
")",
">",
"$",
"lengths",
"[",
"$",
"key",
"]",
")",
"{",
"$",
"lengths",
"[",
"$",
"key",
"]",
"=",
"strlen",
"(",
"$",
"key",
")",
";",
"}",
"}",
"}",
"return",
"$",
"lengths",
";",
"}"
] |
Calculate the length of the table
@return Array
|
[
"Calculate",
"the",
"length",
"of",
"the",
"table"
] |
0d6293d5d899158705f8e3a31886d176e595ee38
|
https://github.com/Danzabar/phalcon-cli/blob/0d6293d5d899158705f8e3a31886d176e595ee38/src/Tasks/Helpers/Table.php#L127-L146
|
229,062
|
jameshalsall/licenser
|
src/Factory/LicenseHeaderFactory.php
|
LicenseHeaderFactory.createFromLicenseName
|
public function createFromLicenseName($licenseName, array $replacements = array())
{
$replacements['thisYear'] = date('Y');
try {
return $this->twig->render($licenseName, $replacements);
} catch (\Twig_Error_Loader $e) {
throw new \InvalidArgumentException('Invalid license name provided');
}
}
|
php
|
public function createFromLicenseName($licenseName, array $replacements = array())
{
$replacements['thisYear'] = date('Y');
try {
return $this->twig->render($licenseName, $replacements);
} catch (\Twig_Error_Loader $e) {
throw new \InvalidArgumentException('Invalid license name provided');
}
}
|
[
"public",
"function",
"createFromLicenseName",
"(",
"$",
"licenseName",
",",
"array",
"$",
"replacements",
"=",
"array",
"(",
")",
")",
"{",
"$",
"replacements",
"[",
"'thisYear'",
"]",
"=",
"date",
"(",
"'Y'",
")",
";",
"try",
"{",
"return",
"$",
"this",
"->",
"twig",
"->",
"render",
"(",
"$",
"licenseName",
",",
"$",
"replacements",
")",
";",
"}",
"catch",
"(",
"\\",
"Twig_Error_Loader",
"$",
"e",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Invalid license name provided'",
")",
";",
"}",
"}"
] |
Creates a license header string from a license name
@param string $licenseName The license name
@param array $replacements Values to use replacing placeholders in the license header (indexed by their placeholder name)
@throws \InvalidArgumentException If the license name doesn't exist
@return string
|
[
"Creates",
"a",
"license",
"header",
"string",
"from",
"a",
"license",
"name"
] |
41fce6a66bf42e0045bd479397f788c83f7d78af
|
https://github.com/jameshalsall/licenser/blob/41fce6a66bf42e0045bd479397f788c83f7d78af/src/Factory/LicenseHeaderFactory.php#L64-L73
|
229,063
|
cornernote/yii-audit-module
|
audit/AuditModule.php
|
AuditModule.init
|
public function init()
{
parent::init();
// setup paths
$this->setImport(array(
'audit.models.*',
'audit.components.*',
));
// map models
foreach ($this->getDefaultModelMap() as $method => $data)
foreach ($data as $name => $options)
if (empty($this->modelMap[$method][$name]))
$this->modelMap[$method][$name] = $options;
// init yiiStrap
$this->initYiiStrap();
}
|
php
|
public function init()
{
parent::init();
// setup paths
$this->setImport(array(
'audit.models.*',
'audit.components.*',
));
// map models
foreach ($this->getDefaultModelMap() as $method => $data)
foreach ($data as $name => $options)
if (empty($this->modelMap[$method][$name]))
$this->modelMap[$method][$name] = $options;
// init yiiStrap
$this->initYiiStrap();
}
|
[
"public",
"function",
"init",
"(",
")",
"{",
"parent",
"::",
"init",
"(",
")",
";",
"// setup paths",
"$",
"this",
"->",
"setImport",
"(",
"array",
"(",
"'audit.models.*'",
",",
"'audit.components.*'",
",",
")",
")",
";",
"// map models",
"foreach",
"(",
"$",
"this",
"->",
"getDefaultModelMap",
"(",
")",
"as",
"$",
"method",
"=>",
"$",
"data",
")",
"foreach",
"(",
"$",
"data",
"as",
"$",
"name",
"=>",
"$",
"options",
")",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"modelMap",
"[",
"$",
"method",
"]",
"[",
"$",
"name",
"]",
")",
")",
"$",
"this",
"->",
"modelMap",
"[",
"$",
"method",
"]",
"[",
"$",
"name",
"]",
"=",
"$",
"options",
";",
"// init yiiStrap",
"$",
"this",
"->",
"initYiiStrap",
"(",
")",
";",
"}"
] |
Initializes the audit module.
|
[
"Initializes",
"the",
"audit",
"module",
"."
] |
07362f79741b5343d22bb9bb516d840072a097d4
|
https://github.com/cornernote/yii-audit-module/blob/07362f79741b5343d22bb9bb516d840072a097d4/audit/AuditModule.php#L142-L160
|
229,064
|
slickframework/slick
|
src/Slick/Database/Schema/Loader/Sqlite.php
|
Sqlite._createFkData
|
private function _createFkData($data, $table)
{
$name = $table . ucfirst(Text::singular($data['table'])) . 'Fk';
$structure = [
'constraintType' => 'FOREIGN KEY',
'constraintName' => $name,
'columnName' => $data['from'],
'referenceTable' => $data['table'],
'referenceColumn' => $data['to'],
'onUpdate' => $data['on_update'],
'onDelete' => $data['on_delete']
];
return $structure;
}
|
php
|
private function _createFkData($data, $table)
{
$name = $table . ucfirst(Text::singular($data['table'])) . 'Fk';
$structure = [
'constraintType' => 'FOREIGN KEY',
'constraintName' => $name,
'columnName' => $data['from'],
'referenceTable' => $data['table'],
'referenceColumn' => $data['to'],
'onUpdate' => $data['on_update'],
'onDelete' => $data['on_delete']
];
return $structure;
}
|
[
"private",
"function",
"_createFkData",
"(",
"$",
"data",
",",
"$",
"table",
")",
"{",
"$",
"name",
"=",
"$",
"table",
".",
"ucfirst",
"(",
"Text",
"::",
"singular",
"(",
"$",
"data",
"[",
"'table'",
"]",
")",
")",
".",
"'Fk'",
";",
"$",
"structure",
"=",
"[",
"'constraintType'",
"=>",
"'FOREIGN KEY'",
",",
"'constraintName'",
"=>",
"$",
"name",
",",
"'columnName'",
"=>",
"$",
"data",
"[",
"'from'",
"]",
",",
"'referenceTable'",
"=>",
"$",
"data",
"[",
"'table'",
"]",
",",
"'referenceColumn'",
"=>",
"$",
"data",
"[",
"'to'",
"]",
",",
"'onUpdate'",
"=>",
"$",
"data",
"[",
"'on_update'",
"]",
",",
"'onDelete'",
"=>",
"$",
"data",
"[",
"'on_delete'",
"]",
"]",
";",
"return",
"$",
"structure",
";",
"}"
] |
Creates a known structure for foreign key constraint creation
@param array $data
@param string $table
@return array
|
[
"Creates",
"a",
"known",
"structure",
"for",
"foreign",
"key",
"constraint",
"creation"
] |
77f56b81020ce8c10f25f7d918661ccd9a918a37
|
https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Database/Schema/Loader/Sqlite.php#L182-L195
|
229,065
|
AOEpeople/StackFormation
|
src/StackFormation/ValueResolver/Stage/ConditionalValue.php
|
ConditionalValue.isTrue
|
public function isTrue($condition, Blueprint $sourceBlueprint=null)
{
// resolve placeholders
$condition = $this->valueResolver->resolvePlaceholders($condition, $sourceBlueprint, 'conditional_value', $condition);
if ($condition == 'default') {
return true;
}
if (strpos($condition, '==') !== false) {
list($left, $right) = explode('==', $condition, 2);
$left = trim($left);
$right = trim($right);
return ($left == $right);
} elseif (strpos($condition, '!=') !== false) {
list($left, $right) = explode('!=', $condition, 2);
$left = trim($left);
$right = trim($right);
return ($left != $right);
} elseif (strpos($condition, '~=') !== false) {
list($subject, $pattern) = explode('~=', $condition, 2);
$subject = trim($subject);
$pattern = trim($pattern);
return preg_match($pattern, $subject);
}
throw new \Exception('Invalid condition: ' . $condition);
}
|
php
|
public function isTrue($condition, Blueprint $sourceBlueprint=null)
{
// resolve placeholders
$condition = $this->valueResolver->resolvePlaceholders($condition, $sourceBlueprint, 'conditional_value', $condition);
if ($condition == 'default') {
return true;
}
if (strpos($condition, '==') !== false) {
list($left, $right) = explode('==', $condition, 2);
$left = trim($left);
$right = trim($right);
return ($left == $right);
} elseif (strpos($condition, '!=') !== false) {
list($left, $right) = explode('!=', $condition, 2);
$left = trim($left);
$right = trim($right);
return ($left != $right);
} elseif (strpos($condition, '~=') !== false) {
list($subject, $pattern) = explode('~=', $condition, 2);
$subject = trim($subject);
$pattern = trim($pattern);
return preg_match($pattern, $subject);
}
throw new \Exception('Invalid condition: ' . $condition);
}
|
[
"public",
"function",
"isTrue",
"(",
"$",
"condition",
",",
"Blueprint",
"$",
"sourceBlueprint",
"=",
"null",
")",
"{",
"// resolve placeholders",
"$",
"condition",
"=",
"$",
"this",
"->",
"valueResolver",
"->",
"resolvePlaceholders",
"(",
"$",
"condition",
",",
"$",
"sourceBlueprint",
",",
"'conditional_value'",
",",
"$",
"condition",
")",
";",
"if",
"(",
"$",
"condition",
"==",
"'default'",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"strpos",
"(",
"$",
"condition",
",",
"'=='",
")",
"!==",
"false",
")",
"{",
"list",
"(",
"$",
"left",
",",
"$",
"right",
")",
"=",
"explode",
"(",
"'=='",
",",
"$",
"condition",
",",
"2",
")",
";",
"$",
"left",
"=",
"trim",
"(",
"$",
"left",
")",
";",
"$",
"right",
"=",
"trim",
"(",
"$",
"right",
")",
";",
"return",
"(",
"$",
"left",
"==",
"$",
"right",
")",
";",
"}",
"elseif",
"(",
"strpos",
"(",
"$",
"condition",
",",
"'!='",
")",
"!==",
"false",
")",
"{",
"list",
"(",
"$",
"left",
",",
"$",
"right",
")",
"=",
"explode",
"(",
"'!='",
",",
"$",
"condition",
",",
"2",
")",
";",
"$",
"left",
"=",
"trim",
"(",
"$",
"left",
")",
";",
"$",
"right",
"=",
"trim",
"(",
"$",
"right",
")",
";",
"return",
"(",
"$",
"left",
"!=",
"$",
"right",
")",
";",
"}",
"elseif",
"(",
"strpos",
"(",
"$",
"condition",
",",
"'~='",
")",
"!==",
"false",
")",
"{",
"list",
"(",
"$",
"subject",
",",
"$",
"pattern",
")",
"=",
"explode",
"(",
"'~='",
",",
"$",
"condition",
",",
"2",
")",
";",
"$",
"subject",
"=",
"trim",
"(",
"$",
"subject",
")",
";",
"$",
"pattern",
"=",
"trim",
"(",
"$",
"pattern",
")",
";",
"return",
"preg_match",
"(",
"$",
"pattern",
",",
"$",
"subject",
")",
";",
"}",
"throw",
"new",
"\\",
"Exception",
"(",
"'Invalid condition: '",
".",
"$",
"condition",
")",
";",
"}"
] |
Evaluate is key 'is true'
@param $condition
@param Blueprint|null $sourceBlueprint
@return bool
@throws \Exception
|
[
"Evaluate",
"is",
"key",
"is",
"true"
] |
5332dbbe54653e50d610cbaf75fb865c68aa2f1e
|
https://github.com/AOEpeople/StackFormation/blob/5332dbbe54653e50d610cbaf75fb865c68aa2f1e/src/StackFormation/ValueResolver/Stage/ConditionalValue.php#L31-L56
|
229,066
|
lekoala/silverstripe-form-extras
|
code/fieldtypes/DBColor.php
|
DBColor.getInvertedColor
|
public function getInvertedColor($color)
{
$color = str_replace('#', '', $this->hex6($color));
if (strlen($color) != 6) {
return '#000000';
}
$rgb = '';
for ($x = 0; $x < 3; $x++) {
$c = 255 - hexdec(substr($color, (2 * $x), 2));
$c = ($c < 0) ? 0 : dechex($c);
$rgb .= (strlen($c) < 2) ? '0'.$c : $c;
}
return '#'.$rgb;
}
|
php
|
public function getInvertedColor($color)
{
$color = str_replace('#', '', $this->hex6($color));
if (strlen($color) != 6) {
return '#000000';
}
$rgb = '';
for ($x = 0; $x < 3; $x++) {
$c = 255 - hexdec(substr($color, (2 * $x), 2));
$c = ($c < 0) ? 0 : dechex($c);
$rgb .= (strlen($c) < 2) ? '0'.$c : $c;
}
return '#'.$rgb;
}
|
[
"public",
"function",
"getInvertedColor",
"(",
"$",
"color",
")",
"{",
"$",
"color",
"=",
"str_replace",
"(",
"'#'",
",",
"''",
",",
"$",
"this",
"->",
"hex6",
"(",
"$",
"color",
")",
")",
";",
"if",
"(",
"strlen",
"(",
"$",
"color",
")",
"!=",
"6",
")",
"{",
"return",
"'#000000'",
";",
"}",
"$",
"rgb",
"=",
"''",
";",
"for",
"(",
"$",
"x",
"=",
"0",
";",
"$",
"x",
"<",
"3",
";",
"$",
"x",
"++",
")",
"{",
"$",
"c",
"=",
"255",
"-",
"hexdec",
"(",
"substr",
"(",
"$",
"color",
",",
"(",
"2",
"*",
"$",
"x",
")",
",",
"2",
")",
")",
";",
"$",
"c",
"=",
"(",
"$",
"c",
"<",
"0",
")",
"?",
"0",
":",
"dechex",
"(",
"$",
"c",
")",
";",
"$",
"rgb",
".=",
"(",
"strlen",
"(",
"$",
"c",
")",
"<",
"2",
")",
"?",
"'0'",
".",
"$",
"c",
":",
"$",
"c",
";",
"}",
"return",
"'#'",
".",
"$",
"rgb",
";",
"}"
] |
Get inverted color
@param string $color
@return string
|
[
"Get",
"inverted",
"color"
] |
e0c1200792af8e6cea916e1999c73cf8408c6dd2
|
https://github.com/lekoala/silverstripe-form-extras/blob/e0c1200792af8e6cea916e1999c73cf8408c6dd2/code/fieldtypes/DBColor.php#L37-L52
|
229,067
|
lekoala/silverstripe-form-extras
|
code/fieldtypes/DBColor.php
|
DBColor.getLightOrDark
|
public function getLightOrDark($color, $dark = '#000000', $light = '#FFFFFF')
{
$color = str_replace('#', '', $this->hex6($color));
$r = hexdec(substr($color, 0, 2));
$g = hexdec(substr($color, 2, 2));
$b = hexdec(substr($color, 4, 2));
$brightness = (($r * 299) + ($g * 587) + ($b * 114)) / 1000;
return ($brightness >= 155) ? $dark : $light;
}
|
php
|
public function getLightOrDark($color, $dark = '#000000', $light = '#FFFFFF')
{
$color = str_replace('#', '', $this->hex6($color));
$r = hexdec(substr($color, 0, 2));
$g = hexdec(substr($color, 2, 2));
$b = hexdec(substr($color, 4, 2));
$brightness = (($r * 299) + ($g * 587) + ($b * 114)) / 1000;
return ($brightness >= 155) ? $dark : $light;
}
|
[
"public",
"function",
"getLightOrDark",
"(",
"$",
"color",
",",
"$",
"dark",
"=",
"'#000000'",
",",
"$",
"light",
"=",
"'#FFFFFF'",
")",
"{",
"$",
"color",
"=",
"str_replace",
"(",
"'#'",
",",
"''",
",",
"$",
"this",
"->",
"hex6",
"(",
"$",
"color",
")",
")",
";",
"$",
"r",
"=",
"hexdec",
"(",
"substr",
"(",
"$",
"color",
",",
"0",
",",
"2",
")",
")",
";",
"$",
"g",
"=",
"hexdec",
"(",
"substr",
"(",
"$",
"color",
",",
"2",
",",
"2",
")",
")",
";",
"$",
"b",
"=",
"hexdec",
"(",
"substr",
"(",
"$",
"color",
",",
"4",
",",
"2",
")",
")",
";",
"$",
"brightness",
"=",
"(",
"(",
"$",
"r",
"*",
"299",
")",
"+",
"(",
"$",
"g",
"*",
"587",
")",
"+",
"(",
"$",
"b",
"*",
"114",
")",
")",
"/",
"1000",
";",
"return",
"(",
"$",
"brightness",
">=",
"155",
")",
"?",
"$",
"dark",
":",
"$",
"light",
";",
"}"
] |
Get a light or dark color based on the contrast required for a good readability
@param string $color
@param string $dark
@param string $light
@return string
|
[
"Get",
"a",
"light",
"or",
"dark",
"color",
"based",
"on",
"the",
"contrast",
"required",
"for",
"a",
"good",
"readability"
] |
e0c1200792af8e6cea916e1999c73cf8408c6dd2
|
https://github.com/lekoala/silverstripe-form-extras/blob/e0c1200792af8e6cea916e1999c73cf8408c6dd2/code/fieldtypes/DBColor.php#L62-L73
|
229,068
|
lekoala/silverstripe-form-extras
|
code/fieldtypes/DBColor.php
|
DBColor.toRgbArray
|
public function toRgbArray()
{
$hex = str_replace("#", "", $this->getValue());
if (strlen($hex) == 3) {
$r = hexdec(substr($hex, 0, 1).substr($hex, 0, 1));
$g = hexdec(substr($hex, 1, 1).substr($hex, 1, 1));
$b = hexdec(substr($hex, 2, 1).substr($hex, 2, 1));
} else {
$r = hexdec(substr($hex, 0, 2));
$g = hexdec(substr($hex, 2, 2));
$b = hexdec(substr($hex, 4, 2));
}
$rgb = array($r, $g, $b);
return $rgb;
}
|
php
|
public function toRgbArray()
{
$hex = str_replace("#", "", $this->getValue());
if (strlen($hex) == 3) {
$r = hexdec(substr($hex, 0, 1).substr($hex, 0, 1));
$g = hexdec(substr($hex, 1, 1).substr($hex, 1, 1));
$b = hexdec(substr($hex, 2, 1).substr($hex, 2, 1));
} else {
$r = hexdec(substr($hex, 0, 2));
$g = hexdec(substr($hex, 2, 2));
$b = hexdec(substr($hex, 4, 2));
}
$rgb = array($r, $g, $b);
return $rgb;
}
|
[
"public",
"function",
"toRgbArray",
"(",
")",
"{",
"$",
"hex",
"=",
"str_replace",
"(",
"\"#\"",
",",
"\"\"",
",",
"$",
"this",
"->",
"getValue",
"(",
")",
")",
";",
"if",
"(",
"strlen",
"(",
"$",
"hex",
")",
"==",
"3",
")",
"{",
"$",
"r",
"=",
"hexdec",
"(",
"substr",
"(",
"$",
"hex",
",",
"0",
",",
"1",
")",
".",
"substr",
"(",
"$",
"hex",
",",
"0",
",",
"1",
")",
")",
";",
"$",
"g",
"=",
"hexdec",
"(",
"substr",
"(",
"$",
"hex",
",",
"1",
",",
"1",
")",
".",
"substr",
"(",
"$",
"hex",
",",
"1",
",",
"1",
")",
")",
";",
"$",
"b",
"=",
"hexdec",
"(",
"substr",
"(",
"$",
"hex",
",",
"2",
",",
"1",
")",
".",
"substr",
"(",
"$",
"hex",
",",
"2",
",",
"1",
")",
")",
";",
"}",
"else",
"{",
"$",
"r",
"=",
"hexdec",
"(",
"substr",
"(",
"$",
"hex",
",",
"0",
",",
"2",
")",
")",
";",
"$",
"g",
"=",
"hexdec",
"(",
"substr",
"(",
"$",
"hex",
",",
"2",
",",
"2",
")",
")",
";",
"$",
"b",
"=",
"hexdec",
"(",
"substr",
"(",
"$",
"hex",
",",
"4",
",",
"2",
")",
")",
";",
"}",
"$",
"rgb",
"=",
"array",
"(",
"$",
"r",
",",
"$",
"g",
",",
"$",
"b",
")",
";",
"return",
"$",
"rgb",
";",
"}"
] |
Get rgb value as array
@return array
|
[
"Get",
"rgb",
"value",
"as",
"array"
] |
e0c1200792af8e6cea916e1999c73cf8408c6dd2
|
https://github.com/lekoala/silverstripe-form-extras/blob/e0c1200792af8e6cea916e1999c73cf8408c6dd2/code/fieldtypes/DBColor.php#L80-L95
|
229,069
|
mjacobus/php-query-builder
|
lib/PO/QueryBuilder.php
|
QueryBuilder.update
|
public static function update($table = null)
{
$query = new Update();
if ($table) {
$query->table($table);
}
return $query;
}
|
php
|
public static function update($table = null)
{
$query = new Update();
if ($table) {
$query->table($table);
}
return $query;
}
|
[
"public",
"static",
"function",
"update",
"(",
"$",
"table",
"=",
"null",
")",
"{",
"$",
"query",
"=",
"new",
"Update",
"(",
")",
";",
"if",
"(",
"$",
"table",
")",
"{",
"$",
"query",
"->",
"table",
"(",
"$",
"table",
")",
";",
"}",
"return",
"$",
"query",
";",
"}"
] |
Factory Update Builder
@param string $table the table to update
@return Update
|
[
"Factory",
"Update",
"Builder"
] |
eb7a90ae3bc433659306807535b39f12ce4dfd9f
|
https://github.com/mjacobus/php-query-builder/blob/eb7a90ae3bc433659306807535b39f12ce4dfd9f/lib/PO/QueryBuilder.php#L36-L45
|
229,070
|
mjacobus/php-query-builder
|
lib/PO/QueryBuilder.php
|
QueryBuilder.insert
|
public static function insert($table = null)
{
$query = new Insert();
if ($table) {
$query->into($table);
}
return $query;
}
|
php
|
public static function insert($table = null)
{
$query = new Insert();
if ($table) {
$query->into($table);
}
return $query;
}
|
[
"public",
"static",
"function",
"insert",
"(",
"$",
"table",
"=",
"null",
")",
"{",
"$",
"query",
"=",
"new",
"Insert",
"(",
")",
";",
"if",
"(",
"$",
"table",
")",
"{",
"$",
"query",
"->",
"into",
"(",
"$",
"table",
")",
";",
"}",
"return",
"$",
"query",
";",
"}"
] |
Factory Insert Builder
@param string $table the table to update
@return Insert
|
[
"Factory",
"Insert",
"Builder"
] |
eb7a90ae3bc433659306807535b39f12ce4dfd9f
|
https://github.com/mjacobus/php-query-builder/blob/eb7a90ae3bc433659306807535b39f12ce4dfd9f/lib/PO/QueryBuilder.php#L53-L62
|
229,071
|
mbilbille/jpnforphp
|
src/JpnForPhp/Helper/Helper.php
|
Helper.split
|
public static function split($str, $length = 1, $yoon = false)
{
// First split the given string into single characters ; default and
// most common case.
$chrs = preg_split("//u", $str, 0, PREG_SPLIT_NO_EMPTY);
if($length === 1 && !$yoon) {
return $chrs;
}
// ... handle cases where length != 1
$str_length = count($chrs);
$concatChrs = array();
for ($i = 0, $j = -1, $k = -1; $i < $str_length; $i++) {
// With yoon set to TRUE, consider the base syllable and the yoon
// character as a single character.
$skip = false;
$k++;
if($yoon && preg_match(self::PREG_PATTERN_KANA_YOON, $chrs[$i])) {
$skip = true;
$k--;
}
if(!$skip && $k % $length === 0) {
$j++;
$concatChrs[$j] = $chrs[$i];
}
else {
$concatChrs[$j] .= $chrs[$i];
}
}
return $concatChrs;
}
|
php
|
public static function split($str, $length = 1, $yoon = false)
{
// First split the given string into single characters ; default and
// most common case.
$chrs = preg_split("//u", $str, 0, PREG_SPLIT_NO_EMPTY);
if($length === 1 && !$yoon) {
return $chrs;
}
// ... handle cases where length != 1
$str_length = count($chrs);
$concatChrs = array();
for ($i = 0, $j = -1, $k = -1; $i < $str_length; $i++) {
// With yoon set to TRUE, consider the base syllable and the yoon
// character as a single character.
$skip = false;
$k++;
if($yoon && preg_match(self::PREG_PATTERN_KANA_YOON, $chrs[$i])) {
$skip = true;
$k--;
}
if(!$skip && $k % $length === 0) {
$j++;
$concatChrs[$j] = $chrs[$i];
}
else {
$concatChrs[$j] .= $chrs[$i];
}
}
return $concatChrs;
}
|
[
"public",
"static",
"function",
"split",
"(",
"$",
"str",
",",
"$",
"length",
"=",
"1",
",",
"$",
"yoon",
"=",
"false",
")",
"{",
"// First split the given string into single characters ; default and",
"// most common case.",
"$",
"chrs",
"=",
"preg_split",
"(",
"\"//u\"",
",",
"$",
"str",
",",
"0",
",",
"PREG_SPLIT_NO_EMPTY",
")",
";",
"if",
"(",
"$",
"length",
"===",
"1",
"&&",
"!",
"$",
"yoon",
")",
"{",
"return",
"$",
"chrs",
";",
"}",
"// ... handle cases where length != 1",
"$",
"str_length",
"=",
"count",
"(",
"$",
"chrs",
")",
";",
"$",
"concatChrs",
"=",
"array",
"(",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
",",
"$",
"j",
"=",
"-",
"1",
",",
"$",
"k",
"=",
"-",
"1",
";",
"$",
"i",
"<",
"$",
"str_length",
";",
"$",
"i",
"++",
")",
"{",
"// With yoon set to TRUE, consider the base syllable and the yoon",
"// character as a single character.",
"$",
"skip",
"=",
"false",
";",
"$",
"k",
"++",
";",
"if",
"(",
"$",
"yoon",
"&&",
"preg_match",
"(",
"self",
"::",
"PREG_PATTERN_KANA_YOON",
",",
"$",
"chrs",
"[",
"$",
"i",
"]",
")",
")",
"{",
"$",
"skip",
"=",
"true",
";",
"$",
"k",
"--",
";",
"}",
"if",
"(",
"!",
"$",
"skip",
"&&",
"$",
"k",
"%",
"$",
"length",
"===",
"0",
")",
"{",
"$",
"j",
"++",
";",
"$",
"concatChrs",
"[",
"$",
"j",
"]",
"=",
"$",
"chrs",
"[",
"$",
"i",
"]",
";",
"}",
"else",
"{",
"$",
"concatChrs",
"[",
"$",
"j",
"]",
".=",
"$",
"chrs",
"[",
"$",
"i",
"]",
";",
"}",
"}",
"return",
"$",
"concatChrs",
";",
"}"
] |
Enhance default splitter function to handle UTF-8 characters.
@param string $str The string to split.
@param integer $length (optional) Define an optional substring length.
Default to 1.
@param boolean $yoon (optional) Whether considering the base syllable and
the following yoon character as a single character or not
Default to false.
@return array An array of strings.
|
[
"Enhance",
"default",
"splitter",
"function",
"to",
"handle",
"UTF",
"-",
"8",
"characters",
"."
] |
5623468503cc2941f4656b0ee1a58b939d263453
|
https://github.com/mbilbille/jpnforphp/blob/5623468503cc2941f4656b0ee1a58b939d263453/src/JpnForPhp/Helper/Helper.php#L50-L83
|
229,072
|
mbilbille/jpnforphp
|
src/JpnForPhp/Helper/Helper.php
|
Helper.extractKanji
|
public static function extractKanji($str, $length = 0)
{
// No length given, extract kanji substrings as it is.
if(!$length) {
return preg_split(self::PREG_PATTERN_NOT_KANJI, $str, 0, PREG_SPLIT_NO_EMPTY);
}
// Otherwise...
// remove any non kanji characters and split the remaining string as per
// the given length
$str = preg_replace(self::PREG_PATTERN_NOT_KANJI, "", $str);
return self::split($str, $length);
}
|
php
|
public static function extractKanji($str, $length = 0)
{
// No length given, extract kanji substrings as it is.
if(!$length) {
return preg_split(self::PREG_PATTERN_NOT_KANJI, $str, 0, PREG_SPLIT_NO_EMPTY);
}
// Otherwise...
// remove any non kanji characters and split the remaining string as per
// the given length
$str = preg_replace(self::PREG_PATTERN_NOT_KANJI, "", $str);
return self::split($str, $length);
}
|
[
"public",
"static",
"function",
"extractKanji",
"(",
"$",
"str",
",",
"$",
"length",
"=",
"0",
")",
"{",
"// No length given, extract kanji substrings as it is.",
"if",
"(",
"!",
"$",
"length",
")",
"{",
"return",
"preg_split",
"(",
"self",
"::",
"PREG_PATTERN_NOT_KANJI",
",",
"$",
"str",
",",
"0",
",",
"PREG_SPLIT_NO_EMPTY",
")",
";",
"}",
"// Otherwise...",
"// remove any non kanji characters and split the remaining string as per",
"// the given length",
"$",
"str",
"=",
"preg_replace",
"(",
"self",
"::",
"PREG_PATTERN_NOT_KANJI",
",",
"\"\"",
",",
"$",
"str",
")",
";",
"return",
"self",
"::",
"split",
"(",
"$",
"str",
",",
"$",
"length",
")",
";",
"}"
] |
Split a given string to extract kanji substrings.
@param string $str The input string.
@param integer $length (optional) Define an optional substring length.
Default to 0 which means substrings will be returned as it is.
@return array An array of kanji substrings.
|
[
"Split",
"a",
"given",
"string",
"to",
"extract",
"kanji",
"substrings",
"."
] |
5623468503cc2941f4656b0ee1a58b939d263453
|
https://github.com/mbilbille/jpnforphp/blob/5623468503cc2941f4656b0ee1a58b939d263453/src/JpnForPhp/Helper/Helper.php#L142-L154
|
229,073
|
mbilbille/jpnforphp
|
src/JpnForPhp/Helper/Helper.php
|
Helper.extractHiragana
|
public static function extractHiragana($str, $length = 0, $yoon = false)
{
// No length given, extract hiragana substrings as it is.
if(!$length) {
return preg_split(self::PREG_PATTERN_NOT_HIRAGANA, $str, 0, PREG_SPLIT_NO_EMPTY);
}
// Otherwise...
// remove any non hiragana characters and split the remaining string as per
// the given length
$str = preg_replace(self::PREG_PATTERN_NOT_HIRAGANA, "", $str);
return self::split($str, $length, $yoon);
}
|
php
|
public static function extractHiragana($str, $length = 0, $yoon = false)
{
// No length given, extract hiragana substrings as it is.
if(!$length) {
return preg_split(self::PREG_PATTERN_NOT_HIRAGANA, $str, 0, PREG_SPLIT_NO_EMPTY);
}
// Otherwise...
// remove any non hiragana characters and split the remaining string as per
// the given length
$str = preg_replace(self::PREG_PATTERN_NOT_HIRAGANA, "", $str);
return self::split($str, $length, $yoon);
}
|
[
"public",
"static",
"function",
"extractHiragana",
"(",
"$",
"str",
",",
"$",
"length",
"=",
"0",
",",
"$",
"yoon",
"=",
"false",
")",
"{",
"// No length given, extract hiragana substrings as it is.",
"if",
"(",
"!",
"$",
"length",
")",
"{",
"return",
"preg_split",
"(",
"self",
"::",
"PREG_PATTERN_NOT_HIRAGANA",
",",
"$",
"str",
",",
"0",
",",
"PREG_SPLIT_NO_EMPTY",
")",
";",
"}",
"// Otherwise...",
"// remove any non hiragana characters and split the remaining string as per",
"// the given length",
"$",
"str",
"=",
"preg_replace",
"(",
"self",
"::",
"PREG_PATTERN_NOT_HIRAGANA",
",",
"\"\"",
",",
"$",
"str",
")",
";",
"return",
"self",
"::",
"split",
"(",
"$",
"str",
",",
"$",
"length",
",",
"$",
"yoon",
")",
";",
"}"
] |
Split a given string to extract hiragana substrings.
@param string $str The input string.
@param integer $length (optional) Define an optional substring length.
Default to 0 which means substrings will be returned as it is.
@param boolean $yoon (optional) Whether considering the base syllable and
the following yoon character as a single character or not
Default to false.
@return array An array of hiragana substrings.
|
[
"Split",
"a",
"given",
"string",
"to",
"extract",
"hiragana",
"substrings",
"."
] |
5623468503cc2941f4656b0ee1a58b939d263453
|
https://github.com/mbilbille/jpnforphp/blob/5623468503cc2941f4656b0ee1a58b939d263453/src/JpnForPhp/Helper/Helper.php#L168-L180
|
229,074
|
mbilbille/jpnforphp
|
src/JpnForPhp/Helper/Helper.php
|
Helper.extractKatakana
|
public static function extractKatakana($str, $length = 0, $yoon = false)
{
// No length given, extract katakana substrings as it is.
if(!$length) {
return preg_split(self::PREG_PATTERN_NOT_KATAKANA, $str, 0, PREG_SPLIT_NO_EMPTY);
}
// Otherwise...
// remove any non katakana characters and split the remaining string as per
// the given length
$str = preg_replace(self::PREG_PATTERN_NOT_KATAKANA, "", $str);
return self::split($str, $length, $yoon);
}
|
php
|
public static function extractKatakana($str, $length = 0, $yoon = false)
{
// No length given, extract katakana substrings as it is.
if(!$length) {
return preg_split(self::PREG_PATTERN_NOT_KATAKANA, $str, 0, PREG_SPLIT_NO_EMPTY);
}
// Otherwise...
// remove any non katakana characters and split the remaining string as per
// the given length
$str = preg_replace(self::PREG_PATTERN_NOT_KATAKANA, "", $str);
return self::split($str, $length, $yoon);
}
|
[
"public",
"static",
"function",
"extractKatakana",
"(",
"$",
"str",
",",
"$",
"length",
"=",
"0",
",",
"$",
"yoon",
"=",
"false",
")",
"{",
"// No length given, extract katakana substrings as it is.",
"if",
"(",
"!",
"$",
"length",
")",
"{",
"return",
"preg_split",
"(",
"self",
"::",
"PREG_PATTERN_NOT_KATAKANA",
",",
"$",
"str",
",",
"0",
",",
"PREG_SPLIT_NO_EMPTY",
")",
";",
"}",
"// Otherwise...",
"// remove any non katakana characters and split the remaining string as per",
"// the given length",
"$",
"str",
"=",
"preg_replace",
"(",
"self",
"::",
"PREG_PATTERN_NOT_KATAKANA",
",",
"\"\"",
",",
"$",
"str",
")",
";",
"return",
"self",
"::",
"split",
"(",
"$",
"str",
",",
"$",
"length",
",",
"$",
"yoon",
")",
";",
"}"
] |
Split a given string to extract katakana substrings.
@param string $str The input string.
@param integer $length (optional) Define an optional substring length.
Default to 0 which means substrings will be returned as it is.
@param boolean $yoon (optional) Whether considering the base syllable and
the following yoon character as a single character or not
Default to false.
@return array An array of katakana substrings.
|
[
"Split",
"a",
"given",
"string",
"to",
"extract",
"katakana",
"substrings",
"."
] |
5623468503cc2941f4656b0ee1a58b939d263453
|
https://github.com/mbilbille/jpnforphp/blob/5623468503cc2941f4656b0ee1a58b939d263453/src/JpnForPhp/Helper/Helper.php#L194-L206
|
229,075
|
mbilbille/jpnforphp
|
src/JpnForPhp/Helper/Helper.php
|
Helper.extractKana
|
public static function extractKana($str, $length = 0, $yoon = false)
{
// No length given, extract kana substrings as it is.
if(!$length) {
return preg_split(self::PREG_PATTERN_NOT_KANA, $str, 0, PREG_SPLIT_NO_EMPTY);
}
// Otherwise...
// remove any non kana characters and split the remaining string as per
// the given length
$str = preg_replace(self::PREG_PATTERN_NOT_KANA, "", $str);
return self::split($str, $length, $yoon);
}
|
php
|
public static function extractKana($str, $length = 0, $yoon = false)
{
// No length given, extract kana substrings as it is.
if(!$length) {
return preg_split(self::PREG_PATTERN_NOT_KANA, $str, 0, PREG_SPLIT_NO_EMPTY);
}
// Otherwise...
// remove any non kana characters and split the remaining string as per
// the given length
$str = preg_replace(self::PREG_PATTERN_NOT_KANA, "", $str);
return self::split($str, $length, $yoon);
}
|
[
"public",
"static",
"function",
"extractKana",
"(",
"$",
"str",
",",
"$",
"length",
"=",
"0",
",",
"$",
"yoon",
"=",
"false",
")",
"{",
"// No length given, extract kana substrings as it is.",
"if",
"(",
"!",
"$",
"length",
")",
"{",
"return",
"preg_split",
"(",
"self",
"::",
"PREG_PATTERN_NOT_KANA",
",",
"$",
"str",
",",
"0",
",",
"PREG_SPLIT_NO_EMPTY",
")",
";",
"}",
"// Otherwise...",
"// remove any non kana characters and split the remaining string as per",
"// the given length",
"$",
"str",
"=",
"preg_replace",
"(",
"self",
"::",
"PREG_PATTERN_NOT_KANA",
",",
"\"\"",
",",
"$",
"str",
")",
";",
"return",
"self",
"::",
"split",
"(",
"$",
"str",
",",
"$",
"length",
",",
"$",
"yoon",
")",
";",
"}"
] |
Split a given string to extract kana substrings.
@param string $str The input string.
@param integer $length (optional) Define an optional substring length.
Default to 0 which means substrings will be returned as it is.
@param boolean $yoon (optional) Whether considering the base syllable and
the following yoon character as a single character or not
Default to false.
@return array An array of kana substrings.
|
[
"Split",
"a",
"given",
"string",
"to",
"extract",
"kana",
"substrings",
"."
] |
5623468503cc2941f4656b0ee1a58b939d263453
|
https://github.com/mbilbille/jpnforphp/blob/5623468503cc2941f4656b0ee1a58b939d263453/src/JpnForPhp/Helper/Helper.php#L220-L232
|
229,076
|
mbilbille/jpnforphp
|
src/JpnForPhp/Helper/Helper.php
|
Helper.removeMacrons
|
public static function removeMacrons($str)
{
if ( !preg_match('/[\x80-\xff]/', $str) ) {
return $str;
}
$chars = array(
// Some romanization system may use circumflex accent rather than macron
chr(195).chr(130) => 'A', chr(195).chr(162) => 'a',
chr(195).chr(142) => 'I', chr(195).chr(174) => 'i',
chr(195).chr(155) => 'U', chr(195).chr(187) => 'u',
chr(195).chr(138) => 'E', chr(195).chr(170) => 'e',
chr(195).chr(148) => 'O', chr(195).chr(180) => 'o',
// Macrons
chr(196).chr(128) => 'A', chr(196).chr(129) => 'a',
chr(196).chr(170) => 'I', chr(196).chr(171) => 'i',
chr(197).chr(170) => 'U', chr(197).chr(171) => 'u',
chr(196).chr(146) => 'E', chr(196).chr(147) => 'e',
chr(197).chr(140) => 'O', chr(197).chr(141) => 'o',
);
return strtr($str, $chars);
}
|
php
|
public static function removeMacrons($str)
{
if ( !preg_match('/[\x80-\xff]/', $str) ) {
return $str;
}
$chars = array(
// Some romanization system may use circumflex accent rather than macron
chr(195).chr(130) => 'A', chr(195).chr(162) => 'a',
chr(195).chr(142) => 'I', chr(195).chr(174) => 'i',
chr(195).chr(155) => 'U', chr(195).chr(187) => 'u',
chr(195).chr(138) => 'E', chr(195).chr(170) => 'e',
chr(195).chr(148) => 'O', chr(195).chr(180) => 'o',
// Macrons
chr(196).chr(128) => 'A', chr(196).chr(129) => 'a',
chr(196).chr(170) => 'I', chr(196).chr(171) => 'i',
chr(197).chr(170) => 'U', chr(197).chr(171) => 'u',
chr(196).chr(146) => 'E', chr(196).chr(147) => 'e',
chr(197).chr(140) => 'O', chr(197).chr(141) => 'o',
);
return strtr($str, $chars);
}
|
[
"public",
"static",
"function",
"removeMacrons",
"(",
"$",
"str",
")",
"{",
"if",
"(",
"!",
"preg_match",
"(",
"'/[\\x80-\\xff]/'",
",",
"$",
"str",
")",
")",
"{",
"return",
"$",
"str",
";",
"}",
"$",
"chars",
"=",
"array",
"(",
"// Some romanization system may use circumflex accent rather than macron",
"chr",
"(",
"195",
")",
".",
"chr",
"(",
"130",
")",
"=>",
"'A'",
",",
"chr",
"(",
"195",
")",
".",
"chr",
"(",
"162",
")",
"=>",
"'a'",
",",
"chr",
"(",
"195",
")",
".",
"chr",
"(",
"142",
")",
"=>",
"'I'",
",",
"chr",
"(",
"195",
")",
".",
"chr",
"(",
"174",
")",
"=>",
"'i'",
",",
"chr",
"(",
"195",
")",
".",
"chr",
"(",
"155",
")",
"=>",
"'U'",
",",
"chr",
"(",
"195",
")",
".",
"chr",
"(",
"187",
")",
"=>",
"'u'",
",",
"chr",
"(",
"195",
")",
".",
"chr",
"(",
"138",
")",
"=>",
"'E'",
",",
"chr",
"(",
"195",
")",
".",
"chr",
"(",
"170",
")",
"=>",
"'e'",
",",
"chr",
"(",
"195",
")",
".",
"chr",
"(",
"148",
")",
"=>",
"'O'",
",",
"chr",
"(",
"195",
")",
".",
"chr",
"(",
"180",
")",
"=>",
"'o'",
",",
"// Macrons",
"chr",
"(",
"196",
")",
".",
"chr",
"(",
"128",
")",
"=>",
"'A'",
",",
"chr",
"(",
"196",
")",
".",
"chr",
"(",
"129",
")",
"=>",
"'a'",
",",
"chr",
"(",
"196",
")",
".",
"chr",
"(",
"170",
")",
"=>",
"'I'",
",",
"chr",
"(",
"196",
")",
".",
"chr",
"(",
"171",
")",
"=>",
"'i'",
",",
"chr",
"(",
"197",
")",
".",
"chr",
"(",
"170",
")",
"=>",
"'U'",
",",
"chr",
"(",
"197",
")",
".",
"chr",
"(",
"171",
")",
"=>",
"'u'",
",",
"chr",
"(",
"196",
")",
".",
"chr",
"(",
"146",
")",
"=>",
"'E'",
",",
"chr",
"(",
"196",
")",
".",
"chr",
"(",
"147",
")",
"=>",
"'e'",
",",
"chr",
"(",
"197",
")",
".",
"chr",
"(",
"140",
")",
"=>",
"'O'",
",",
"chr",
"(",
"197",
")",
".",
"chr",
"(",
"141",
")",
"=>",
"'o'",
",",
")",
";",
"return",
"strtr",
"(",
"$",
"str",
",",
"$",
"chars",
")",
";",
"}"
] |
Remove macrons from the specified string.
Based on Wordpress remove_accents().
@param string $str The input string.
@return string Cleaned string.
|
[
"Remove",
"macrons",
"from",
"the",
"specified",
"string",
"."
] |
5623468503cc2941f4656b0ee1a58b939d263453
|
https://github.com/mbilbille/jpnforphp/blob/5623468503cc2941f4656b0ee1a58b939d263453/src/JpnForPhp/Helper/Helper.php#L254-L276
|
229,077
|
Josantonius/PHP-ErrorHandler
|
src/ErrorHandler.php
|
ErrorHandler.getErrorType
|
public function getErrorType($code)
{
switch ($code) {
case E_ERROR:
return self::$stack['type'] = 'Error'; // 1
case E_WARNING:
return self::$stack['type'] = 'Warning'; // 2
case E_PARSE:
return self::$stack['type'] = 'Parse'; // 4
case E_NOTICE:
return self::$stack['type'] = 'Notice'; // 8
case E_CORE_ERROR:
return self::$stack['type'] = 'Core-Error'; // 16
case E_CORE_WARNING:
return self::$stack['type'] = 'Core Warning'; // 32
case E_COMPILE_ERROR:
return self::$stack['type'] = 'Compile Error'; // 64
case E_COMPILE_WARNING:
return self::$stack['type'] = 'Compile Warning'; // 128
case E_USER_ERROR:
return self::$stack['type'] = 'User Error'; // 256
case E_USER_WARNING:
return self::$stack['type'] = 'User Warning'; // 512
case E_USER_NOTICE:
return self::$stack['type'] = 'User Notice'; // 1024
case E_STRICT:
return self::$stack['type'] = 'Strict'; // 2048
case E_RECOVERABLE_ERROR:
return self::$stack['type'] = 'Recoverable Error'; // 4096
case E_DEPRECATED:
return self::$stack['type'] = 'Deprecated'; // 8192
case E_USER_DEPRECATED:
return self::$stack['type'] = 'User Deprecated'; // 16384
default:
return self::$stack['type'] = 'Error';
}
}
|
php
|
public function getErrorType($code)
{
switch ($code) {
case E_ERROR:
return self::$stack['type'] = 'Error'; // 1
case E_WARNING:
return self::$stack['type'] = 'Warning'; // 2
case E_PARSE:
return self::$stack['type'] = 'Parse'; // 4
case E_NOTICE:
return self::$stack['type'] = 'Notice'; // 8
case E_CORE_ERROR:
return self::$stack['type'] = 'Core-Error'; // 16
case E_CORE_WARNING:
return self::$stack['type'] = 'Core Warning'; // 32
case E_COMPILE_ERROR:
return self::$stack['type'] = 'Compile Error'; // 64
case E_COMPILE_WARNING:
return self::$stack['type'] = 'Compile Warning'; // 128
case E_USER_ERROR:
return self::$stack['type'] = 'User Error'; // 256
case E_USER_WARNING:
return self::$stack['type'] = 'User Warning'; // 512
case E_USER_NOTICE:
return self::$stack['type'] = 'User Notice'; // 1024
case E_STRICT:
return self::$stack['type'] = 'Strict'; // 2048
case E_RECOVERABLE_ERROR:
return self::$stack['type'] = 'Recoverable Error'; // 4096
case E_DEPRECATED:
return self::$stack['type'] = 'Deprecated'; // 8192
case E_USER_DEPRECATED:
return self::$stack['type'] = 'User Deprecated'; // 16384
default:
return self::$stack['type'] = 'Error';
}
}
|
[
"public",
"function",
"getErrorType",
"(",
"$",
"code",
")",
"{",
"switch",
"(",
"$",
"code",
")",
"{",
"case",
"E_ERROR",
":",
"return",
"self",
"::",
"$",
"stack",
"[",
"'type'",
"]",
"=",
"'Error'",
";",
"// 1",
"case",
"E_WARNING",
":",
"return",
"self",
"::",
"$",
"stack",
"[",
"'type'",
"]",
"=",
"'Warning'",
";",
"// 2",
"case",
"E_PARSE",
":",
"return",
"self",
"::",
"$",
"stack",
"[",
"'type'",
"]",
"=",
"'Parse'",
";",
"// 4",
"case",
"E_NOTICE",
":",
"return",
"self",
"::",
"$",
"stack",
"[",
"'type'",
"]",
"=",
"'Notice'",
";",
"// 8",
"case",
"E_CORE_ERROR",
":",
"return",
"self",
"::",
"$",
"stack",
"[",
"'type'",
"]",
"=",
"'Core-Error'",
";",
"// 16",
"case",
"E_CORE_WARNING",
":",
"return",
"self",
"::",
"$",
"stack",
"[",
"'type'",
"]",
"=",
"'Core Warning'",
";",
"// 32",
"case",
"E_COMPILE_ERROR",
":",
"return",
"self",
"::",
"$",
"stack",
"[",
"'type'",
"]",
"=",
"'Compile Error'",
";",
"// 64",
"case",
"E_COMPILE_WARNING",
":",
"return",
"self",
"::",
"$",
"stack",
"[",
"'type'",
"]",
"=",
"'Compile Warning'",
";",
"// 128",
"case",
"E_USER_ERROR",
":",
"return",
"self",
"::",
"$",
"stack",
"[",
"'type'",
"]",
"=",
"'User Error'",
";",
"// 256",
"case",
"E_USER_WARNING",
":",
"return",
"self",
"::",
"$",
"stack",
"[",
"'type'",
"]",
"=",
"'User Warning'",
";",
"// 512",
"case",
"E_USER_NOTICE",
":",
"return",
"self",
"::",
"$",
"stack",
"[",
"'type'",
"]",
"=",
"'User Notice'",
";",
"// 1024",
"case",
"E_STRICT",
":",
"return",
"self",
"::",
"$",
"stack",
"[",
"'type'",
"]",
"=",
"'Strict'",
";",
"// 2048",
"case",
"E_RECOVERABLE_ERROR",
":",
"return",
"self",
"::",
"$",
"stack",
"[",
"'type'",
"]",
"=",
"'Recoverable Error'",
";",
"// 4096",
"case",
"E_DEPRECATED",
":",
"return",
"self",
"::",
"$",
"stack",
"[",
"'type'",
"]",
"=",
"'Deprecated'",
";",
"// 8192",
"case",
"E_USER_DEPRECATED",
":",
"return",
"self",
"::",
"$",
"stack",
"[",
"'type'",
"]",
"=",
"'User Deprecated'",
";",
"// 16384",
"default",
":",
"return",
"self",
"::",
"$",
"stack",
"[",
"'type'",
"]",
"=",
"'Error'",
";",
"}",
"}"
] |
Convert error code to text.
@param int $code → error code
@return string → error type
|
[
"Convert",
"error",
"code",
"to",
"text",
"."
] |
99cfbff614e31968f602382b5f8346fb07b05729
|
https://github.com/Josantonius/PHP-ErrorHandler/blob/99cfbff614e31968f602382b5f8346fb07b05729/src/ErrorHandler.php#L115-L151
|
229,078
|
Josantonius/PHP-ErrorHandler
|
src/ErrorHandler.php
|
ErrorHandler.getPreviewCode
|
protected function getPreviewCode()
{
$file = file(self::$stack['file']);
$line = self::$stack['line'];
$start = ($line - 5 >= 0) ? $line - 5 : $line - 1;
$end = ($line - 5 >= 0) ? $line + 4 : $line + 8;
for ($i = $start; $i < $end; $i++) {
if (! isset($file[$i])) {
continue;
}
$text = trim($file[$i]);
if ($i == $line - 1) {
self::$stack['preview'] .=
"<span class='jst-line'>" . ($i + 1) . '</span>' .
"<span class='jst-mark text'>" . $text . '</span><br>';
continue;
}
self::$stack['preview'] .=
"<span class='jst-line'>" . ($i + 1) . '</span>' .
"<span class='text'>" . $text . '</span><br>';
}
}
|
php
|
protected function getPreviewCode()
{
$file = file(self::$stack['file']);
$line = self::$stack['line'];
$start = ($line - 5 >= 0) ? $line - 5 : $line - 1;
$end = ($line - 5 >= 0) ? $line + 4 : $line + 8;
for ($i = $start; $i < $end; $i++) {
if (! isset($file[$i])) {
continue;
}
$text = trim($file[$i]);
if ($i == $line - 1) {
self::$stack['preview'] .=
"<span class='jst-line'>" . ($i + 1) . '</span>' .
"<span class='jst-mark text'>" . $text . '</span><br>';
continue;
}
self::$stack['preview'] .=
"<span class='jst-line'>" . ($i + 1) . '</span>' .
"<span class='text'>" . $text . '</span><br>';
}
}
|
[
"protected",
"function",
"getPreviewCode",
"(",
")",
"{",
"$",
"file",
"=",
"file",
"(",
"self",
"::",
"$",
"stack",
"[",
"'file'",
"]",
")",
";",
"$",
"line",
"=",
"self",
"::",
"$",
"stack",
"[",
"'line'",
"]",
";",
"$",
"start",
"=",
"(",
"$",
"line",
"-",
"5",
">=",
"0",
")",
"?",
"$",
"line",
"-",
"5",
":",
"$",
"line",
"-",
"1",
";",
"$",
"end",
"=",
"(",
"$",
"line",
"-",
"5",
">=",
"0",
")",
"?",
"$",
"line",
"+",
"4",
":",
"$",
"line",
"+",
"8",
";",
"for",
"(",
"$",
"i",
"=",
"$",
"start",
";",
"$",
"i",
"<",
"$",
"end",
";",
"$",
"i",
"++",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"file",
"[",
"$",
"i",
"]",
")",
")",
"{",
"continue",
";",
"}",
"$",
"text",
"=",
"trim",
"(",
"$",
"file",
"[",
"$",
"i",
"]",
")",
";",
"if",
"(",
"$",
"i",
"==",
"$",
"line",
"-",
"1",
")",
"{",
"self",
"::",
"$",
"stack",
"[",
"'preview'",
"]",
".=",
"\"<span class='jst-line'>\"",
".",
"(",
"$",
"i",
"+",
"1",
")",
".",
"'</span>'",
".",
"\"<span class='jst-mark text'>\"",
".",
"$",
"text",
".",
"'</span><br>'",
";",
"continue",
";",
"}",
"self",
"::",
"$",
"stack",
"[",
"'preview'",
"]",
".=",
"\"<span class='jst-line'>\"",
".",
"(",
"$",
"i",
"+",
"1",
")",
".",
"'</span>'",
".",
"\"<span class='text'>\"",
".",
"$",
"text",
".",
"'</span><br>'",
";",
"}",
"}"
] |
Get preview of the error line.
@since 1.1.0
|
[
"Get",
"preview",
"of",
"the",
"error",
"line",
"."
] |
99cfbff614e31968f602382b5f8346fb07b05729
|
https://github.com/Josantonius/PHP-ErrorHandler/blob/99cfbff614e31968f602382b5f8346fb07b05729/src/ErrorHandler.php#L201-L227
|
229,079
|
Josantonius/PHP-ErrorHandler
|
src/ErrorHandler.php
|
ErrorHandler.getCustomMethods
|
protected function getCustomMethods()
{
$showDefaultView = true;
$params = [self::$stack];
unset($params[0]['trace'], $params[0]['preview']);
$count = count(self::$customMethods);
$customMethods = self::$customMethods;
for ($i = 0; $i < $count; $i++) {
$custom = $customMethods[$i];
$class = isset($custom[0]) ? $custom[0] : false;
$method = isset($custom[1]) ? $custom[1] : false;
$repeat = $custom[2];
$showDefault = $custom[3];
if ($showDefault === false) {
$showDefaultView = false;
}
if ($repeat === 0) {
unset(self::$customMethods[$i]);
} else {
self::$customMethods[$i] = [$class, $method, $repeat--];
}
call_user_func_array([$class, $method], $params);
}
self::$customMethods = false;
return $showDefaultView;
}
|
php
|
protected function getCustomMethods()
{
$showDefaultView = true;
$params = [self::$stack];
unset($params[0]['trace'], $params[0]['preview']);
$count = count(self::$customMethods);
$customMethods = self::$customMethods;
for ($i = 0; $i < $count; $i++) {
$custom = $customMethods[$i];
$class = isset($custom[0]) ? $custom[0] : false;
$method = isset($custom[1]) ? $custom[1] : false;
$repeat = $custom[2];
$showDefault = $custom[3];
if ($showDefault === false) {
$showDefaultView = false;
}
if ($repeat === 0) {
unset(self::$customMethods[$i]);
} else {
self::$customMethods[$i] = [$class, $method, $repeat--];
}
call_user_func_array([$class, $method], $params);
}
self::$customMethods = false;
return $showDefaultView;
}
|
[
"protected",
"function",
"getCustomMethods",
"(",
")",
"{",
"$",
"showDefaultView",
"=",
"true",
";",
"$",
"params",
"=",
"[",
"self",
"::",
"$",
"stack",
"]",
";",
"unset",
"(",
"$",
"params",
"[",
"0",
"]",
"[",
"'trace'",
"]",
",",
"$",
"params",
"[",
"0",
"]",
"[",
"'preview'",
"]",
")",
";",
"$",
"count",
"=",
"count",
"(",
"self",
"::",
"$",
"customMethods",
")",
";",
"$",
"customMethods",
"=",
"self",
"::",
"$",
"customMethods",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"count",
";",
"$",
"i",
"++",
")",
"{",
"$",
"custom",
"=",
"$",
"customMethods",
"[",
"$",
"i",
"]",
";",
"$",
"class",
"=",
"isset",
"(",
"$",
"custom",
"[",
"0",
"]",
")",
"?",
"$",
"custom",
"[",
"0",
"]",
":",
"false",
";",
"$",
"method",
"=",
"isset",
"(",
"$",
"custom",
"[",
"1",
"]",
")",
"?",
"$",
"custom",
"[",
"1",
"]",
":",
"false",
";",
"$",
"repeat",
"=",
"$",
"custom",
"[",
"2",
"]",
";",
"$",
"showDefault",
"=",
"$",
"custom",
"[",
"3",
"]",
";",
"if",
"(",
"$",
"showDefault",
"===",
"false",
")",
"{",
"$",
"showDefaultView",
"=",
"false",
";",
"}",
"if",
"(",
"$",
"repeat",
"===",
"0",
")",
"{",
"unset",
"(",
"self",
"::",
"$",
"customMethods",
"[",
"$",
"i",
"]",
")",
";",
"}",
"else",
"{",
"self",
"::",
"$",
"customMethods",
"[",
"$",
"i",
"]",
"=",
"[",
"$",
"class",
",",
"$",
"method",
",",
"$",
"repeat",
"--",
"]",
";",
"}",
"call_user_func_array",
"(",
"[",
"$",
"class",
",",
"$",
"method",
"]",
",",
"$",
"params",
")",
";",
"}",
"self",
"::",
"$",
"customMethods",
"=",
"false",
";",
"return",
"$",
"showDefaultView",
";",
"}"
] |
Get customs methods to renderizate.
@since 1.1.3
|
[
"Get",
"customs",
"methods",
"to",
"renderizate",
"."
] |
99cfbff614e31968f602382b5f8346fb07b05729
|
https://github.com/Josantonius/PHP-ErrorHandler/blob/99cfbff614e31968f602382b5f8346fb07b05729/src/ErrorHandler.php#L234-L267
|
229,080
|
slickframework/slick
|
src/Slick/Database/Query/Sql/Select.php
|
Select.first
|
public function first()
{
$limit = $this->_limit;
$offset = $this->_offset;
$this->limit(1);
$result = $this->all();
$this->_limit = $limit;
$this->_offset = $offset;
return is_bool($result) ? [] : reset($result);
}
|
php
|
public function first()
{
$limit = $this->_limit;
$offset = $this->_offset;
$this->limit(1);
$result = $this->all();
$this->_limit = $limit;
$this->_offset = $offset;
return is_bool($result) ? [] : reset($result);
}
|
[
"public",
"function",
"first",
"(",
")",
"{",
"$",
"limit",
"=",
"$",
"this",
"->",
"_limit",
";",
"$",
"offset",
"=",
"$",
"this",
"->",
"_offset",
";",
"$",
"this",
"->",
"limit",
"(",
"1",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"all",
"(",
")",
";",
"$",
"this",
"->",
"_limit",
"=",
"$",
"limit",
";",
"$",
"this",
"->",
"_offset",
"=",
"$",
"offset",
";",
"return",
"is_bool",
"(",
"$",
"result",
")",
"?",
"[",
"]",
":",
"reset",
"(",
"$",
"result",
")",
";",
"}"
] |
Retrieves the first row of a given select query
@return object The record or null.
|
[
"Retrieves",
"the",
"first",
"row",
"of",
"a",
"given",
"select",
"query"
] |
77f56b81020ce8c10f25f7d918661ccd9a918a37
|
https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Database/Query/Sql/Select.php#L94-L104
|
229,081
|
slickframework/slick
|
src/Slick/Database/Query/Sql/Select.php
|
Select.count
|
public function count()
{
$limit = $this->_limit;
$offset = $this->_offset;
$this->limit(0);
$joins = $this->getJoins();
$copyJoins = clone($joins);
$keys = array_keys($copyJoins->getArrayCopy());
foreach ($keys as $key) {
$joins[$key]['fields'] = array();
}
$this->_joins = $joins;
$fields = $this->_fields;
$this->_fields = array('COUNT(*) AS totalRows');
$prefix = $this->_prefixTableName;
$this->_prefixTableName = false;
$result = $this->all();
$this->_prefixTableName = $prefix;
$this->_fields = $fields;
$this->_joins = $copyJoins;
$this->_limit = $limit;
$this->_offset = $offset;
return (isset($result[0]['totalRows'])) ? $result[0]['totalRows'] : 0;
}
|
php
|
public function count()
{
$limit = $this->_limit;
$offset = $this->_offset;
$this->limit(0);
$joins = $this->getJoins();
$copyJoins = clone($joins);
$keys = array_keys($copyJoins->getArrayCopy());
foreach ($keys as $key) {
$joins[$key]['fields'] = array();
}
$this->_joins = $joins;
$fields = $this->_fields;
$this->_fields = array('COUNT(*) AS totalRows');
$prefix = $this->_prefixTableName;
$this->_prefixTableName = false;
$result = $this->all();
$this->_prefixTableName = $prefix;
$this->_fields = $fields;
$this->_joins = $copyJoins;
$this->_limit = $limit;
$this->_offset = $offset;
return (isset($result[0]['totalRows'])) ? $result[0]['totalRows'] : 0;
}
|
[
"public",
"function",
"count",
"(",
")",
"{",
"$",
"limit",
"=",
"$",
"this",
"->",
"_limit",
";",
"$",
"offset",
"=",
"$",
"this",
"->",
"_offset",
";",
"$",
"this",
"->",
"limit",
"(",
"0",
")",
";",
"$",
"joins",
"=",
"$",
"this",
"->",
"getJoins",
"(",
")",
";",
"$",
"copyJoins",
"=",
"clone",
"(",
"$",
"joins",
")",
";",
"$",
"keys",
"=",
"array_keys",
"(",
"$",
"copyJoins",
"->",
"getArrayCopy",
"(",
")",
")",
";",
"foreach",
"(",
"$",
"keys",
"as",
"$",
"key",
")",
"{",
"$",
"joins",
"[",
"$",
"key",
"]",
"[",
"'fields'",
"]",
"=",
"array",
"(",
")",
";",
"}",
"$",
"this",
"->",
"_joins",
"=",
"$",
"joins",
";",
"$",
"fields",
"=",
"$",
"this",
"->",
"_fields",
";",
"$",
"this",
"->",
"_fields",
"=",
"array",
"(",
"'COUNT(*) AS totalRows'",
")",
";",
"$",
"prefix",
"=",
"$",
"this",
"->",
"_prefixTableName",
";",
"$",
"this",
"->",
"_prefixTableName",
"=",
"false",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"all",
"(",
")",
";",
"$",
"this",
"->",
"_prefixTableName",
"=",
"$",
"prefix",
";",
"$",
"this",
"->",
"_fields",
"=",
"$",
"fields",
";",
"$",
"this",
"->",
"_joins",
"=",
"$",
"copyJoins",
";",
"$",
"this",
"->",
"_limit",
"=",
"$",
"limit",
";",
"$",
"this",
"->",
"_offset",
"=",
"$",
"offset",
";",
"return",
"(",
"isset",
"(",
"$",
"result",
"[",
"0",
"]",
"[",
"'totalRows'",
"]",
")",
")",
"?",
"$",
"result",
"[",
"0",
"]",
"[",
"'totalRows'",
"]",
":",
"0",
";",
"}"
] |
Count the rows for current where conditions
@return integer The total rows for current conditions
|
[
"Count",
"the",
"rows",
"for",
"current",
"where",
"conditions"
] |
77f56b81020ce8c10f25f7d918661ccd9a918a37
|
https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Database/Query/Sql/Select.php#L111-L140
|
229,082
|
slickframework/slick
|
src/Slick/Database/Query/Sql/Select.php
|
Select.join
|
public function join(
$table, $clause, array $fields = [], $type = self::JOIN_LEFT)
{
if (empty($fields)) {
$fields = array("*");
}
$this->getJoins()->append(
array(
'table' => $table,
'onClause' => $clause,
'fields' => $fields,
'type' => $type
)
);
return $this;
}
|
php
|
public function join(
$table, $clause, array $fields = [], $type = self::JOIN_LEFT)
{
if (empty($fields)) {
$fields = array("*");
}
$this->getJoins()->append(
array(
'table' => $table,
'onClause' => $clause,
'fields' => $fields,
'type' => $type
)
);
return $this;
}
|
[
"public",
"function",
"join",
"(",
"$",
"table",
",",
"$",
"clause",
",",
"array",
"$",
"fields",
"=",
"[",
"]",
",",
"$",
"type",
"=",
"self",
"::",
"JOIN_LEFT",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"fields",
")",
")",
"{",
"$",
"fields",
"=",
"array",
"(",
"\"*\"",
")",
";",
"}",
"$",
"this",
"->",
"getJoins",
"(",
")",
"->",
"append",
"(",
"array",
"(",
"'table'",
"=>",
"$",
"table",
",",
"'onClause'",
"=>",
"$",
"clause",
",",
"'fields'",
"=>",
"$",
"fields",
",",
"'type'",
"=>",
"$",
"type",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Adds a join table to the current select statement
@param string $table The join table name
@param string $clause The condition for the join
@param array $fields The fields list to retrieve
@param string $type The join type
@return \Slick\Database\Query\Sql\Select A self instance for method
call chains
|
[
"Adds",
"a",
"join",
"table",
"to",
"the",
"current",
"select",
"statement"
] |
77f56b81020ce8c10f25f7d918661ccd9a918a37
|
https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Database/Query/Sql/Select.php#L166-L181
|
229,083
|
slickframework/slick
|
src/Slick/Database/Query/Sql/Select.php
|
Select.limit
|
public function limit($total, $offset = 0)
{
$this->_limit = $total;
$this->_offset = $offset;
return $this;
}
|
php
|
public function limit($total, $offset = 0)
{
$this->_limit = $total;
$this->_offset = $offset;
return $this;
}
|
[
"public",
"function",
"limit",
"(",
"$",
"total",
",",
"$",
"offset",
"=",
"0",
")",
"{",
"$",
"this",
"->",
"_limit",
"=",
"$",
"total",
";",
"$",
"this",
"->",
"_offset",
"=",
"$",
"offset",
";",
"return",
"$",
"this",
";",
"}"
] |
Sets the limit and the offset for this query
@param integer $total The total rows to retrieve
@param integer $offset The starting point where to count rows
@return \Slick\Database\Query\Sql\Select A self instance for method
call chains
|
[
"Sets",
"the",
"limit",
"and",
"the",
"offset",
"for",
"this",
"query"
] |
77f56b81020ce8c10f25f7d918661ccd9a918a37
|
https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Database/Query/Sql/Select.php#L220-L225
|
229,084
|
slickframework/slick
|
src/Slick/Template/Engine/Twig.php
|
Twig.process
|
public function process($data = array())
{
try {
return $this->twig->render($this->_source, $data);
} catch (Twig_Error $exp) {
throw new Exception\ParserException(
"Error Processing Request: " . $exp->getMessage()
);
}
}
|
php
|
public function process($data = array())
{
try {
return $this->twig->render($this->_source, $data);
} catch (Twig_Error $exp) {
throw new Exception\ParserException(
"Error Processing Request: " . $exp->getMessage()
);
}
}
|
[
"public",
"function",
"process",
"(",
"$",
"data",
"=",
"array",
"(",
")",
")",
"{",
"try",
"{",
"return",
"$",
"this",
"->",
"twig",
"->",
"render",
"(",
"$",
"this",
"->",
"_source",
",",
"$",
"data",
")",
";",
"}",
"catch",
"(",
"Twig_Error",
"$",
"exp",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"ParserException",
"(",
"\"Error Processing Request: \"",
".",
"$",
"exp",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] |
Processes the template with data to produce the final output.
@param mixed $data The data that will be used to process the view.
@throws \Slick\Template\Exception\ParserException
@return string Returns processed output string.
|
[
"Processes",
"the",
"template",
"with",
"data",
"to",
"produce",
"the",
"final",
"output",
"."
] |
77f56b81020ce8c10f25f7d918661ccd9a918a37
|
https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Template/Engine/Twig.php#L73-L83
|
229,085
|
slickframework/slick
|
src/Slick/Template/Engine/Twig.php
|
Twig.getTwig
|
public function getTwig()
{
if (is_null($this->_twig)) {
$this->_twig = new Twig_Environment(
new Twig_Loader_Filesystem($this->_paths),
[
'debug' => true,
]
);
$this->_twig->addExtension(new Twig_Extension_Debug());
$this->_twig->addExtension(new SlickTwigExtension());
}
return $this->_twig;
}
|
php
|
public function getTwig()
{
if (is_null($this->_twig)) {
$this->_twig = new Twig_Environment(
new Twig_Loader_Filesystem($this->_paths),
[
'debug' => true,
]
);
$this->_twig->addExtension(new Twig_Extension_Debug());
$this->_twig->addExtension(new SlickTwigExtension());
}
return $this->_twig;
}
|
[
"public",
"function",
"getTwig",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"_twig",
")",
")",
"{",
"$",
"this",
"->",
"_twig",
"=",
"new",
"Twig_Environment",
"(",
"new",
"Twig_Loader_Filesystem",
"(",
"$",
"this",
"->",
"_paths",
")",
",",
"[",
"'debug'",
"=>",
"true",
",",
"]",
")",
";",
"$",
"this",
"->",
"_twig",
"->",
"addExtension",
"(",
"new",
"Twig_Extension_Debug",
"(",
")",
")",
";",
"$",
"this",
"->",
"_twig",
"->",
"addExtension",
"(",
"new",
"SlickTwigExtension",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_twig",
";",
"}"
] |
Lazy loading of twig library
@return Twig_Loader_Filesystem
|
[
"Lazy",
"loading",
"of",
"twig",
"library"
] |
77f56b81020ce8c10f25f7d918661ccd9a918a37
|
https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Template/Engine/Twig.php#L90-L103
|
229,086
|
mbilbille/jpnforphp
|
src/JpnForPhp/Inflector/Verb/AbstractVerb.php
|
AbstractVerb.getStem
|
public function getStem($transliterationForm, $verbalForm, $languageForm)
{
return ($transliterationForm === Inflector::KANJI_FORM) ? $this->stem[Inflector::KANJI_FORM] : $this->stem[Inflector::KANA_FORM];
}
|
php
|
public function getStem($transliterationForm, $verbalForm, $languageForm)
{
return ($transliterationForm === Inflector::KANJI_FORM) ? $this->stem[Inflector::KANJI_FORM] : $this->stem[Inflector::KANA_FORM];
}
|
[
"public",
"function",
"getStem",
"(",
"$",
"transliterationForm",
",",
"$",
"verbalForm",
",",
"$",
"languageForm",
")",
"{",
"return",
"(",
"$",
"transliterationForm",
"===",
"Inflector",
"::",
"KANJI_FORM",
")",
"?",
"$",
"this",
"->",
"stem",
"[",
"Inflector",
"::",
"KANJI_FORM",
"]",
":",
"$",
"this",
"->",
"stem",
"[",
"Inflector",
"::",
"KANA_FORM",
"]",
";",
"}"
] |
Basic `getStem` implementation which returns the kanji form otherwise the
kana form, no matter which verbal and language forms have been given.
|
[
"Basic",
"getStem",
"implementation",
"which",
"returns",
"the",
"kanji",
"form",
"otherwise",
"the",
"kana",
"form",
"no",
"matter",
"which",
"verbal",
"and",
"language",
"forms",
"have",
"been",
"given",
"."
] |
5623468503cc2941f4656b0ee1a58b939d263453
|
https://github.com/mbilbille/jpnforphp/blob/5623468503cc2941f4656b0ee1a58b939d263453/src/JpnForPhp/Inflector/Verb/AbstractVerb.php#L65-L68
|
229,087
|
mbilbille/jpnforphp
|
src/JpnForPhp/Inflector/Verb/AbstractVerb.php
|
AbstractVerb.getSuffix
|
public function getSuffix($verbalForm, $languageForm)
{
return isset($this->suffixMap[$verbalForm]) && isset($this->suffixMap[$verbalForm][$languageForm]) ?
$this->suffixMap[$verbalForm][$languageForm] : null;
}
|
php
|
public function getSuffix($verbalForm, $languageForm)
{
return isset($this->suffixMap[$verbalForm]) && isset($this->suffixMap[$verbalForm][$languageForm]) ?
$this->suffixMap[$verbalForm][$languageForm] : null;
}
|
[
"public",
"function",
"getSuffix",
"(",
"$",
"verbalForm",
",",
"$",
"languageForm",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"suffixMap",
"[",
"$",
"verbalForm",
"]",
")",
"&&",
"isset",
"(",
"$",
"this",
"->",
"suffixMap",
"[",
"$",
"verbalForm",
"]",
"[",
"$",
"languageForm",
"]",
")",
"?",
"$",
"this",
"->",
"suffixMap",
"[",
"$",
"verbalForm",
"]",
"[",
"$",
"languageForm",
"]",
":",
"null",
";",
"}"
] |
Get inflection suffix for a given verbal and language forms.
|
[
"Get",
"inflection",
"suffix",
"for",
"a",
"given",
"verbal",
"and",
"language",
"forms",
"."
] |
5623468503cc2941f4656b0ee1a58b939d263453
|
https://github.com/mbilbille/jpnforphp/blob/5623468503cc2941f4656b0ee1a58b939d263453/src/JpnForPhp/Inflector/Verb/AbstractVerb.php#L100-L104
|
229,088
|
lekoala/silverstripe-form-extras
|
code/fields/SimpleTinyMceField.php
|
SimpleTinyMceField.getFileManager
|
public function getFileManager()
{
if ($this->fileManager === null) {
if ($this->config()->file_manager_enabled_by_default) {
return true;
} else {
return false;
}
}
return $this->fileManager;
}
|
php
|
public function getFileManager()
{
if ($this->fileManager === null) {
if ($this->config()->file_manager_enabled_by_default) {
return true;
} else {
return false;
}
}
return $this->fileManager;
}
|
[
"public",
"function",
"getFileManager",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"fileManager",
"===",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"config",
"(",
")",
"->",
"file_manager_enabled_by_default",
")",
"{",
"return",
"true",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"fileManager",
";",
"}"
] |
Get the responsive file manager state
It can be enabled by default through the config
@return boolean
|
[
"Get",
"the",
"responsive",
"file",
"manager",
"state"
] |
e0c1200792af8e6cea916e1999c73cf8408c6dd2
|
https://github.com/lekoala/silverstripe-form-extras/blob/e0c1200792af8e6cea916e1999c73cf8408c6dd2/code/fields/SimpleTinyMceField.php#L48-L58
|
229,089
|
lekoala/silverstripe-form-extras
|
code/fields/SimpleTinyMceField.php
|
SimpleTinyMceField.setFileManager
|
public function setFileManager($fileManager = true)
{
if ($this->config()->prevent_file_manager) {
return false;
}
$this->fileManager = $fileManager;
return $fileManager;
}
|
php
|
public function setFileManager($fileManager = true)
{
if ($this->config()->prevent_file_manager) {
return false;
}
$this->fileManager = $fileManager;
return $fileManager;
}
|
[
"public",
"function",
"setFileManager",
"(",
"$",
"fileManager",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"config",
"(",
")",
"->",
"prevent_file_manager",
")",
"{",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"fileManager",
"=",
"$",
"fileManager",
";",
"return",
"$",
"fileManager",
";",
"}"
] |
Enable the responsive file manager for this tinymce instance
@param boolean $fileManager
@return boolean File manager enabled or not?
|
[
"Enable",
"the",
"responsive",
"file",
"manager",
"for",
"this",
"tinymce",
"instance"
] |
e0c1200792af8e6cea916e1999c73cf8408c6dd2
|
https://github.com/lekoala/silverstripe-form-extras/blob/e0c1200792af8e6cea916e1999c73cf8408c6dd2/code/fields/SimpleTinyMceField.php#L66-L73
|
229,090
|
Danzabar/phalcon-cli
|
src/Tasks/Utility/Help.php
|
Help.printApplicationDetails
|
public function printApplicationDetails()
{
$this->output->writeln($this->console->getName());
if (!is_null($this->console->getVersion())) {
$this->output->writeln('version '.$this->console->getVersion());
}
// New line padding
$this->output->writeln('');
}
|
php
|
public function printApplicationDetails()
{
$this->output->writeln($this->console->getName());
if (!is_null($this->console->getVersion())) {
$this->output->writeln('version '.$this->console->getVersion());
}
// New line padding
$this->output->writeln('');
}
|
[
"public",
"function",
"printApplicationDetails",
"(",
")",
"{",
"$",
"this",
"->",
"output",
"->",
"writeln",
"(",
"$",
"this",
"->",
"console",
"->",
"getName",
"(",
")",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"this",
"->",
"console",
"->",
"getVersion",
"(",
")",
")",
")",
"{",
"$",
"this",
"->",
"output",
"->",
"writeln",
"(",
"'version '",
".",
"$",
"this",
"->",
"console",
"->",
"getVersion",
"(",
")",
")",
";",
"}",
"// New line padding",
"$",
"this",
"->",
"output",
"->",
"writeln",
"(",
"''",
")",
";",
"}"
] |
Prints the app name and version
@return void
|
[
"Prints",
"the",
"app",
"name",
"and",
"version"
] |
0d6293d5d899158705f8e3a31886d176e595ee38
|
https://github.com/Danzabar/phalcon-cli/blob/0d6293d5d899158705f8e3a31886d176e595ee38/src/Tasks/Utility/Help.php#L53-L63
|
229,091
|
Danzabar/phalcon-cli
|
src/Tasks/Utility/Help.php
|
Help.listCommands
|
public function listCommands()
{
$commands = $this->library->getAll();
foreach ($commands as $name => $details) {
$this->output->writeln(ucwords($name));
$this->output->hr(strlen($details['description']), '-');
$this->output->writeln($details['description']);
$this->output->hr(strlen($details['description']), '-');
foreach ($details['actions'] as $action) {
$this->output->writeln(
sprintf(
"%s - php [file] %s%s [params]",
$action,
$name,
($action != 'main' ? ":$action" : '')
)
);
}
// Just for padding
$this->output->writeln('');
}
}
|
php
|
public function listCommands()
{
$commands = $this->library->getAll();
foreach ($commands as $name => $details) {
$this->output->writeln(ucwords($name));
$this->output->hr(strlen($details['description']), '-');
$this->output->writeln($details['description']);
$this->output->hr(strlen($details['description']), '-');
foreach ($details['actions'] as $action) {
$this->output->writeln(
sprintf(
"%s - php [file] %s%s [params]",
$action,
$name,
($action != 'main' ? ":$action" : '')
)
);
}
// Just for padding
$this->output->writeln('');
}
}
|
[
"public",
"function",
"listCommands",
"(",
")",
"{",
"$",
"commands",
"=",
"$",
"this",
"->",
"library",
"->",
"getAll",
"(",
")",
";",
"foreach",
"(",
"$",
"commands",
"as",
"$",
"name",
"=>",
"$",
"details",
")",
"{",
"$",
"this",
"->",
"output",
"->",
"writeln",
"(",
"ucwords",
"(",
"$",
"name",
")",
")",
";",
"$",
"this",
"->",
"output",
"->",
"hr",
"(",
"strlen",
"(",
"$",
"details",
"[",
"'description'",
"]",
")",
",",
"'-'",
")",
";",
"$",
"this",
"->",
"output",
"->",
"writeln",
"(",
"$",
"details",
"[",
"'description'",
"]",
")",
";",
"$",
"this",
"->",
"output",
"->",
"hr",
"(",
"strlen",
"(",
"$",
"details",
"[",
"'description'",
"]",
")",
",",
"'-'",
")",
";",
"foreach",
"(",
"$",
"details",
"[",
"'actions'",
"]",
"as",
"$",
"action",
")",
"{",
"$",
"this",
"->",
"output",
"->",
"writeln",
"(",
"sprintf",
"(",
"\"%s - php [file] %s%s [params]\"",
",",
"$",
"action",
",",
"$",
"name",
",",
"(",
"$",
"action",
"!=",
"'main'",
"?",
"\":$action\"",
":",
"''",
")",
")",
")",
";",
"}",
"// Just for padding",
"$",
"this",
"->",
"output",
"->",
"writeln",
"(",
"''",
")",
";",
"}",
"}"
] |
Lists out command names and descriptions
@return void
|
[
"Lists",
"out",
"command",
"names",
"and",
"descriptions"
] |
0d6293d5d899158705f8e3a31886d176e595ee38
|
https://github.com/Danzabar/phalcon-cli/blob/0d6293d5d899158705f8e3a31886d176e595ee38/src/Tasks/Utility/Help.php#L83-L107
|
229,092
|
slickframework/slick
|
src/Slick/FileSystem/FileSystemList.php
|
FileSystemList.current
|
public function current()
{
$fileInfo = parent::current();
if ($fileInfo->isDir()) {
return new Folder(array('name' => $fileInfo->getRealPath()));
}
return new File($fileInfo->getRealPath());
}
|
php
|
public function current()
{
$fileInfo = parent::current();
if ($fileInfo->isDir()) {
return new Folder(array('name' => $fileInfo->getRealPath()));
}
return new File($fileInfo->getRealPath());
}
|
[
"public",
"function",
"current",
"(",
")",
"{",
"$",
"fileInfo",
"=",
"parent",
"::",
"current",
"(",
")",
";",
"if",
"(",
"$",
"fileInfo",
"->",
"isDir",
"(",
")",
")",
"{",
"return",
"new",
"Folder",
"(",
"array",
"(",
"'name'",
"=>",
"$",
"fileInfo",
"->",
"getRealPath",
"(",
")",
")",
")",
";",
"}",
"return",
"new",
"File",
"(",
"$",
"fileInfo",
"->",
"getRealPath",
"(",
")",
")",
";",
"}"
] |
Returns current element
@return \Slick\FileSystem\Node A File or a Folder object.
|
[
"Returns",
"current",
"element"
] |
77f56b81020ce8c10f25f7d918661ccd9a918a37
|
https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/FileSystem/FileSystemList.php#L29-L36
|
229,093
|
slickframework/slick
|
src/Slick/Mvc/Model/Descriptor.php
|
Descriptor.getDisplayField
|
public function getDisplayField()
{
if (is_null($this->_displayField)) {
$properties = array_keys($this->getDescriptor()->getColumns());
foreach ($properties as $property) {
$name = trim($property, '_');
$pmk = $this->getDescriptor()->getEntity()->primaryKey;
if ($name == $pmk) {
continue;
}
$annotations = $this->getDescriptor()->getInspector()
->getPropertyAnnotations($property);
if ($annotations->hasAnnotation('@display')) {
$this->_displayField = $name;
break;
}
$this->_displayField = $name;
}
}
return $this->_displayField;
}
|
php
|
public function getDisplayField()
{
if (is_null($this->_displayField)) {
$properties = array_keys($this->getDescriptor()->getColumns());
foreach ($properties as $property) {
$name = trim($property, '_');
$pmk = $this->getDescriptor()->getEntity()->primaryKey;
if ($name == $pmk) {
continue;
}
$annotations = $this->getDescriptor()->getInspector()
->getPropertyAnnotations($property);
if ($annotations->hasAnnotation('@display')) {
$this->_displayField = $name;
break;
}
$this->_displayField = $name;
}
}
return $this->_displayField;
}
|
[
"public",
"function",
"getDisplayField",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"_displayField",
")",
")",
"{",
"$",
"properties",
"=",
"array_keys",
"(",
"$",
"this",
"->",
"getDescriptor",
"(",
")",
"->",
"getColumns",
"(",
")",
")",
";",
"foreach",
"(",
"$",
"properties",
"as",
"$",
"property",
")",
"{",
"$",
"name",
"=",
"trim",
"(",
"$",
"property",
",",
"'_'",
")",
";",
"$",
"pmk",
"=",
"$",
"this",
"->",
"getDescriptor",
"(",
")",
"->",
"getEntity",
"(",
")",
"->",
"primaryKey",
";",
"if",
"(",
"$",
"name",
"==",
"$",
"pmk",
")",
"{",
"continue",
";",
"}",
"$",
"annotations",
"=",
"$",
"this",
"->",
"getDescriptor",
"(",
")",
"->",
"getInspector",
"(",
")",
"->",
"getPropertyAnnotations",
"(",
"$",
"property",
")",
";",
"if",
"(",
"$",
"annotations",
"->",
"hasAnnotation",
"(",
"'@display'",
")",
")",
"{",
"$",
"this",
"->",
"_displayField",
"=",
"$",
"name",
";",
"break",
";",
"}",
"$",
"this",
"->",
"_displayField",
"=",
"$",
"name",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"_displayField",
";",
"}"
] |
Returns the display field name
The display field is used to print out the model instance name
when you request to print a model.
For example:
model as the id, name, address fields, if you print out model with
echo $model, it will use the name field to print it or other field
if you define $_displayField property.
@return string
|
[
"Returns",
"the",
"display",
"field",
"name"
] |
77f56b81020ce8c10f25f7d918661ccd9a918a37
|
https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Mvc/Model/Descriptor.php#L82-L105
|
229,094
|
slickframework/slick
|
src/Slick/Mvc/Model/Descriptor.php
|
Descriptor.modelPlural
|
public function modelPlural(RelationInterface $relation)
{
if (!isset($this->_modelPlural[$relation->getPropertyName()])) {
$parts = explode('\\', $relation->getRelatedEntity());
$name = Text::camelCaseToSeparator(end($parts), '#');
$name = explode('#', $name);
$final = ucfirst(Text::plural(strtolower(array_pop($name))));
$name[] = $final;
$modelName = '';
foreach ($name as $part) {
$modelName .= ucfirst($part);
}
$this->_modelPlural[$relation->getPropertyName()] =
lcfirst($modelName);
}
return $this->_modelPlural[$relation->getPropertyName()];
}
|
php
|
public function modelPlural(RelationInterface $relation)
{
if (!isset($this->_modelPlural[$relation->getPropertyName()])) {
$parts = explode('\\', $relation->getRelatedEntity());
$name = Text::camelCaseToSeparator(end($parts), '#');
$name = explode('#', $name);
$final = ucfirst(Text::plural(strtolower(array_pop($name))));
$name[] = $final;
$modelName = '';
foreach ($name as $part) {
$modelName .= ucfirst($part);
}
$this->_modelPlural[$relation->getPropertyName()] =
lcfirst($modelName);
}
return $this->_modelPlural[$relation->getPropertyName()];
}
|
[
"public",
"function",
"modelPlural",
"(",
"RelationInterface",
"$",
"relation",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_modelPlural",
"[",
"$",
"relation",
"->",
"getPropertyName",
"(",
")",
"]",
")",
")",
"{",
"$",
"parts",
"=",
"explode",
"(",
"'\\\\'",
",",
"$",
"relation",
"->",
"getRelatedEntity",
"(",
")",
")",
";",
"$",
"name",
"=",
"Text",
"::",
"camelCaseToSeparator",
"(",
"end",
"(",
"$",
"parts",
")",
",",
"'#'",
")",
";",
"$",
"name",
"=",
"explode",
"(",
"'#'",
",",
"$",
"name",
")",
";",
"$",
"final",
"=",
"ucfirst",
"(",
"Text",
"::",
"plural",
"(",
"strtolower",
"(",
"array_pop",
"(",
"$",
"name",
")",
")",
")",
")",
";",
"$",
"name",
"[",
"]",
"=",
"$",
"final",
";",
"$",
"modelName",
"=",
"''",
";",
"foreach",
"(",
"$",
"name",
"as",
"$",
"part",
")",
"{",
"$",
"modelName",
".=",
"ucfirst",
"(",
"$",
"part",
")",
";",
"}",
"$",
"this",
"->",
"_modelPlural",
"[",
"$",
"relation",
"->",
"getPropertyName",
"(",
")",
"]",
"=",
"lcfirst",
"(",
"$",
"modelName",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_modelPlural",
"[",
"$",
"relation",
"->",
"getPropertyName",
"(",
")",
"]",
";",
"}"
] |
Returns the plural form of the class name
@param RelationInterface $relation
@return string
|
[
"Returns",
"the",
"plural",
"form",
"of",
"the",
"class",
"name"
] |
77f56b81020ce8c10f25f7d918661ccd9a918a37
|
https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Mvc/Model/Descriptor.php#L147-L164
|
229,095
|
slickframework/slick
|
src/Slick/Mvc/Model/Descriptor.php
|
Descriptor.modelSingular
|
public function modelSingular(RelationInterface $relation)
{
if (!isset($this->_modelSingular[$relation->getPropertyName()])) {
$parts = explode('\\', $relation->getRelatedEntity());
$this->_modelSingular[$relation->getPropertyName()] = lcfirst(end($parts));
}
return $this->_modelSingular[$relation->getPropertyName()];
}
|
php
|
public function modelSingular(RelationInterface $relation)
{
if (!isset($this->_modelSingular[$relation->getPropertyName()])) {
$parts = explode('\\', $relation->getRelatedEntity());
$this->_modelSingular[$relation->getPropertyName()] = lcfirst(end($parts));
}
return $this->_modelSingular[$relation->getPropertyName()];
}
|
[
"public",
"function",
"modelSingular",
"(",
"RelationInterface",
"$",
"relation",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_modelSingular",
"[",
"$",
"relation",
"->",
"getPropertyName",
"(",
")",
"]",
")",
")",
"{",
"$",
"parts",
"=",
"explode",
"(",
"'\\\\'",
",",
"$",
"relation",
"->",
"getRelatedEntity",
"(",
")",
")",
";",
"$",
"this",
"->",
"_modelSingular",
"[",
"$",
"relation",
"->",
"getPropertyName",
"(",
")",
"]",
"=",
"lcfirst",
"(",
"end",
"(",
"$",
"parts",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_modelSingular",
"[",
"$",
"relation",
"->",
"getPropertyName",
"(",
")",
"]",
";",
"}"
] |
Returns the singular form of the class name
@param RelationInterface $relation
@return string
|
[
"Returns",
"the",
"singular",
"form",
"of",
"the",
"class",
"name"
] |
77f56b81020ce8c10f25f7d918661ccd9a918a37
|
https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Mvc/Model/Descriptor.php#L173-L180
|
229,096
|
slickframework/slick
|
src/Slick/Mvc/Model/Descriptor.php
|
Descriptor.getPrimaryKey
|
public function getPrimaryKey()
{
if (is_null($this->_primaryKey)) {
$this->_primaryKey = $this->getDescriptor()
->getEntity()->getPrimaryKey();
}
return $this->_primaryKey;
}
|
php
|
public function getPrimaryKey()
{
if (is_null($this->_primaryKey)) {
$this->_primaryKey = $this->getDescriptor()
->getEntity()->getPrimaryKey();
}
return $this->_primaryKey;
}
|
[
"public",
"function",
"getPrimaryKey",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"_primaryKey",
")",
")",
"{",
"$",
"this",
"->",
"_primaryKey",
"=",
"$",
"this",
"->",
"getDescriptor",
"(",
")",
"->",
"getEntity",
"(",
")",
"->",
"getPrimaryKey",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_primaryKey",
";",
"}"
] |
Returns model primary key name
@return string
|
[
"Returns",
"model",
"primary",
"key",
"name"
] |
77f56b81020ce8c10f25f7d918661ccd9a918a37
|
https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Mvc/Model/Descriptor.php#L187-L194
|
229,097
|
slickframework/slick
|
src/Slick/Mvc/Model/Descriptor.php
|
Descriptor.getTableName
|
public function getTableName()
{
if (is_null($this->_tableName)) {
$this->_tableName = $this->getDescriptor()->getEntity()
->getTableName();
}
return $this->_tableName;
}
|
php
|
public function getTableName()
{
if (is_null($this->_tableName)) {
$this->_tableName = $this->getDescriptor()->getEntity()
->getTableName();
}
return $this->_tableName;
}
|
[
"public",
"function",
"getTableName",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"_tableName",
")",
")",
"{",
"$",
"this",
"->",
"_tableName",
"=",
"$",
"this",
"->",
"getDescriptor",
"(",
")",
"->",
"getEntity",
"(",
")",
"->",
"getTableName",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_tableName",
";",
"}"
] |
Returns model table name
@return string
|
[
"Returns",
"model",
"table",
"name"
] |
77f56b81020ce8c10f25f7d918661ccd9a918a37
|
https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Mvc/Model/Descriptor.php#L220-L227
|
229,098
|
slickframework/slick
|
src/Slick/Mvc/Codeception/Module.php
|
Slick._after
|
public function _after(TestCase $test)
{
$_SESSION = array();
$_GET = array();
$_POST = array();
$_COOKIE = array();
parent::_after($test);
}
|
php
|
public function _after(TestCase $test)
{
$_SESSION = array();
$_GET = array();
$_POST = array();
$_COOKIE = array();
parent::_after($test);
}
|
[
"public",
"function",
"_after",
"(",
"TestCase",
"$",
"test",
")",
"{",
"$",
"_SESSION",
"=",
"array",
"(",
")",
";",
"$",
"_GET",
"=",
"array",
"(",
")",
";",
"$",
"_POST",
"=",
"array",
"(",
")",
";",
"$",
"_COOKIE",
"=",
"array",
"(",
")",
";",
"parent",
"::",
"_after",
"(",
"$",
"test",
")",
";",
"}"
] |
Runs after each test
@param TestCase $test
|
[
"Runs",
"after",
"each",
"test"
] |
77f56b81020ce8c10f25f7d918661ccd9a918a37
|
https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Mvc/Codeception/Module.php#L45-L52
|
229,099
|
lekoala/silverstripe-form-extras
|
code/controller/AjaxUploadController.php
|
AjaxUploadController.findExternalLinks
|
public static function findExternalLinks($content)
{
$matches = null;
preg_match_all('/(?:href|src)=\"([^\"]+)/', $content, $matches);
if (empty($matches[1])) {
return [];
}
return $matches[1];
}
|
php
|
public static function findExternalLinks($content)
{
$matches = null;
preg_match_all('/(?:href|src)=\"([^\"]+)/', $content, $matches);
if (empty($matches[1])) {
return [];
}
return $matches[1];
}
|
[
"public",
"static",
"function",
"findExternalLinks",
"(",
"$",
"content",
")",
"{",
"$",
"matches",
"=",
"null",
";",
"preg_match_all",
"(",
"'/(?:href|src)=\\\"([^\\\"]+)/'",
",",
"$",
"content",
",",
"$",
"matches",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"matches",
"[",
"1",
"]",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
"return",
"$",
"matches",
"[",
"1",
"]",
";",
"}"
] |
Finds external links in a given html content
@param string $content Your html content
@return array An array of files
|
[
"Finds",
"external",
"links",
"in",
"a",
"given",
"html",
"content"
] |
e0c1200792af8e6cea916e1999c73cf8408c6dd2
|
https://github.com/lekoala/silverstripe-form-extras/blob/e0c1200792af8e6cea916e1999c73cf8408c6dd2/code/controller/AjaxUploadController.php#L165-L175
|
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.