id
int32 0
241k
| repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
list | docstring
stringlengths 3
47.2k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 91
247
|
|---|---|---|---|---|---|---|---|---|---|---|---|
239,200
|
NitroXy/php-forms
|
src/lib/FormBuilder.php
|
FormBuilder.fieldsFor
|
public function fieldsFor($id, $obj, callable $callback){
$this->context->fieldsFor($id, $obj, $callback);
}
|
php
|
public function fieldsFor($id, $obj, callable $callback){
$this->context->fieldsFor($id, $obj, $callback);
}
|
[
"public",
"function",
"fieldsFor",
"(",
"$",
"id",
",",
"$",
"obj",
",",
"callable",
"$",
"callback",
")",
"{",
"$",
"this",
"->",
"context",
"->",
"fieldsFor",
"(",
"$",
"id",
",",
"$",
"obj",
",",
"$",
"callback",
")",
";",
"}"
] |
Changes the resource object to another object. Used to generate
forms for multiple object at the same times. Objects doesn't have
to be of the same type but ID must be unique.
@param $callback A new rendering context.
|
[
"Changes",
"the",
"resource",
"object",
"to",
"another",
"object",
".",
"Used",
"to",
"generate",
"forms",
"for",
"multiple",
"object",
"at",
"the",
"same",
"times",
".",
"Objects",
"doesn",
"t",
"have",
"to",
"be",
"of",
"the",
"same",
"type",
"but",
"ID",
"must",
"be",
"unique",
"."
] |
28970779c3b438372c83f4f651a9897a542c1e54
|
https://github.com/NitroXy/php-forms/blob/28970779c3b438372c83f4f651a9897a542c1e54/src/lib/FormBuilder.php#L304-L306
|
239,201
|
mjacobus/php-objects
|
lib/PO/String.php
|
String.split
|
public function split($separator)
{
$hash = new Hash(explode((string) $separator, (string) $this));
return $hash->map(
function ($value) {
return new String($value);
}
);
}
|
php
|
public function split($separator)
{
$hash = new Hash(explode((string) $separator, (string) $this));
return $hash->map(
function ($value) {
return new String($value);
}
);
}
|
[
"public",
"function",
"split",
"(",
"$",
"separator",
")",
"{",
"$",
"hash",
"=",
"new",
"Hash",
"(",
"explode",
"(",
"(",
"string",
")",
"$",
"separator",
",",
"(",
"string",
")",
"$",
"this",
")",
")",
";",
"return",
"$",
"hash",
"->",
"map",
"(",
"function",
"(",
"$",
"value",
")",
"{",
"return",
"new",
"String",
"(",
"$",
"value",
")",
";",
"}",
")",
";",
"}"
] |
Splits the string
@param string separator
@return Hash[String]
|
[
"Splits",
"the",
"string"
] |
5e5c5f14e2bb30565a0a758c899ecf877558f58b
|
https://github.com/mjacobus/php-objects/blob/5e5c5f14e2bb30565a0a758c899ecf877558f58b/lib/PO/String.php#L112-L121
|
239,202
|
mjacobus/php-objects
|
lib/PO/String.php
|
String.at
|
public function at($start = null, $length = null)
{
return new String(mb_substr((string) $this, $start, $length, 'UTF-8'));
}
|
php
|
public function at($start = null, $length = null)
{
return new String(mb_substr((string) $this, $start, $length, 'UTF-8'));
}
|
[
"public",
"function",
"at",
"(",
"$",
"start",
"=",
"null",
",",
"$",
"length",
"=",
"null",
")",
"{",
"return",
"new",
"String",
"(",
"mb_substr",
"(",
"(",
"string",
")",
"$",
"this",
",",
"$",
"start",
",",
"$",
"length",
",",
"'UTF-8'",
")",
")",
";",
"}"
] |
Returns part of a string
@param integer start
@param integer $length the length of the string from the starting point
@return PO\String
|
[
"Returns",
"part",
"of",
"a",
"string"
] |
5e5c5f14e2bb30565a0a758c899ecf877558f58b
|
https://github.com/mjacobus/php-objects/blob/5e5c5f14e2bb30565a0a758c899ecf877558f58b/lib/PO/String.php#L148-L151
|
239,203
|
Silvestra/Silvestra
|
src/Silvestra/Component/Sitemap/Dumper/SitemapFileDumper.php
|
SitemapFileDumper.getSitemapEntries
|
protected function getSitemapEntries(ProfileInterface $profile)
{
$now = new \DateTime();
$urlEntries = $profile->getUrlEntries();
$numberOfSitemap = $this->getNumberOfSitemap($urlEntries);
if (1 === $numberOfSitemap) {
$this->writeFile(
$this->helper->getSitemapEntryFilePath($this->getFilename($profile)),
$this->render->renderSitemap($urlEntries)
);
return array(new SitemapEntry($this->helper->getSitemapEntryFileUrl($this->getFilename($profile)), $now));
}
$sitemapEntries = array();
for ($number = 0; $number < $numberOfSitemap; $number++) {
$filename = $this->getFilename($profile, $number);
$entries = array_slice($urlEntries, $number * $this->maxPerSitemap, $this->maxPerSitemap);
$this->writeFile($this->helper->getSitemapEntryFilePath($filename), $this->render->renderSitemap($entries));
$sitemapEntries[] = new SitemapEntry($this->helper->getSitemapEntryFileUrl($filename), $now);
}
return $sitemapEntries;
}
|
php
|
protected function getSitemapEntries(ProfileInterface $profile)
{
$now = new \DateTime();
$urlEntries = $profile->getUrlEntries();
$numberOfSitemap = $this->getNumberOfSitemap($urlEntries);
if (1 === $numberOfSitemap) {
$this->writeFile(
$this->helper->getSitemapEntryFilePath($this->getFilename($profile)),
$this->render->renderSitemap($urlEntries)
);
return array(new SitemapEntry($this->helper->getSitemapEntryFileUrl($this->getFilename($profile)), $now));
}
$sitemapEntries = array();
for ($number = 0; $number < $numberOfSitemap; $number++) {
$filename = $this->getFilename($profile, $number);
$entries = array_slice($urlEntries, $number * $this->maxPerSitemap, $this->maxPerSitemap);
$this->writeFile($this->helper->getSitemapEntryFilePath($filename), $this->render->renderSitemap($entries));
$sitemapEntries[] = new SitemapEntry($this->helper->getSitemapEntryFileUrl($filename), $now);
}
return $sitemapEntries;
}
|
[
"protected",
"function",
"getSitemapEntries",
"(",
"ProfileInterface",
"$",
"profile",
")",
"{",
"$",
"now",
"=",
"new",
"\\",
"DateTime",
"(",
")",
";",
"$",
"urlEntries",
"=",
"$",
"profile",
"->",
"getUrlEntries",
"(",
")",
";",
"$",
"numberOfSitemap",
"=",
"$",
"this",
"->",
"getNumberOfSitemap",
"(",
"$",
"urlEntries",
")",
";",
"if",
"(",
"1",
"===",
"$",
"numberOfSitemap",
")",
"{",
"$",
"this",
"->",
"writeFile",
"(",
"$",
"this",
"->",
"helper",
"->",
"getSitemapEntryFilePath",
"(",
"$",
"this",
"->",
"getFilename",
"(",
"$",
"profile",
")",
")",
",",
"$",
"this",
"->",
"render",
"->",
"renderSitemap",
"(",
"$",
"urlEntries",
")",
")",
";",
"return",
"array",
"(",
"new",
"SitemapEntry",
"(",
"$",
"this",
"->",
"helper",
"->",
"getSitemapEntryFileUrl",
"(",
"$",
"this",
"->",
"getFilename",
"(",
"$",
"profile",
")",
")",
",",
"$",
"now",
")",
")",
";",
"}",
"$",
"sitemapEntries",
"=",
"array",
"(",
")",
";",
"for",
"(",
"$",
"number",
"=",
"0",
";",
"$",
"number",
"<",
"$",
"numberOfSitemap",
";",
"$",
"number",
"++",
")",
"{",
"$",
"filename",
"=",
"$",
"this",
"->",
"getFilename",
"(",
"$",
"profile",
",",
"$",
"number",
")",
";",
"$",
"entries",
"=",
"array_slice",
"(",
"$",
"urlEntries",
",",
"$",
"number",
"*",
"$",
"this",
"->",
"maxPerSitemap",
",",
"$",
"this",
"->",
"maxPerSitemap",
")",
";",
"$",
"this",
"->",
"writeFile",
"(",
"$",
"this",
"->",
"helper",
"->",
"getSitemapEntryFilePath",
"(",
"$",
"filename",
")",
",",
"$",
"this",
"->",
"render",
"->",
"renderSitemap",
"(",
"$",
"entries",
")",
")",
";",
"$",
"sitemapEntries",
"[",
"]",
"=",
"new",
"SitemapEntry",
"(",
"$",
"this",
"->",
"helper",
"->",
"getSitemapEntryFileUrl",
"(",
"$",
"filename",
")",
",",
"$",
"now",
")",
";",
"}",
"return",
"$",
"sitemapEntries",
";",
"}"
] |
Get sitemap entries.
@param ProfileInterface $profile
@return array|SitemapEntry[]
|
[
"Get",
"sitemap",
"entries",
"."
] |
b7367601b01495ae3c492b42042f804dee13ab06
|
https://github.com/Silvestra/Silvestra/blob/b7367601b01495ae3c492b42042f804dee13ab06/src/Silvestra/Component/Sitemap/Dumper/SitemapFileDumper.php#L97-L125
|
239,204
|
Silvestra/Silvestra
|
src/Silvestra/Component/Sitemap/Dumper/SitemapFileDumper.php
|
SitemapFileDumper.getNumberOfSitemap
|
private function getNumberOfSitemap(array $urlEntries)
{
$total = count($urlEntries);
if ($total <= $this->maxPerSitemap) {
return 1;
}
return intval(ceil($total / $this->maxPerSitemap));
}
|
php
|
private function getNumberOfSitemap(array $urlEntries)
{
$total = count($urlEntries);
if ($total <= $this->maxPerSitemap) {
return 1;
}
return intval(ceil($total / $this->maxPerSitemap));
}
|
[
"private",
"function",
"getNumberOfSitemap",
"(",
"array",
"$",
"urlEntries",
")",
"{",
"$",
"total",
"=",
"count",
"(",
"$",
"urlEntries",
")",
";",
"if",
"(",
"$",
"total",
"<=",
"$",
"this",
"->",
"maxPerSitemap",
")",
"{",
"return",
"1",
";",
"}",
"return",
"intval",
"(",
"ceil",
"(",
"$",
"total",
"/",
"$",
"this",
"->",
"maxPerSitemap",
")",
")",
";",
"}"
] |
Get number of sitemap.
@param array|UrlEntryInterface[] $urlEntries
@return int
|
[
"Get",
"number",
"of",
"sitemap",
"."
] |
b7367601b01495ae3c492b42042f804dee13ab06
|
https://github.com/Silvestra/Silvestra/blob/b7367601b01495ae3c492b42042f804dee13ab06/src/Silvestra/Component/Sitemap/Dumper/SitemapFileDumper.php#L134-L143
|
239,205
|
Silvestra/Silvestra
|
src/Silvestra/Component/Sitemap/Dumper/SitemapFileDumper.php
|
SitemapFileDumper.writeFile
|
private function writeFile($path, $data)
{
if (false === @file_put_contents($path, $data)) {
throw new DumperException(sprintf('Unable to write file "%s"', $path));
}
}
|
php
|
private function writeFile($path, $data)
{
if (false === @file_put_contents($path, $data)) {
throw new DumperException(sprintf('Unable to write file "%s"', $path));
}
}
|
[
"private",
"function",
"writeFile",
"(",
"$",
"path",
",",
"$",
"data",
")",
"{",
"if",
"(",
"false",
"===",
"@",
"file_put_contents",
"(",
"$",
"path",
",",
"$",
"data",
")",
")",
"{",
"throw",
"new",
"DumperException",
"(",
"sprintf",
"(",
"'Unable to write file \"%s\"'",
",",
"$",
"path",
")",
")",
";",
"}",
"}"
] |
Write file.
@param string $path
@param string $data
@throws DumperException
|
[
"Write",
"file",
"."
] |
b7367601b01495ae3c492b42042f804dee13ab06
|
https://github.com/Silvestra/Silvestra/blob/b7367601b01495ae3c492b42042f804dee13ab06/src/Silvestra/Component/Sitemap/Dumper/SitemapFileDumper.php#L170-L175
|
239,206
|
ensphere/core
|
Ensphere/Libs/Config/Database.php
|
Database.mySQLconnection
|
public static function mySQLconnection( $array )
{
if ( env( 'APP_ENV' ) === 'local' && in_array( env( 'DB_HOST' ), [ 'localhost', '127.0.0.1' ] ) ) {
$path = '/Applications/MAMP/tmp/mysql/mysql.sock';
$mampSocket = ( file_exists( $path ) ) ? $path : '';
$array['unix_socket'] = env( 'DB_SOCKET', $mampSocket );
}
return $array;
}
|
php
|
public static function mySQLconnection( $array )
{
if ( env( 'APP_ENV' ) === 'local' && in_array( env( 'DB_HOST' ), [ 'localhost', '127.0.0.1' ] ) ) {
$path = '/Applications/MAMP/tmp/mysql/mysql.sock';
$mampSocket = ( file_exists( $path ) ) ? $path : '';
$array['unix_socket'] = env( 'DB_SOCKET', $mampSocket );
}
return $array;
}
|
[
"public",
"static",
"function",
"mySQLconnection",
"(",
"$",
"array",
")",
"{",
"if",
"(",
"env",
"(",
"'APP_ENV'",
")",
"===",
"'local'",
"&&",
"in_array",
"(",
"env",
"(",
"'DB_HOST'",
")",
",",
"[",
"'localhost'",
",",
"'127.0.0.1'",
"]",
")",
")",
"{",
"$",
"path",
"=",
"'/Applications/MAMP/tmp/mysql/mysql.sock'",
";",
"$",
"mampSocket",
"=",
"(",
"file_exists",
"(",
"$",
"path",
")",
")",
"?",
"$",
"path",
":",
"''",
";",
"$",
"array",
"[",
"'unix_socket'",
"]",
"=",
"env",
"(",
"'DB_SOCKET'",
",",
"$",
"mampSocket",
")",
";",
"}",
"return",
"$",
"array",
";",
"}"
] |
If on local environment, DB_SOCKET is an available .env option, if we can find a MAMP socket, that's the default
@param $array
@return mixed
|
[
"If",
"on",
"local",
"environment",
"DB_SOCKET",
"is",
"an",
"available",
".",
"env",
"option",
"if",
"we",
"can",
"find",
"a",
"MAMP",
"socket",
"that",
"s",
"the",
"default"
] |
a9ed12b49b7f3a8d5560a1114419888e0fdf5bf3
|
https://github.com/ensphere/core/blob/a9ed12b49b7f3a8d5560a1114419888e0fdf5bf3/Ensphere/Libs/Config/Database.php#L16-L24
|
239,207
|
shopery/view
|
src/Factory/RootViewFactory.php
|
RootViewFactory.createView
|
public function createView($object)
{
if (is_array($object)) {
return array_map([ $this, 'createView' ], $object);
}
$view = $this->factory->createView($object);
if (false === $view instanceof View) {
return $this->notSuitableFactoryFor($object);
}
if ($view instanceof RootViewFactoryAware) {
$view->setRootViewFactory($this);
}
return $view;
}
|
php
|
public function createView($object)
{
if (is_array($object)) {
return array_map([ $this, 'createView' ], $object);
}
$view = $this->factory->createView($object);
if (false === $view instanceof View) {
return $this->notSuitableFactoryFor($object);
}
if ($view instanceof RootViewFactoryAware) {
$view->setRootViewFactory($this);
}
return $view;
}
|
[
"public",
"function",
"createView",
"(",
"$",
"object",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"object",
")",
")",
"{",
"return",
"array_map",
"(",
"[",
"$",
"this",
",",
"'createView'",
"]",
",",
"$",
"object",
")",
";",
"}",
"$",
"view",
"=",
"$",
"this",
"->",
"factory",
"->",
"createView",
"(",
"$",
"object",
")",
";",
"if",
"(",
"false",
"===",
"$",
"view",
"instanceof",
"View",
")",
"{",
"return",
"$",
"this",
"->",
"notSuitableFactoryFor",
"(",
"$",
"object",
")",
";",
"}",
"if",
"(",
"$",
"view",
"instanceof",
"RootViewFactoryAware",
")",
"{",
"$",
"view",
"->",
"setRootViewFactory",
"(",
"$",
"this",
")",
";",
"}",
"return",
"$",
"view",
";",
"}"
] |
Create a view for the object, allows arrays recursively
@param $object
@return View
@throws Exception\UnsupportedObjectException
|
[
"Create",
"a",
"view",
"for",
"the",
"object",
"allows",
"arrays",
"recursively"
] |
cc38154a2b649ec99e7eb13f79b99cdf143bd4af
|
https://github.com/shopery/view/blob/cc38154a2b649ec99e7eb13f79b99cdf143bd4af/src/Factory/RootViewFactory.php#L69-L86
|
239,208
|
shopery/view
|
src/Factory/RootViewFactory.php
|
RootViewFactory.notSuitableFactoryFor
|
private function notSuitableFactoryFor($object)
{
switch ($this->notFoundBehaviour) {
case self::NOT_FOUND_RETURNS_NULL:
return null;
case self::NOT_FOUND_RETURN_SOURCE:
return $object;
case self::NOT_FOUND_THROWS_EXCEPTION:
default:
throw new Exception\UnsupportedObjectException(sprintf(
'Can\'t create a View from object of type "%s"',
is_object($object) ? get_class($object) : gettype($object)
));
}
}
|
php
|
private function notSuitableFactoryFor($object)
{
switch ($this->notFoundBehaviour) {
case self::NOT_FOUND_RETURNS_NULL:
return null;
case self::NOT_FOUND_RETURN_SOURCE:
return $object;
case self::NOT_FOUND_THROWS_EXCEPTION:
default:
throw new Exception\UnsupportedObjectException(sprintf(
'Can\'t create a View from object of type "%s"',
is_object($object) ? get_class($object) : gettype($object)
));
}
}
|
[
"private",
"function",
"notSuitableFactoryFor",
"(",
"$",
"object",
")",
"{",
"switch",
"(",
"$",
"this",
"->",
"notFoundBehaviour",
")",
"{",
"case",
"self",
"::",
"NOT_FOUND_RETURNS_NULL",
":",
"return",
"null",
";",
"case",
"self",
"::",
"NOT_FOUND_RETURN_SOURCE",
":",
"return",
"$",
"object",
";",
"case",
"self",
"::",
"NOT_FOUND_THROWS_EXCEPTION",
":",
"default",
":",
"throw",
"new",
"Exception",
"\\",
"UnsupportedObjectException",
"(",
"sprintf",
"(",
"'Can\\'t create a View from object of type \"%s\"'",
",",
"is_object",
"(",
"$",
"object",
")",
"?",
"get_class",
"(",
"$",
"object",
")",
":",
"gettype",
"(",
"$",
"object",
")",
")",
")",
";",
"}",
"}"
] |
Behaviour when a suitable view factory can't be found
@param mixed $object
@return null
|
[
"Behaviour",
"when",
"a",
"suitable",
"view",
"factory",
"can",
"t",
"be",
"found"
] |
cc38154a2b649ec99e7eb13f79b99cdf143bd4af
|
https://github.com/shopery/view/blob/cc38154a2b649ec99e7eb13f79b99cdf143bd4af/src/Factory/RootViewFactory.php#L95-L111
|
239,209
|
Attibee/Bumble-Form
|
src/Form.php
|
Form.getHTML
|
public function getHTML() {
$tag = '<form';
$q = $this->quoteType;
//build attribute strings
foreach( $this->attrs as $name=>$value ) {
//if true, such as CHECKED, we just add the name
if( $value === true )
$tag .= " $name";
elseif( is_string( $value ) ) //if it's a string, we add attr="value"
$tag .= " {$name}={$q}{$value}{$q}";
}
//not a short tag, close it
$tag .= '>';
//add the children if they exist
if( $this->hasChildren() ) {
for( $i = 0; $i < count( $this->children ); $i++ ) {
//datalists are hidden and should not be decorated
if( $this->children[$i] instanceof Element\Datalist ) {
$tag .= $this->children[$i]->getHTML();
} else {
$tag .= $this->decorator->element( $this->children[$i]->getHTML(), $this->titles[$i] );
}
}
}
//closing tag
$tag .= "</form>";
return $this->decorator->form( $tag );
}
|
php
|
public function getHTML() {
$tag = '<form';
$q = $this->quoteType;
//build attribute strings
foreach( $this->attrs as $name=>$value ) {
//if true, such as CHECKED, we just add the name
if( $value === true )
$tag .= " $name";
elseif( is_string( $value ) ) //if it's a string, we add attr="value"
$tag .= " {$name}={$q}{$value}{$q}";
}
//not a short tag, close it
$tag .= '>';
//add the children if they exist
if( $this->hasChildren() ) {
for( $i = 0; $i < count( $this->children ); $i++ ) {
//datalists are hidden and should not be decorated
if( $this->children[$i] instanceof Element\Datalist ) {
$tag .= $this->children[$i]->getHTML();
} else {
$tag .= $this->decorator->element( $this->children[$i]->getHTML(), $this->titles[$i] );
}
}
}
//closing tag
$tag .= "</form>";
return $this->decorator->form( $tag );
}
|
[
"public",
"function",
"getHTML",
"(",
")",
"{",
"$",
"tag",
"=",
"'<form'",
";",
"$",
"q",
"=",
"$",
"this",
"->",
"quoteType",
";",
"//build attribute strings\r",
"foreach",
"(",
"$",
"this",
"->",
"attrs",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"//if true, such as CHECKED, we just add the name\r",
"if",
"(",
"$",
"value",
"===",
"true",
")",
"$",
"tag",
".=",
"\" $name\"",
";",
"elseif",
"(",
"is_string",
"(",
"$",
"value",
")",
")",
"//if it's a string, we add attr=\"value\"\r",
"$",
"tag",
".=",
"\" {$name}={$q}{$value}{$q}\"",
";",
"}",
"//not a short tag, close it\r",
"$",
"tag",
".=",
"'>'",
";",
"//add the children if they exist\r",
"if",
"(",
"$",
"this",
"->",
"hasChildren",
"(",
")",
")",
"{",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"count",
"(",
"$",
"this",
"->",
"children",
")",
";",
"$",
"i",
"++",
")",
"{",
"//datalists are hidden and should not be decorated\r",
"if",
"(",
"$",
"this",
"->",
"children",
"[",
"$",
"i",
"]",
"instanceof",
"Element",
"\\",
"Datalist",
")",
"{",
"$",
"tag",
".=",
"$",
"this",
"->",
"children",
"[",
"$",
"i",
"]",
"->",
"getHTML",
"(",
")",
";",
"}",
"else",
"{",
"$",
"tag",
".=",
"$",
"this",
"->",
"decorator",
"->",
"element",
"(",
"$",
"this",
"->",
"children",
"[",
"$",
"i",
"]",
"->",
"getHTML",
"(",
")",
",",
"$",
"this",
"->",
"titles",
"[",
"$",
"i",
"]",
")",
";",
"}",
"}",
"}",
"//closing tag\r",
"$",
"tag",
".=",
"\"</form>\"",
";",
"return",
"$",
"this",
"->",
"decorator",
"->",
"form",
"(",
"$",
"tag",
")",
";",
"}"
] |
Returns the HTML string.
@return string The HTML string.
|
[
"Returns",
"the",
"HTML",
"string",
"."
] |
546c4b01806c68d8ffc09766f74dc157d9ab4960
|
https://github.com/Attibee/Bumble-Form/blob/546c4b01806c68d8ffc09766f74dc157d9ab4960/src/Form.php#L84-L116
|
239,210
|
Attibee/Bumble-Form
|
src/Form.php
|
Form.setData
|
public function setData( array $array ) {
foreach( $array as $name=>$value ) {
if( !isset( $this->nameHash[$name] ) ) {
continue;
}
$element = $this->nameHash[$name];
$element->setAttribute( 'value', (string)$value );
}
}
|
php
|
public function setData( array $array ) {
foreach( $array as $name=>$value ) {
if( !isset( $this->nameHash[$name] ) ) {
continue;
}
$element = $this->nameHash[$name];
$element->setAttribute( 'value', (string)$value );
}
}
|
[
"public",
"function",
"setData",
"(",
"array",
"$",
"array",
")",
"{",
"foreach",
"(",
"$",
"array",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"nameHash",
"[",
"$",
"name",
"]",
")",
")",
"{",
"continue",
";",
"}",
"$",
"element",
"=",
"$",
"this",
"->",
"nameHash",
"[",
"$",
"name",
"]",
";",
"$",
"element",
"->",
"setAttribute",
"(",
"'value'",
",",
"(",
"string",
")",
"$",
"value",
")",
";",
"}",
"}"
] |
Sets the form elements values given an array of name=>value pairs.
@param $array the array of data to set
|
[
"Sets",
"the",
"form",
"elements",
"values",
"given",
"an",
"array",
"of",
"name",
"=",
">",
"value",
"pairs",
"."
] |
546c4b01806c68d8ffc09766f74dc157d9ab4960
|
https://github.com/Attibee/Bumble-Form/blob/546c4b01806c68d8ffc09766f74dc157d9ab4960/src/Form.php#L123-L133
|
239,211
|
anklimsk/cakephp-basic-functions
|
Vendor/langcode-conv/zendframework/zend-filter/src/Word/AbstractSeparator.php
|
AbstractSeparator.setSeparator
|
public function setSeparator($separator)
{
if (!is_string($separator)) {
throw new Exception\InvalidArgumentException('"' . $separator . '" is not a valid separator.');
}
$this->separator = $separator;
return $this;
}
|
php
|
public function setSeparator($separator)
{
if (!is_string($separator)) {
throw new Exception\InvalidArgumentException('"' . $separator . '" is not a valid separator.');
}
$this->separator = $separator;
return $this;
}
|
[
"public",
"function",
"setSeparator",
"(",
"$",
"separator",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"separator",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"InvalidArgumentException",
"(",
"'\"'",
".",
"$",
"separator",
".",
"'\" is not a valid separator.'",
")",
";",
"}",
"$",
"this",
"->",
"separator",
"=",
"$",
"separator",
";",
"return",
"$",
"this",
";",
"}"
] |
Sets a new separator
@param string $separator Separator
@return self
@throws Exception\InvalidArgumentException
|
[
"Sets",
"a",
"new",
"separator"
] |
7554e8b0b420fd3155593af7bf76b7ccbdc8701e
|
https://github.com/anklimsk/cakephp-basic-functions/blob/7554e8b0b420fd3155593af7bf76b7ccbdc8701e/Vendor/langcode-conv/zendframework/zend-filter/src/Word/AbstractSeparator.php#L43-L50
|
239,212
|
philliphq/phillip
|
src/Phillip/Assertion.php
|
Assertion.assert
|
public function assert($assertion, $message)
{
// Increment the assertion count
$this->test->incrementAssertionCount();
$assertion = $this->negative ? !((bool) $assertion) : (bool) $assertion;
if ($assertion === false) {
return call_user_func_array([$this, 'fail'], $message);
}
return true;
}
|
php
|
public function assert($assertion, $message)
{
// Increment the assertion count
$this->test->incrementAssertionCount();
$assertion = $this->negative ? !((bool) $assertion) : (bool) $assertion;
if ($assertion === false) {
return call_user_func_array([$this, 'fail'], $message);
}
return true;
}
|
[
"public",
"function",
"assert",
"(",
"$",
"assertion",
",",
"$",
"message",
")",
"{",
"// Increment the assertion count",
"$",
"this",
"->",
"test",
"->",
"incrementAssertionCount",
"(",
")",
";",
"$",
"assertion",
"=",
"$",
"this",
"->",
"negative",
"?",
"!",
"(",
"(",
"bool",
")",
"$",
"assertion",
")",
":",
"(",
"bool",
")",
"$",
"assertion",
";",
"if",
"(",
"$",
"assertion",
"===",
"false",
")",
"{",
"return",
"call_user_func_array",
"(",
"[",
"$",
"this",
",",
"'fail'",
"]",
",",
"$",
"message",
")",
";",
"}",
"return",
"true",
";",
"}"
] |
Check the resolution of a function.
@param bool $assertion The result of the assertion
@param array $message An array containing a failure message and
variables to substitute into it
@return bool
|
[
"Check",
"the",
"resolution",
"of",
"a",
"function",
"."
] |
42dac9d0f52fb77b49054b15b8baecca031151dc
|
https://github.com/philliphq/phillip/blob/42dac9d0f52fb77b49054b15b8baecca031151dc/src/Phillip/Assertion.php#L81-L93
|
239,213
|
philliphq/phillip
|
src/Phillip/Assertion.php
|
Assertion.fail
|
private function fail()
{
$args = func_get_args();
$format = array_shift($args);
$regex = '/\{\{(?P<positive>[^{}]*)\|(?<negative>[^{}]*)\}\}/';
preg_match_all($regex, $format, $matches);
$replacements = $this->negative ? $matches['negative'] : $matches['positive'];
foreach ($matches[0] as $i => $match) {
$format = str_replace($match, $replacements[$i], $format);
}
$format = preg_replace('/\s+/', ' ', $format);
foreach ($args as &$arg) {
if (is_array($arg)) {
$arg = 'Array';
continue;
}
if (is_object($arg)) {
$arg = 'Object of type "'.get_class($arg).'"';
continue;
}
if ($arg === true) {
$arg = 'TRUE';
continue;
}
if ($arg === false) {
$arg = 'FALSE';
continue;
}
if ($arg === null) {
$arg = 'NULL';
continue;
}
if (is_string($arg)) {
$arg = '"'.$arg.'"';
continue;
}
}
array_unshift($args, $format);
$msg = (new ReflectionFunction('sprintf'))->invokeArgs($args);
throw new AssertionFailureException($msg);
}
|
php
|
private function fail()
{
$args = func_get_args();
$format = array_shift($args);
$regex = '/\{\{(?P<positive>[^{}]*)\|(?<negative>[^{}]*)\}\}/';
preg_match_all($regex, $format, $matches);
$replacements = $this->negative ? $matches['negative'] : $matches['positive'];
foreach ($matches[0] as $i => $match) {
$format = str_replace($match, $replacements[$i], $format);
}
$format = preg_replace('/\s+/', ' ', $format);
foreach ($args as &$arg) {
if (is_array($arg)) {
$arg = 'Array';
continue;
}
if (is_object($arg)) {
$arg = 'Object of type "'.get_class($arg).'"';
continue;
}
if ($arg === true) {
$arg = 'TRUE';
continue;
}
if ($arg === false) {
$arg = 'FALSE';
continue;
}
if ($arg === null) {
$arg = 'NULL';
continue;
}
if (is_string($arg)) {
$arg = '"'.$arg.'"';
continue;
}
}
array_unshift($args, $format);
$msg = (new ReflectionFunction('sprintf'))->invokeArgs($args);
throw new AssertionFailureException($msg);
}
|
[
"private",
"function",
"fail",
"(",
")",
"{",
"$",
"args",
"=",
"func_get_args",
"(",
")",
";",
"$",
"format",
"=",
"array_shift",
"(",
"$",
"args",
")",
";",
"$",
"regex",
"=",
"'/\\{\\{(?P<positive>[^{}]*)\\|(?<negative>[^{}]*)\\}\\}/'",
";",
"preg_match_all",
"(",
"$",
"regex",
",",
"$",
"format",
",",
"$",
"matches",
")",
";",
"$",
"replacements",
"=",
"$",
"this",
"->",
"negative",
"?",
"$",
"matches",
"[",
"'negative'",
"]",
":",
"$",
"matches",
"[",
"'positive'",
"]",
";",
"foreach",
"(",
"$",
"matches",
"[",
"0",
"]",
"as",
"$",
"i",
"=>",
"$",
"match",
")",
"{",
"$",
"format",
"=",
"str_replace",
"(",
"$",
"match",
",",
"$",
"replacements",
"[",
"$",
"i",
"]",
",",
"$",
"format",
")",
";",
"}",
"$",
"format",
"=",
"preg_replace",
"(",
"'/\\s+/'",
",",
"' '",
",",
"$",
"format",
")",
";",
"foreach",
"(",
"$",
"args",
"as",
"&",
"$",
"arg",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"arg",
")",
")",
"{",
"$",
"arg",
"=",
"'Array'",
";",
"continue",
";",
"}",
"if",
"(",
"is_object",
"(",
"$",
"arg",
")",
")",
"{",
"$",
"arg",
"=",
"'Object of type \"'",
".",
"get_class",
"(",
"$",
"arg",
")",
".",
"'\"'",
";",
"continue",
";",
"}",
"if",
"(",
"$",
"arg",
"===",
"true",
")",
"{",
"$",
"arg",
"=",
"'TRUE'",
";",
"continue",
";",
"}",
"if",
"(",
"$",
"arg",
"===",
"false",
")",
"{",
"$",
"arg",
"=",
"'FALSE'",
";",
"continue",
";",
"}",
"if",
"(",
"$",
"arg",
"===",
"null",
")",
"{",
"$",
"arg",
"=",
"'NULL'",
";",
"continue",
";",
"}",
"if",
"(",
"is_string",
"(",
"$",
"arg",
")",
")",
"{",
"$",
"arg",
"=",
"'\"'",
".",
"$",
"arg",
".",
"'\"'",
";",
"continue",
";",
"}",
"}",
"array_unshift",
"(",
"$",
"args",
",",
"$",
"format",
")",
";",
"$",
"msg",
"=",
"(",
"new",
"ReflectionFunction",
"(",
"'sprintf'",
")",
")",
"->",
"invokeArgs",
"(",
"$",
"args",
")",
";",
"throw",
"new",
"AssertionFailureException",
"(",
"$",
"msg",
")",
";",
"}"
] |
Convert arguments into a string-safe exception message,
then throw an assertion failure.
@throws AssertionFailureException
|
[
"Convert",
"arguments",
"into",
"a",
"string",
"-",
"safe",
"exception",
"message",
"then",
"throw",
"an",
"assertion",
"failure",
"."
] |
42dac9d0f52fb77b49054b15b8baecca031151dc
|
https://github.com/philliphq/phillip/blob/42dac9d0f52fb77b49054b15b8baecca031151dc/src/Phillip/Assertion.php#L101-L154
|
239,214
|
philliphq/phillip
|
src/Phillip/Assertion.php
|
Assertion.boolean
|
public function boolean()
{
$message = ['%s is {{not|}} a boolean', $this->value];
$this->assert(is_bool($this->value), $message);
return $this;
}
|
php
|
public function boolean()
{
$message = ['%s is {{not|}} a boolean', $this->value];
$this->assert(is_bool($this->value), $message);
return $this;
}
|
[
"public",
"function",
"boolean",
"(",
")",
"{",
"$",
"message",
"=",
"[",
"'%s is {{not|}} a boolean'",
",",
"$",
"this",
"->",
"value",
"]",
";",
"$",
"this",
"->",
"assert",
"(",
"is_bool",
"(",
"$",
"this",
"->",
"value",
")",
",",
"$",
"message",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Assert that the value is a boolean type.
@throws AssertionFailureException
@return self
|
[
"Assert",
"that",
"the",
"value",
"is",
"a",
"boolean",
"type",
"."
] |
42dac9d0f52fb77b49054b15b8baecca031151dc
|
https://github.com/philliphq/phillip/blob/42dac9d0f52fb77b49054b15b8baecca031151dc/src/Phillip/Assertion.php#L163-L169
|
239,215
|
philliphq/phillip
|
src/Phillip/Assertion.php
|
Assertion.true
|
public function true()
{
$message = ['%s is {{not|}} true', $this->value];
$this->assert(($this->value === true), $message);
return $this;
}
|
php
|
public function true()
{
$message = ['%s is {{not|}} true', $this->value];
$this->assert(($this->value === true), $message);
return $this;
}
|
[
"public",
"function",
"true",
"(",
")",
"{",
"$",
"message",
"=",
"[",
"'%s is {{not|}} true'",
",",
"$",
"this",
"->",
"value",
"]",
";",
"$",
"this",
"->",
"assert",
"(",
"(",
"$",
"this",
"->",
"value",
"===",
"true",
")",
",",
"$",
"message",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Assert that the value is true.
@throws AssertionFailureException
@return self
|
[
"Assert",
"that",
"the",
"value",
"is",
"true",
"."
] |
42dac9d0f52fb77b49054b15b8baecca031151dc
|
https://github.com/philliphq/phillip/blob/42dac9d0f52fb77b49054b15b8baecca031151dc/src/Phillip/Assertion.php#L178-L184
|
239,216
|
philliphq/phillip
|
src/Phillip/Assertion.php
|
Assertion.false
|
public function false()
{
$message = ['%s is {{not|}} false', $this->value];
$this->assert(($this->value === false), $message);
return $this;
}
|
php
|
public function false()
{
$message = ['%s is {{not|}} false', $this->value];
$this->assert(($this->value === false), $message);
return $this;
}
|
[
"public",
"function",
"false",
"(",
")",
"{",
"$",
"message",
"=",
"[",
"'%s is {{not|}} false'",
",",
"$",
"this",
"->",
"value",
"]",
";",
"$",
"this",
"->",
"assert",
"(",
"(",
"$",
"this",
"->",
"value",
"===",
"false",
")",
",",
"$",
"message",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Assert that the value is false.
@throws AssertionFailureException
@return self
|
[
"Assert",
"that",
"the",
"value",
"is",
"false",
"."
] |
42dac9d0f52fb77b49054b15b8baecca031151dc
|
https://github.com/philliphq/phillip/blob/42dac9d0f52fb77b49054b15b8baecca031151dc/src/Phillip/Assertion.php#L193-L199
|
239,217
|
philliphq/phillip
|
src/Phillip/Assertion.php
|
Assertion.equal
|
public function equal($value)
{
$message = ['%s is {{not|}} equal to %s', $this->value, $value];
$this->assert(($this->value === $value), $message);
return $this;
}
|
php
|
public function equal($value)
{
$message = ['%s is {{not|}} equal to %s', $this->value, $value];
$this->assert(($this->value === $value), $message);
return $this;
}
|
[
"public",
"function",
"equal",
"(",
"$",
"value",
")",
"{",
"$",
"message",
"=",
"[",
"'%s is {{not|}} equal to %s'",
",",
"$",
"this",
"->",
"value",
",",
"$",
"value",
"]",
";",
"$",
"this",
"->",
"assert",
"(",
"(",
"$",
"this",
"->",
"value",
"===",
"$",
"value",
")",
",",
"$",
"message",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Assert that two values are equal.
@param mixed $value The value to test
@throws AssertionFailureException
@return self
|
[
"Assert",
"that",
"two",
"values",
"are",
"equal",
"."
] |
42dac9d0f52fb77b49054b15b8baecca031151dc
|
https://github.com/philliphq/phillip/blob/42dac9d0f52fb77b49054b15b8baecca031151dc/src/Phillip/Assertion.php#L210-L216
|
239,218
|
philliphq/phillip
|
src/Phillip/Assertion.php
|
Assertion.equivalentTo
|
public function equivalentTo($value)
{
$message = ['%s is {{not|}} equivalent to %s', $this->value, $value];
$this->assert(($this->value == $value), $message);
return $this;
}
|
php
|
public function equivalentTo($value)
{
$message = ['%s is {{not|}} equivalent to %s', $this->value, $value];
$this->assert(($this->value == $value), $message);
return $this;
}
|
[
"public",
"function",
"equivalentTo",
"(",
"$",
"value",
")",
"{",
"$",
"message",
"=",
"[",
"'%s is {{not|}} equivalent to %s'",
",",
"$",
"this",
"->",
"value",
",",
"$",
"value",
"]",
";",
"$",
"this",
"->",
"assert",
"(",
"(",
"$",
"this",
"->",
"value",
"==",
"$",
"value",
")",
",",
"$",
"message",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Assert that two values are equivalent.
@param mixed $value The value to test
@throws AssertionFailureException
@return self
|
[
"Assert",
"that",
"two",
"values",
"are",
"equivalent",
"."
] |
42dac9d0f52fb77b49054b15b8baecca031151dc
|
https://github.com/philliphq/phillip/blob/42dac9d0f52fb77b49054b15b8baecca031151dc/src/Phillip/Assertion.php#L227-L233
|
239,219
|
philliphq/phillip
|
src/Phillip/Assertion.php
|
Assertion.size
|
public function size($len)
{
$len = (int) $len;
if (is_string($this->value)) {
$message = ['%s {{does not have|has}} a string length of %s', $this->value, $len];
$this->assert((strlen($this->value) === $len), $message);
}
if (is_int($this->value)) {
$message = ['Integer %s {{does not have|has}} a size of %s', $this->value, $len];
$this->assert(($this->value === $len), $message);
}
if (is_array($this->value)) {
$message = ['Array {{does not have|has}} a size of %s', $len];
$this->assert((count($this->value) === $len), $message);
}
return $this;
}
|
php
|
public function size($len)
{
$len = (int) $len;
if (is_string($this->value)) {
$message = ['%s {{does not have|has}} a string length of %s', $this->value, $len];
$this->assert((strlen($this->value) === $len), $message);
}
if (is_int($this->value)) {
$message = ['Integer %s {{does not have|has}} a size of %s', $this->value, $len];
$this->assert(($this->value === $len), $message);
}
if (is_array($this->value)) {
$message = ['Array {{does not have|has}} a size of %s', $len];
$this->assert((count($this->value) === $len), $message);
}
return $this;
}
|
[
"public",
"function",
"size",
"(",
"$",
"len",
")",
"{",
"$",
"len",
"=",
"(",
"int",
")",
"$",
"len",
";",
"if",
"(",
"is_string",
"(",
"$",
"this",
"->",
"value",
")",
")",
"{",
"$",
"message",
"=",
"[",
"'%s {{does not have|has}} a string length of %s'",
",",
"$",
"this",
"->",
"value",
",",
"$",
"len",
"]",
";",
"$",
"this",
"->",
"assert",
"(",
"(",
"strlen",
"(",
"$",
"this",
"->",
"value",
")",
"===",
"$",
"len",
")",
",",
"$",
"message",
")",
";",
"}",
"if",
"(",
"is_int",
"(",
"$",
"this",
"->",
"value",
")",
")",
"{",
"$",
"message",
"=",
"[",
"'Integer %s {{does not have|has}} a size of %s'",
",",
"$",
"this",
"->",
"value",
",",
"$",
"len",
"]",
";",
"$",
"this",
"->",
"assert",
"(",
"(",
"$",
"this",
"->",
"value",
"===",
"$",
"len",
")",
",",
"$",
"message",
")",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"this",
"->",
"value",
")",
")",
"{",
"$",
"message",
"=",
"[",
"'Array {{does not have|has}} a size of %s'",
",",
"$",
"len",
"]",
";",
"$",
"this",
"->",
"assert",
"(",
"(",
"count",
"(",
"$",
"this",
"->",
"value",
")",
"===",
"$",
"len",
")",
",",
"$",
"message",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Check the size of the value.
@param int $len The length to test
@throws AssertionFailureException
@return self
|
[
"Check",
"the",
"size",
"of",
"the",
"value",
"."
] |
42dac9d0f52fb77b49054b15b8baecca031151dc
|
https://github.com/philliphq/phillip/blob/42dac9d0f52fb77b49054b15b8baecca031151dc/src/Phillip/Assertion.php#L244-L263
|
239,220
|
philliphq/phillip
|
src/Phillip/Assertion.php
|
Assertion.blank
|
public function blank()
{
$message = ['%s is {{not|}} empty', $this->value];
$this->assert((empty($this->value)), $message);
return $this;
}
|
php
|
public function blank()
{
$message = ['%s is {{not|}} empty', $this->value];
$this->assert((empty($this->value)), $message);
return $this;
}
|
[
"public",
"function",
"blank",
"(",
")",
"{",
"$",
"message",
"=",
"[",
"'%s is {{not|}} empty'",
",",
"$",
"this",
"->",
"value",
"]",
";",
"$",
"this",
"->",
"assert",
"(",
"(",
"empty",
"(",
"$",
"this",
"->",
"value",
")",
")",
",",
"$",
"message",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Assert that the value is empty.
@throws AssertionFailureException
@return self
|
[
"Assert",
"that",
"the",
"value",
"is",
"empty",
"."
] |
42dac9d0f52fb77b49054b15b8baecca031151dc
|
https://github.com/philliphq/phillip/blob/42dac9d0f52fb77b49054b15b8baecca031151dc/src/Phillip/Assertion.php#L286-L292
|
239,221
|
philliphq/phillip
|
src/Phillip/Assertion.php
|
Assertion.anArray
|
public function anArray()
{
$message = ['%s is {{not|}} an array', $this->value];
$this->assert((is_array($this->value)), $message);
return $this;
}
|
php
|
public function anArray()
{
$message = ['%s is {{not|}} an array', $this->value];
$this->assert((is_array($this->value)), $message);
return $this;
}
|
[
"public",
"function",
"anArray",
"(",
")",
"{",
"$",
"message",
"=",
"[",
"'%s is {{not|}} an array'",
",",
"$",
"this",
"->",
"value",
"]",
";",
"$",
"this",
"->",
"assert",
"(",
"(",
"is_array",
"(",
"$",
"this",
"->",
"value",
")",
")",
",",
"$",
"message",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Assert that the value is an array.
@throws AssertionFailureException
@return self
|
[
"Assert",
"that",
"the",
"value",
"is",
"an",
"array",
"."
] |
42dac9d0f52fb77b49054b15b8baecca031151dc
|
https://github.com/philliphq/phillip/blob/42dac9d0f52fb77b49054b15b8baecca031151dc/src/Phillip/Assertion.php#L301-L307
|
239,222
|
philliphq/phillip
|
src/Phillip/Assertion.php
|
Assertion.implement
|
public function implement($interface)
{
$message = ['Class %s {{does not implement|implements}} interface %s', $this->value, $interface];
$this->assert((in_array($interface, class_implements($this->value))), $message);
return $this;
}
|
php
|
public function implement($interface)
{
$message = ['Class %s {{does not implement|implements}} interface %s', $this->value, $interface];
$this->assert((in_array($interface, class_implements($this->value))), $message);
return $this;
}
|
[
"public",
"function",
"implement",
"(",
"$",
"interface",
")",
"{",
"$",
"message",
"=",
"[",
"'Class %s {{does not implement|implements}} interface %s'",
",",
"$",
"this",
"->",
"value",
",",
"$",
"interface",
"]",
";",
"$",
"this",
"->",
"assert",
"(",
"(",
"in_array",
"(",
"$",
"interface",
",",
"class_implements",
"(",
"$",
"this",
"->",
"value",
")",
")",
")",
",",
"$",
"message",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Assert that the value implements the given interface.
@param string $interface The interface to assert against
@throws AssertionFailureException
@return self
|
[
"Assert",
"that",
"the",
"value",
"implements",
"the",
"given",
"interface",
"."
] |
42dac9d0f52fb77b49054b15b8baecca031151dc
|
https://github.com/philliphq/phillip/blob/42dac9d0f52fb77b49054b15b8baecca031151dc/src/Phillip/Assertion.php#L351-L357
|
239,223
|
philliphq/phillip
|
src/Phillip/Assertion.php
|
Assertion.match
|
public function match($regex)
{
$matches = preg_match($regex, $this->value);
$message = ['%s {{does not match|matches}} the regular expression %s', $this->value, $regex];
$this->assert((!empty($matches)), $message);
return $this;
}
|
php
|
public function match($regex)
{
$matches = preg_match($regex, $this->value);
$message = ['%s {{does not match|matches}} the regular expression %s', $this->value, $regex];
$this->assert((!empty($matches)), $message);
return $this;
}
|
[
"public",
"function",
"match",
"(",
"$",
"regex",
")",
"{",
"$",
"matches",
"=",
"preg_match",
"(",
"$",
"regex",
",",
"$",
"this",
"->",
"value",
")",
";",
"$",
"message",
"=",
"[",
"'%s {{does not match|matches}} the regular expression %s'",
",",
"$",
"this",
"->",
"value",
",",
"$",
"regex",
"]",
";",
"$",
"this",
"->",
"assert",
"(",
"(",
"!",
"empty",
"(",
"$",
"matches",
")",
")",
",",
"$",
"message",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Assert that the value matches a given regular expression.
@param string $regex A regular expression to match against
@throws AssertionFailureException
@return self
|
[
"Assert",
"that",
"the",
"value",
"matches",
"a",
"given",
"regular",
"expression",
"."
] |
42dac9d0f52fb77b49054b15b8baecca031151dc
|
https://github.com/philliphq/phillip/blob/42dac9d0f52fb77b49054b15b8baecca031151dc/src/Phillip/Assertion.php#L368-L375
|
239,224
|
jaimeeee/laravelpanel
|
src/LaravelPanel/models/HTMLBrick.php
|
HTMLBrick.addClass
|
public function addClass($class)
{
if (isset($this->attr['class'])) {
$classes = explode(' ', $this->attr['class']);
if (!in_array($class, $classes)) {
$classes[] = $class;
}
$this->attr['class'] = implode(' ', $classes);
} else {
$this->attr['class'] = $class;
}
}
|
php
|
public function addClass($class)
{
if (isset($this->attr['class'])) {
$classes = explode(' ', $this->attr['class']);
if (!in_array($class, $classes)) {
$classes[] = $class;
}
$this->attr['class'] = implode(' ', $classes);
} else {
$this->attr['class'] = $class;
}
}
|
[
"public",
"function",
"addClass",
"(",
"$",
"class",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"attr",
"[",
"'class'",
"]",
")",
")",
"{",
"$",
"classes",
"=",
"explode",
"(",
"' '",
",",
"$",
"this",
"->",
"attr",
"[",
"'class'",
"]",
")",
";",
"if",
"(",
"!",
"in_array",
"(",
"$",
"class",
",",
"$",
"classes",
")",
")",
"{",
"$",
"classes",
"[",
"]",
"=",
"$",
"class",
";",
"}",
"$",
"this",
"->",
"attr",
"[",
"'class'",
"]",
"=",
"implode",
"(",
"' '",
",",
"$",
"classes",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"attr",
"[",
"'class'",
"]",
"=",
"$",
"class",
";",
"}",
"}"
] |
Add class to the "class" attribute.
@param string $class Class name
|
[
"Add",
"class",
"to",
"the",
"class",
"attribute",
"."
] |
211599ba0be7dc5ea11af292a75d4104c41512ca
|
https://github.com/jaimeeee/laravelpanel/blob/211599ba0be7dc5ea11af292a75d4104c41512ca/src/LaravelPanel/models/HTMLBrick.php#L40-L52
|
239,225
|
jaimeeee/laravelpanel
|
src/LaravelPanel/models/HTMLBrick.php
|
HTMLBrick.removeClass
|
public function removeClass($class)
{
if (isset($this->attr['class'])) {
$classes = explode(' ', $this->attr['class']);
if (in_array($class, $classes)) {
$classes = array_diff($classes, [$class]);
}
if (empty($classes)) {
unset($this->attr['class']);
} else {
$this->attr['class'] = implode(' ', $classes);
}
}
}
|
php
|
public function removeClass($class)
{
if (isset($this->attr['class'])) {
$classes = explode(' ', $this->attr['class']);
if (in_array($class, $classes)) {
$classes = array_diff($classes, [$class]);
}
if (empty($classes)) {
unset($this->attr['class']);
} else {
$this->attr['class'] = implode(' ', $classes);
}
}
}
|
[
"public",
"function",
"removeClass",
"(",
"$",
"class",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"attr",
"[",
"'class'",
"]",
")",
")",
"{",
"$",
"classes",
"=",
"explode",
"(",
"' '",
",",
"$",
"this",
"->",
"attr",
"[",
"'class'",
"]",
")",
";",
"if",
"(",
"in_array",
"(",
"$",
"class",
",",
"$",
"classes",
")",
")",
"{",
"$",
"classes",
"=",
"array_diff",
"(",
"$",
"classes",
",",
"[",
"$",
"class",
"]",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"classes",
")",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"attr",
"[",
"'class'",
"]",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"attr",
"[",
"'class'",
"]",
"=",
"implode",
"(",
"' '",
",",
"$",
"classes",
")",
";",
"}",
"}",
"}"
] |
Remove class from the "class" attribute.
@param string $class Class to remove
|
[
"Remove",
"class",
"from",
"the",
"class",
"attribute",
"."
] |
211599ba0be7dc5ea11af292a75d4104c41512ca
|
https://github.com/jaimeeee/laravelpanel/blob/211599ba0be7dc5ea11af292a75d4104c41512ca/src/LaravelPanel/models/HTMLBrick.php#L59-L73
|
239,226
|
fzed51/Routeur
|
core/routeur/Route.php
|
Route.setValidations
|
public function setValidations(ArrayObject $validations) {
foreach ($validations as $param => $validation) {
$this->setValidation($param, $validation);
}
return $this;
}
|
php
|
public function setValidations(ArrayObject $validations) {
foreach ($validations as $param => $validation) {
$this->setValidation($param, $validation);
}
return $this;
}
|
[
"public",
"function",
"setValidations",
"(",
"ArrayObject",
"$",
"validations",
")",
"{",
"foreach",
"(",
"$",
"validations",
"as",
"$",
"param",
"=>",
"$",
"validation",
")",
"{",
"$",
"this",
"->",
"setValidation",
"(",
"$",
"param",
",",
"$",
"validation",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
ajoute plusieur validations
@param ArrayObject $validations tableau de prametre => regex de validation
@return Route
|
[
"ajoute",
"plusieur",
"validations"
] |
b23cc1bc0dc06dbb708435bb4406889b8fddba04
|
https://github.com/fzed51/Routeur/blob/b23cc1bc0dc06dbb708435bb4406889b8fddba04/core/routeur/Route.php#L120-L125
|
239,227
|
fzed51/Routeur
|
core/routeur/Route.php
|
Route.setValidation
|
public function setValidation($param, $validation) {
// supprime les parentaises pour eviter les captures innattendus
$validation = \preg_replace('`\((?=[^?][^:])`', '(?:', $validation);
$this->Validations[$param] = $validation;
return $this;
}
|
php
|
public function setValidation($param, $validation) {
// supprime les parentaises pour eviter les captures innattendus
$validation = \preg_replace('`\((?=[^?][^:])`', '(?:', $validation);
$this->Validations[$param] = $validation;
return $this;
}
|
[
"public",
"function",
"setValidation",
"(",
"$",
"param",
",",
"$",
"validation",
")",
"{",
"// supprime les parentaises pour eviter les captures innattendus",
"$",
"validation",
"=",
"\\",
"preg_replace",
"(",
"'`\\((?=[^?][^:])`'",
",",
"'(?:'",
",",
"$",
"validation",
")",
";",
"$",
"this",
"->",
"Validations",
"[",
"$",
"param",
"]",
"=",
"$",
"validation",
";",
"return",
"$",
"this",
";",
"}"
] |
ajoute une validation
@param string $param nom du paramètre
@param string $validation regex de validation
@return Route
|
[
"ajoute",
"une",
"validation"
] |
b23cc1bc0dc06dbb708435bb4406889b8fddba04
|
https://github.com/fzed51/Routeur/blob/b23cc1bc0dc06dbb708435bb4406889b8fddba04/core/routeur/Route.php#L133-L138
|
239,228
|
indigophp-archive/codeception-fuel-module
|
fuel/fuel/packages/oil/tasks/fromdb.php
|
Fromdb.scaffold
|
public static function scaffold($tables = null)
{
// do we have any tables defined?
if (empty($tables))
{
// do we want to generate for all tables?
if ( ! \Cli::option('all', false))
{
\Cli::write('No table names specified to run scaffolding on.', 'red');
exit();
}
// get the list of all available tables
try
{
$list = \DB::list_tables(null, \Cli::option('db', null));
}
catch (\FuelException $e)
{
\Cli::write('The database driver configured does not support listing tables. Please specify them manually.', 'red');
exit();
}
$prefix = \DB::table_prefix();
$migration = \Config::get('migrations.table', 'migration');
$tables = array();
// create the table list
foreach ($list as $table)
{
// strip any defined table prefix from the table name
if ( ! empty($prefix) and strpos($table, $prefix) === 0)
{
$table = substr($table, strlen($prefix));
}
// skip the migration table
$table == $migration or $tables[] = $table;
}
}
// make sure we have an array to work with
is_array($tables) or $tables = explode(',', $tables);
// check what kind of models we need to generate
$subfolder = \Cli::option('crud') ? 'crud' : 'orm';
// generate for each table defined
foreach ($tables as $table)
{
// start with an empty list
\Oil\Generate::$create_files = array();
// and generate
if (\Cli::option('admin', \Cli::option('a', false)))
{
call_user_func('\\Oil\\Generate_Admin::forge', static::arguments($table), $subfolder);
}
else
{
call_user_func('\\Oil\\Generate_Scaffold::forge', static::arguments($table), $subfolder);
}
}
}
|
php
|
public static function scaffold($tables = null)
{
// do we have any tables defined?
if (empty($tables))
{
// do we want to generate for all tables?
if ( ! \Cli::option('all', false))
{
\Cli::write('No table names specified to run scaffolding on.', 'red');
exit();
}
// get the list of all available tables
try
{
$list = \DB::list_tables(null, \Cli::option('db', null));
}
catch (\FuelException $e)
{
\Cli::write('The database driver configured does not support listing tables. Please specify them manually.', 'red');
exit();
}
$prefix = \DB::table_prefix();
$migration = \Config::get('migrations.table', 'migration');
$tables = array();
// create the table list
foreach ($list as $table)
{
// strip any defined table prefix from the table name
if ( ! empty($prefix) and strpos($table, $prefix) === 0)
{
$table = substr($table, strlen($prefix));
}
// skip the migration table
$table == $migration or $tables[] = $table;
}
}
// make sure we have an array to work with
is_array($tables) or $tables = explode(',', $tables);
// check what kind of models we need to generate
$subfolder = \Cli::option('crud') ? 'crud' : 'orm';
// generate for each table defined
foreach ($tables as $table)
{
// start with an empty list
\Oil\Generate::$create_files = array();
// and generate
if (\Cli::option('admin', \Cli::option('a', false)))
{
call_user_func('\\Oil\\Generate_Admin::forge', static::arguments($table), $subfolder);
}
else
{
call_user_func('\\Oil\\Generate_Scaffold::forge', static::arguments($table), $subfolder);
}
}
}
|
[
"public",
"static",
"function",
"scaffold",
"(",
"$",
"tables",
"=",
"null",
")",
"{",
"// do we have any tables defined?",
"if",
"(",
"empty",
"(",
"$",
"tables",
")",
")",
"{",
"// do we want to generate for all tables?",
"if",
"(",
"!",
"\\",
"Cli",
"::",
"option",
"(",
"'all'",
",",
"false",
")",
")",
"{",
"\\",
"Cli",
"::",
"write",
"(",
"'No table names specified to run scaffolding on.'",
",",
"'red'",
")",
";",
"exit",
"(",
")",
";",
"}",
"// get the list of all available tables",
"try",
"{",
"$",
"list",
"=",
"\\",
"DB",
"::",
"list_tables",
"(",
"null",
",",
"\\",
"Cli",
"::",
"option",
"(",
"'db'",
",",
"null",
")",
")",
";",
"}",
"catch",
"(",
"\\",
"FuelException",
"$",
"e",
")",
"{",
"\\",
"Cli",
"::",
"write",
"(",
"'The database driver configured does not support listing tables. Please specify them manually.'",
",",
"'red'",
")",
";",
"exit",
"(",
")",
";",
"}",
"$",
"prefix",
"=",
"\\",
"DB",
"::",
"table_prefix",
"(",
")",
";",
"$",
"migration",
"=",
"\\",
"Config",
"::",
"get",
"(",
"'migrations.table'",
",",
"'migration'",
")",
";",
"$",
"tables",
"=",
"array",
"(",
")",
";",
"// create the table list",
"foreach",
"(",
"$",
"list",
"as",
"$",
"table",
")",
"{",
"// strip any defined table prefix from the table name",
"if",
"(",
"!",
"empty",
"(",
"$",
"prefix",
")",
"and",
"strpos",
"(",
"$",
"table",
",",
"$",
"prefix",
")",
"===",
"0",
")",
"{",
"$",
"table",
"=",
"substr",
"(",
"$",
"table",
",",
"strlen",
"(",
"$",
"prefix",
")",
")",
";",
"}",
"// skip the migration table",
"$",
"table",
"==",
"$",
"migration",
"or",
"$",
"tables",
"[",
"]",
"=",
"$",
"table",
";",
"}",
"}",
"// make sure we have an array to work with",
"is_array",
"(",
"$",
"tables",
")",
"or",
"$",
"tables",
"=",
"explode",
"(",
"','",
",",
"$",
"tables",
")",
";",
"// check what kind of models we need to generate",
"$",
"subfolder",
"=",
"\\",
"Cli",
"::",
"option",
"(",
"'crud'",
")",
"?",
"'crud'",
":",
"'orm'",
";",
"// generate for each table defined",
"foreach",
"(",
"$",
"tables",
"as",
"$",
"table",
")",
"{",
"// start with an empty list",
"\\",
"Oil",
"\\",
"Generate",
"::",
"$",
"create_files",
"=",
"array",
"(",
")",
";",
"// and generate",
"if",
"(",
"\\",
"Cli",
"::",
"option",
"(",
"'admin'",
",",
"\\",
"Cli",
"::",
"option",
"(",
"'a'",
",",
"false",
")",
")",
")",
"{",
"call_user_func",
"(",
"'\\\\Oil\\\\Generate_Admin::forge'",
",",
"static",
"::",
"arguments",
"(",
"$",
"table",
")",
",",
"$",
"subfolder",
")",
";",
"}",
"else",
"{",
"call_user_func",
"(",
"'\\\\Oil\\\\Generate_Scaffold::forge'",
",",
"static",
"::",
"arguments",
"(",
"$",
"table",
")",
",",
"$",
"subfolder",
")",
";",
"}",
"}",
"}"
] |
Generate scaffold for a database table.
Usage (from command line):
php oil refine fromdb:scaffold <table_name,table_name...>
|
[
"Generate",
"scaffold",
"for",
"a",
"database",
"table",
"."
] |
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
|
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/packages/oil/tasks/fromdb.php#L89-L153
|
239,229
|
indigophp-archive/codeception-fuel-module
|
fuel/fuel/packages/oil/tasks/fromdb.php
|
Fromdb.arguments
|
protected static function arguments($table)
{
// get the list of columns from the table
try
{
$columns = \DB::list_columns(trim($table), null, \Cli::option('db', null));
}
catch (\Exception $e)
{
\Cli::write($e->getMessage(), 'red');
exit();
}
// construct the arguments list, starting with the table name
$arguments = array($table);
// set some switches
$include_timestamps = false;
$timestamp_is_int = true;
// process the columns found
foreach ($columns as $column)
{
// do we have a data_type defined? If not, use the generic type
isset($column['data_type']) or $column['data_type'] = $column['type'];
// skip the 'id' column, it will be added automatically
if ($column['name'] == 'id')
{
continue;
}
// detect timestamp columns
if (in_array($column['name'], array('created_at', 'updated_at')))
{
$include_timestamps = true;
$timestamp_is_int = $column['data_type'] == 'int';
continue;
}
// do we need to add constraints?
$constraint = '';
foreach (array('length', 'character_maximum_length', 'display') as $idx)
{
// check if we have such a column, and filter out some default values
if (isset($column[$idx]) and ! in_array($column[$idx], array('65535', '4294967295')))
{
$constraint = '['.$column[$idx].']';
break;
}
}
// if it's an enum column, list the available options
if (in_array($column['data_type'], array('set', 'enum')))
{
$constraint = '['.implode(',', $column['options']).']';
}
// store the column in the argument list
$arguments[] = $column['name'].':'.$column['data_type'].$constraint;
}
// set the switches for the code generation
\Cli::set_option('no-timestamp', $include_timestamps === false);
\Cli::set_option('mysql-timestamp', $timestamp_is_int === false);
// return the generated argument list
return $arguments;
}
|
php
|
protected static function arguments($table)
{
// get the list of columns from the table
try
{
$columns = \DB::list_columns(trim($table), null, \Cli::option('db', null));
}
catch (\Exception $e)
{
\Cli::write($e->getMessage(), 'red');
exit();
}
// construct the arguments list, starting with the table name
$arguments = array($table);
// set some switches
$include_timestamps = false;
$timestamp_is_int = true;
// process the columns found
foreach ($columns as $column)
{
// do we have a data_type defined? If not, use the generic type
isset($column['data_type']) or $column['data_type'] = $column['type'];
// skip the 'id' column, it will be added automatically
if ($column['name'] == 'id')
{
continue;
}
// detect timestamp columns
if (in_array($column['name'], array('created_at', 'updated_at')))
{
$include_timestamps = true;
$timestamp_is_int = $column['data_type'] == 'int';
continue;
}
// do we need to add constraints?
$constraint = '';
foreach (array('length', 'character_maximum_length', 'display') as $idx)
{
// check if we have such a column, and filter out some default values
if (isset($column[$idx]) and ! in_array($column[$idx], array('65535', '4294967295')))
{
$constraint = '['.$column[$idx].']';
break;
}
}
// if it's an enum column, list the available options
if (in_array($column['data_type'], array('set', 'enum')))
{
$constraint = '['.implode(',', $column['options']).']';
}
// store the column in the argument list
$arguments[] = $column['name'].':'.$column['data_type'].$constraint;
}
// set the switches for the code generation
\Cli::set_option('no-timestamp', $include_timestamps === false);
\Cli::set_option('mysql-timestamp', $timestamp_is_int === false);
// return the generated argument list
return $arguments;
}
|
[
"protected",
"static",
"function",
"arguments",
"(",
"$",
"table",
")",
"{",
"// get the list of columns from the table",
"try",
"{",
"$",
"columns",
"=",
"\\",
"DB",
"::",
"list_columns",
"(",
"trim",
"(",
"$",
"table",
")",
",",
"null",
",",
"\\",
"Cli",
"::",
"option",
"(",
"'db'",
",",
"null",
")",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"\\",
"Cli",
"::",
"write",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"'red'",
")",
";",
"exit",
"(",
")",
";",
"}",
"// construct the arguments list, starting with the table name",
"$",
"arguments",
"=",
"array",
"(",
"$",
"table",
")",
";",
"// set some switches",
"$",
"include_timestamps",
"=",
"false",
";",
"$",
"timestamp_is_int",
"=",
"true",
";",
"// process the columns found",
"foreach",
"(",
"$",
"columns",
"as",
"$",
"column",
")",
"{",
"// do we have a data_type defined? If not, use the generic type",
"isset",
"(",
"$",
"column",
"[",
"'data_type'",
"]",
")",
"or",
"$",
"column",
"[",
"'data_type'",
"]",
"=",
"$",
"column",
"[",
"'type'",
"]",
";",
"// skip the 'id' column, it will be added automatically",
"if",
"(",
"$",
"column",
"[",
"'name'",
"]",
"==",
"'id'",
")",
"{",
"continue",
";",
"}",
"// detect timestamp columns",
"if",
"(",
"in_array",
"(",
"$",
"column",
"[",
"'name'",
"]",
",",
"array",
"(",
"'created_at'",
",",
"'updated_at'",
")",
")",
")",
"{",
"$",
"include_timestamps",
"=",
"true",
";",
"$",
"timestamp_is_int",
"=",
"$",
"column",
"[",
"'data_type'",
"]",
"==",
"'int'",
";",
"continue",
";",
"}",
"// do we need to add constraints?",
"$",
"constraint",
"=",
"''",
";",
"foreach",
"(",
"array",
"(",
"'length'",
",",
"'character_maximum_length'",
",",
"'display'",
")",
"as",
"$",
"idx",
")",
"{",
"// check if we have such a column, and filter out some default values",
"if",
"(",
"isset",
"(",
"$",
"column",
"[",
"$",
"idx",
"]",
")",
"and",
"!",
"in_array",
"(",
"$",
"column",
"[",
"$",
"idx",
"]",
",",
"array",
"(",
"'65535'",
",",
"'4294967295'",
")",
")",
")",
"{",
"$",
"constraint",
"=",
"'['",
".",
"$",
"column",
"[",
"$",
"idx",
"]",
".",
"']'",
";",
"break",
";",
"}",
"}",
"// if it's an enum column, list the available options",
"if",
"(",
"in_array",
"(",
"$",
"column",
"[",
"'data_type'",
"]",
",",
"array",
"(",
"'set'",
",",
"'enum'",
")",
")",
")",
"{",
"$",
"constraint",
"=",
"'['",
".",
"implode",
"(",
"','",
",",
"$",
"column",
"[",
"'options'",
"]",
")",
".",
"']'",
";",
"}",
"// store the column in the argument list",
"$",
"arguments",
"[",
"]",
"=",
"$",
"column",
"[",
"'name'",
"]",
".",
"':'",
".",
"$",
"column",
"[",
"'data_type'",
"]",
".",
"$",
"constraint",
";",
"}",
"// set the switches for the code generation",
"\\",
"Cli",
"::",
"set_option",
"(",
"'no-timestamp'",
",",
"$",
"include_timestamps",
"===",
"false",
")",
";",
"\\",
"Cli",
"::",
"set_option",
"(",
"'mysql-timestamp'",
",",
"$",
"timestamp_is_int",
"===",
"false",
")",
";",
"// return the generated argument list",
"return",
"$",
"arguments",
";",
"}"
] |
Construct the argument list
@param string $table name of the database table we need to create the list for
@return array
|
[
"Construct",
"the",
"argument",
"list"
] |
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
|
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/packages/oil/tasks/fromdb.php#L225-L292
|
239,230
|
jmpantoja/planb-utils
|
src/DS/Set/Set.php
|
Set.typed
|
public static function typed(string $type, iterable $input = []): Set
{
$resolver = Resolver::typed($type);
return new static($input, $resolver);
}
|
php
|
public static function typed(string $type, iterable $input = []): Set
{
$resolver = Resolver::typed($type);
return new static($input, $resolver);
}
|
[
"public",
"static",
"function",
"typed",
"(",
"string",
"$",
"type",
",",
"iterable",
"$",
"input",
"=",
"[",
"]",
")",
":",
"Set",
"{",
"$",
"resolver",
"=",
"Resolver",
"::",
"typed",
"(",
"$",
"type",
")",
";",
"return",
"new",
"static",
"(",
"$",
"input",
",",
"$",
"resolver",
")",
";",
"}"
] |
Set named constructor.
@param string $type
@param mixed[] $input
@return \PlanB\DS\Set\Set
|
[
"Set",
"named",
"constructor",
"."
] |
d17fbced4a285275928f8428ee56e269eb851690
|
https://github.com/jmpantoja/planb-utils/blob/d17fbced4a285275928f8428ee56e269eb851690/src/DS/Set/Set.php#L45-L50
|
239,231
|
kiler129/Shout
|
src/Shout.php
|
Shout.flush
|
public function flush()
{
if (!$this->config["blocking"] && !empty($this->asyncBuffer)) {
$wrote = fwrite($this->destinationHandler, $this->asyncBuffer);
$this->asyncBuffer = substr($this->asyncBuffer, $wrote);
}
return empty($this->asyncBuffer);
}
|
php
|
public function flush()
{
if (!$this->config["blocking"] && !empty($this->asyncBuffer)) {
$wrote = fwrite($this->destinationHandler, $this->asyncBuffer);
$this->asyncBuffer = substr($this->asyncBuffer, $wrote);
}
return empty($this->asyncBuffer);
}
|
[
"public",
"function",
"flush",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"config",
"[",
"\"blocking\"",
"]",
"&&",
"!",
"empty",
"(",
"$",
"this",
"->",
"asyncBuffer",
")",
")",
"{",
"$",
"wrote",
"=",
"fwrite",
"(",
"$",
"this",
"->",
"destinationHandler",
",",
"$",
"this",
"->",
"asyncBuffer",
")",
";",
"$",
"this",
"->",
"asyncBuffer",
"=",
"substr",
"(",
"$",
"this",
"->",
"asyncBuffer",
",",
"$",
"wrote",
")",
";",
"}",
"return",
"empty",
"(",
"$",
"this",
"->",
"asyncBuffer",
")",
";",
"}"
] |
Forces pushing remaining data from buffer to destination.
This method only makes sense in non-blocking mode.
@return bool
|
[
"Forces",
"pushing",
"remaining",
"data",
"from",
"buffer",
"to",
"destination",
".",
"This",
"method",
"only",
"makes",
"sense",
"in",
"non",
"-",
"blocking",
"mode",
"."
] |
604d143fd98ee5d3c7f1c3c869f9249bac9f90ec
|
https://github.com/kiler129/Shout/blob/604d143fd98ee5d3c7f1c3c869f9249bac9f90ec/src/Shout.php#L146-L154
|
239,232
|
kiler129/Shout
|
src/Shout.php
|
Shout.rotate
|
public function rotate($resetTimer = true)
{
if (!$this->config["blocking"]) {
while (!empty($this->asyncBuffer)) {
$this->flush();
}
}
if ($resetTimer) {
$this->lastRotationTime = time();
}
$this->log(self::INFO, "Rotating log file...");
fclose($this->destinationHandler);
$this->createFileHandler();
}
|
php
|
public function rotate($resetTimer = true)
{
if (!$this->config["blocking"]) {
while (!empty($this->asyncBuffer)) {
$this->flush();
}
}
if ($resetTimer) {
$this->lastRotationTime = time();
}
$this->log(self::INFO, "Rotating log file...");
fclose($this->destinationHandler);
$this->createFileHandler();
}
|
[
"public",
"function",
"rotate",
"(",
"$",
"resetTimer",
"=",
"true",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"config",
"[",
"\"blocking\"",
"]",
")",
"{",
"while",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"asyncBuffer",
")",
")",
"{",
"$",
"this",
"->",
"flush",
"(",
")",
";",
"}",
"}",
"if",
"(",
"$",
"resetTimer",
")",
"{",
"$",
"this",
"->",
"lastRotationTime",
"=",
"time",
"(",
")",
";",
"}",
"$",
"this",
"->",
"log",
"(",
"self",
"::",
"INFO",
",",
"\"Rotating log file...\"",
")",
";",
"fclose",
"(",
"$",
"this",
"->",
"destinationHandler",
")",
";",
"$",
"this",
"->",
"createFileHandler",
"(",
")",
";",
"}"
] |
Rotate log file
@param bool $resetTimer
@throws RuntimeException Thrown if new file cannot be opened for write
|
[
"Rotate",
"log",
"file"
] |
604d143fd98ee5d3c7f1c3c869f9249bac9f90ec
|
https://github.com/kiler129/Shout/blob/604d143fd98ee5d3c7f1c3c869f9249bac9f90ec/src/Shout.php#L220-L235
|
239,233
|
kiler129/Shout
|
src/Shout.php
|
Shout.setMaximumLogLevel
|
public function setMaximumLogLevel($level)
{
if ($level !== null && !is_numeric($level)) {
throw new InvalidArgumentException("Maximum log level must be a number or null");
}
$this->config["maximumLogLevel"] = $level;
}
|
php
|
public function setMaximumLogLevel($level)
{
if ($level !== null && !is_numeric($level)) {
throw new InvalidArgumentException("Maximum log level must be a number or null");
}
$this->config["maximumLogLevel"] = $level;
}
|
[
"public",
"function",
"setMaximumLogLevel",
"(",
"$",
"level",
")",
"{",
"if",
"(",
"$",
"level",
"!==",
"null",
"&&",
"!",
"is_numeric",
"(",
"$",
"level",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"Maximum log level must be a number or null\"",
")",
";",
"}",
"$",
"this",
"->",
"config",
"[",
"\"maximumLogLevel\"",
"]",
"=",
"$",
"level",
";",
"}"
] |
Every log level contains it's numeric value (default ones are defined by `Table 2. Syslog Message Severities` of
RFC 5424.
This method allows to specify maximum log level delivered to destination, eg. if you set it to 1 only ALERT and
EMERGENCY message will pass.
@param number $level Any numeric value
@throws InvalidArgumentException Non-numeric level passed
|
[
"Every",
"log",
"level",
"contains",
"it",
"s",
"numeric",
"value",
"(",
"default",
"ones",
"are",
"defined",
"by",
"Table",
"2",
".",
"Syslog",
"Message",
"Severities",
"of",
"RFC",
"5424",
".",
"This",
"method",
"allows",
"to",
"specify",
"maximum",
"log",
"level",
"delivered",
"to",
"destination",
"eg",
".",
"if",
"you",
"set",
"it",
"to",
"1",
"only",
"ALERT",
"and",
"EMERGENCY",
"message",
"will",
"pass",
"."
] |
604d143fd98ee5d3c7f1c3c869f9249bac9f90ec
|
https://github.com/kiler129/Shout/blob/604d143fd98ee5d3c7f1c3c869f9249bac9f90ec/src/Shout.php#L339-L346
|
239,234
|
atelierspierrot/git-api
|
src/GitApi/Repository.php
|
Repository.run
|
public function run($command)
{
return $this->getGitConsole()->run(GitApi::getBin()." ".$command, $this->getRepositoryPath());
}
|
php
|
public function run($command)
{
return $this->getGitConsole()->run(GitApi::getBin()." ".$command, $this->getRepositoryPath());
}
|
[
"public",
"function",
"run",
"(",
"$",
"command",
")",
"{",
"return",
"$",
"this",
"->",
"getGitConsole",
"(",
")",
"->",
"run",
"(",
"GitApi",
"::",
"getBin",
"(",
")",
".",
"\" \"",
".",
"$",
"command",
",",
"$",
"this",
"->",
"getRepositoryPath",
"(",
")",
")",
";",
"}"
] |
Run a git command in the git repository
@param string $command
@return string
|
[
"Run",
"a",
"git",
"command",
"in",
"the",
"git",
"repository"
] |
ff15816650274a66077c0a55257fa99c9d7bcf8c
|
https://github.com/atelierspierrot/git-api/blob/ff15816650274a66077c0a55257fa99c9d7bcf8c/src/GitApi/Repository.php#L224-L227
|
239,235
|
atelierspierrot/git-api
|
src/GitApi/Repository.php
|
Repository.getBranchesList
|
public function getBranchesList($keep_asterisk = false)
{
$branchArray = explode("\n", $this->run("branch"));
foreach ($branchArray as $i => &$branch) {
$branch = trim($branch);
if (! $keep_asterisk) {
$branch = str_replace("* ", "", $branch);
}
if ($branch == "") {
unset($branchArray[$i]);
}
}
return $branchArray;
}
|
php
|
public function getBranchesList($keep_asterisk = false)
{
$branchArray = explode("\n", $this->run("branch"));
foreach ($branchArray as $i => &$branch) {
$branch = trim($branch);
if (! $keep_asterisk) {
$branch = str_replace("* ", "", $branch);
}
if ($branch == "") {
unset($branchArray[$i]);
}
}
return $branchArray;
}
|
[
"public",
"function",
"getBranchesList",
"(",
"$",
"keep_asterisk",
"=",
"false",
")",
"{",
"$",
"branchArray",
"=",
"explode",
"(",
"\"\\n\"",
",",
"$",
"this",
"->",
"run",
"(",
"\"branch\"",
")",
")",
";",
"foreach",
"(",
"$",
"branchArray",
"as",
"$",
"i",
"=>",
"&",
"$",
"branch",
")",
"{",
"$",
"branch",
"=",
"trim",
"(",
"$",
"branch",
")",
";",
"if",
"(",
"!",
"$",
"keep_asterisk",
")",
"{",
"$",
"branch",
"=",
"str_replace",
"(",
"\"* \"",
",",
"\"\"",
",",
"$",
"branch",
")",
";",
"}",
"if",
"(",
"$",
"branch",
"==",
"\"\"",
")",
"{",
"unset",
"(",
"$",
"branchArray",
"[",
"$",
"i",
"]",
")",
";",
"}",
"}",
"return",
"$",
"branchArray",
";",
"}"
] |
Runs a `git branch` call
@param bool $keep_asterisk keep asterisk mark on active branch
@return array
|
[
"Runs",
"a",
"git",
"branch",
"call"
] |
ff15816650274a66077c0a55257fa99c9d7bcf8c
|
https://github.com/atelierspierrot/git-api/blob/ff15816650274a66077c0a55257fa99c9d7bcf8c/src/GitApi/Repository.php#L697-L710
|
239,236
|
vinala/kernel
|
src/Lumos/Commands.php
|
Commands.anatomy
|
protected function anatomy()
{
$this->members = Strings::splite($this->key, ' ');
$this->command = $this->members[0];
//
$y = '';
for ($i = 1; $i < count($this->members); $i++) {
$y .= $this->members[$i].' ';
}
//
$rest2 = [];
$rest = Strings::splite($y, '} ');
for ($i = 0; $i < count($rest) - 1; $i++) {
$rest2[] = $rest[$i].'}';
}
//
$this->members = $rest2;
return $this->members;
}
|
php
|
protected function anatomy()
{
$this->members = Strings::splite($this->key, ' ');
$this->command = $this->members[0];
//
$y = '';
for ($i = 1; $i < count($this->members); $i++) {
$y .= $this->members[$i].' ';
}
//
$rest2 = [];
$rest = Strings::splite($y, '} ');
for ($i = 0; $i < count($rest) - 1; $i++) {
$rest2[] = $rest[$i].'}';
}
//
$this->members = $rest2;
return $this->members;
}
|
[
"protected",
"function",
"anatomy",
"(",
")",
"{",
"$",
"this",
"->",
"members",
"=",
"Strings",
"::",
"splite",
"(",
"$",
"this",
"->",
"key",
",",
"' '",
")",
";",
"$",
"this",
"->",
"command",
"=",
"$",
"this",
"->",
"members",
"[",
"0",
"]",
";",
"//",
"$",
"y",
"=",
"''",
";",
"for",
"(",
"$",
"i",
"=",
"1",
";",
"$",
"i",
"<",
"count",
"(",
"$",
"this",
"->",
"members",
")",
";",
"$",
"i",
"++",
")",
"{",
"$",
"y",
".=",
"$",
"this",
"->",
"members",
"[",
"$",
"i",
"]",
".",
"' '",
";",
"}",
"//",
"$",
"rest2",
"=",
"[",
"]",
";",
"$",
"rest",
"=",
"Strings",
"::",
"splite",
"(",
"$",
"y",
",",
"'} '",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"count",
"(",
"$",
"rest",
")",
"-",
"1",
";",
"$",
"i",
"++",
")",
"{",
"$",
"rest2",
"[",
"]",
"=",
"$",
"rest",
"[",
"$",
"i",
"]",
".",
"'}'",
";",
"}",
"//",
"$",
"this",
"->",
"members",
"=",
"$",
"rest2",
";",
"return",
"$",
"this",
"->",
"members",
";",
"}"
] |
Set members including command and args and options.
@return array
|
[
"Set",
"members",
"including",
"command",
"and",
"args",
"and",
"options",
"."
] |
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
|
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Lumos/Commands.php#L173-L192
|
239,237
|
vinala/kernel
|
src/Lumos/Commands.php
|
Commands.params
|
protected function params()
{
$params = [];
//
for ($i = 0; $i < count($this->members); $i++) {
$params[] = $this->members[$i];
}
//
$this->params = $params;
return $params;
}
|
php
|
protected function params()
{
$params = [];
//
for ($i = 0; $i < count($this->members); $i++) {
$params[] = $this->members[$i];
}
//
$this->params = $params;
return $params;
}
|
[
"protected",
"function",
"params",
"(",
")",
"{",
"$",
"params",
"=",
"[",
"]",
";",
"//",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"count",
"(",
"$",
"this",
"->",
"members",
")",
";",
"$",
"i",
"++",
")",
"{",
"$",
"params",
"[",
"]",
"=",
"$",
"this",
"->",
"members",
"[",
"$",
"i",
"]",
";",
"}",
"//",
"$",
"this",
"->",
"params",
"=",
"$",
"params",
";",
"return",
"$",
"params",
";",
"}"
] |
get the params from members.
|
[
"get",
"the",
"params",
"from",
"members",
"."
] |
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
|
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Lumos/Commands.php#L197-L208
|
239,238
|
vinala/kernel
|
src/Lumos/Commands.php
|
Commands.setParams
|
protected function setParams()
{
$this->params();
//
foreach ($this->params as $key => $value) {
$cont = $this->strip($value);
//
if (Strings::length($cont) > 2) {
if ($cont[0] == '-' && $cont[1] == '-') {
$this->setOption($cont);
} elseif ($cont[0] != '-' && $cont[1] != '-') {
$this->setArgument($cont);
}
} else {
$this->setArgument($cont);
}
}
}
|
php
|
protected function setParams()
{
$this->params();
//
foreach ($this->params as $key => $value) {
$cont = $this->strip($value);
//
if (Strings::length($cont) > 2) {
if ($cont[0] == '-' && $cont[1] == '-') {
$this->setOption($cont);
} elseif ($cont[0] != '-' && $cont[1] != '-') {
$this->setArgument($cont);
}
} else {
$this->setArgument($cont);
}
}
}
|
[
"protected",
"function",
"setParams",
"(",
")",
"{",
"$",
"this",
"->",
"params",
"(",
")",
";",
"//",
"foreach",
"(",
"$",
"this",
"->",
"params",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"cont",
"=",
"$",
"this",
"->",
"strip",
"(",
"$",
"value",
")",
";",
"//",
"if",
"(",
"Strings",
"::",
"length",
"(",
"$",
"cont",
")",
">",
"2",
")",
"{",
"if",
"(",
"$",
"cont",
"[",
"0",
"]",
"==",
"'-'",
"&&",
"$",
"cont",
"[",
"1",
"]",
"==",
"'-'",
")",
"{",
"$",
"this",
"->",
"setOption",
"(",
"$",
"cont",
")",
";",
"}",
"elseif",
"(",
"$",
"cont",
"[",
"0",
"]",
"!=",
"'-'",
"&&",
"$",
"cont",
"[",
"1",
"]",
"!=",
"'-'",
")",
"{",
"$",
"this",
"->",
"setArgument",
"(",
"$",
"cont",
")",
";",
"}",
"}",
"else",
"{",
"$",
"this",
"->",
"setArgument",
"(",
"$",
"cont",
")",
";",
"}",
"}",
"}"
] |
set the args and options.
|
[
"set",
"the",
"args",
"and",
"options",
"."
] |
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
|
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Lumos/Commands.php#L229-L246
|
239,239
|
vinala/kernel
|
src/Lumos/Commands.php
|
Commands.setArgument
|
protected function setArgument($arg)
{
if ($this->checkDiscription($arg)) {
$this->advanceArg($arg);
} else {
$this->simpleArg($arg);
}
}
|
php
|
protected function setArgument($arg)
{
if ($this->checkDiscription($arg)) {
$this->advanceArg($arg);
} else {
$this->simpleArg($arg);
}
}
|
[
"protected",
"function",
"setArgument",
"(",
"$",
"arg",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"checkDiscription",
"(",
"$",
"arg",
")",
")",
"{",
"$",
"this",
"->",
"advanceArg",
"(",
"$",
"arg",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"simpleArg",
"(",
"$",
"arg",
")",
";",
"}",
"}"
] |
set the args and check if ther is description.
|
[
"set",
"the",
"args",
"and",
"check",
"if",
"ther",
"is",
"description",
"."
] |
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
|
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Lumos/Commands.php#L251-L258
|
239,240
|
vinala/kernel
|
src/Lumos/Commands.php
|
Commands.simpleArg
|
protected function simpleArg($key, $desc = '')
{
if ($this->isOption($key)) {
$name = substr($key, 0, -1);
$this->addArgument($name, InputArgument::OPTIONAL, $desc);
$this->addArgumentInput($name, InputArgument::OPTIONAL, $desc);
} else {
$this->addArgument($key, InputArgument::REQUIRED, $desc);
$this->addArgumentInput($key, InputArgument::REQUIRED, $desc);
}
}
|
php
|
protected function simpleArg($key, $desc = '')
{
if ($this->isOption($key)) {
$name = substr($key, 0, -1);
$this->addArgument($name, InputArgument::OPTIONAL, $desc);
$this->addArgumentInput($name, InputArgument::OPTIONAL, $desc);
} else {
$this->addArgument($key, InputArgument::REQUIRED, $desc);
$this->addArgumentInput($key, InputArgument::REQUIRED, $desc);
}
}
|
[
"protected",
"function",
"simpleArg",
"(",
"$",
"key",
",",
"$",
"desc",
"=",
"''",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isOption",
"(",
"$",
"key",
")",
")",
"{",
"$",
"name",
"=",
"substr",
"(",
"$",
"key",
",",
"0",
",",
"-",
"1",
")",
";",
"$",
"this",
"->",
"addArgument",
"(",
"$",
"name",
",",
"InputArgument",
"::",
"OPTIONAL",
",",
"$",
"desc",
")",
";",
"$",
"this",
"->",
"addArgumentInput",
"(",
"$",
"name",
",",
"InputArgument",
"::",
"OPTIONAL",
",",
"$",
"desc",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"addArgument",
"(",
"$",
"key",
",",
"InputArgument",
"::",
"REQUIRED",
",",
"$",
"desc",
")",
";",
"$",
"this",
"->",
"addArgumentInput",
"(",
"$",
"key",
",",
"InputArgument",
"::",
"REQUIRED",
",",
"$",
"desc",
")",
";",
"}",
"}"
] |
set simple arg with optional description.
|
[
"set",
"simple",
"arg",
"with",
"optional",
"description",
"."
] |
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
|
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Lumos/Commands.php#L271-L281
|
239,241
|
vinala/kernel
|
src/Lumos/Commands.php
|
Commands.advanceArg
|
protected function advanceArg($key)
{
$data = Strings::splite($key, ' : ');
//
$arg = $data[0];
$desc = $data[1];
//
$this->simpleArg($arg, $desc);
}
|
php
|
protected function advanceArg($key)
{
$data = Strings::splite($key, ' : ');
//
$arg = $data[0];
$desc = $data[1];
//
$this->simpleArg($arg, $desc);
}
|
[
"protected",
"function",
"advanceArg",
"(",
"$",
"key",
")",
"{",
"$",
"data",
"=",
"Strings",
"::",
"splite",
"(",
"$",
"key",
",",
"' : '",
")",
";",
"//",
"$",
"arg",
"=",
"$",
"data",
"[",
"0",
"]",
";",
"$",
"desc",
"=",
"$",
"data",
"[",
"1",
"]",
";",
"//",
"$",
"this",
"->",
"simpleArg",
"(",
"$",
"arg",
",",
"$",
"desc",
")",
";",
"}"
] |
set advanced arg with required description.
|
[
"set",
"advanced",
"arg",
"with",
"required",
"description",
"."
] |
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
|
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Lumos/Commands.php#L286-L294
|
239,242
|
vinala/kernel
|
src/Lumos/Commands.php
|
Commands.addArgumentInput
|
protected function addArgumentInput($name, $requirement, $description = '')
{
$this->inputs[] = new Argument($name, $requirement, $description);
}
|
php
|
protected function addArgumentInput($name, $requirement, $description = '')
{
$this->inputs[] = new Argument($name, $requirement, $description);
}
|
[
"protected",
"function",
"addArgumentInput",
"(",
"$",
"name",
",",
"$",
"requirement",
",",
"$",
"description",
"=",
"''",
")",
"{",
"$",
"this",
"->",
"inputs",
"[",
"]",
"=",
"new",
"Argument",
"(",
"$",
"name",
",",
"$",
"requirement",
",",
"$",
"description",
")",
";",
"}"
] |
add ARgument to inputs array.
|
[
"add",
"ARgument",
"to",
"inputs",
"array",
"."
] |
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
|
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Lumos/Commands.php#L299-L302
|
239,243
|
vinala/kernel
|
src/Lumos/Commands.php
|
Commands.setOption
|
protected function setOption($opt)
{
if ($this->checkDiscription($opt)) {
$this->advanceOpt($opt);
} else {
$this->simpleOpt($opt);
}
}
|
php
|
protected function setOption($opt)
{
if ($this->checkDiscription($opt)) {
$this->advanceOpt($opt);
} else {
$this->simpleOpt($opt);
}
}
|
[
"protected",
"function",
"setOption",
"(",
"$",
"opt",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"checkDiscription",
"(",
"$",
"opt",
")",
")",
"{",
"$",
"this",
"->",
"advanceOpt",
"(",
"$",
"opt",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"simpleOpt",
"(",
"$",
"opt",
")",
";",
"}",
"}"
] |
check if ther is description.
|
[
"check",
"if",
"ther",
"is",
"description",
"."
] |
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
|
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Lumos/Commands.php#L315-L322
|
239,244
|
vinala/kernel
|
src/Lumos/Commands.php
|
Commands.simpleOpt
|
protected function simpleOpt($opt, $disc = '')
{
$type = $this->getOptionType($opt);
$key = $this->stripOpt($opt);
//
if ($type == self::REQUIRED) {
$key = substr($key, 0, -1);
$this->addOption($key, null, InputOption::VALUE_REQUIRED, $disc);
$this->addOptionInput($key, InputOption::VALUE_REQUIRED, $disc);
} elseif ($type == self::OPTIONAL) {
$this->addOption($key, null, InputOption::VALUE_NONE, $disc);
$this->addOptionInput($key, InputOption::VALUE_NONE, $disc);
} elseif ($type == self::VALUE) {
$value = $this->getOptionalValue($key);
//
$key = $this->getOptionalKeyValue($key);
//
$this->addOption($key, null, InputOption::VALUE_OPTIONAL, $disc, $value);
$this->addOptionInput($key, InputOption::VALUE_OPTIONAL, $disc, $value);
}
}
|
php
|
protected function simpleOpt($opt, $disc = '')
{
$type = $this->getOptionType($opt);
$key = $this->stripOpt($opt);
//
if ($type == self::REQUIRED) {
$key = substr($key, 0, -1);
$this->addOption($key, null, InputOption::VALUE_REQUIRED, $disc);
$this->addOptionInput($key, InputOption::VALUE_REQUIRED, $disc);
} elseif ($type == self::OPTIONAL) {
$this->addOption($key, null, InputOption::VALUE_NONE, $disc);
$this->addOptionInput($key, InputOption::VALUE_NONE, $disc);
} elseif ($type == self::VALUE) {
$value = $this->getOptionalValue($key);
//
$key = $this->getOptionalKeyValue($key);
//
$this->addOption($key, null, InputOption::VALUE_OPTIONAL, $disc, $value);
$this->addOptionInput($key, InputOption::VALUE_OPTIONAL, $disc, $value);
}
}
|
[
"protected",
"function",
"simpleOpt",
"(",
"$",
"opt",
",",
"$",
"disc",
"=",
"''",
")",
"{",
"$",
"type",
"=",
"$",
"this",
"->",
"getOptionType",
"(",
"$",
"opt",
")",
";",
"$",
"key",
"=",
"$",
"this",
"->",
"stripOpt",
"(",
"$",
"opt",
")",
";",
"//",
"if",
"(",
"$",
"type",
"==",
"self",
"::",
"REQUIRED",
")",
"{",
"$",
"key",
"=",
"substr",
"(",
"$",
"key",
",",
"0",
",",
"-",
"1",
")",
";",
"$",
"this",
"->",
"addOption",
"(",
"$",
"key",
",",
"null",
",",
"InputOption",
"::",
"VALUE_REQUIRED",
",",
"$",
"disc",
")",
";",
"$",
"this",
"->",
"addOptionInput",
"(",
"$",
"key",
",",
"InputOption",
"::",
"VALUE_REQUIRED",
",",
"$",
"disc",
")",
";",
"}",
"elseif",
"(",
"$",
"type",
"==",
"self",
"::",
"OPTIONAL",
")",
"{",
"$",
"this",
"->",
"addOption",
"(",
"$",
"key",
",",
"null",
",",
"InputOption",
"::",
"VALUE_NONE",
",",
"$",
"disc",
")",
";",
"$",
"this",
"->",
"addOptionInput",
"(",
"$",
"key",
",",
"InputOption",
"::",
"VALUE_NONE",
",",
"$",
"disc",
")",
";",
"}",
"elseif",
"(",
"$",
"type",
"==",
"self",
"::",
"VALUE",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"getOptionalValue",
"(",
"$",
"key",
")",
";",
"//",
"$",
"key",
"=",
"$",
"this",
"->",
"getOptionalKeyValue",
"(",
"$",
"key",
")",
";",
"//",
"$",
"this",
"->",
"addOption",
"(",
"$",
"key",
",",
"null",
",",
"InputOption",
"::",
"VALUE_OPTIONAL",
",",
"$",
"disc",
",",
"$",
"value",
")",
";",
"$",
"this",
"->",
"addOptionInput",
"(",
"$",
"key",
",",
"InputOption",
"::",
"VALUE_OPTIONAL",
",",
"$",
"disc",
",",
"$",
"value",
")",
";",
"}",
"}"
] |
set simple option with optional description.
|
[
"set",
"simple",
"option",
"with",
"optional",
"description",
"."
] |
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
|
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Lumos/Commands.php#L327-L347
|
239,245
|
vinala/kernel
|
src/Lumos/Commands.php
|
Commands.advanceOpt
|
protected function advanceOpt($opt)
{
$data = Strings::splite($opt, ' : ');
//
$opt = $data[0];
$disc = $data[1];
//
$this->simpleOpt($opt, $disc);
}
|
php
|
protected function advanceOpt($opt)
{
$data = Strings::splite($opt, ' : ');
//
$opt = $data[0];
$disc = $data[1];
//
$this->simpleOpt($opt, $disc);
}
|
[
"protected",
"function",
"advanceOpt",
"(",
"$",
"opt",
")",
"{",
"$",
"data",
"=",
"Strings",
"::",
"splite",
"(",
"$",
"opt",
",",
"' : '",
")",
";",
"//",
"$",
"opt",
"=",
"$",
"data",
"[",
"0",
"]",
";",
"$",
"disc",
"=",
"$",
"data",
"[",
"1",
"]",
";",
"//",
"$",
"this",
"->",
"simpleOpt",
"(",
"$",
"opt",
",",
"$",
"disc",
")",
";",
"}"
] |
set advanced option with optional description.
|
[
"set",
"advanced",
"option",
"with",
"optional",
"description",
"."
] |
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
|
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Lumos/Commands.php#L352-L360
|
239,246
|
vinala/kernel
|
src/Lumos/Commands.php
|
Commands.addOptionInput
|
protected function addOptionInput($name, $requirement = null, $description = '', $value = null)
{
$this->inputs[] = new Option($name, $requirement, $description, $value);
}
|
php
|
protected function addOptionInput($name, $requirement = null, $description = '', $value = null)
{
$this->inputs[] = new Option($name, $requirement, $description, $value);
}
|
[
"protected",
"function",
"addOptionInput",
"(",
"$",
"name",
",",
"$",
"requirement",
"=",
"null",
",",
"$",
"description",
"=",
"''",
",",
"$",
"value",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"inputs",
"[",
"]",
"=",
"new",
"Option",
"(",
"$",
"name",
",",
"$",
"requirement",
",",
"$",
"description",
",",
"$",
"value",
")",
";",
"}"
] |
add Option to inputs array.
|
[
"add",
"Option",
"to",
"inputs",
"array",
"."
] |
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
|
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Lumos/Commands.php#L365-L368
|
239,247
|
vinala/kernel
|
src/Lumos/Commands.php
|
Commands.getOptionType
|
protected function getOptionType($opt)
{
if (substr($opt, -1) == '=') {
return self::REQUIRED;
} elseif (Strings::contains($opt, '=')) {
return self::VALUE;
} else {
return self::OPTIONAL;
}
}
|
php
|
protected function getOptionType($opt)
{
if (substr($opt, -1) == '=') {
return self::REQUIRED;
} elseif (Strings::contains($opt, '=')) {
return self::VALUE;
} else {
return self::OPTIONAL;
}
}
|
[
"protected",
"function",
"getOptionType",
"(",
"$",
"opt",
")",
"{",
"if",
"(",
"substr",
"(",
"$",
"opt",
",",
"-",
"1",
")",
"==",
"'='",
")",
"{",
"return",
"self",
"::",
"REQUIRED",
";",
"}",
"elseif",
"(",
"Strings",
"::",
"contains",
"(",
"$",
"opt",
",",
"'='",
")",
")",
"{",
"return",
"self",
"::",
"VALUE",
";",
"}",
"else",
"{",
"return",
"self",
"::",
"OPTIONAL",
";",
"}",
"}"
] |
get the type of the option.
|
[
"get",
"the",
"type",
"of",
"the",
"option",
"."
] |
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
|
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Lumos/Commands.php#L405-L414
|
239,248
|
vinala/kernel
|
src/Lumos/Commands.php
|
Commands.info
|
public function info($text, $sameLine = false)
{
$output = $this->console->info($text);
//
if ($sameLine) {
$this->console->write($output);
} else {
$this->console->line($output);
}
}
|
php
|
public function info($text, $sameLine = false)
{
$output = $this->console->info($text);
//
if ($sameLine) {
$this->console->write($output);
} else {
$this->console->line($output);
}
}
|
[
"public",
"function",
"info",
"(",
"$",
"text",
",",
"$",
"sameLine",
"=",
"false",
")",
"{",
"$",
"output",
"=",
"$",
"this",
"->",
"console",
"->",
"info",
"(",
"$",
"text",
")",
";",
"//",
"if",
"(",
"$",
"sameLine",
")",
"{",
"$",
"this",
"->",
"console",
"->",
"write",
"(",
"$",
"output",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"console",
"->",
"line",
"(",
"$",
"output",
")",
";",
"}",
"}"
] |
to write text in green color in the console.
|
[
"to",
"write",
"text",
"in",
"green",
"color",
"in",
"the",
"console",
"."
] |
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
|
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Lumos/Commands.php#L455-L464
|
239,249
|
vinala/kernel
|
src/Lumos/Commands.php
|
Commands.title
|
public function title($sub = '', $title = 'Vinala Lumos')
{
if ($title != '') {
$this->console->line("\n".$title);
//
$underline = '';
for ($i = 0; $i < strlen($title); $i++) {
$underline .= '=';
}
//
$this->console->line($underline);
}
//
if ($sub != '') {
$this->console->line("\n".$sub);
}
}
|
php
|
public function title($sub = '', $title = 'Vinala Lumos')
{
if ($title != '') {
$this->console->line("\n".$title);
//
$underline = '';
for ($i = 0; $i < strlen($title); $i++) {
$underline .= '=';
}
//
$this->console->line($underline);
}
//
if ($sub != '') {
$this->console->line("\n".$sub);
}
}
|
[
"public",
"function",
"title",
"(",
"$",
"sub",
"=",
"''",
",",
"$",
"title",
"=",
"'Vinala Lumos'",
")",
"{",
"if",
"(",
"$",
"title",
"!=",
"''",
")",
"{",
"$",
"this",
"->",
"console",
"->",
"line",
"(",
"\"\\n\"",
".",
"$",
"title",
")",
";",
"//",
"$",
"underline",
"=",
"''",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"strlen",
"(",
"$",
"title",
")",
";",
"$",
"i",
"++",
")",
"{",
"$",
"underline",
".=",
"'='",
";",
"}",
"//",
"$",
"this",
"->",
"console",
"->",
"line",
"(",
"$",
"underline",
")",
";",
"}",
"//",
"if",
"(",
"$",
"sub",
"!=",
"''",
")",
"{",
"$",
"this",
"->",
"console",
"->",
"line",
"(",
"\"\\n\"",
".",
"$",
"sub",
")",
";",
"}",
"}"
] |
Show to Vinala lumos title.
@param string $title
@return null
|
[
"Show",
"to",
"Vinala",
"lumos",
"title",
"."
] |
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
|
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Lumos/Commands.php#L543-L559
|
239,250
|
vinala/kernel
|
src/Lumos/Commands.php
|
Commands.confirm
|
public function confirm($text, $default = false)
{
$helper = $this->getHelper('question');
//
$question = new ConfirmationQuestion($this->console->question($text.' '), $default);
//
return $helper->ask($this->input, $this->output, $question);
}
|
php
|
public function confirm($text, $default = false)
{
$helper = $this->getHelper('question');
//
$question = new ConfirmationQuestion($this->console->question($text.' '), $default);
//
return $helper->ask($this->input, $this->output, $question);
}
|
[
"public",
"function",
"confirm",
"(",
"$",
"text",
",",
"$",
"default",
"=",
"false",
")",
"{",
"$",
"helper",
"=",
"$",
"this",
"->",
"getHelper",
"(",
"'question'",
")",
";",
"//",
"$",
"question",
"=",
"new",
"ConfirmationQuestion",
"(",
"$",
"this",
"->",
"console",
"->",
"question",
"(",
"$",
"text",
".",
"' '",
")",
",",
"$",
"default",
")",
";",
"//",
"return",
"$",
"helper",
"->",
"ask",
"(",
"$",
"this",
"->",
"input",
",",
"$",
"this",
"->",
"output",
",",
"$",
"question",
")",
";",
"}"
] |
ask user for confirmation.
|
[
"ask",
"user",
"for",
"confirmation",
"."
] |
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
|
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Lumos/Commands.php#L576-L583
|
239,251
|
vinala/kernel
|
src/Lumos/Commands.php
|
Commands.hidden
|
public function hidden($text)
{
$helper = $this->getHelper('question');
//
$question = new Question($this->console->question($text.' '));
//
$question->setHidden(true);
//
$question->setHiddenFallback(true);
//
return $helper->ask($this->input, $this->output, $question);
}
|
php
|
public function hidden($text)
{
$helper = $this->getHelper('question');
//
$question = new Question($this->console->question($text.' '));
//
$question->setHidden(true);
//
$question->setHiddenFallback(true);
//
return $helper->ask($this->input, $this->output, $question);
}
|
[
"public",
"function",
"hidden",
"(",
"$",
"text",
")",
"{",
"$",
"helper",
"=",
"$",
"this",
"->",
"getHelper",
"(",
"'question'",
")",
";",
"//",
"$",
"question",
"=",
"new",
"Question",
"(",
"$",
"this",
"->",
"console",
"->",
"question",
"(",
"$",
"text",
".",
"' '",
")",
")",
";",
"//",
"$",
"question",
"->",
"setHidden",
"(",
"true",
")",
";",
"//",
"$",
"question",
"->",
"setHiddenFallback",
"(",
"true",
")",
";",
"//",
"return",
"$",
"helper",
"->",
"ask",
"(",
"$",
"this",
"->",
"input",
",",
"$",
"this",
"->",
"output",
",",
"$",
"question",
")",
";",
"}"
] |
ask user for password.
|
[
"ask",
"user",
"for",
"password",
"."
] |
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
|
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Lumos/Commands.php#L588-L599
|
239,252
|
vinala/kernel
|
src/Lumos/Commands.php
|
Commands.table
|
public function table($header, $data)
{
$table = new Table($this->output);
//
$table->setHeaders($header)->setRows($data);
//
$table->render();
}
|
php
|
public function table($header, $data)
{
$table = new Table($this->output);
//
$table->setHeaders($header)->setRows($data);
//
$table->render();
}
|
[
"public",
"function",
"table",
"(",
"$",
"header",
",",
"$",
"data",
")",
"{",
"$",
"table",
"=",
"new",
"Table",
"(",
"$",
"this",
"->",
"output",
")",
";",
"//",
"$",
"table",
"->",
"setHeaders",
"(",
"$",
"header",
")",
"->",
"setRows",
"(",
"$",
"data",
")",
";",
"//",
"$",
"table",
"->",
"render",
"(",
")",
";",
"}"
] |
display Table.
|
[
"display",
"Table",
"."
] |
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
|
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Lumos/Commands.php#L618-L625
|
239,253
|
theluckyteam/php-jira
|
src/jira/Repository/CookieAuthSessionRepository.php
|
CookieAuthSessionRepository.create
|
private function create(): CookieAuthSession
{
$response = $this->request($this->endpoint . $this->path, [
RequestOptions::JSON => [
'username' => $this->username,
'password' => $this->password,
],
]);
$body = $response->getBody();
$body->seek(0);
$contents = $body->getContents();
$contents = json_decode($contents, true);
if (isset($contents['session']['name'], $contents['session']['value'])) {
return new CookieAuthSession($contents['session']['name'], $contents['session']['value']);
}
throw new \Exception('Failed to create ' . CookieAuthSession::class . '.');
}
|
php
|
private function create(): CookieAuthSession
{
$response = $this->request($this->endpoint . $this->path, [
RequestOptions::JSON => [
'username' => $this->username,
'password' => $this->password,
],
]);
$body = $response->getBody();
$body->seek(0);
$contents = $body->getContents();
$contents = json_decode($contents, true);
if (isset($contents['session']['name'], $contents['session']['value'])) {
return new CookieAuthSession($contents['session']['name'], $contents['session']['value']);
}
throw new \Exception('Failed to create ' . CookieAuthSession::class . '.');
}
|
[
"private",
"function",
"create",
"(",
")",
":",
"CookieAuthSession",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"request",
"(",
"$",
"this",
"->",
"endpoint",
".",
"$",
"this",
"->",
"path",
",",
"[",
"RequestOptions",
"::",
"JSON",
"=>",
"[",
"'username'",
"=>",
"$",
"this",
"->",
"username",
",",
"'password'",
"=>",
"$",
"this",
"->",
"password",
",",
"]",
",",
"]",
")",
";",
"$",
"body",
"=",
"$",
"response",
"->",
"getBody",
"(",
")",
";",
"$",
"body",
"->",
"seek",
"(",
"0",
")",
";",
"$",
"contents",
"=",
"$",
"body",
"->",
"getContents",
"(",
")",
";",
"$",
"contents",
"=",
"json_decode",
"(",
"$",
"contents",
",",
"true",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"contents",
"[",
"'session'",
"]",
"[",
"'name'",
"]",
",",
"$",
"contents",
"[",
"'session'",
"]",
"[",
"'value'",
"]",
")",
")",
"{",
"return",
"new",
"CookieAuthSession",
"(",
"$",
"contents",
"[",
"'session'",
"]",
"[",
"'name'",
"]",
",",
"$",
"contents",
"[",
"'session'",
"]",
"[",
"'value'",
"]",
")",
";",
"}",
"throw",
"new",
"\\",
"Exception",
"(",
"'Failed to create '",
".",
"CookieAuthSession",
"::",
"class",
".",
"'.'",
")",
";",
"}"
] |
Creates cookie auth session
@return CookieAuthSession
@throws \Exception If failed to create object
|
[
"Creates",
"cookie",
"auth",
"session"
] |
5a50ab4fc57dd77239f1b7e9c87738318c258c38
|
https://github.com/theluckyteam/php-jira/blob/5a50ab4fc57dd77239f1b7e9c87738318c258c38/src/jira/Repository/CookieAuthSessionRepository.php#L74-L94
|
239,254
|
theluckyteam/php-jira
|
src/jira/Repository/CookieAuthSessionRepository.php
|
CookieAuthSessionRepository.request
|
private function request($url, array $options)
{
$response = $this->client->request('POST', $url, $options);
$body = $response->getBody();
if ($response->getStatusCode() != 200
|| !isset($body)) {
throw new \Exception('Failed request to ' . $this->endpoint . '.');
}
return $response;
}
|
php
|
private function request($url, array $options)
{
$response = $this->client->request('POST', $url, $options);
$body = $response->getBody();
if ($response->getStatusCode() != 200
|| !isset($body)) {
throw new \Exception('Failed request to ' . $this->endpoint . '.');
}
return $response;
}
|
[
"private",
"function",
"request",
"(",
"$",
"url",
",",
"array",
"$",
"options",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"client",
"->",
"request",
"(",
"'POST'",
",",
"$",
"url",
",",
"$",
"options",
")",
";",
"$",
"body",
"=",
"$",
"response",
"->",
"getBody",
"(",
")",
";",
"if",
"(",
"$",
"response",
"->",
"getStatusCode",
"(",
")",
"!=",
"200",
"||",
"!",
"isset",
"(",
"$",
"body",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Failed request to '",
".",
"$",
"this",
"->",
"endpoint",
".",
"'.'",
")",
";",
"}",
"return",
"$",
"response",
";",
"}"
] |
Requires a cookie authentication session
@param string $url Endpoint for obtaining AuthSession
@param array $options Request options
@return \Psr\Http\Message\ResponseInterface
@throws \Exception If failed request
|
[
"Requires",
"a",
"cookie",
"authentication",
"session"
] |
5a50ab4fc57dd77239f1b7e9c87738318c258c38
|
https://github.com/theluckyteam/php-jira/blob/5a50ab4fc57dd77239f1b7e9c87738318c258c38/src/jira/Repository/CookieAuthSessionRepository.php#L105-L116
|
239,255
|
tenside/core-bundle
|
src/Util/InstallationStatusDeterminator.php
|
InstallationStatusDeterminator.isTensideConfigured
|
public function isTensideConfigured()
{
if (isset($this->isTensideConfigured)) {
return $this->isTensideConfigured;
}
return $this->isTensideConfigured = file_exists(
$this->home->tensideDataDir() . DIRECTORY_SEPARATOR . 'tenside.json'
);
}
|
php
|
public function isTensideConfigured()
{
if (isset($this->isTensideConfigured)) {
return $this->isTensideConfigured;
}
return $this->isTensideConfigured = file_exists(
$this->home->tensideDataDir() . DIRECTORY_SEPARATOR . 'tenside.json'
);
}
|
[
"public",
"function",
"isTensideConfigured",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"isTensideConfigured",
")",
")",
"{",
"return",
"$",
"this",
"->",
"isTensideConfigured",
";",
"}",
"return",
"$",
"this",
"->",
"isTensideConfigured",
"=",
"file_exists",
"(",
"$",
"this",
"->",
"home",
"->",
"tensideDataDir",
"(",
")",
".",
"DIRECTORY_SEPARATOR",
".",
"'tenside.json'",
")",
";",
"}"
] |
Check if a "tenside.json" is present.
@return bool
|
[
"Check",
"if",
"a",
"tenside",
".",
"json",
"is",
"present",
"."
] |
a7ffad3649cddac1e5594b4f8b65a5504363fccd
|
https://github.com/tenside/core-bundle/blob/a7ffad3649cddac1e5594b4f8b65a5504363fccd/src/Util/InstallationStatusDeterminator.php#L73-L82
|
239,256
|
tenside/core-bundle
|
src/Util/InstallationStatusDeterminator.php
|
InstallationStatusDeterminator.isProjectPresent
|
public function isProjectPresent()
{
if (isset($this->isProjectPresent)) {
return $this->isProjectPresent;
}
return $this->isProjectPresent = file_exists($this->home->homeDir() . DIRECTORY_SEPARATOR . 'composer.json');
}
|
php
|
public function isProjectPresent()
{
if (isset($this->isProjectPresent)) {
return $this->isProjectPresent;
}
return $this->isProjectPresent = file_exists($this->home->homeDir() . DIRECTORY_SEPARATOR . 'composer.json');
}
|
[
"public",
"function",
"isProjectPresent",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"isProjectPresent",
")",
")",
"{",
"return",
"$",
"this",
"->",
"isProjectPresent",
";",
"}",
"return",
"$",
"this",
"->",
"isProjectPresent",
"=",
"file_exists",
"(",
"$",
"this",
"->",
"home",
"->",
"homeDir",
"(",
")",
".",
"DIRECTORY_SEPARATOR",
".",
"'composer.json'",
")",
";",
"}"
] |
Check if a project "composer.json" is present.
@return bool
|
[
"Check",
"if",
"a",
"project",
"composer",
".",
"json",
"is",
"present",
"."
] |
a7ffad3649cddac1e5594b4f8b65a5504363fccd
|
https://github.com/tenside/core-bundle/blob/a7ffad3649cddac1e5594b4f8b65a5504363fccd/src/Util/InstallationStatusDeterminator.php#L89-L96
|
239,257
|
tenside/core-bundle
|
src/Util/InstallationStatusDeterminator.php
|
InstallationStatusDeterminator.isProjectInstalled
|
public function isProjectInstalled()
{
if (isset($this->isProjectInstalled)) {
return $this->isProjectInstalled;
}
return $this->isProjectInstalled = is_dir($this->home->homeDir() . DIRECTORY_SEPARATOR . 'vendor');
}
|
php
|
public function isProjectInstalled()
{
if (isset($this->isProjectInstalled)) {
return $this->isProjectInstalled;
}
return $this->isProjectInstalled = is_dir($this->home->homeDir() . DIRECTORY_SEPARATOR . 'vendor');
}
|
[
"public",
"function",
"isProjectInstalled",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"isProjectInstalled",
")",
")",
"{",
"return",
"$",
"this",
"->",
"isProjectInstalled",
";",
"}",
"return",
"$",
"this",
"->",
"isProjectInstalled",
"=",
"is_dir",
"(",
"$",
"this",
"->",
"home",
"->",
"homeDir",
"(",
")",
".",
"DIRECTORY_SEPARATOR",
".",
"'vendor'",
")",
";",
"}"
] |
Check if the vendor directory is present.
@return bool
|
[
"Check",
"if",
"the",
"vendor",
"directory",
"is",
"present",
"."
] |
a7ffad3649cddac1e5594b4f8b65a5504363fccd
|
https://github.com/tenside/core-bundle/blob/a7ffad3649cddac1e5594b4f8b65a5504363fccd/src/Util/InstallationStatusDeterminator.php#L103-L110
|
239,258
|
phunc-org/Phunc
|
src/Collection.php
|
Collection.createFlatArrayWithValuesAsAttributeName
|
public function createFlatArrayWithValuesAsAttributeName($attribute_name)
{
$a = [];
foreach ($this->getCollection() as $key => $object) {
$object_array = $object->toArray();
if (isset($object_array[$attribute_name])) {
$a[$key] = $object_array[$attribute_name];
}
}
return $a;
}
|
php
|
public function createFlatArrayWithValuesAsAttributeName($attribute_name)
{
$a = [];
foreach ($this->getCollection() as $key => $object) {
$object_array = $object->toArray();
if (isset($object_array[$attribute_name])) {
$a[$key] = $object_array[$attribute_name];
}
}
return $a;
}
|
[
"public",
"function",
"createFlatArrayWithValuesAsAttributeName",
"(",
"$",
"attribute_name",
")",
"{",
"$",
"a",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"getCollection",
"(",
")",
"as",
"$",
"key",
"=>",
"$",
"object",
")",
"{",
"$",
"object_array",
"=",
"$",
"object",
"->",
"toArray",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"object_array",
"[",
"$",
"attribute_name",
"]",
")",
")",
"{",
"$",
"a",
"[",
"$",
"key",
"]",
"=",
"$",
"object_array",
"[",
"$",
"attribute_name",
"]",
";",
"}",
"}",
"return",
"$",
"a",
";",
"}"
] |
solutions for reducing Collection just to one attribute - flat array
@param $attribute_name
@return array
|
[
"solutions",
"for",
"reducing",
"Collection",
"just",
"to",
"one",
"attribute",
"-",
"flat",
"array"
] |
80c69d5a63e352c8e0c3330e3b8bb1288d0a9256
|
https://github.com/phunc-org/Phunc/blob/80c69d5a63e352c8e0c3330e3b8bb1288d0a9256/src/Collection.php#L504-L514
|
239,259
|
Niirrty/Niirrty.Core
|
src/NiirrtyException.php
|
NiirrtyException.getErrorMessage
|
public function getErrorMessage( bool $appendPreviousByNewline = false ) : string
{
// Getting a optional previous exception
$prev = $this->getPrevious();
if ( null === $prev )
{
// If no previous exception is used
return \sprintf(
'%s(%d): %s',
static::GetCodeName( $this->getCode() ),
$this->getCode(),
$this->getMessage()
);
}
// Define the separator between current and previous exception.
$separator = $appendPreviousByNewline ? "\n" : ' ';
if ( $prev instanceof NiirrtyException )
{
return \sprintf(
'%s(%d): %s%s%s',
static::GetCodeName( $this->getCode() ),
$this->getCode(),
$this->getMessage(),
$separator,
$prev->getErrorMessage( $appendPreviousByNewline )
);
}
return \sprintf(
'%s(%d): %s%s%s',
static::GetCodeName( $this->getCode() ),
$this->getCode(),
$this->getMessage(),
$separator,
$prev->getMessage()
);
}
|
php
|
public function getErrorMessage( bool $appendPreviousByNewline = false ) : string
{
// Getting a optional previous exception
$prev = $this->getPrevious();
if ( null === $prev )
{
// If no previous exception is used
return \sprintf(
'%s(%d): %s',
static::GetCodeName( $this->getCode() ),
$this->getCode(),
$this->getMessage()
);
}
// Define the separator between current and previous exception.
$separator = $appendPreviousByNewline ? "\n" : ' ';
if ( $prev instanceof NiirrtyException )
{
return \sprintf(
'%s(%d): %s%s%s',
static::GetCodeName( $this->getCode() ),
$this->getCode(),
$this->getMessage(),
$separator,
$prev->getErrorMessage( $appendPreviousByNewline )
);
}
return \sprintf(
'%s(%d): %s%s%s',
static::GetCodeName( $this->getCode() ),
$this->getCode(),
$this->getMessage(),
$separator,
$prev->getMessage()
);
}
|
[
"public",
"function",
"getErrorMessage",
"(",
"bool",
"$",
"appendPreviousByNewline",
"=",
"false",
")",
":",
"string",
"{",
"// Getting a optional previous exception",
"$",
"prev",
"=",
"$",
"this",
"->",
"getPrevious",
"(",
")",
";",
"if",
"(",
"null",
"===",
"$",
"prev",
")",
"{",
"// If no previous exception is used",
"return",
"\\",
"sprintf",
"(",
"'%s(%d): %s'",
",",
"static",
"::",
"GetCodeName",
"(",
"$",
"this",
"->",
"getCode",
"(",
")",
")",
",",
"$",
"this",
"->",
"getCode",
"(",
")",
",",
"$",
"this",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"// Define the separator between current and previous exception.",
"$",
"separator",
"=",
"$",
"appendPreviousByNewline",
"?",
"\"\\n\"",
":",
"' '",
";",
"if",
"(",
"$",
"prev",
"instanceof",
"NiirrtyException",
")",
"{",
"return",
"\\",
"sprintf",
"(",
"'%s(%d): %s%s%s'",
",",
"static",
"::",
"GetCodeName",
"(",
"$",
"this",
"->",
"getCode",
"(",
")",
")",
",",
"$",
"this",
"->",
"getCode",
"(",
")",
",",
"$",
"this",
"->",
"getMessage",
"(",
")",
",",
"$",
"separator",
",",
"$",
"prev",
"->",
"getErrorMessage",
"(",
"$",
"appendPreviousByNewline",
")",
")",
";",
"}",
"return",
"\\",
"sprintf",
"(",
"'%s(%d): %s%s%s'",
",",
"static",
"::",
"GetCodeName",
"(",
"$",
"this",
"->",
"getCode",
"(",
")",
")",
",",
"$",
"this",
"->",
"getCode",
"(",
")",
",",
"$",
"this",
"->",
"getMessage",
"(",
")",
",",
"$",
"separator",
",",
"$",
"prev",
"->",
"getMessage",
"(",
")",
")",
";",
"}"
] |
Extends the origin getMessage method, so also previous messages are included, if defined.
@param bool $appendPreviousByNewline If a prev. Exception is defined append it by a new line? (' ' other)
@return string
|
[
"Extends",
"the",
"origin",
"getMessage",
"method",
"so",
"also",
"previous",
"messages",
"are",
"included",
"if",
"defined",
"."
] |
6faede6ea051b42e8eb776cfa05808d5978cd730
|
https://github.com/Niirrty/Niirrty.Core/blob/6faede6ea051b42e8eb776cfa05808d5978cd730/src/NiirrtyException.php#L95-L140
|
239,260
|
Niirrty/Niirrty.Core
|
src/NiirrtyException.php
|
NiirrtyException.toCustomString
|
public function toCustomString( int $subExceptionLevel = 0, string $indentSpaces = ' ' ) : string
{
// Concatenate the base error message from usable elements
$msg = \sprintf(
'%s%s in %s[%d]. %s',
\str_repeat( $indentSpaces, $subExceptionLevel ),
\get_class( $this ),
$this->file,
$this->line,
\str_replace( "\n", "\n" . \str_repeat( $indentSpaces, $subExceptionLevel ), $this->message )
);
// getting a may defined previous exception
$previous = $this->getPrevious();
// if no previous exception is defined return the current generated message
if ( null === $previous || ! ( $previous instanceof \Throwable ) )
{
return $msg;
}
// If previous message is a framework internal exception
if ( $previous instanceof NiirrtyException )
{
// Simple cast the exception to a string and append it with rewrite the indention
$msg .= "\n" . $previous->toCustomString( $subExceptionLevel + 1, $indentSpaces );
// And return the message
return $msg;
}
// Else its a normal PHP exception
// Concatenate the previous error message from usable elements
$msg .= \sprintf(
"\n%s%s %s in %s[%d]\n %s",
\str_repeat( $indentSpaces, $subExceptionLevel + 1 ),
\get_class( $previous ),
static::GetCodeName( $previous->getCode() ),
$previous->file,
$previous->line,
\str_replace( "\n", "\n" . \str_repeat( $indentSpaces, $subExceptionLevel + 1 ), $previous->message )
);
// And return the message
return $msg;
}
|
php
|
public function toCustomString( int $subExceptionLevel = 0, string $indentSpaces = ' ' ) : string
{
// Concatenate the base error message from usable elements
$msg = \sprintf(
'%s%s in %s[%d]. %s',
\str_repeat( $indentSpaces, $subExceptionLevel ),
\get_class( $this ),
$this->file,
$this->line,
\str_replace( "\n", "\n" . \str_repeat( $indentSpaces, $subExceptionLevel ), $this->message )
);
// getting a may defined previous exception
$previous = $this->getPrevious();
// if no previous exception is defined return the current generated message
if ( null === $previous || ! ( $previous instanceof \Throwable ) )
{
return $msg;
}
// If previous message is a framework internal exception
if ( $previous instanceof NiirrtyException )
{
// Simple cast the exception to a string and append it with rewrite the indention
$msg .= "\n" . $previous->toCustomString( $subExceptionLevel + 1, $indentSpaces );
// And return the message
return $msg;
}
// Else its a normal PHP exception
// Concatenate the previous error message from usable elements
$msg .= \sprintf(
"\n%s%s %s in %s[%d]\n %s",
\str_repeat( $indentSpaces, $subExceptionLevel + 1 ),
\get_class( $previous ),
static::GetCodeName( $previous->getCode() ),
$previous->file,
$previous->line,
\str_replace( "\n", "\n" . \str_repeat( $indentSpaces, $subExceptionLevel + 1 ), $previous->message )
);
// And return the message
return $msg;
}
|
[
"public",
"function",
"toCustomString",
"(",
"int",
"$",
"subExceptionLevel",
"=",
"0",
",",
"string",
"$",
"indentSpaces",
"=",
"' '",
")",
":",
"string",
"{",
"// Concatenate the base error message from usable elements",
"$",
"msg",
"=",
"\\",
"sprintf",
"(",
"'%s%s in %s[%d]. %s'",
",",
"\\",
"str_repeat",
"(",
"$",
"indentSpaces",
",",
"$",
"subExceptionLevel",
")",
",",
"\\",
"get_class",
"(",
"$",
"this",
")",
",",
"$",
"this",
"->",
"file",
",",
"$",
"this",
"->",
"line",
",",
"\\",
"str_replace",
"(",
"\"\\n\"",
",",
"\"\\n\"",
".",
"\\",
"str_repeat",
"(",
"$",
"indentSpaces",
",",
"$",
"subExceptionLevel",
")",
",",
"$",
"this",
"->",
"message",
")",
")",
";",
"// getting a may defined previous exception",
"$",
"previous",
"=",
"$",
"this",
"->",
"getPrevious",
"(",
")",
";",
"// if no previous exception is defined return the current generated message",
"if",
"(",
"null",
"===",
"$",
"previous",
"||",
"!",
"(",
"$",
"previous",
"instanceof",
"\\",
"Throwable",
")",
")",
"{",
"return",
"$",
"msg",
";",
"}",
"// If previous message is a framework internal exception",
"if",
"(",
"$",
"previous",
"instanceof",
"NiirrtyException",
")",
"{",
"// Simple cast the exception to a string and append it with rewrite the indention",
"$",
"msg",
".=",
"\"\\n\"",
".",
"$",
"previous",
"->",
"toCustomString",
"(",
"$",
"subExceptionLevel",
"+",
"1",
",",
"$",
"indentSpaces",
")",
";",
"// And return the message",
"return",
"$",
"msg",
";",
"}",
"// Else its a normal PHP exception",
"// Concatenate the previous error message from usable elements",
"$",
"msg",
".=",
"\\",
"sprintf",
"(",
"\"\\n%s%s %s in %s[%d]\\n %s\"",
",",
"\\",
"str_repeat",
"(",
"$",
"indentSpaces",
",",
"$",
"subExceptionLevel",
"+",
"1",
")",
",",
"\\",
"get_class",
"(",
"$",
"previous",
")",
",",
"static",
"::",
"GetCodeName",
"(",
"$",
"previous",
"->",
"getCode",
"(",
")",
")",
",",
"$",
"previous",
"->",
"file",
",",
"$",
"previous",
"->",
"line",
",",
"\\",
"str_replace",
"(",
"\"\\n\"",
",",
"\"\\n\"",
".",
"\\",
"str_repeat",
"(",
"$",
"indentSpaces",
",",
"$",
"subExceptionLevel",
"+",
"1",
")",
",",
"$",
"previous",
"->",
"message",
")",
")",
";",
"// And return the message",
"return",
"$",
"msg",
";",
"}"
] |
Allows the definition of the sub exception level if there is a parent exception that contains this exception.
@param int $subExceptionLevel
@param string $indentSpaces Spaces to use for a single indention level.
@return string
|
[
"Allows",
"the",
"definition",
"of",
"the",
"sub",
"exception",
"level",
"if",
"there",
"is",
"a",
"parent",
"exception",
"that",
"contains",
"this",
"exception",
"."
] |
6faede6ea051b42e8eb776cfa05808d5978cd730
|
https://github.com/Niirrty/Niirrty.Core/blob/6faede6ea051b42e8eb776cfa05808d5978cd730/src/NiirrtyException.php#L149-L195
|
239,261
|
SocietyCMS/User
|
Http/Controllers/backend/ProfileController.php
|
ProfileController.updatePassword
|
public function updatePassword(UpdateProfilePasswordRequest $request)
{
$user = $this->user->find($this->auth->id());
$credentials = [
'id' => $this->auth->id(),
'email' => $user->email,
'password' => $request->old_password,
];
if (! $this->auth->attempt($credentials)) {
Flash::error(trans('user::messages.invalid old password'));
return redirect()->back();
}
$this->user->update($request->all(), $this->auth->id());
flash(trans('user::messages.password updated'));
return redirect()->back();
}
|
php
|
public function updatePassword(UpdateProfilePasswordRequest $request)
{
$user = $this->user->find($this->auth->id());
$credentials = [
'id' => $this->auth->id(),
'email' => $user->email,
'password' => $request->old_password,
];
if (! $this->auth->attempt($credentials)) {
Flash::error(trans('user::messages.invalid old password'));
return redirect()->back();
}
$this->user->update($request->all(), $this->auth->id());
flash(trans('user::messages.password updated'));
return redirect()->back();
}
|
[
"public",
"function",
"updatePassword",
"(",
"UpdateProfilePasswordRequest",
"$",
"request",
")",
"{",
"$",
"user",
"=",
"$",
"this",
"->",
"user",
"->",
"find",
"(",
"$",
"this",
"->",
"auth",
"->",
"id",
"(",
")",
")",
";",
"$",
"credentials",
"=",
"[",
"'id'",
"=>",
"$",
"this",
"->",
"auth",
"->",
"id",
"(",
")",
",",
"'email'",
"=>",
"$",
"user",
"->",
"email",
",",
"'password'",
"=>",
"$",
"request",
"->",
"old_password",
",",
"]",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"auth",
"->",
"attempt",
"(",
"$",
"credentials",
")",
")",
"{",
"Flash",
"::",
"error",
"(",
"trans",
"(",
"'user::messages.invalid old password'",
")",
")",
";",
"return",
"redirect",
"(",
")",
"->",
"back",
"(",
")",
";",
"}",
"$",
"this",
"->",
"user",
"->",
"update",
"(",
"$",
"request",
"->",
"all",
"(",
")",
",",
"$",
"this",
"->",
"auth",
"->",
"id",
"(",
")",
")",
";",
"flash",
"(",
"trans",
"(",
"'user::messages.password updated'",
")",
")",
";",
"return",
"redirect",
"(",
")",
"->",
"back",
"(",
")",
";",
"}"
] |
Update the password of the given user.
@param UpdateProfilePasswordRequest|UpdateUserRequest $request
@return Response
@internal param int $id
|
[
"Update",
"the",
"password",
"of",
"the",
"given",
"user",
"."
] |
76f7b52b27e8a9740f8d5a9c3b86181e1c231634
|
https://github.com/SocietyCMS/User/blob/76f7b52b27e8a9740f8d5a9c3b86181e1c231634/Http/Controllers/backend/ProfileController.php#L115-L136
|
239,262
|
phizzl/querygenerate
|
src/Drivers/MysqlDriver.php
|
MysqlDriver.isColumnInIndex
|
private function isColumnInIndex(TableInterface $table, ColumnInterface $column){
$indexes = $table->getAddedIndexes();
if(in_array($column->getName(), $table->getPrimaryKey())){
return true;
}
foreach($indexes as $columnNames){
if(in_array($column->getName(), $columnNames)){
return true;
}
}
return false;
}
|
php
|
private function isColumnInIndex(TableInterface $table, ColumnInterface $column){
$indexes = $table->getAddedIndexes();
if(in_array($column->getName(), $table->getPrimaryKey())){
return true;
}
foreach($indexes as $columnNames){
if(in_array($column->getName(), $columnNames)){
return true;
}
}
return false;
}
|
[
"private",
"function",
"isColumnInIndex",
"(",
"TableInterface",
"$",
"table",
",",
"ColumnInterface",
"$",
"column",
")",
"{",
"$",
"indexes",
"=",
"$",
"table",
"->",
"getAddedIndexes",
"(",
")",
";",
"if",
"(",
"in_array",
"(",
"$",
"column",
"->",
"getName",
"(",
")",
",",
"$",
"table",
"->",
"getPrimaryKey",
"(",
")",
")",
")",
"{",
"return",
"true",
";",
"}",
"foreach",
"(",
"$",
"indexes",
"as",
"$",
"columnNames",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"column",
"->",
"getName",
"(",
")",
",",
"$",
"columnNames",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Check if a column is marked as index
@param TableInterface $table
@param ColumnInterface $column
@return bool
|
[
"Check",
"if",
"a",
"column",
"is",
"marked",
"as",
"index"
] |
a578aa755f1a26fc53104abd05d9b45b696a61a9
|
https://github.com/phizzl/querygenerate/blob/a578aa755f1a26fc53104abd05d9b45b696a61a9/src/Drivers/MysqlDriver.php#L269-L283
|
239,263
|
AthensFramework/Core
|
src/page/PageBuilder.php
|
PageBuilder.buildTopMatter
|
protected function buildTopMatter()
{
$topMatterBuilder = SectionBuilder::begin()
->setType(SectionBuilder::TYPE_SPAN);
if ($this->breadCrumbTitles !== []) {
$breadCrumbsBuilder = SectionBuilder::begin()
->setType(SectionBuilder::TYPE_BREADCRUMBS);
foreach ($this->breadCrumbTitles as $index => $breadCrumbTitle) {
$breadCrumbLink = $this->breadCrumbLinks[$index];
if ($breadCrumbLink !== '') {
$breadCrumbsBuilder->addWritable(
LinkBuilder::begin()->setText($breadCrumbTitle)->setURI($breadCrumbLink)->build()
);
} else {
$breadCrumbsBuilder->addContent(
$breadCrumbTitle
);
}
}
$topMatterBuilder->addWritable($breadCrumbsBuilder->build());
}
if ($this->header !== null) {
$topMatterBuilder->addWritable(
SectionBuilder::begin()
->setType(SectionBuilder::TYPE_HEADER)
->addLiteralContent($this->header)
->build()
);
}
$topMatterBuilder->addWritable(
SectionBuilder::begin()
->setType(SectionBuilder::TYPE_DIV)
->setId('top-filters')
->build()
);
if ($this->subHeader !== null) {
$topMatterBuilder->addWritable(
SectionBuilder::begin()
->setType(SectionBuilder::TYPE_SUBHEADER)
->addLiteralContent($this->subHeader)
->build()
);
}
return $topMatterBuilder->build();
}
|
php
|
protected function buildTopMatter()
{
$topMatterBuilder = SectionBuilder::begin()
->setType(SectionBuilder::TYPE_SPAN);
if ($this->breadCrumbTitles !== []) {
$breadCrumbsBuilder = SectionBuilder::begin()
->setType(SectionBuilder::TYPE_BREADCRUMBS);
foreach ($this->breadCrumbTitles as $index => $breadCrumbTitle) {
$breadCrumbLink = $this->breadCrumbLinks[$index];
if ($breadCrumbLink !== '') {
$breadCrumbsBuilder->addWritable(
LinkBuilder::begin()->setText($breadCrumbTitle)->setURI($breadCrumbLink)->build()
);
} else {
$breadCrumbsBuilder->addContent(
$breadCrumbTitle
);
}
}
$topMatterBuilder->addWritable($breadCrumbsBuilder->build());
}
if ($this->header !== null) {
$topMatterBuilder->addWritable(
SectionBuilder::begin()
->setType(SectionBuilder::TYPE_HEADER)
->addLiteralContent($this->header)
->build()
);
}
$topMatterBuilder->addWritable(
SectionBuilder::begin()
->setType(SectionBuilder::TYPE_DIV)
->setId('top-filters')
->build()
);
if ($this->subHeader !== null) {
$topMatterBuilder->addWritable(
SectionBuilder::begin()
->setType(SectionBuilder::TYPE_SUBHEADER)
->addLiteralContent($this->subHeader)
->build()
);
}
return $topMatterBuilder->build();
}
|
[
"protected",
"function",
"buildTopMatter",
"(",
")",
"{",
"$",
"topMatterBuilder",
"=",
"SectionBuilder",
"::",
"begin",
"(",
")",
"->",
"setType",
"(",
"SectionBuilder",
"::",
"TYPE_SPAN",
")",
";",
"if",
"(",
"$",
"this",
"->",
"breadCrumbTitles",
"!==",
"[",
"]",
")",
"{",
"$",
"breadCrumbsBuilder",
"=",
"SectionBuilder",
"::",
"begin",
"(",
")",
"->",
"setType",
"(",
"SectionBuilder",
"::",
"TYPE_BREADCRUMBS",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"breadCrumbTitles",
"as",
"$",
"index",
"=>",
"$",
"breadCrumbTitle",
")",
"{",
"$",
"breadCrumbLink",
"=",
"$",
"this",
"->",
"breadCrumbLinks",
"[",
"$",
"index",
"]",
";",
"if",
"(",
"$",
"breadCrumbLink",
"!==",
"''",
")",
"{",
"$",
"breadCrumbsBuilder",
"->",
"addWritable",
"(",
"LinkBuilder",
"::",
"begin",
"(",
")",
"->",
"setText",
"(",
"$",
"breadCrumbTitle",
")",
"->",
"setURI",
"(",
"$",
"breadCrumbLink",
")",
"->",
"build",
"(",
")",
")",
";",
"}",
"else",
"{",
"$",
"breadCrumbsBuilder",
"->",
"addContent",
"(",
"$",
"breadCrumbTitle",
")",
";",
"}",
"}",
"$",
"topMatterBuilder",
"->",
"addWritable",
"(",
"$",
"breadCrumbsBuilder",
"->",
"build",
"(",
")",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"header",
"!==",
"null",
")",
"{",
"$",
"topMatterBuilder",
"->",
"addWritable",
"(",
"SectionBuilder",
"::",
"begin",
"(",
")",
"->",
"setType",
"(",
"SectionBuilder",
"::",
"TYPE_HEADER",
")",
"->",
"addLiteralContent",
"(",
"$",
"this",
"->",
"header",
")",
"->",
"build",
"(",
")",
")",
";",
"}",
"$",
"topMatterBuilder",
"->",
"addWritable",
"(",
"SectionBuilder",
"::",
"begin",
"(",
")",
"->",
"setType",
"(",
"SectionBuilder",
"::",
"TYPE_DIV",
")",
"->",
"setId",
"(",
"'top-filters'",
")",
"->",
"build",
"(",
")",
")",
";",
"if",
"(",
"$",
"this",
"->",
"subHeader",
"!==",
"null",
")",
"{",
"$",
"topMatterBuilder",
"->",
"addWritable",
"(",
"SectionBuilder",
"::",
"begin",
"(",
")",
"->",
"setType",
"(",
"SectionBuilder",
"::",
"TYPE_SUBHEADER",
")",
"->",
"addLiteralContent",
"(",
"$",
"this",
"->",
"subHeader",
")",
"->",
"build",
"(",
")",
")",
";",
"}",
"return",
"$",
"topMatterBuilder",
"->",
"build",
"(",
")",
";",
"}"
] |
Build the bread crumbs, header, sub header, etc., of the page.
@return SectionInterface
|
[
"Build",
"the",
"bread",
"crumbs",
"header",
"sub",
"header",
"etc",
".",
"of",
"the",
"page",
"."
] |
6237b914b9f6aef6b2fcac23094b657a86185340
|
https://github.com/AthensFramework/Core/blob/6237b914b9f6aef6b2fcac23094b657a86185340/src/page/PageBuilder.php#L117-L169
|
239,264
|
AthensFramework/Core
|
src/page/PageBuilder.php
|
PageBuilder.validateRenderer
|
protected function validateRenderer()
{
if ($this->renderer === null) {
$settingsInstance = $this->getSettingsInstance();
if ($this->type === static::TYPE_EXCEL) {
$writerClasses = $settingsInstance->getDefaultExcelWriterClasses();
$rendererClass = $settingsInstance->getDefaultExcelRendererClass();
} elseif ($this->type === static::TYPE_PDF) {
$writerClasses = $settingsInstance->getDefaultPDFWriterClasses();
$rendererClass = $settingsInstance->getDefaultPDFRendererClass();
} else {
$writerClasses = $settingsInstance->getDefaultWriterClasses();
$rendererClass = $settingsInstance->getDefaultRendererClass();
}
$writerInstances = [];
foreach ($writerClasses as $writerClass) {
$writerInstances[] = new $writerClass();
}
$this->renderer = new $rendererClass($writerInstances);
}
}
|
php
|
protected function validateRenderer()
{
if ($this->renderer === null) {
$settingsInstance = $this->getSettingsInstance();
if ($this->type === static::TYPE_EXCEL) {
$writerClasses = $settingsInstance->getDefaultExcelWriterClasses();
$rendererClass = $settingsInstance->getDefaultExcelRendererClass();
} elseif ($this->type === static::TYPE_PDF) {
$writerClasses = $settingsInstance->getDefaultPDFWriterClasses();
$rendererClass = $settingsInstance->getDefaultPDFRendererClass();
} else {
$writerClasses = $settingsInstance->getDefaultWriterClasses();
$rendererClass = $settingsInstance->getDefaultRendererClass();
}
$writerInstances = [];
foreach ($writerClasses as $writerClass) {
$writerInstances[] = new $writerClass();
}
$this->renderer = new $rendererClass($writerInstances);
}
}
|
[
"protected",
"function",
"validateRenderer",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"renderer",
"===",
"null",
")",
"{",
"$",
"settingsInstance",
"=",
"$",
"this",
"->",
"getSettingsInstance",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"type",
"===",
"static",
"::",
"TYPE_EXCEL",
")",
"{",
"$",
"writerClasses",
"=",
"$",
"settingsInstance",
"->",
"getDefaultExcelWriterClasses",
"(",
")",
";",
"$",
"rendererClass",
"=",
"$",
"settingsInstance",
"->",
"getDefaultExcelRendererClass",
"(",
")",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"type",
"===",
"static",
"::",
"TYPE_PDF",
")",
"{",
"$",
"writerClasses",
"=",
"$",
"settingsInstance",
"->",
"getDefaultPDFWriterClasses",
"(",
")",
";",
"$",
"rendererClass",
"=",
"$",
"settingsInstance",
"->",
"getDefaultPDFRendererClass",
"(",
")",
";",
"}",
"else",
"{",
"$",
"writerClasses",
"=",
"$",
"settingsInstance",
"->",
"getDefaultWriterClasses",
"(",
")",
";",
"$",
"rendererClass",
"=",
"$",
"settingsInstance",
"->",
"getDefaultRendererClass",
"(",
")",
";",
"}",
"$",
"writerInstances",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"writerClasses",
"as",
"$",
"writerClass",
")",
"{",
"$",
"writerInstances",
"[",
"]",
"=",
"new",
"$",
"writerClass",
"(",
")",
";",
"}",
"$",
"this",
"->",
"renderer",
"=",
"new",
"$",
"rendererClass",
"(",
"$",
"writerInstances",
")",
";",
"}",
"}"
] |
Construct a renderer from setting defaults, if none has been provided.
@return void
|
[
"Construct",
"a",
"renderer",
"from",
"setting",
"defaults",
"if",
"none",
"has",
"been",
"provided",
"."
] |
6237b914b9f6aef6b2fcac23094b657a86185340
|
https://github.com/AthensFramework/Core/blob/6237b914b9f6aef6b2fcac23094b657a86185340/src/page/PageBuilder.php#L176-L199
|
239,265
|
AthensFramework/Core
|
src/page/PageBuilder.php
|
PageBuilder.validateInitializer
|
protected function validateInitializer()
{
if ($this->renderer === null) {
$settingsInstance = $this->getSettingsInstance();
if ($this->type === static::TYPE_EXCEL) {
$initializerClass = $settingsInstance->getDefaultExcelInitializerClass();
} elseif ($this->type === static::TYPE_PDF) {
$initializerClass = $settingsInstance->getDefaultPDFInitializerClass();
} else {
$initializerClass = $settingsInstance->getDefaultInitializerClass();
}
$this->initializer = new $initializerClass;
}
}
|
php
|
protected function validateInitializer()
{
if ($this->renderer === null) {
$settingsInstance = $this->getSettingsInstance();
if ($this->type === static::TYPE_EXCEL) {
$initializerClass = $settingsInstance->getDefaultExcelInitializerClass();
} elseif ($this->type === static::TYPE_PDF) {
$initializerClass = $settingsInstance->getDefaultPDFInitializerClass();
} else {
$initializerClass = $settingsInstance->getDefaultInitializerClass();
}
$this->initializer = new $initializerClass;
}
}
|
[
"protected",
"function",
"validateInitializer",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"renderer",
"===",
"null",
")",
"{",
"$",
"settingsInstance",
"=",
"$",
"this",
"->",
"getSettingsInstance",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"type",
"===",
"static",
"::",
"TYPE_EXCEL",
")",
"{",
"$",
"initializerClass",
"=",
"$",
"settingsInstance",
"->",
"getDefaultExcelInitializerClass",
"(",
")",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"type",
"===",
"static",
"::",
"TYPE_PDF",
")",
"{",
"$",
"initializerClass",
"=",
"$",
"settingsInstance",
"->",
"getDefaultPDFInitializerClass",
"(",
")",
";",
"}",
"else",
"{",
"$",
"initializerClass",
"=",
"$",
"settingsInstance",
"->",
"getDefaultInitializerClass",
"(",
")",
";",
"}",
"$",
"this",
"->",
"initializer",
"=",
"new",
"$",
"initializerClass",
";",
"}",
"}"
] |
Construct an initializer from setting defaults, if none has been provided.
@return void
|
[
"Construct",
"an",
"initializer",
"from",
"setting",
"defaults",
"if",
"none",
"has",
"been",
"provided",
"."
] |
6237b914b9f6aef6b2fcac23094b657a86185340
|
https://github.com/AthensFramework/Core/blob/6237b914b9f6aef6b2fcac23094b657a86185340/src/page/PageBuilder.php#L206-L221
|
239,266
|
ellipsephp/validation
|
src/Rule.php
|
Rule.validate
|
public function validate(string $key, array $scope = [], array $input = []): void
{
$value = $key == '*' ? '*' : $scope[$key] ?? null;
($this->validate)($value, $key, $scope, $input);
}
|
php
|
public function validate(string $key, array $scope = [], array $input = []): void
{
$value = $key == '*' ? '*' : $scope[$key] ?? null;
($this->validate)($value, $key, $scope, $input);
}
|
[
"public",
"function",
"validate",
"(",
"string",
"$",
"key",
",",
"array",
"$",
"scope",
"=",
"[",
"]",
",",
"array",
"$",
"input",
"=",
"[",
"]",
")",
":",
"void",
"{",
"$",
"value",
"=",
"$",
"key",
"==",
"'*'",
"?",
"'*'",
":",
"$",
"scope",
"[",
"$",
"key",
"]",
"??",
"null",
";",
"(",
"$",
"this",
"->",
"validate",
")",
"(",
"$",
"value",
",",
"$",
"key",
",",
"$",
"scope",
",",
"$",
"input",
")",
";",
"}"
] |
Execute the validate callable. Inject the value to validate, the key to
validate within the injected scope and the whole input.
@return void
|
[
"Execute",
"the",
"validate",
"callable",
".",
"Inject",
"the",
"value",
"to",
"validate",
"the",
"key",
"to",
"validate",
"within",
"the",
"injected",
"scope",
"and",
"the",
"whole",
"input",
"."
] |
5a7e11807099165ff6217bf8c38df4b21d99599d
|
https://github.com/ellipsephp/validation/blob/5a7e11807099165ff6217bf8c38df4b21d99599d/src/Rule.php#L50-L55
|
239,267
|
infinity-se/infinity-base
|
src/InfinityBase/Controller/AbstractActionController.php
|
AbstractActionController.getService
|
protected function getService()
{
if (!isset($this->service)) {
$this->service = $this->getServiceLocator()
->get($this->getModuleNamespace() . '\Service\\' . $this->getEntityName());
}
return $this->service;
}
|
php
|
protected function getService()
{
if (!isset($this->service)) {
$this->service = $this->getServiceLocator()
->get($this->getModuleNamespace() . '\Service\\' . $this->getEntityName());
}
return $this->service;
}
|
[
"protected",
"function",
"getService",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"service",
")",
")",
"{",
"$",
"this",
"->",
"service",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"$",
"this",
"->",
"getModuleNamespace",
"(",
")",
".",
"'\\Service\\\\'",
".",
"$",
"this",
"->",
"getEntityName",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"service",
";",
"}"
] |
Retrieve the service
@return AbstractService
|
[
"Retrieve",
"the",
"service"
] |
4f869ae4b549e779560a83528d2ed2664f6deb5b
|
https://github.com/infinity-se/infinity-base/blob/4f869ae4b549e779560a83528d2ed2664f6deb5b/src/InfinityBase/Controller/AbstractActionController.php#L31-L39
|
239,268
|
marando/phpSOFA
|
src/Marando/IAU/iauRefco.php
|
iauRefco.Refco
|
public static function Refco($phpa, $tc, $rh, $wl, &$refa, &$refb) {
$optic;
$p;
$t;
$r;
$w;
$ps;
$pw;
$tk;
$wlsq;
$gamma;
$beta;
/* Decide whether optical/IR or radio case: switch at 100 microns. */
$optic = ( $wl <= 100.0 );
/* Restrict parameters to safe values. */
$t = max($tc, -150.0);
$t = min($t, 200.0);
$p = max($phpa, 0.0);
$p = min($p, 10000.0);
$r = max($rh, 0.0);
$r = min($r, 1.0);
$w = max($wl, 0.1);
$w = min($w, 1e6);
/* Water vapour pressure at the observer. */
if ($p > 0.0) {
$ps = pow(10.0,
( 0.7859 + 0.03477 * $t ) /
( 1.0 + 0.00412 * $t )) *
( 1.0 + $p * ( 4.5e-6 + 6e-10 * $t * $t ) );
$pw = $r * $ps / ( 1.0 - (1.0 - $r) * $ps / $p );
}
else {
$pw = 0.0;
}
/* Refractive index minus 1 at the observer. */
$tk = $t + 273.15;
if ($optic) {
$wlsq = $w * $w;
$gamma = ( ( 77.53484e-6 +
( 4.39108e-7 + 3.666e-9 / $wlsq ) / $wlsq ) * $p - 11.2684e-6 * $pw ) / $tk;
}
else {
$gamma = ( 77.6890e-6 * $p - ( 6.3938e-6 - 0.375463 / $tk ) * $pw ) / $tk;
}
/* Formula for beta from Stone, with empirical adjustments. */
$beta = 4.4474e-6 * $tk;
if (!$optic)
$beta -= 0.0074 * $pw * $beta;
/* Refraction constants from Green. */
$refa = $gamma * ( 1.0 - $beta );
$refb = - $gamma * ( $beta - $gamma / 2.0 );
/* Finished. */
}
|
php
|
public static function Refco($phpa, $tc, $rh, $wl, &$refa, &$refb) {
$optic;
$p;
$t;
$r;
$w;
$ps;
$pw;
$tk;
$wlsq;
$gamma;
$beta;
/* Decide whether optical/IR or radio case: switch at 100 microns. */
$optic = ( $wl <= 100.0 );
/* Restrict parameters to safe values. */
$t = max($tc, -150.0);
$t = min($t, 200.0);
$p = max($phpa, 0.0);
$p = min($p, 10000.0);
$r = max($rh, 0.0);
$r = min($r, 1.0);
$w = max($wl, 0.1);
$w = min($w, 1e6);
/* Water vapour pressure at the observer. */
if ($p > 0.0) {
$ps = pow(10.0,
( 0.7859 + 0.03477 * $t ) /
( 1.0 + 0.00412 * $t )) *
( 1.0 + $p * ( 4.5e-6 + 6e-10 * $t * $t ) );
$pw = $r * $ps / ( 1.0 - (1.0 - $r) * $ps / $p );
}
else {
$pw = 0.0;
}
/* Refractive index minus 1 at the observer. */
$tk = $t + 273.15;
if ($optic) {
$wlsq = $w * $w;
$gamma = ( ( 77.53484e-6 +
( 4.39108e-7 + 3.666e-9 / $wlsq ) / $wlsq ) * $p - 11.2684e-6 * $pw ) / $tk;
}
else {
$gamma = ( 77.6890e-6 * $p - ( 6.3938e-6 - 0.375463 / $tk ) * $pw ) / $tk;
}
/* Formula for beta from Stone, with empirical adjustments. */
$beta = 4.4474e-6 * $tk;
if (!$optic)
$beta -= 0.0074 * $pw * $beta;
/* Refraction constants from Green. */
$refa = $gamma * ( 1.0 - $beta );
$refb = - $gamma * ( $beta - $gamma / 2.0 );
/* Finished. */
}
|
[
"public",
"static",
"function",
"Refco",
"(",
"$",
"phpa",
",",
"$",
"tc",
",",
"$",
"rh",
",",
"$",
"wl",
",",
"&",
"$",
"refa",
",",
"&",
"$",
"refb",
")",
"{",
"$",
"optic",
";",
"$",
"p",
";",
"$",
"t",
";",
"$",
"r",
";",
"$",
"w",
";",
"$",
"ps",
";",
"$",
"pw",
";",
"$",
"tk",
";",
"$",
"wlsq",
";",
"$",
"gamma",
";",
"$",
"beta",
";",
"/* Decide whether optical/IR or radio case: switch at 100 microns. */",
"$",
"optic",
"=",
"(",
"$",
"wl",
"<=",
"100.0",
")",
";",
"/* Restrict parameters to safe values. */",
"$",
"t",
"=",
"max",
"(",
"$",
"tc",
",",
"-",
"150.0",
")",
";",
"$",
"t",
"=",
"min",
"(",
"$",
"t",
",",
"200.0",
")",
";",
"$",
"p",
"=",
"max",
"(",
"$",
"phpa",
",",
"0.0",
")",
";",
"$",
"p",
"=",
"min",
"(",
"$",
"p",
",",
"10000.0",
")",
";",
"$",
"r",
"=",
"max",
"(",
"$",
"rh",
",",
"0.0",
")",
";",
"$",
"r",
"=",
"min",
"(",
"$",
"r",
",",
"1.0",
")",
";",
"$",
"w",
"=",
"max",
"(",
"$",
"wl",
",",
"0.1",
")",
";",
"$",
"w",
"=",
"min",
"(",
"$",
"w",
",",
"1e6",
")",
";",
"/* Water vapour pressure at the observer. */",
"if",
"(",
"$",
"p",
">",
"0.0",
")",
"{",
"$",
"ps",
"=",
"pow",
"(",
"10.0",
",",
"(",
"0.7859",
"+",
"0.03477",
"*",
"$",
"t",
")",
"/",
"(",
"1.0",
"+",
"0.00412",
"*",
"$",
"t",
")",
")",
"*",
"(",
"1.0",
"+",
"$",
"p",
"*",
"(",
"4.5e-6",
"+",
"6e-10",
"*",
"$",
"t",
"*",
"$",
"t",
")",
")",
";",
"$",
"pw",
"=",
"$",
"r",
"*",
"$",
"ps",
"/",
"(",
"1.0",
"-",
"(",
"1.0",
"-",
"$",
"r",
")",
"*",
"$",
"ps",
"/",
"$",
"p",
")",
";",
"}",
"else",
"{",
"$",
"pw",
"=",
"0.0",
";",
"}",
"/* Refractive index minus 1 at the observer. */",
"$",
"tk",
"=",
"$",
"t",
"+",
"273.15",
";",
"if",
"(",
"$",
"optic",
")",
"{",
"$",
"wlsq",
"=",
"$",
"w",
"*",
"$",
"w",
";",
"$",
"gamma",
"=",
"(",
"(",
"77.53484e-6",
"+",
"(",
"4.39108e-7",
"+",
"3.666e-9",
"/",
"$",
"wlsq",
")",
"/",
"$",
"wlsq",
")",
"*",
"$",
"p",
"-",
"11.2684e-6",
"*",
"$",
"pw",
")",
"/",
"$",
"tk",
";",
"}",
"else",
"{",
"$",
"gamma",
"=",
"(",
"77.6890e-6",
"*",
"$",
"p",
"-",
"(",
"6.3938e-6",
"-",
"0.375463",
"/",
"$",
"tk",
")",
"*",
"$",
"pw",
")",
"/",
"$",
"tk",
";",
"}",
"/* Formula for beta from Stone, with empirical adjustments. */",
"$",
"beta",
"=",
"4.4474e-6",
"*",
"$",
"tk",
";",
"if",
"(",
"!",
"$",
"optic",
")",
"$",
"beta",
"-=",
"0.0074",
"*",
"$",
"pw",
"*",
"$",
"beta",
";",
"/* Refraction constants from Green. */",
"$",
"refa",
"=",
"$",
"gamma",
"*",
"(",
"1.0",
"-",
"$",
"beta",
")",
";",
"$",
"refb",
"=",
"-",
"$",
"gamma",
"*",
"(",
"$",
"beta",
"-",
"$",
"gamma",
"/",
"2.0",
")",
";",
"/* Finished. */",
"}"
] |
- - - - - - - - -
i a u R e f c o
- - - - - - - - -
Determine the constants A and B in the atmospheric refraction model
dZ = A tan Z + B tan^3 Z.
Z is the "observed" zenith distance (i.e. affected by refraction)
and dZ is what to add to Z to give the "topocentric" (i.e. in vacuo)
zenith distance.
This function is part of the International Astronomical Union's
SOFA (Standards of Fundamental Astronomy) software collection.
Status: support function.
Given:
phpa double pressure at the observer (hPa = millibar)
tc double ambient temperature at the observer (deg C)
rh double relative humidity at the observer (range 0-1)
wl double wavelength (micrometers)
Returned:
refa double* tan Z coefficient (radians)
refb double* tan^3 Z coefficient (radians)
Notes:
1) The model balances speed and accuracy to give good results in
applications where performance at low altitudes is not paramount.
Performance is maintained across a range of conditions, and
applies to both optical/IR and radio.
2) The model omits the effects of (i) height above sea level (apart
from the reduced pressure itself), (ii) latitude (i.e. the
flattening of the Earth), (iii) variations in tropospheric lapse
rate and (iv) dispersive effects in the radio.
The model was tested using the following range of conditions:
lapse rates 0.0055, 0.0065, 0.0075 deg/meter
latitudes 0, 25, 50, 75 degrees
heights 0, 2500, 5000 meters ASL
pressures mean for height -10% to +5% in steps of 5%
temperatures -10 deg to +20 deg with respect to 280 deg at SL
relative humidity 0, 0.5, 1
wavelengths 0.4, 0.6, ... 2 micron, + radio
zenith distances 15, 45, 75 degrees
The accuracy with respect to raytracing through a model
atmosphere was as follows:
worst RMS
optical/IR 62 mas 8 mas
radio 319 mas 49 mas
For this particular set of conditions:
lapse rate 0.0065 K/meter
latitude 50 degrees
sea level
pressure 1005 mb
temperature 280.15 K
humidity 80%
wavelength 5740 Angstroms
the results were as follows:
ZD raytrace iauRefco Saastamoinen
10 10.27 10.27 10.27
20 21.19 21.20 21.19
30 33.61 33.61 33.60
40 48.82 48.83 48.81
45 58.16 58.18 58.16
50 69.28 69.30 69.27
55 82.97 82.99 82.95
60 100.51 100.54 100.50
65 124.23 124.26 124.20
70 158.63 158.68 158.61
72 177.32 177.37 177.31
74 200.35 200.38 200.32
76 229.45 229.43 229.42
78 267.44 267.29 267.41
80 319.13 318.55 319.10
deg arcsec arcsec arcsec
The values for Saastamoinen's formula (which includes terms
up to tan^5) are taken from Hohenkerk and Sinclair (1985).
3) A wl value in the range 0-100 selects the optical/IR case and is
wavelength in micrometers. Any value outside this range selects
the radio case.
4) Outlandish input parameters are silently limited to
mathematically safe values. Zero pressure is permissible, and
causes zeroes to be returned.
5) The algorithm draws on several sources, as follows:
a) The formula for the saturation vapour pressure of water as
a function of temperature and temperature is taken from
Equations (A4.5-A4.7) of Gill (1982).
b) The formula for the water vapour pressure, given the
saturation pressure and the relative humidity, is from
Crane (1976), Equation (2.5.5).
c) The refractivity of air is a function of temperature,
total pressure, water-vapour pressure and, in the case
of optical/IR, wavelength. The formulae for the two cases are
developed from Hohenkerk & Sinclair (1985) and Rueger (2002).
d) The formula for beta, the ratio of the scale height of the
atmosphere to the geocentric distance of the observer, is
an adaption of Equation (9) from Stone (1996). The
adaptations, arrived at empirically, consist of (i) a small
adjustment to the coefficient and (ii) a humidity term for the
radio case only.
e) The formulae for the refraction constants as a function of
n-1 and beta are from Green (1987), Equation (4.31).
References:
Crane, R.K., Meeks, M.L. (ed), "Refraction Effects in the Neutral
Atmosphere", Methods of Experimental Physics: Astrophysics 12B,
Academic Press, 1976.
Gill, Adrian E., "Atmosphere-Ocean Dynamics", Academic Press,
1982.
Green, R.M., "Spherical Astronomy", Cambridge University Press,
1987.
Hohenkerk, C.Y., & Sinclair, A.T., NAO Technical Note No. 63,
1985.
Rueger, J.M., "Refractive Index Formulae for Electronic Distance
Measurement with Radio and Millimetre Waves", in Unisurv Report
S-68, School of Surveying and Spatial Information Systems,
University of New South Wales, Sydney, Australia, 2002.
Stone, Ronald C., P.A.S.P. 108, 1051-1058, 1996.
This revision: 2013 October 9
SOFA release 2015-02-09
Copyright (C) 2015 IAU SOFA Board. See notes at end.
|
[
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"i",
"a",
"u",
"R",
"e",
"f",
"c",
"o",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-"
] |
757fa49fe335ae1210eaa7735473fd4388b13f07
|
https://github.com/marando/phpSOFA/blob/757fa49fe335ae1210eaa7735473fd4388b13f07/src/Marando/IAU/iauRefco.php#L161-L220
|
239,269
|
codenamephp/prototype.utils
|
src/main/php/de/codenamephp/prototype/utils/answerCollector/ComposerIO.php
|
ComposerIO.getAnswers
|
public function getAnswers(\Composer\IO\IOInterface $io, array $questions): array {
$answers = [];
foreach($questions as $key => $question) {
$answers[$key] = $io->ask($question->getQuestion(), $question->getDefault());
}
return $answers;
}
|
php
|
public function getAnswers(\Composer\IO\IOInterface $io, array $questions): array {
$answers = [];
foreach($questions as $key => $question) {
$answers[$key] = $io->ask($question->getQuestion(), $question->getDefault());
}
return $answers;
}
|
[
"public",
"function",
"getAnswers",
"(",
"\\",
"Composer",
"\\",
"IO",
"\\",
"IOInterface",
"$",
"io",
",",
"array",
"$",
"questions",
")",
":",
"array",
"{",
"$",
"answers",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"questions",
"as",
"$",
"key",
"=>",
"$",
"question",
")",
"{",
"$",
"answers",
"[",
"$",
"key",
"]",
"=",
"$",
"io",
"->",
"ask",
"(",
"$",
"question",
"->",
"getQuestion",
"(",
")",
",",
"$",
"question",
"->",
"getDefault",
"(",
")",
")",
";",
"}",
"return",
"$",
"answers",
";",
"}"
] |
Iterates over the given questions and uses them to ask the questions via the given io and feed with the defaults.
The answers array will contain the answer from the io with the key from the questions array.
$questions: ['some key' => \de\codenamephp\platform\cli\question\iQuestion, ...]
$answers: ['some key' => 'given answer', ...]
@param \Composer\IO\IOInterface $io The composer io used to ask the questions on the command line
@param \de\codenamephp\platform\cli\question\iQuestion[string] $questions The questions to be asked, the keys will be used for tha answers array
@return string[] Contains the given answers with the keys from the questions
|
[
"Iterates",
"over",
"the",
"given",
"questions",
"and",
"uses",
"them",
"to",
"ask",
"the",
"questions",
"via",
"the",
"given",
"io",
"and",
"feed",
"with",
"the",
"defaults",
"."
] |
aeb81e1e03624534e8b3e38d6466efda04e435d6
|
https://github.com/codenamephp/prototype.utils/blob/aeb81e1e03624534e8b3e38d6466efda04e435d6/src/main/php/de/codenamephp/prototype/utils/answerCollector/ComposerIO.php#L45-L51
|
239,270
|
mszewcz/php-json-schema-validator
|
src/Validators/StringValidators/FormatDateTimeValidator.php
|
FormatDateTimeValidator.validateTimezoneTime
|
private function validateTimezoneTime(int $hour, int $minutes): bool
{
if (!$this->validateHour($hour)) {
return false;
}
if (!$this->validateMinutes($minutes)) {
return false;
}
return true;
}
|
php
|
private function validateTimezoneTime(int $hour, int $minutes): bool
{
if (!$this->validateHour($hour)) {
return false;
}
if (!$this->validateMinutes($minutes)) {
return false;
}
return true;
}
|
[
"private",
"function",
"validateTimezoneTime",
"(",
"int",
"$",
"hour",
",",
"int",
"$",
"minutes",
")",
":",
"bool",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"validateHour",
"(",
"$",
"hour",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"validateMinutes",
"(",
"$",
"minutes",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] |
Validates timezone time
@param int $hour
@param int $minutes
@return bool
|
[
"Validates",
"timezone",
"time"
] |
f7768bfe07ce6508bb1ff36163560a5e5791de7d
|
https://github.com/mszewcz/php-json-schema-validator/blob/f7768bfe07ce6508bb1ff36163560a5e5791de7d/src/Validators/StringValidators/FormatDateTimeValidator.php#L137-L146
|
239,271
|
phlexible/phlexible
|
src/Phlexible/Bundle/TeaserBundle/Controller/LayoutController.php
|
LayoutController.childElementtypesAction
|
public function childElementtypesAction(Request $request)
{
$id = $request->get('id');
$elementSourceManager = $this->get('phlexible_element.element_source_manager');
$elementService = $this->get('phlexible_element.element_service');
$iconResolver = $this->get('phlexible_element.icon_resolver');
$elementtype = $elementSourceManager->findElementtype($id);
$childElementtypes = $elementService->findAllowedChildren($elementtype);
$data = [];
foreach ($childElementtypes as $childElementtype) {
$data[$childElementtype->getTitle().$childElementtype->getId()] = [
'id' => $childElementtype->getId(),
'title' => $childElementtype->getTitle(),
'icon' => $iconResolver->resolveElementtype($childElementtype),
];
}
ksort($data);
$data = array_values($data);
return new JsonResponse(['elementtypes' => $data]);
}
|
php
|
public function childElementtypesAction(Request $request)
{
$id = $request->get('id');
$elementSourceManager = $this->get('phlexible_element.element_source_manager');
$elementService = $this->get('phlexible_element.element_service');
$iconResolver = $this->get('phlexible_element.icon_resolver');
$elementtype = $elementSourceManager->findElementtype($id);
$childElementtypes = $elementService->findAllowedChildren($elementtype);
$data = [];
foreach ($childElementtypes as $childElementtype) {
$data[$childElementtype->getTitle().$childElementtype->getId()] = [
'id' => $childElementtype->getId(),
'title' => $childElementtype->getTitle(),
'icon' => $iconResolver->resolveElementtype($childElementtype),
];
}
ksort($data);
$data = array_values($data);
return new JsonResponse(['elementtypes' => $data]);
}
|
[
"public",
"function",
"childElementtypesAction",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"id",
"=",
"$",
"request",
"->",
"get",
"(",
"'id'",
")",
";",
"$",
"elementSourceManager",
"=",
"$",
"this",
"->",
"get",
"(",
"'phlexible_element.element_source_manager'",
")",
";",
"$",
"elementService",
"=",
"$",
"this",
"->",
"get",
"(",
"'phlexible_element.element_service'",
")",
";",
"$",
"iconResolver",
"=",
"$",
"this",
"->",
"get",
"(",
"'phlexible_element.icon_resolver'",
")",
";",
"$",
"elementtype",
"=",
"$",
"elementSourceManager",
"->",
"findElementtype",
"(",
"$",
"id",
")",
";",
"$",
"childElementtypes",
"=",
"$",
"elementService",
"->",
"findAllowedChildren",
"(",
"$",
"elementtype",
")",
";",
"$",
"data",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"childElementtypes",
"as",
"$",
"childElementtype",
")",
"{",
"$",
"data",
"[",
"$",
"childElementtype",
"->",
"getTitle",
"(",
")",
".",
"$",
"childElementtype",
"->",
"getId",
"(",
")",
"]",
"=",
"[",
"'id'",
"=>",
"$",
"childElementtype",
"->",
"getId",
"(",
")",
",",
"'title'",
"=>",
"$",
"childElementtype",
"->",
"getTitle",
"(",
")",
",",
"'icon'",
"=>",
"$",
"iconResolver",
"->",
"resolveElementtype",
"(",
"$",
"childElementtype",
")",
",",
"]",
";",
"}",
"ksort",
"(",
"$",
"data",
")",
";",
"$",
"data",
"=",
"array_values",
"(",
"$",
"data",
")",
";",
"return",
"new",
"JsonResponse",
"(",
"[",
"'elementtypes'",
"=>",
"$",
"data",
"]",
")",
";",
"}"
] |
List all element child elementtypes.
@param Request $request
@return JsonResponse
@Route("/childelementtypes", name="teasers_layout_childelementtypes")
|
[
"List",
"all",
"element",
"child",
"elementtypes",
"."
] |
132f24924c9bb0dbb6c1ea84db0a463f97fa3893
|
https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Bundle/TeaserBundle/Controller/LayoutController.php#L371-L394
|
239,272
|
phlexible/phlexible
|
src/Phlexible/Bundle/TeaserBundle/Controller/LayoutController.php
|
LayoutController.childElementsAction
|
public function childElementsAction(Request $request)
{
$tid = $request->get('tree_id');
$layoutareaId = $request->get('layoutarea_id');
$language = $request->get('language', 'de');
$translator = $this->get('translator');
$treeManager = $this->get('phlexible_tree.tree_manager');
$teaserManager = $this->get('phlexible_teaser.teaser_manager');
$elementService = $this->get('phlexible_element.element_service');
$elementtypeService = $this->get('phlexible_elementtype.elementtype_service');
$iconResolver = $this->get('phlexible_element.icon_resolver');
$data = [];
$data[] = [
'id' => '0',
'title' => $translator->trans('elements.first', [], 'gui'),
'icon' => $iconResolver->resolveIcon('_top.gif'),
];
$tree = $treeManager->getByNodeId($tid);
$treeNode = $tree->get($tid);
$treeNodePath = $tree->getPath($treeNode);
$layoutarea = $elementtypeService->findElementtype($layoutareaId);
$teasers = $teaserManager->findForLayoutAreaAndTreeNodePath($layoutarea, $treeNodePath);
foreach ($teasers as $teaser) {
$teaserElement = $elementService->findElement($teaser->getTypeId());
$teaserElementVersion = $elementService->findLatestElementVersion($teaserElement);
$data[] = [
'id' => $teaser->getId(),
'title' => $teaserElementVersion->getBackendTitle($language),
'icon' => $iconResolver->resolveTeaser($teaser, $language),
];
}
return new JsonResponse(['elements' => $data]);
}
|
php
|
public function childElementsAction(Request $request)
{
$tid = $request->get('tree_id');
$layoutareaId = $request->get('layoutarea_id');
$language = $request->get('language', 'de');
$translator = $this->get('translator');
$treeManager = $this->get('phlexible_tree.tree_manager');
$teaserManager = $this->get('phlexible_teaser.teaser_manager');
$elementService = $this->get('phlexible_element.element_service');
$elementtypeService = $this->get('phlexible_elementtype.elementtype_service');
$iconResolver = $this->get('phlexible_element.icon_resolver');
$data = [];
$data[] = [
'id' => '0',
'title' => $translator->trans('elements.first', [], 'gui'),
'icon' => $iconResolver->resolveIcon('_top.gif'),
];
$tree = $treeManager->getByNodeId($tid);
$treeNode = $tree->get($tid);
$treeNodePath = $tree->getPath($treeNode);
$layoutarea = $elementtypeService->findElementtype($layoutareaId);
$teasers = $teaserManager->findForLayoutAreaAndTreeNodePath($layoutarea, $treeNodePath);
foreach ($teasers as $teaser) {
$teaserElement = $elementService->findElement($teaser->getTypeId());
$teaserElementVersion = $elementService->findLatestElementVersion($teaserElement);
$data[] = [
'id' => $teaser->getId(),
'title' => $teaserElementVersion->getBackendTitle($language),
'icon' => $iconResolver->resolveTeaser($teaser, $language),
];
}
return new JsonResponse(['elements' => $data]);
}
|
[
"public",
"function",
"childElementsAction",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"tid",
"=",
"$",
"request",
"->",
"get",
"(",
"'tree_id'",
")",
";",
"$",
"layoutareaId",
"=",
"$",
"request",
"->",
"get",
"(",
"'layoutarea_id'",
")",
";",
"$",
"language",
"=",
"$",
"request",
"->",
"get",
"(",
"'language'",
",",
"'de'",
")",
";",
"$",
"translator",
"=",
"$",
"this",
"->",
"get",
"(",
"'translator'",
")",
";",
"$",
"treeManager",
"=",
"$",
"this",
"->",
"get",
"(",
"'phlexible_tree.tree_manager'",
")",
";",
"$",
"teaserManager",
"=",
"$",
"this",
"->",
"get",
"(",
"'phlexible_teaser.teaser_manager'",
")",
";",
"$",
"elementService",
"=",
"$",
"this",
"->",
"get",
"(",
"'phlexible_element.element_service'",
")",
";",
"$",
"elementtypeService",
"=",
"$",
"this",
"->",
"get",
"(",
"'phlexible_elementtype.elementtype_service'",
")",
";",
"$",
"iconResolver",
"=",
"$",
"this",
"->",
"get",
"(",
"'phlexible_element.icon_resolver'",
")",
";",
"$",
"data",
"=",
"[",
"]",
";",
"$",
"data",
"[",
"]",
"=",
"[",
"'id'",
"=>",
"'0'",
",",
"'title'",
"=>",
"$",
"translator",
"->",
"trans",
"(",
"'elements.first'",
",",
"[",
"]",
",",
"'gui'",
")",
",",
"'icon'",
"=>",
"$",
"iconResolver",
"->",
"resolveIcon",
"(",
"'_top.gif'",
")",
",",
"]",
";",
"$",
"tree",
"=",
"$",
"treeManager",
"->",
"getByNodeId",
"(",
"$",
"tid",
")",
";",
"$",
"treeNode",
"=",
"$",
"tree",
"->",
"get",
"(",
"$",
"tid",
")",
";",
"$",
"treeNodePath",
"=",
"$",
"tree",
"->",
"getPath",
"(",
"$",
"treeNode",
")",
";",
"$",
"layoutarea",
"=",
"$",
"elementtypeService",
"->",
"findElementtype",
"(",
"$",
"layoutareaId",
")",
";",
"$",
"teasers",
"=",
"$",
"teaserManager",
"->",
"findForLayoutAreaAndTreeNodePath",
"(",
"$",
"layoutarea",
",",
"$",
"treeNodePath",
")",
";",
"foreach",
"(",
"$",
"teasers",
"as",
"$",
"teaser",
")",
"{",
"$",
"teaserElement",
"=",
"$",
"elementService",
"->",
"findElement",
"(",
"$",
"teaser",
"->",
"getTypeId",
"(",
")",
")",
";",
"$",
"teaserElementVersion",
"=",
"$",
"elementService",
"->",
"findLatestElementVersion",
"(",
"$",
"teaserElement",
")",
";",
"$",
"data",
"[",
"]",
"=",
"[",
"'id'",
"=>",
"$",
"teaser",
"->",
"getId",
"(",
")",
",",
"'title'",
"=>",
"$",
"teaserElementVersion",
"->",
"getBackendTitle",
"(",
"$",
"language",
")",
",",
"'icon'",
"=>",
"$",
"iconResolver",
"->",
"resolveTeaser",
"(",
"$",
"teaser",
",",
"$",
"language",
")",
",",
"]",
";",
"}",
"return",
"new",
"JsonResponse",
"(",
"[",
"'elements'",
"=>",
"$",
"data",
"]",
")",
";",
"}"
] |
List all child element types.
@param Request $request
@return JsonResponse
@Route("/childelements", name="teasers_layout_childelements")
|
[
"List",
"all",
"child",
"element",
"types",
"."
] |
132f24924c9bb0dbb6c1ea84db0a463f97fa3893
|
https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Bundle/TeaserBundle/Controller/LayoutController.php#L404-L442
|
239,273
|
cosmow/riak
|
lib/CosmoW/Riak/LoggableCollection.php
|
LoggableCollection.wrapCursor
|
protected function wrapCursor(\RiakCursor $cursor, $query, $fields)
{
return new LoggableCursor($this, $cursor, $query, $fields, $this->numRetries, $this->loggerCallable);
}
|
php
|
protected function wrapCursor(\RiakCursor $cursor, $query, $fields)
{
return new LoggableCursor($this, $cursor, $query, $fields, $this->numRetries, $this->loggerCallable);
}
|
[
"protected",
"function",
"wrapCursor",
"(",
"\\",
"RiakCursor",
"$",
"cursor",
",",
"$",
"query",
",",
"$",
"fields",
")",
"{",
"return",
"new",
"LoggableCursor",
"(",
"$",
"this",
",",
"$",
"cursor",
",",
"$",
"query",
",",
"$",
"fields",
",",
"$",
"this",
"->",
"numRetries",
",",
"$",
"this",
"->",
"loggerCallable",
")",
";",
"}"
] |
Wraps a RiakCursor instance with a LoggableCursor.
@see Collection::wrapCursor()
@param \RiakCursor $cursor
@param array $query
@param array $fields
@return LoggableCursor
|
[
"Wraps",
"a",
"RiakCursor",
"instance",
"with",
"a",
"LoggableCursor",
"."
] |
49c2bbfbbc036cd38babfeba1e93667ceca5ec0a
|
https://github.com/cosmow/riak/blob/49c2bbfbbc036cd38babfeba1e93667ceca5ec0a/lib/CosmoW/Riak/LoggableCollection.php#L399-L402
|
239,274
|
xloit/xloit-bridge-zend-validator
|
src/Password.php
|
Password.setMaximumLength
|
public function setMaximumLength($maximumLength)
{
if ($maximumLength <= $this->minimalLength) {
throw new Exception\InvalidArgumentException('Maximum length must be larger than minimal length.');
}
$this->maximumLength = $maximumLength;
return $this;
}
|
php
|
public function setMaximumLength($maximumLength)
{
if ($maximumLength <= $this->minimalLength) {
throw new Exception\InvalidArgumentException('Maximum length must be larger than minimal length.');
}
$this->maximumLength = $maximumLength;
return $this;
}
|
[
"public",
"function",
"setMaximumLength",
"(",
"$",
"maximumLength",
")",
"{",
"if",
"(",
"$",
"maximumLength",
"<=",
"$",
"this",
"->",
"minimalLength",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"InvalidArgumentException",
"(",
"'Maximum length must be larger than minimal length.'",
")",
";",
"}",
"$",
"this",
"->",
"maximumLength",
"=",
"$",
"maximumLength",
";",
"return",
"$",
"this",
";",
"}"
] |
Sets the MaximumLength value.
@param int $maximumLength
@return $this
@throws \Xloit\Bridge\Zend\Validator\Exception\InvalidArgumentException
|
[
"Sets",
"the",
"MaximumLength",
"value",
"."
] |
2e789986e6551f157d4e07cf4c27d027dd070324
|
https://github.com/xloit/xloit-bridge-zend-validator/blob/2e789986e6551f157d4e07cf4c27d027dd070324/src/Password.php#L233-L242
|
239,275
|
indigophp-archive/fuel-core
|
lib/Fuel/Orm/Observer/CreatedBy.php
|
CreatedBy.before_insert
|
public function before_insert(Orm\Model $obj)
{
if ($obj instanceof Orm\Model_Temporal)
{
if ($obj->{$obj->temporal_property('end_column')} !== $obj->temporal_property('max_timestamp')) {
return false;
}
}
if ($user_id = \Auth::get_user_id())
{
$obj->{$this->_property} = $user_id[1];
}
}
|
php
|
public function before_insert(Orm\Model $obj)
{
if ($obj instanceof Orm\Model_Temporal)
{
if ($obj->{$obj->temporal_property('end_column')} !== $obj->temporal_property('max_timestamp')) {
return false;
}
}
if ($user_id = \Auth::get_user_id())
{
$obj->{$this->_property} = $user_id[1];
}
}
|
[
"public",
"function",
"before_insert",
"(",
"Orm",
"\\",
"Model",
"$",
"obj",
")",
"{",
"if",
"(",
"$",
"obj",
"instanceof",
"Orm",
"\\",
"Model_Temporal",
")",
"{",
"if",
"(",
"$",
"obj",
"->",
"{",
"$",
"obj",
"->",
"temporal_property",
"(",
"'end_column'",
")",
"}",
"!==",
"$",
"obj",
"->",
"temporal_property",
"(",
"'max_timestamp'",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"if",
"(",
"$",
"user_id",
"=",
"\\",
"Auth",
"::",
"get_user_id",
"(",
")",
")",
"{",
"$",
"obj",
"->",
"{",
"$",
"this",
"->",
"_property",
"}",
"=",
"$",
"user_id",
"[",
"1",
"]",
";",
"}",
"}"
] |
Sets the CreatedBy property to the current user id
@param Model Model object subject of this observer method
|
[
"Sets",
"the",
"CreatedBy",
"property",
"to",
"the",
"current",
"user",
"id"
] |
275462154fb7937f8e1c2c541b31d8e7c5760e39
|
https://github.com/indigophp-archive/fuel-core/blob/275462154fb7937f8e1c2c541b31d8e7c5760e39/lib/Fuel/Orm/Observer/CreatedBy.php#L56-L69
|
239,276
|
matteosister/PygmentsElephantBundle
|
Routing/CssRoutingLoader.php
|
CssRoutingLoader.load
|
public function load($resource, $type = null)
{
$routes = new RouteCollection();
$pattern = '/_pygments_bundle/style.css';
$defaults = array(
'_controller' => 'CypressPygmentsElephantBundle:Main:css',
);
$route = new Route($pattern, $defaults);
$routes->add('pygments_bundle_style', $route);
return $routes;
}
|
php
|
public function load($resource, $type = null)
{
$routes = new RouteCollection();
$pattern = '/_pygments_bundle/style.css';
$defaults = array(
'_controller' => 'CypressPygmentsElephantBundle:Main:css',
);
$route = new Route($pattern, $defaults);
$routes->add('pygments_bundle_style', $route);
return $routes;
}
|
[
"public",
"function",
"load",
"(",
"$",
"resource",
",",
"$",
"type",
"=",
"null",
")",
"{",
"$",
"routes",
"=",
"new",
"RouteCollection",
"(",
")",
";",
"$",
"pattern",
"=",
"'/_pygments_bundle/style.css'",
";",
"$",
"defaults",
"=",
"array",
"(",
"'_controller'",
"=>",
"'CypressPygmentsElephantBundle:Main:css'",
",",
")",
";",
"$",
"route",
"=",
"new",
"Route",
"(",
"$",
"pattern",
",",
"$",
"defaults",
")",
";",
"$",
"routes",
"->",
"add",
"(",
"'pygments_bundle_style'",
",",
"$",
"route",
")",
";",
"return",
"$",
"routes",
";",
"}"
] |
Loads a resource
@param mixed $resource The resource
@param string $type The resource type
@return \Symfony\Component\Routing\RouteCollection
|
[
"Loads",
"a",
"resource"
] |
647cc00272126314f6d083d8b2350a9d6280bade
|
https://github.com/matteosister/PygmentsElephantBundle/blob/647cc00272126314f6d083d8b2350a9d6280bade/Routing/CssRoutingLoader.php#L27-L40
|
239,277
|
qi-interactive/matacms-rbac
|
controllers/AssignmentController.php
|
AssignmentController.actionAssign
|
public function actionAssign($id)
{
$model = Yii::createObject([
'class' => Assignment::className(),
'user_id' => $id,
]);
if ($model->load(\Yii::$app->request->post()) && $model->updateAssignments()) {
}
return \matacms\rbac\widgets\Assignments::widget([
'model' => $model,
]);
/*$model = Yii::createObject([
'class' => Assignment::className(),
'user_id' => $id,
]);
if ($model->load(Yii::$app->request->post()) && $model->updateAssignments()) {
}
return $this->render('assign', [
'model' => $model,
]);*/
}
|
php
|
public function actionAssign($id)
{
$model = Yii::createObject([
'class' => Assignment::className(),
'user_id' => $id,
]);
if ($model->load(\Yii::$app->request->post()) && $model->updateAssignments()) {
}
return \matacms\rbac\widgets\Assignments::widget([
'model' => $model,
]);
/*$model = Yii::createObject([
'class' => Assignment::className(),
'user_id' => $id,
]);
if ($model->load(Yii::$app->request->post()) && $model->updateAssignments()) {
}
return $this->render('assign', [
'model' => $model,
]);*/
}
|
[
"public",
"function",
"actionAssign",
"(",
"$",
"id",
")",
"{",
"$",
"model",
"=",
"Yii",
"::",
"createObject",
"(",
"[",
"'class'",
"=>",
"Assignment",
"::",
"className",
"(",
")",
",",
"'user_id'",
"=>",
"$",
"id",
",",
"]",
")",
";",
"if",
"(",
"$",
"model",
"->",
"load",
"(",
"\\",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"post",
"(",
")",
")",
"&&",
"$",
"model",
"->",
"updateAssignments",
"(",
")",
")",
"{",
"}",
"return",
"\\",
"matacms",
"\\",
"rbac",
"\\",
"widgets",
"\\",
"Assignments",
"::",
"widget",
"(",
"[",
"'model'",
"=>",
"$",
"model",
",",
"]",
")",
";",
"/*$model = Yii::createObject([\n 'class' => Assignment::className(),\n 'user_id' => $id,\n ]);\n\n if ($model->load(Yii::$app->request->post()) && $model->updateAssignments()) {\n\n }\n\n return $this->render('assign', [\n 'model' => $model,\n ]);*/",
"}"
] |
Show form with auth items for user.
@param int $id
|
[
"Show",
"form",
"with",
"auth",
"items",
"for",
"user",
"."
] |
f273de201006a127b95c332e53f31de02c559130
|
https://github.com/qi-interactive/matacms-rbac/blob/f273de201006a127b95c332e53f31de02c559130/controllers/AssignmentController.php#L22-L47
|
239,278
|
studyportals/Utils
|
src/Number.php
|
Number.getBytes
|
public static function getBytes($value){
$value = trim($value);
$unit = $value{strlen($value)-1};
$value = floatval($value);
switch(strtolower($unit)){
case 'g':
$multiplier = 1073741824;
break;
case 'm':
$multiplier = 1048576;
break;
case 'k':
$multiplier = 1024;
break;
default:
ExceptionHandler::notice('Number::getBytes() expects unit to be either "g", "m" or "k"');
$multiplier = 1;
}
return $multiplier * $value;
}
|
php
|
public static function getBytes($value){
$value = trim($value);
$unit = $value{strlen($value)-1};
$value = floatval($value);
switch(strtolower($unit)){
case 'g':
$multiplier = 1073741824;
break;
case 'm':
$multiplier = 1048576;
break;
case 'k':
$multiplier = 1024;
break;
default:
ExceptionHandler::notice('Number::getBytes() expects unit to be either "g", "m" or "k"');
$multiplier = 1;
}
return $multiplier * $value;
}
|
[
"public",
"static",
"function",
"getBytes",
"(",
"$",
"value",
")",
"{",
"$",
"value",
"=",
"trim",
"(",
"$",
"value",
")",
";",
"$",
"unit",
"=",
"$",
"value",
"{",
"strlen",
"(",
"$",
"value",
")",
"-",
"1",
"}",
";",
"$",
"value",
"=",
"floatval",
"(",
"$",
"value",
")",
";",
"switch",
"(",
"strtolower",
"(",
"$",
"unit",
")",
")",
"{",
"case",
"'g'",
":",
"$",
"multiplier",
"=",
"1073741824",
";",
"break",
";",
"case",
"'m'",
":",
"$",
"multiplier",
"=",
"1048576",
";",
"break",
";",
"case",
"'k'",
":",
"$",
"multiplier",
"=",
"1024",
";",
"break",
";",
"default",
":",
"ExceptionHandler",
"::",
"notice",
"(",
"'Number::getBytes() expects unit to be either \"g\", \"m\" or \"k\"'",
")",
";",
"$",
"multiplier",
"=",
"1",
";",
"}",
"return",
"$",
"multiplier",
"*",
"$",
"value",
";",
"}"
] |
Get the number of bytes in a pretty-formated binary size string.
<p>Turns values like "1M" or "1.5K" into the actual number of bytes
these values represent.</p>
@param string $value
@return float
|
[
"Get",
"the",
"number",
"of",
"bytes",
"in",
"a",
"pretty",
"-",
"formated",
"binary",
"size",
"string",
"."
] |
eab69ca10ce3261480164cf8108ae7020459c847
|
https://github.com/studyportals/Utils/blob/eab69ca10ce3261480164cf8108ae7020459c847/src/Number.php#L36-L70
|
239,279
|
studyportals/Utils
|
src/Number.php
|
Number.formatNumber
|
public static function formatNumber($number, $decimals = 0, $invalid = '-'){
if(!is_numeric($number)) return $invalid;
$locale = localeconv();
return number_format($number, $decimals, $locale['decimal_point'], $locale['thousands_sep']);
}
|
php
|
public static function formatNumber($number, $decimals = 0, $invalid = '-'){
if(!is_numeric($number)) return $invalid;
$locale = localeconv();
return number_format($number, $decimals, $locale['decimal_point'], $locale['thousands_sep']);
}
|
[
"public",
"static",
"function",
"formatNumber",
"(",
"$",
"number",
",",
"$",
"decimals",
"=",
"0",
",",
"$",
"invalid",
"=",
"'-'",
")",
"{",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"number",
")",
")",
"return",
"$",
"invalid",
";",
"$",
"locale",
"=",
"localeconv",
"(",
")",
";",
"return",
"number_format",
"(",
"$",
"number",
",",
"$",
"decimals",
",",
"$",
"locale",
"[",
"'decimal_point'",
"]",
",",
"$",
"locale",
"[",
"'thousands_sep'",
"]",
")",
";",
"}"
] |
Locale aware number-format.
<p>Works similar to PHP's number_format(), only this version is locale
aware and will automatically use the correct decimal and thousand
seperators.</p>
<p>The parameter {@link $invalid} can be used to supply a value to
return in case a non-numeric value is passed in.</p>
@param float $number
@param integer $decimals
@param string $invalid
@return string
|
[
"Locale",
"aware",
"number",
"-",
"format",
"."
] |
eab69ca10ce3261480164cf8108ae7020459c847
|
https://github.com/studyportals/Utils/blob/eab69ca10ce3261480164cf8108ae7020459c847/src/Number.php#L88-L95
|
239,280
|
studyportals/Utils
|
src/Number.php
|
Number.formatTime
|
public static function formatTime($format, $time = null){
if(empty($time)) $time = time();
// Apply Windows-specific format mapping
if(PHP_OS == 'WINNT'){
$mapping = [
'%C' => sprintf('%02d', date('Y', $time) / 100),
'%D' => '%m/%d/%y',
'%e' => sprintf('%\' 2d', date('j', $time)),
'%h' => '%b',
'%n' => "\n",
'%r' => date('h:i:s', $time) . ' %p',
'%R' => date('H:i', $time),
'%t' => "\t",
'%T' => '%H:%M:%S',
'%u' => (($w = date('w', $time)) ? $w : 7)
];
$format = str_replace(array_keys($mapping), array_values($mapping), $format);
}
return strftime($format, $time);
}
|
php
|
public static function formatTime($format, $time = null){
if(empty($time)) $time = time();
// Apply Windows-specific format mapping
if(PHP_OS == 'WINNT'){
$mapping = [
'%C' => sprintf('%02d', date('Y', $time) / 100),
'%D' => '%m/%d/%y',
'%e' => sprintf('%\' 2d', date('j', $time)),
'%h' => '%b',
'%n' => "\n",
'%r' => date('h:i:s', $time) . ' %p',
'%R' => date('H:i', $time),
'%t' => "\t",
'%T' => '%H:%M:%S',
'%u' => (($w = date('w', $time)) ? $w : 7)
];
$format = str_replace(array_keys($mapping), array_values($mapping), $format);
}
return strftime($format, $time);
}
|
[
"public",
"static",
"function",
"formatTime",
"(",
"$",
"format",
",",
"$",
"time",
"=",
"null",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"time",
")",
")",
"$",
"time",
"=",
"time",
"(",
")",
";",
"// Apply Windows-specific format mapping",
"if",
"(",
"PHP_OS",
"==",
"'WINNT'",
")",
"{",
"$",
"mapping",
"=",
"[",
"'%C'",
"=>",
"sprintf",
"(",
"'%02d'",
",",
"date",
"(",
"'Y'",
",",
"$",
"time",
")",
"/",
"100",
")",
",",
"'%D'",
"=>",
"'%m/%d/%y'",
",",
"'%e'",
"=>",
"sprintf",
"(",
"'%\\' 2d'",
",",
"date",
"(",
"'j'",
",",
"$",
"time",
")",
")",
",",
"'%h'",
"=>",
"'%b'",
",",
"'%n'",
"=>",
"\"\\n\"",
",",
"'%r'",
"=>",
"date",
"(",
"'h:i:s'",
",",
"$",
"time",
")",
".",
"' %p'",
",",
"'%R'",
"=>",
"date",
"(",
"'H:i'",
",",
"$",
"time",
")",
",",
"'%t'",
"=>",
"\"\\t\"",
",",
"'%T'",
"=>",
"'%H:%M:%S'",
",",
"'%u'",
"=>",
"(",
"(",
"$",
"w",
"=",
"date",
"(",
"'w'",
",",
"$",
"time",
")",
")",
"?",
"$",
"w",
":",
"7",
")",
"]",
";",
"$",
"format",
"=",
"str_replace",
"(",
"array_keys",
"(",
"$",
"mapping",
")",
",",
"array_values",
"(",
"$",
"mapping",
")",
",",
"$",
"format",
")",
";",
"}",
"return",
"strftime",
"(",
"$",
"format",
",",
"$",
"time",
")",
";",
"}"
] |
Format timestamp as a human-readable string.
<p>This method is a wrapper around strftime() and as such accepts all
{@link $format} strings strftime() accepts. On non-Win32 systems this
method directly calls strftime(). On Win32 systems it attempts to
implement most of the formatting options missing from the native Win32
implementation.</p>
@param string $format
@param integer $time
@return string
@see \strftime()
|
[
"Format",
"timestamp",
"as",
"a",
"human",
"-",
"readable",
"string",
"."
] |
eab69ca10ce3261480164cf8108ae7020459c847
|
https://github.com/studyportals/Utils/blob/eab69ca10ce3261480164cf8108ae7020459c847/src/Number.php#L112-L137
|
239,281
|
studyportals/Utils
|
src/Number.php
|
Number.isValidTelephoneNumber
|
public static function isValidTelephoneNumber($telephone){
$numbers = str_split($telephone);
$nums = [];
foreach($numbers as $number){
if(ctype_digit($number)){
$nums[] = $number;
}
}
if(count($nums) > 8){
return true;
}
return false;
}
|
php
|
public static function isValidTelephoneNumber($telephone){
$numbers = str_split($telephone);
$nums = [];
foreach($numbers as $number){
if(ctype_digit($number)){
$nums[] = $number;
}
}
if(count($nums) > 8){
return true;
}
return false;
}
|
[
"public",
"static",
"function",
"isValidTelephoneNumber",
"(",
"$",
"telephone",
")",
"{",
"$",
"numbers",
"=",
"str_split",
"(",
"$",
"telephone",
")",
";",
"$",
"nums",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"numbers",
"as",
"$",
"number",
")",
"{",
"if",
"(",
"ctype_digit",
"(",
"$",
"number",
")",
")",
"{",
"$",
"nums",
"[",
"]",
"=",
"$",
"number",
";",
"}",
"}",
"if",
"(",
"count",
"(",
"$",
"nums",
")",
">",
"8",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Check if a phone number has at least 8 numbers.
<p>Really rough guesstimate.</p>
@param $telephone
@return bool
|
[
"Check",
"if",
"a",
"phone",
"number",
"has",
"at",
"least",
"8",
"numbers",
"."
] |
eab69ca10ce3261480164cf8108ae7020459c847
|
https://github.com/studyportals/Utils/blob/eab69ca10ce3261480164cf8108ae7020459c847/src/Number.php#L174-L193
|
239,282
|
studyportals/Utils
|
src/Number.php
|
Number.formatSocialNumber
|
public static function formatSocialNumber($number){
assert('is_integer($number)');
if(!is_integer($number)) return $number;
if($number > 10000000){
$number = round($number / 1000000) . 'M';
}
elseif($number > 1000000){
$number = round($number / 1000000, 1) . 'M';
}
elseif($number > 10000){
$number = round($number / 1000) . 'K';
}
elseif($number > 1000){
$number = round($number / 1000, 1) . 'K';
}
return $number;
}
|
php
|
public static function formatSocialNumber($number){
assert('is_integer($number)');
if(!is_integer($number)) return $number;
if($number > 10000000){
$number = round($number / 1000000) . 'M';
}
elseif($number > 1000000){
$number = round($number / 1000000, 1) . 'M';
}
elseif($number > 10000){
$number = round($number / 1000) . 'K';
}
elseif($number > 1000){
$number = round($number / 1000, 1) . 'K';
}
return $number;
}
|
[
"public",
"static",
"function",
"formatSocialNumber",
"(",
"$",
"number",
")",
"{",
"assert",
"(",
"'is_integer($number)'",
")",
";",
"if",
"(",
"!",
"is_integer",
"(",
"$",
"number",
")",
")",
"return",
"$",
"number",
";",
"if",
"(",
"$",
"number",
">",
"10000000",
")",
"{",
"$",
"number",
"=",
"round",
"(",
"$",
"number",
"/",
"1000000",
")",
".",
"'M'",
";",
"}",
"elseif",
"(",
"$",
"number",
">",
"1000000",
")",
"{",
"$",
"number",
"=",
"round",
"(",
"$",
"number",
"/",
"1000000",
",",
"1",
")",
".",
"'M'",
";",
"}",
"elseif",
"(",
"$",
"number",
">",
"10000",
")",
"{",
"$",
"number",
"=",
"round",
"(",
"$",
"number",
"/",
"1000",
")",
".",
"'K'",
";",
"}",
"elseif",
"(",
"$",
"number",
">",
"1000",
")",
"{",
"$",
"number",
"=",
"round",
"(",
"$",
"number",
"/",
"1000",
",",
"1",
")",
".",
"'K'",
";",
"}",
"return",
"$",
"number",
";",
"}"
] |
Formats the numer to populate 1, 10, 100, 1.1K, 10K, 1.1M, 10M
@param integer $number
@return string
|
[
"Formats",
"the",
"numer",
"to",
"populate",
"1",
"10",
"100",
"1",
".",
"1K",
"10K",
"1",
".",
"1M",
"10M"
] |
eab69ca10ce3261480164cf8108ae7020459c847
|
https://github.com/studyportals/Utils/blob/eab69ca10ce3261480164cf8108ae7020459c847/src/Number.php#L202-L226
|
239,283
|
kael-shipman/php-executables
|
src/AbstractExecutable.php
|
AbstractExecutable.handleSignal
|
protected function handleSignal(int $signo, $siginfo) : void
{
$this->log("Signal received: $signo", LOG_DEBUG, "syslog");
if ($signo === SIGTERM || $signo === SIGINT || $signo === SIGQUIT) {
$this->log("Termination signal received. Shutting down.", LOG_INFO, [ "syslog", STDOUT ], true);
$this->shutdown();
} elseif ($signo === SIGHUP) {
$this->config->reload();
}
}
|
php
|
protected function handleSignal(int $signo, $siginfo) : void
{
$this->log("Signal received: $signo", LOG_DEBUG, "syslog");
if ($signo === SIGTERM || $signo === SIGINT || $signo === SIGQUIT) {
$this->log("Termination signal received. Shutting down.", LOG_INFO, [ "syslog", STDOUT ], true);
$this->shutdown();
} elseif ($signo === SIGHUP) {
$this->config->reload();
}
}
|
[
"protected",
"function",
"handleSignal",
"(",
"int",
"$",
"signo",
",",
"$",
"siginfo",
")",
":",
"void",
"{",
"$",
"this",
"->",
"log",
"(",
"\"Signal received: $signo\"",
",",
"LOG_DEBUG",
",",
"\"syslog\"",
")",
";",
"if",
"(",
"$",
"signo",
"===",
"SIGTERM",
"||",
"$",
"signo",
"===",
"SIGINT",
"||",
"$",
"signo",
"===",
"SIGQUIT",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"\"Termination signal received. Shutting down.\"",
",",
"LOG_INFO",
",",
"[",
"\"syslog\"",
",",
"STDOUT",
"]",
",",
"true",
")",
";",
"$",
"this",
"->",
"shutdown",
"(",
")",
";",
"}",
"elseif",
"(",
"$",
"signo",
"===",
"SIGHUP",
")",
"{",
"$",
"this",
"->",
"config",
"->",
"reload",
"(",
")",
";",
"}",
"}"
] |
An overridable function for signal handling
See http://php.net/manual/en/function.pcntl-signal.php for information about signal handling
@param int $signo The int representation of the signal received
@param mixed $siginfo An optional (and usually absent) info packet associated with the signal
@return void
|
[
"An",
"overridable",
"function",
"for",
"signal",
"handling"
] |
f9b3f2222ced3ce7772673c5f5e84813e7651351
|
https://github.com/kael-shipman/php-executables/blob/f9b3f2222ced3ce7772673c5f5e84813e7651351/src/AbstractExecutable.php#L35-L44
|
239,284
|
mjacobus/php-objects
|
lib/PO/Hash.php
|
Hash.toArray
|
public function toArray($recursive = true)
{
$values = $this->values;
if (!$recursive) {
return $values;
}
foreach ($values as $key => $value) {
if (gettype($value) === 'object') {
if ($value instanceof Hash) {
$value = $value->toArray($recursive);
}
}
$values[$key] = $value;
}
return $values;
}
|
php
|
public function toArray($recursive = true)
{
$values = $this->values;
if (!$recursive) {
return $values;
}
foreach ($values as $key => $value) {
if (gettype($value) === 'object') {
if ($value instanceof Hash) {
$value = $value->toArray($recursive);
}
}
$values[$key] = $value;
}
return $values;
}
|
[
"public",
"function",
"toArray",
"(",
"$",
"recursive",
"=",
"true",
")",
"{",
"$",
"values",
"=",
"$",
"this",
"->",
"values",
";",
"if",
"(",
"!",
"$",
"recursive",
")",
"{",
"return",
"$",
"values",
";",
"}",
"foreach",
"(",
"$",
"values",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"gettype",
"(",
"$",
"value",
")",
"===",
"'object'",
")",
"{",
"if",
"(",
"$",
"value",
"instanceof",
"Hash",
")",
"{",
"$",
"value",
"=",
"$",
"value",
"->",
"toArray",
"(",
"$",
"recursive",
")",
";",
"}",
"}",
"$",
"values",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"return",
"$",
"values",
";",
"}"
] |
Converts hash to array
@param boolean $recursive defaults to true
@return array
|
[
"Converts",
"hash",
"to",
"array"
] |
5e5c5f14e2bb30565a0a758c899ecf877558f58b
|
https://github.com/mjacobus/php-objects/blob/5e5c5f14e2bb30565a0a758c899ecf877558f58b/lib/PO/Hash.php#L44-L63
|
239,285
|
mjacobus/php-objects
|
lib/PO/Hash.php
|
Hash.select
|
public function select($callback)
{
$hash = $this->create();
foreach ($this as $key => $value) {
if ($callback($value, $key) == true) {
$hash[$key] = $value;
}
}
return $hash;
}
|
php
|
public function select($callback)
{
$hash = $this->create();
foreach ($this as $key => $value) {
if ($callback($value, $key) == true) {
$hash[$key] = $value;
}
}
return $hash;
}
|
[
"public",
"function",
"select",
"(",
"$",
"callback",
")",
"{",
"$",
"hash",
"=",
"$",
"this",
"->",
"create",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"callback",
"(",
"$",
"value",
",",
"$",
"key",
")",
"==",
"true",
")",
"{",
"$",
"hash",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"return",
"$",
"hash",
";",
"}"
] |
Select elements if the given function evaluates to true
@param $callback callable function
@return Hash the new hash containing the non rejected elements
|
[
"Select",
"elements",
"if",
"the",
"given",
"function",
"evaluates",
"to",
"true"
] |
5e5c5f14e2bb30565a0a758c899ecf877558f58b
|
https://github.com/mjacobus/php-objects/blob/5e5c5f14e2bb30565a0a758c899ecf877558f58b/lib/PO/Hash.php#L185-L196
|
239,286
|
mjacobus/php-objects
|
lib/PO/Hash.php
|
Hash.keys
|
public function keys()
{
return $this->create(array_keys($this->toArray()))->map(
function ($key) {
return new String($key);
}
);
}
|
php
|
public function keys()
{
return $this->create(array_keys($this->toArray()))->map(
function ($key) {
return new String($key);
}
);
}
|
[
"public",
"function",
"keys",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"create",
"(",
"array_keys",
"(",
"$",
"this",
"->",
"toArray",
"(",
")",
")",
")",
"->",
"map",
"(",
"function",
"(",
"$",
"key",
")",
"{",
"return",
"new",
"String",
"(",
"$",
"key",
")",
";",
"}",
")",
";",
"}"
] |
Get the array keys
@return Hash[String] containing the keys
|
[
"Get",
"the",
"array",
"keys"
] |
5e5c5f14e2bb30565a0a758c899ecf877558f58b
|
https://github.com/mjacobus/php-objects/blob/5e5c5f14e2bb30565a0a758c899ecf877558f58b/lib/PO/Hash.php#L270-L277
|
239,287
|
gossi/trixionary
|
src/model/Map/SkillPartTableMap.php
|
SkillPartTableMap.doDelete
|
public static function doDelete($values, ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(SkillPartTableMap::DATABASE_NAME);
}
if ($values instanceof Criteria) {
// rename for clarity
$criteria = $values;
} elseif ($values instanceof \gossi\trixionary\model\SkillPart) { // it's a model object
// create criteria based on pk values
$criteria = $values->buildPkeyCriteria();
} else { // it's a primary key, or an array of pks
$criteria = new Criteria(SkillPartTableMap::DATABASE_NAME);
// primary key is composite; we therefore, expect
// the primary key passed to be an array of pkey values
if (count($values) == count($values, COUNT_RECURSIVE)) {
// array is not multi-dimensional
$values = array($values);
}
foreach ($values as $value) {
$criterion = $criteria->getNewCriterion(SkillPartTableMap::COL_PART_ID, $value[0]);
$criterion->addAnd($criteria->getNewCriterion(SkillPartTableMap::COL_COMPOSITE_ID, $value[1]));
$criteria->addOr($criterion);
}
}
$query = SkillPartQuery::create()->mergeWith($criteria);
if ($values instanceof Criteria) {
SkillPartTableMap::clearInstancePool();
} elseif (!is_object($values)) { // it's a primary key, or an array of pks
foreach ((array) $values as $singleval) {
SkillPartTableMap::removeInstanceFromPool($singleval);
}
}
return $query->delete($con);
}
|
php
|
public static function doDelete($values, ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(SkillPartTableMap::DATABASE_NAME);
}
if ($values instanceof Criteria) {
// rename for clarity
$criteria = $values;
} elseif ($values instanceof \gossi\trixionary\model\SkillPart) { // it's a model object
// create criteria based on pk values
$criteria = $values->buildPkeyCriteria();
} else { // it's a primary key, or an array of pks
$criteria = new Criteria(SkillPartTableMap::DATABASE_NAME);
// primary key is composite; we therefore, expect
// the primary key passed to be an array of pkey values
if (count($values) == count($values, COUNT_RECURSIVE)) {
// array is not multi-dimensional
$values = array($values);
}
foreach ($values as $value) {
$criterion = $criteria->getNewCriterion(SkillPartTableMap::COL_PART_ID, $value[0]);
$criterion->addAnd($criteria->getNewCriterion(SkillPartTableMap::COL_COMPOSITE_ID, $value[1]));
$criteria->addOr($criterion);
}
}
$query = SkillPartQuery::create()->mergeWith($criteria);
if ($values instanceof Criteria) {
SkillPartTableMap::clearInstancePool();
} elseif (!is_object($values)) { // it's a primary key, or an array of pks
foreach ((array) $values as $singleval) {
SkillPartTableMap::removeInstanceFromPool($singleval);
}
}
return $query->delete($con);
}
|
[
"public",
"static",
"function",
"doDelete",
"(",
"$",
"values",
",",
"ConnectionInterface",
"$",
"con",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"con",
")",
"{",
"$",
"con",
"=",
"Propel",
"::",
"getServiceContainer",
"(",
")",
"->",
"getWriteConnection",
"(",
"SkillPartTableMap",
"::",
"DATABASE_NAME",
")",
";",
"}",
"if",
"(",
"$",
"values",
"instanceof",
"Criteria",
")",
"{",
"// rename for clarity",
"$",
"criteria",
"=",
"$",
"values",
";",
"}",
"elseif",
"(",
"$",
"values",
"instanceof",
"\\",
"gossi",
"\\",
"trixionary",
"\\",
"model",
"\\",
"SkillPart",
")",
"{",
"// it's a model object",
"// create criteria based on pk values",
"$",
"criteria",
"=",
"$",
"values",
"->",
"buildPkeyCriteria",
"(",
")",
";",
"}",
"else",
"{",
"// it's a primary key, or an array of pks",
"$",
"criteria",
"=",
"new",
"Criteria",
"(",
"SkillPartTableMap",
"::",
"DATABASE_NAME",
")",
";",
"// primary key is composite; we therefore, expect",
"// the primary key passed to be an array of pkey values",
"if",
"(",
"count",
"(",
"$",
"values",
")",
"==",
"count",
"(",
"$",
"values",
",",
"COUNT_RECURSIVE",
")",
")",
"{",
"// array is not multi-dimensional",
"$",
"values",
"=",
"array",
"(",
"$",
"values",
")",
";",
"}",
"foreach",
"(",
"$",
"values",
"as",
"$",
"value",
")",
"{",
"$",
"criterion",
"=",
"$",
"criteria",
"->",
"getNewCriterion",
"(",
"SkillPartTableMap",
"::",
"COL_PART_ID",
",",
"$",
"value",
"[",
"0",
"]",
")",
";",
"$",
"criterion",
"->",
"addAnd",
"(",
"$",
"criteria",
"->",
"getNewCriterion",
"(",
"SkillPartTableMap",
"::",
"COL_COMPOSITE_ID",
",",
"$",
"value",
"[",
"1",
"]",
")",
")",
";",
"$",
"criteria",
"->",
"addOr",
"(",
"$",
"criterion",
")",
";",
"}",
"}",
"$",
"query",
"=",
"SkillPartQuery",
"::",
"create",
"(",
")",
"->",
"mergeWith",
"(",
"$",
"criteria",
")",
";",
"if",
"(",
"$",
"values",
"instanceof",
"Criteria",
")",
"{",
"SkillPartTableMap",
"::",
"clearInstancePool",
"(",
")",
";",
"}",
"elseif",
"(",
"!",
"is_object",
"(",
"$",
"values",
")",
")",
"{",
"// it's a primary key, or an array of pks",
"foreach",
"(",
"(",
"array",
")",
"$",
"values",
"as",
"$",
"singleval",
")",
"{",
"SkillPartTableMap",
"::",
"removeInstanceFromPool",
"(",
"$",
"singleval",
")",
";",
"}",
"}",
"return",
"$",
"query",
"->",
"delete",
"(",
"$",
"con",
")",
";",
"}"
] |
Performs a DELETE on the database, given a SkillPart or Criteria object OR a primary key value.
@param mixed $values Criteria or SkillPart object or primary key or array of primary keys
which is used to create the DELETE statement
@param ConnectionInterface $con the connection to use
@return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
if supported by native driver or if emulated using Propel.
@throws PropelException Any exceptions caught during processing will be
rethrown wrapped into a PropelException.
|
[
"Performs",
"a",
"DELETE",
"on",
"the",
"database",
"given",
"a",
"SkillPart",
"or",
"Criteria",
"object",
"OR",
"a",
"primary",
"key",
"value",
"."
] |
221a6c5322473d7d7f8e322958a3ee46d87da150
|
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Map/SkillPartTableMap.php#L405-L443
|
239,288
|
gossi/trixionary
|
src/model/Map/SkillPartTableMap.php
|
SkillPartTableMap.doInsert
|
public static function doInsert($criteria, ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(SkillPartTableMap::DATABASE_NAME);
}
if ($criteria instanceof Criteria) {
$criteria = clone $criteria; // rename for clarity
} else {
$criteria = $criteria->buildCriteria(); // build Criteria from SkillPart object
}
// Set the correct dbName
$query = SkillPartQuery::create()->mergeWith($criteria);
// use transaction because $criteria could contain info
// for more than one table (I guess, conceivably)
return $con->transaction(function () use ($con, $query) {
return $query->doInsert($con);
});
}
|
php
|
public static function doInsert($criteria, ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(SkillPartTableMap::DATABASE_NAME);
}
if ($criteria instanceof Criteria) {
$criteria = clone $criteria; // rename for clarity
} else {
$criteria = $criteria->buildCriteria(); // build Criteria from SkillPart object
}
// Set the correct dbName
$query = SkillPartQuery::create()->mergeWith($criteria);
// use transaction because $criteria could contain info
// for more than one table (I guess, conceivably)
return $con->transaction(function () use ($con, $query) {
return $query->doInsert($con);
});
}
|
[
"public",
"static",
"function",
"doInsert",
"(",
"$",
"criteria",
",",
"ConnectionInterface",
"$",
"con",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"con",
")",
"{",
"$",
"con",
"=",
"Propel",
"::",
"getServiceContainer",
"(",
")",
"->",
"getWriteConnection",
"(",
"SkillPartTableMap",
"::",
"DATABASE_NAME",
")",
";",
"}",
"if",
"(",
"$",
"criteria",
"instanceof",
"Criteria",
")",
"{",
"$",
"criteria",
"=",
"clone",
"$",
"criteria",
";",
"// rename for clarity",
"}",
"else",
"{",
"$",
"criteria",
"=",
"$",
"criteria",
"->",
"buildCriteria",
"(",
")",
";",
"// build Criteria from SkillPart object",
"}",
"// Set the correct dbName",
"$",
"query",
"=",
"SkillPartQuery",
"::",
"create",
"(",
")",
"->",
"mergeWith",
"(",
"$",
"criteria",
")",
";",
"// use transaction because $criteria could contain info",
"// for more than one table (I guess, conceivably)",
"return",
"$",
"con",
"->",
"transaction",
"(",
"function",
"(",
")",
"use",
"(",
"$",
"con",
",",
"$",
"query",
")",
"{",
"return",
"$",
"query",
"->",
"doInsert",
"(",
"$",
"con",
")",
";",
"}",
")",
";",
"}"
] |
Performs an INSERT on the database, given a SkillPart or Criteria object.
@param mixed $criteria Criteria or SkillPart object containing data that is used to create the INSERT statement.
@param ConnectionInterface $con the ConnectionInterface connection to use
@return mixed The new primary key.
@throws PropelException Any exceptions caught during processing will be
rethrown wrapped into a PropelException.
|
[
"Performs",
"an",
"INSERT",
"on",
"the",
"database",
"given",
"a",
"SkillPart",
"or",
"Criteria",
"object",
"."
] |
221a6c5322473d7d7f8e322958a3ee46d87da150
|
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Map/SkillPartTableMap.php#L465-L486
|
239,289
|
ellipsephp/validation
|
src/ValidationResult.php
|
ValidationResult.getMessages
|
public function getMessages(): array
{
$errors = $this->getErrors();
$keys = array_keys($errors);
return array_reduce($keys, function ($messages, $key) use ($errors) {
$translated = $this->translator->getMessages($key, $errors[$key]);
return array_merge($messages, $translated);
}, []);
}
|
php
|
public function getMessages(): array
{
$errors = $this->getErrors();
$keys = array_keys($errors);
return array_reduce($keys, function ($messages, $key) use ($errors) {
$translated = $this->translator->getMessages($key, $errors[$key]);
return array_merge($messages, $translated);
}, []);
}
|
[
"public",
"function",
"getMessages",
"(",
")",
":",
"array",
"{",
"$",
"errors",
"=",
"$",
"this",
"->",
"getErrors",
"(",
")",
";",
"$",
"keys",
"=",
"array_keys",
"(",
"$",
"errors",
")",
";",
"return",
"array_reduce",
"(",
"$",
"keys",
",",
"function",
"(",
"$",
"messages",
",",
"$",
"key",
")",
"use",
"(",
"$",
"errors",
")",
"{",
"$",
"translated",
"=",
"$",
"this",
"->",
"translator",
"->",
"getMessages",
"(",
"$",
"key",
",",
"$",
"errors",
"[",
"$",
"key",
"]",
")",
";",
"return",
"array_merge",
"(",
"$",
"messages",
",",
"$",
"translated",
")",
";",
"}",
",",
"[",
"]",
")",
";",
"}"
] |
Return a list of translated error messages.
@return array
|
[
"Return",
"a",
"list",
"of",
"translated",
"error",
"messages",
"."
] |
5a7e11807099165ff6217bf8c38df4b21d99599d
|
https://github.com/ellipsephp/validation/blob/5a7e11807099165ff6217bf8c38df4b21d99599d/src/ValidationResult.php#L70-L83
|
239,290
|
rezzza/jobflow
|
src/Rezzza/Jobflow/Jobs.php
|
Jobs.createJobsBuilder
|
public static function createJobsBuilder()
{
$builder = new JobsBuilder();
$builder->addExtension(new Extension\Core\CoreExtension());
$builder->addExtension(new Extension\ETL\ETLExtension());
return $builder;
}
|
php
|
public static function createJobsBuilder()
{
$builder = new JobsBuilder();
$builder->addExtension(new Extension\Core\CoreExtension());
$builder->addExtension(new Extension\ETL\ETLExtension());
return $builder;
}
|
[
"public",
"static",
"function",
"createJobsBuilder",
"(",
")",
"{",
"$",
"builder",
"=",
"new",
"JobsBuilder",
"(",
")",
";",
"$",
"builder",
"->",
"addExtension",
"(",
"new",
"Extension",
"\\",
"Core",
"\\",
"CoreExtension",
"(",
")",
")",
";",
"$",
"builder",
"->",
"addExtension",
"(",
"new",
"Extension",
"\\",
"ETL",
"\\",
"ETLExtension",
"(",
")",
")",
";",
"return",
"$",
"builder",
";",
"}"
] |
Creates a form factory builder with the default configuration.
@return JobsBuilder The job factory builder.
|
[
"Creates",
"a",
"form",
"factory",
"builder",
"with",
"the",
"default",
"configuration",
"."
] |
80ded8ac6ed6a2f4500b8f86e2958701ec84fd65
|
https://github.com/rezzza/jobflow/blob/80ded8ac6ed6a2f4500b8f86e2958701ec84fd65/src/Rezzza/Jobflow/Jobs.php#L34-L41
|
239,291
|
ellipsephp/http
|
src/Handlers/RequestBasedRequestHandler.php
|
RequestBasedRequestHandler.isAjax
|
private function isAjax(ServerRequestInterface $request): bool
{
$params = $request->getServerParams();
if (! array_key_exists('HTTP_X_REQUESTED_WITH', $params)) {
return false;
}
return strtolower($params['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest';
}
|
php
|
private function isAjax(ServerRequestInterface $request): bool
{
$params = $request->getServerParams();
if (! array_key_exists('HTTP_X_REQUESTED_WITH', $params)) {
return false;
}
return strtolower($params['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest';
}
|
[
"private",
"function",
"isAjax",
"(",
"ServerRequestInterface",
"$",
"request",
")",
":",
"bool",
"{",
"$",
"params",
"=",
"$",
"request",
"->",
"getServerParams",
"(",
")",
";",
"if",
"(",
"!",
"array_key_exists",
"(",
"'HTTP_X_REQUESTED_WITH'",
",",
"$",
"params",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"strtolower",
"(",
"$",
"params",
"[",
"'HTTP_X_REQUESTED_WITH'",
"]",
")",
"==",
"'xmlhttprequest'",
";",
"}"
] |
Return whether the request is an ajax request.
@param \Psr\Http\Message\ServerRequestInterface $request
@return bool
|
[
"Return",
"whether",
"the",
"request",
"is",
"an",
"ajax",
"request",
"."
] |
20a2b0ae1d3a149a905b93ae0993203eb7d414e1
|
https://github.com/ellipsephp/http/blob/20a2b0ae1d3a149a905b93ae0993203eb7d414e1/src/Handlers/RequestBasedRequestHandler.php#L58-L69
|
239,292
|
ellipsephp/http
|
src/Handlers/RequestBasedRequestHandler.php
|
RequestBasedRequestHandler.preferred
|
private function preferred(ServerRequestInterface $request): RequestHandlerInterface
{
$negotiator = new Negotiator;
$accept = $request->getHeaderLine('Accept', '*/*');
$priorities = array_keys($this->handlers);
$best = $negotiator->getBest($accept, $priorities);
$mediatype = $best ? $best->getValue() : current($priorities);
return $this->handlers[$mediatype];
}
|
php
|
private function preferred(ServerRequestInterface $request): RequestHandlerInterface
{
$negotiator = new Negotiator;
$accept = $request->getHeaderLine('Accept', '*/*');
$priorities = array_keys($this->handlers);
$best = $negotiator->getBest($accept, $priorities);
$mediatype = $best ? $best->getValue() : current($priorities);
return $this->handlers[$mediatype];
}
|
[
"private",
"function",
"preferred",
"(",
"ServerRequestInterface",
"$",
"request",
")",
":",
"RequestHandlerInterface",
"{",
"$",
"negotiator",
"=",
"new",
"Negotiator",
";",
"$",
"accept",
"=",
"$",
"request",
"->",
"getHeaderLine",
"(",
"'Accept'",
",",
"'*/*'",
")",
";",
"$",
"priorities",
"=",
"array_keys",
"(",
"$",
"this",
"->",
"handlers",
")",
";",
"$",
"best",
"=",
"$",
"negotiator",
"->",
"getBest",
"(",
"$",
"accept",
",",
"$",
"priorities",
")",
";",
"$",
"mediatype",
"=",
"$",
"best",
"?",
"$",
"best",
"->",
"getValue",
"(",
")",
":",
"current",
"(",
"$",
"priorities",
")",
";",
"return",
"$",
"this",
"->",
"handlers",
"[",
"$",
"mediatype",
"]",
";",
"}"
] |
Return the preferred request handler. Fallback to the first one when no
request handler matches the request accept header.
@param \Psr\Http\Message\ServerRequestInterface $request
@return \Psr\Http\Server\RequestHandlerInterface
|
[
"Return",
"the",
"preferred",
"request",
"handler",
".",
"Fallback",
"to",
"the",
"first",
"one",
"when",
"no",
"request",
"handler",
"matches",
"the",
"request",
"accept",
"header",
"."
] |
20a2b0ae1d3a149a905b93ae0993203eb7d414e1
|
https://github.com/ellipsephp/http/blob/20a2b0ae1d3a149a905b93ae0993203eb7d414e1/src/Handlers/RequestBasedRequestHandler.php#L78-L89
|
239,293
|
vinala/kernel
|
src/Processes/Controller.php
|
Controller.addRoute
|
public static function addRoute($route, $controller, $root)
{
$file = $root.'app/http/Routes.php';
$content = "\n\ntarget('$route','$controller');";
file_put_contents($file, $content, FILE_APPEND | LOCK_EX);
return true;
}
|
php
|
public static function addRoute($route, $controller, $root)
{
$file = $root.'app/http/Routes.php';
$content = "\n\ntarget('$route','$controller');";
file_put_contents($file, $content, FILE_APPEND | LOCK_EX);
return true;
}
|
[
"public",
"static",
"function",
"addRoute",
"(",
"$",
"route",
",",
"$",
"controller",
",",
"$",
"root",
")",
"{",
"$",
"file",
"=",
"$",
"root",
".",
"'app/http/Routes.php'",
";",
"$",
"content",
"=",
"\"\\n\\ntarget('$route','$controller');\"",
";",
"file_put_contents",
"(",
"$",
"file",
",",
"$",
"content",
",",
"FILE_APPEND",
"|",
"LOCK_EX",
")",
";",
"return",
"true",
";",
"}"
] |
Add controller route to routes file.
@param string $route
@param string $controller
@return bool
|
[
"Add",
"controller",
"route",
"to",
"routes",
"file",
"."
] |
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
|
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Processes/Controller.php#L86-L94
|
239,294
|
vinala/kernel
|
src/Processes/Controller.php
|
Controller.clear
|
public static function clear()
{
$path = root().'resources/controllers/*.php';
$files = File::glob($path);
//
foreach ($files as $file) {
File::delete($file);
}
//
return true;
}
|
php
|
public static function clear()
{
$path = root().'resources/controllers/*.php';
$files = File::glob($path);
//
foreach ($files as $file) {
File::delete($file);
}
//
return true;
}
|
[
"public",
"static",
"function",
"clear",
"(",
")",
"{",
"$",
"path",
"=",
"root",
"(",
")",
".",
"'resources/controllers/*.php'",
";",
"$",
"files",
"=",
"File",
"::",
"glob",
"(",
"$",
"path",
")",
";",
"//",
"foreach",
"(",
"$",
"files",
"as",
"$",
"file",
")",
"{",
"File",
"::",
"delete",
"(",
"$",
"file",
")",
";",
"}",
"//",
"return",
"true",
";",
"}"
] |
clear all controllers created.
@return bool
|
[
"clear",
"all",
"controllers",
"created",
"."
] |
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
|
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Processes/Controller.php#L113-L124
|
239,295
|
dryhopped/Gravatar
|
src/GetNinja/Gravatar/Gravatar.php
|
Gravatar.getGravatar
|
public function getGravatar($email, $size = null, $rating = null, $default = null, $secure = null)
{
$hash = $this->getHash($email);
$map = array(
's' => $size ?: $this->settings['size'],
'r' => $rating ?: $this->settings['rating'],
'd' => $default ?: $this->settings['default'],
);
if (null === $secure) {
$secure = $this->settings['secure'];
}
return ($secure ? 'https://secure' : 'http://www').'.gravatar.com/avatar/'.$hash.'?'.http_build_query(array_filter($map));
}
|
php
|
public function getGravatar($email, $size = null, $rating = null, $default = null, $secure = null)
{
$hash = $this->getHash($email);
$map = array(
's' => $size ?: $this->settings['size'],
'r' => $rating ?: $this->settings['rating'],
'd' => $default ?: $this->settings['default'],
);
if (null === $secure) {
$secure = $this->settings['secure'];
}
return ($secure ? 'https://secure' : 'http://www').'.gravatar.com/avatar/'.$hash.'?'.http_build_query(array_filter($map));
}
|
[
"public",
"function",
"getGravatar",
"(",
"$",
"email",
",",
"$",
"size",
"=",
"null",
",",
"$",
"rating",
"=",
"null",
",",
"$",
"default",
"=",
"null",
",",
"$",
"secure",
"=",
"null",
")",
"{",
"$",
"hash",
"=",
"$",
"this",
"->",
"getHash",
"(",
"$",
"email",
")",
";",
"$",
"map",
"=",
"array",
"(",
"'s'",
"=>",
"$",
"size",
"?",
":",
"$",
"this",
"->",
"settings",
"[",
"'size'",
"]",
",",
"'r'",
"=>",
"$",
"rating",
"?",
":",
"$",
"this",
"->",
"settings",
"[",
"'rating'",
"]",
",",
"'d'",
"=>",
"$",
"default",
"?",
":",
"$",
"this",
"->",
"settings",
"[",
"'default'",
"]",
",",
")",
";",
"if",
"(",
"null",
"===",
"$",
"secure",
")",
"{",
"$",
"secure",
"=",
"$",
"this",
"->",
"settings",
"[",
"'secure'",
"]",
";",
"}",
"return",
"(",
"$",
"secure",
"?",
"'https://secure'",
":",
"'http://www'",
")",
".",
"'.gravatar.com/avatar/'",
".",
"$",
"hash",
".",
"'?'",
".",
"http_build_query",
"(",
"array_filter",
"(",
"$",
"map",
")",
")",
";",
"}"
] |
Returns a url for a gravatar for a given email address
@param String $email
@param Integer $size
@param String $rating
@param String $default
@param Boolean $secure
@return String
|
[
"Returns",
"a",
"url",
"for",
"a",
"gravatar",
"for",
"a",
"given",
"email",
"address"
] |
eae7aa43bb057c071ae08f434b0394b0b41870db
|
https://github.com/dryhopped/Gravatar/blob/eae7aa43bb057c071ae08f434b0394b0b41870db/src/GetNinja/Gravatar/Gravatar.php#L50-L65
|
239,296
|
dryhopped/Gravatar
|
src/GetNinja/Gravatar/Gravatar.php
|
Gravatar.getProfile
|
public function getProfile($email, $format = null, $secure = null)
{
$hash = $this->getHash($email);
$extension = '';
if (null !== $format) {
$extension = strtolower($format);
}
if (null === $secure) {
$secure = $this->settings['secure'];
}
$url = ($secure ? 'https://secure' : 'http://www').'.gravatar.com/'.$hash.'.'.$extension;
if ($format === 'qr' || $format === 'json') {
return $url;
}
$browser = new \Buzz\Browser();
if ($format !== 'php') {
$response = $browser->get($url, $this->headers[$format]);
} else {
$response = $browser->get($url);
}
if ($response->isOk()) {
if ($format === 'php') {
return unserialize($response->getContent());
} else {
return $response->getContent();
}
} elseif ($response->isNotFound()) {
throw new GravatarException($response->getStatusCode().' Error: There is no profile associated with this email address.');
} else {
throw new GravatarException($response->getStatusCode().' Error: There was an error trying to fetch this profile.');
}
return;
}
|
php
|
public function getProfile($email, $format = null, $secure = null)
{
$hash = $this->getHash($email);
$extension = '';
if (null !== $format) {
$extension = strtolower($format);
}
if (null === $secure) {
$secure = $this->settings['secure'];
}
$url = ($secure ? 'https://secure' : 'http://www').'.gravatar.com/'.$hash.'.'.$extension;
if ($format === 'qr' || $format === 'json') {
return $url;
}
$browser = new \Buzz\Browser();
if ($format !== 'php') {
$response = $browser->get($url, $this->headers[$format]);
} else {
$response = $browser->get($url);
}
if ($response->isOk()) {
if ($format === 'php') {
return unserialize($response->getContent());
} else {
return $response->getContent();
}
} elseif ($response->isNotFound()) {
throw new GravatarException($response->getStatusCode().' Error: There is no profile associated with this email address.');
} else {
throw new GravatarException($response->getStatusCode().' Error: There was an error trying to fetch this profile.');
}
return;
}
|
[
"public",
"function",
"getProfile",
"(",
"$",
"email",
",",
"$",
"format",
"=",
"null",
",",
"$",
"secure",
"=",
"null",
")",
"{",
"$",
"hash",
"=",
"$",
"this",
"->",
"getHash",
"(",
"$",
"email",
")",
";",
"$",
"extension",
"=",
"''",
";",
"if",
"(",
"null",
"!==",
"$",
"format",
")",
"{",
"$",
"extension",
"=",
"strtolower",
"(",
"$",
"format",
")",
";",
"}",
"if",
"(",
"null",
"===",
"$",
"secure",
")",
"{",
"$",
"secure",
"=",
"$",
"this",
"->",
"settings",
"[",
"'secure'",
"]",
";",
"}",
"$",
"url",
"=",
"(",
"$",
"secure",
"?",
"'https://secure'",
":",
"'http://www'",
")",
".",
"'.gravatar.com/'",
".",
"$",
"hash",
".",
"'.'",
".",
"$",
"extension",
";",
"if",
"(",
"$",
"format",
"===",
"'qr'",
"||",
"$",
"format",
"===",
"'json'",
")",
"{",
"return",
"$",
"url",
";",
"}",
"$",
"browser",
"=",
"new",
"\\",
"Buzz",
"\\",
"Browser",
"(",
")",
";",
"if",
"(",
"$",
"format",
"!==",
"'php'",
")",
"{",
"$",
"response",
"=",
"$",
"browser",
"->",
"get",
"(",
"$",
"url",
",",
"$",
"this",
"->",
"headers",
"[",
"$",
"format",
"]",
")",
";",
"}",
"else",
"{",
"$",
"response",
"=",
"$",
"browser",
"->",
"get",
"(",
"$",
"url",
")",
";",
"}",
"if",
"(",
"$",
"response",
"->",
"isOk",
"(",
")",
")",
"{",
"if",
"(",
"$",
"format",
"===",
"'php'",
")",
"{",
"return",
"unserialize",
"(",
"$",
"response",
"->",
"getContent",
"(",
")",
")",
";",
"}",
"else",
"{",
"return",
"$",
"response",
"->",
"getContent",
"(",
")",
";",
"}",
"}",
"elseif",
"(",
"$",
"response",
"->",
"isNotFound",
"(",
")",
")",
"{",
"throw",
"new",
"GravatarException",
"(",
"$",
"response",
"->",
"getStatusCode",
"(",
")",
".",
"' Error: There is no profile associated with this email address.'",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"GravatarException",
"(",
"$",
"response",
"->",
"getStatusCode",
"(",
")",
".",
"' Error: There was an error trying to fetch this profile.'",
")",
";",
"}",
"return",
";",
"}"
] |
Returns gravatar profile information for a given email address
Valid Formats include: json, xml, php, vcf, qr
If a format is not specified, the profile will be returned in hCard format
Due to the way the gravatar api's work, json and qr formats return a url
string for use in img and script tags
@param String $email
@param String $format
@return Array|String
|
[
"Returns",
"gravatar",
"profile",
"information",
"for",
"a",
"given",
"email",
"address"
] |
eae7aa43bb057c071ae08f434b0394b0b41870db
|
https://github.com/dryhopped/Gravatar/blob/eae7aa43bb057c071ae08f434b0394b0b41870db/src/GetNinja/Gravatar/Gravatar.php#L80-L119
|
239,297
|
zetta-code/tss-bootstrap
|
src/ConfigProvider.php
|
ConfigProvider.getControllerPluginConfig
|
public function getControllerPluginConfig()
{
return [
'aliases' => [
'tssEmail' => Controller\Plugin\EmailPlugin::class,
'tssImageThumb' => Controller\Plugin\ImageThumbPlugin::class,
'tssReferer' => Controller\Plugin\Referer::class,
],
'factories' => [
Controller\Plugin\EmailPlugin::class => Controller\Plugin\EmailPluginFactory::class,
Controller\Plugin\ImageThumbPlugin::class => Controller\Plugin\ImageTumbPluginFactory::class,
Controller\Plugin\Referer::class => InvokableFactory::class,
],
];
}
|
php
|
public function getControllerPluginConfig()
{
return [
'aliases' => [
'tssEmail' => Controller\Plugin\EmailPlugin::class,
'tssImageThumb' => Controller\Plugin\ImageThumbPlugin::class,
'tssReferer' => Controller\Plugin\Referer::class,
],
'factories' => [
Controller\Plugin\EmailPlugin::class => Controller\Plugin\EmailPluginFactory::class,
Controller\Plugin\ImageThumbPlugin::class => Controller\Plugin\ImageTumbPluginFactory::class,
Controller\Plugin\Referer::class => InvokableFactory::class,
],
];
}
|
[
"public",
"function",
"getControllerPluginConfig",
"(",
")",
"{",
"return",
"[",
"'aliases'",
"=>",
"[",
"'tssEmail'",
"=>",
"Controller",
"\\",
"Plugin",
"\\",
"EmailPlugin",
"::",
"class",
",",
"'tssImageThumb'",
"=>",
"Controller",
"\\",
"Plugin",
"\\",
"ImageThumbPlugin",
"::",
"class",
",",
"'tssReferer'",
"=>",
"Controller",
"\\",
"Plugin",
"\\",
"Referer",
"::",
"class",
",",
"]",
",",
"'factories'",
"=>",
"[",
"Controller",
"\\",
"Plugin",
"\\",
"EmailPlugin",
"::",
"class",
"=>",
"Controller",
"\\",
"Plugin",
"\\",
"EmailPluginFactory",
"::",
"class",
",",
"Controller",
"\\",
"Plugin",
"\\",
"ImageThumbPlugin",
"::",
"class",
"=>",
"Controller",
"\\",
"Plugin",
"\\",
"ImageTumbPluginFactory",
"::",
"class",
",",
"Controller",
"\\",
"Plugin",
"\\",
"Referer",
"::",
"class",
"=>",
"InvokableFactory",
"::",
"class",
",",
"]",
",",
"]",
";",
"}"
] |
Return component plugins configuration.
@return array
|
[
"Return",
"component",
"plugins",
"configuration",
"."
] |
8dddfca8440ccd4e5cf645c81f732a424b78235e
|
https://github.com/zetta-code/tss-bootstrap/blob/8dddfca8440ccd4e5cf645c81f732a424b78235e/src/ConfigProvider.php#L48-L62
|
239,298
|
zetta-code/tss-bootstrap
|
src/ConfigProvider.php
|
ConfigProvider.getViewHelpers
|
public function getViewHelpers()
{
return [
'aliases' => [
'tssFlashMessenger' => View\Helper\FlashMessenger::class,
'tssFormRow' => Form\View\Helper\FormRow::class,
'tssPaginator' => View\Helper\Paginator::class,
'tssReferer' => View\Helper\Referer::class,
],
'factories' => [
Form\View\Helper\FormRow::class => InvokableFactory::class,
View\Helper\FlashMessenger::class => InvokableFactory::class,
View\Helper\Paginator::class => View\Helper\PaginatorFactory::class,
View\Helper\Referer::class => View\Helper\RefererFactory::class,
],
];
}
|
php
|
public function getViewHelpers()
{
return [
'aliases' => [
'tssFlashMessenger' => View\Helper\FlashMessenger::class,
'tssFormRow' => Form\View\Helper\FormRow::class,
'tssPaginator' => View\Helper\Paginator::class,
'tssReferer' => View\Helper\Referer::class,
],
'factories' => [
Form\View\Helper\FormRow::class => InvokableFactory::class,
View\Helper\FlashMessenger::class => InvokableFactory::class,
View\Helper\Paginator::class => View\Helper\PaginatorFactory::class,
View\Helper\Referer::class => View\Helper\RefererFactory::class,
],
];
}
|
[
"public",
"function",
"getViewHelpers",
"(",
")",
"{",
"return",
"[",
"'aliases'",
"=>",
"[",
"'tssFlashMessenger'",
"=>",
"View",
"\\",
"Helper",
"\\",
"FlashMessenger",
"::",
"class",
",",
"'tssFormRow'",
"=>",
"Form",
"\\",
"View",
"\\",
"Helper",
"\\",
"FormRow",
"::",
"class",
",",
"'tssPaginator'",
"=>",
"View",
"\\",
"Helper",
"\\",
"Paginator",
"::",
"class",
",",
"'tssReferer'",
"=>",
"View",
"\\",
"Helper",
"\\",
"Referer",
"::",
"class",
",",
"]",
",",
"'factories'",
"=>",
"[",
"Form",
"\\",
"View",
"\\",
"Helper",
"\\",
"FormRow",
"::",
"class",
"=>",
"InvokableFactory",
"::",
"class",
",",
"View",
"\\",
"Helper",
"\\",
"FlashMessenger",
"::",
"class",
"=>",
"InvokableFactory",
"::",
"class",
",",
"View",
"\\",
"Helper",
"\\",
"Paginator",
"::",
"class",
"=>",
"View",
"\\",
"Helper",
"\\",
"PaginatorFactory",
"::",
"class",
",",
"View",
"\\",
"Helper",
"\\",
"Referer",
"::",
"class",
"=>",
"View",
"\\",
"Helper",
"\\",
"RefererFactory",
"::",
"class",
",",
"]",
",",
"]",
";",
"}"
] |
Return component helpers configuration.
@return array
|
[
"Return",
"component",
"helpers",
"configuration",
"."
] |
8dddfca8440ccd4e5cf645c81f732a424b78235e
|
https://github.com/zetta-code/tss-bootstrap/blob/8dddfca8440ccd4e5cf645c81f732a424b78235e/src/ConfigProvider.php#L69-L85
|
239,299
|
codger-php/generate
|
src/Bootstrap.php
|
Bootstrap.run
|
public function run(...$argv) : void
{
$recipe = $this->recipe;
if (isset($this->config->aliases, $this->config->aliases->$recipe)) {
$alias = $this->config->aliases->$recipe;
$recipe = $alias[0];
$argv = array_merge(array_splice($alias, 1), $argv);
}
$file = "{$this->path}/recipes/$recipe/Recipe.php";
if (strpos($recipe, '@')) {
list($vendor, $recipe) = explode('@', $recipe);
$file = "{$this->path}/vendor/$vendor/recipes/$recipe/Recipe.php";
if (!file_exists($file)) {
$file = "{$this->path}/recipes/$recipe/Recipe.php";
}
}
if (file_exists($file)) {
$recipefn = require $file;
$reflection = new ReflectionFunction($recipefn);
$wanteds = $reflection->getParameters();
if ($reflection->getNumberOfRequiredParameters() > count($argv)) {
$usage = call_user_func($tmp = function () use (&$tmp, &$wanteds) : string {
$param = array_shift($wanteds);
$out = ' ';
if ($param->isOptional()) {
$out .= '[';
}
if ($param->isVariadic()) {
$out .= '...';
}
$out .= strtoupper($param->getName());
if ($wanteds) {
$out .= $tmp();
}
if ($param->isOptional()) {
$out .= ']';
}
return $out;
}, $wanteds);
fwrite(STDERR, "\nUsage: `$ vendor/bin/codger $recipe$usage`\n\n");
if ($docComment = $reflection->getDocComment()) {
$docComment = preg_replace("@(^/\*\*\n|\n\s?\*/$)@", '', $docComment);
$docComment = preg_replace("@^\s?\*\s?@m", '', $docComment);
fwrite(STDERR, "$docComment\n\n");
}
} else {
if ($wanteds && end($wanteds)->isVariadic() && end($wanteds)->name == 'options') {
$copy = $argv;
$this->setOptions(array_splice($copy, count($wanteds) - 1));
}
$recipefn->call($this, ...$argv)->process();
}
} else {
fwrite(STDERR, "Recipe `$recipe` could not be found in `{$this->path}/recipes`, skipping...\n");
}
}
|
php
|
public function run(...$argv) : void
{
$recipe = $this->recipe;
if (isset($this->config->aliases, $this->config->aliases->$recipe)) {
$alias = $this->config->aliases->$recipe;
$recipe = $alias[0];
$argv = array_merge(array_splice($alias, 1), $argv);
}
$file = "{$this->path}/recipes/$recipe/Recipe.php";
if (strpos($recipe, '@')) {
list($vendor, $recipe) = explode('@', $recipe);
$file = "{$this->path}/vendor/$vendor/recipes/$recipe/Recipe.php";
if (!file_exists($file)) {
$file = "{$this->path}/recipes/$recipe/Recipe.php";
}
}
if (file_exists($file)) {
$recipefn = require $file;
$reflection = new ReflectionFunction($recipefn);
$wanteds = $reflection->getParameters();
if ($reflection->getNumberOfRequiredParameters() > count($argv)) {
$usage = call_user_func($tmp = function () use (&$tmp, &$wanteds) : string {
$param = array_shift($wanteds);
$out = ' ';
if ($param->isOptional()) {
$out .= '[';
}
if ($param->isVariadic()) {
$out .= '...';
}
$out .= strtoupper($param->getName());
if ($wanteds) {
$out .= $tmp();
}
if ($param->isOptional()) {
$out .= ']';
}
return $out;
}, $wanteds);
fwrite(STDERR, "\nUsage: `$ vendor/bin/codger $recipe$usage`\n\n");
if ($docComment = $reflection->getDocComment()) {
$docComment = preg_replace("@(^/\*\*\n|\n\s?\*/$)@", '', $docComment);
$docComment = preg_replace("@^\s?\*\s?@m", '', $docComment);
fwrite(STDERR, "$docComment\n\n");
}
} else {
if ($wanteds && end($wanteds)->isVariadic() && end($wanteds)->name == 'options') {
$copy = $argv;
$this->setOptions(array_splice($copy, count($wanteds) - 1));
}
$recipefn->call($this, ...$argv)->process();
}
} else {
fwrite(STDERR, "Recipe `$recipe` could not be found in `{$this->path}/recipes`, skipping...\n");
}
}
|
[
"public",
"function",
"run",
"(",
"...",
"$",
"argv",
")",
":",
"void",
"{",
"$",
"recipe",
"=",
"$",
"this",
"->",
"recipe",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"config",
"->",
"aliases",
",",
"$",
"this",
"->",
"config",
"->",
"aliases",
"->",
"$",
"recipe",
")",
")",
"{",
"$",
"alias",
"=",
"$",
"this",
"->",
"config",
"->",
"aliases",
"->",
"$",
"recipe",
";",
"$",
"recipe",
"=",
"$",
"alias",
"[",
"0",
"]",
";",
"$",
"argv",
"=",
"array_merge",
"(",
"array_splice",
"(",
"$",
"alias",
",",
"1",
")",
",",
"$",
"argv",
")",
";",
"}",
"$",
"file",
"=",
"\"{$this->path}/recipes/$recipe/Recipe.php\"",
";",
"if",
"(",
"strpos",
"(",
"$",
"recipe",
",",
"'@'",
")",
")",
"{",
"list",
"(",
"$",
"vendor",
",",
"$",
"recipe",
")",
"=",
"explode",
"(",
"'@'",
",",
"$",
"recipe",
")",
";",
"$",
"file",
"=",
"\"{$this->path}/vendor/$vendor/recipes/$recipe/Recipe.php\"",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"file",
")",
")",
"{",
"$",
"file",
"=",
"\"{$this->path}/recipes/$recipe/Recipe.php\"",
";",
"}",
"}",
"if",
"(",
"file_exists",
"(",
"$",
"file",
")",
")",
"{",
"$",
"recipefn",
"=",
"require",
"$",
"file",
";",
"$",
"reflection",
"=",
"new",
"ReflectionFunction",
"(",
"$",
"recipefn",
")",
";",
"$",
"wanteds",
"=",
"$",
"reflection",
"->",
"getParameters",
"(",
")",
";",
"if",
"(",
"$",
"reflection",
"->",
"getNumberOfRequiredParameters",
"(",
")",
">",
"count",
"(",
"$",
"argv",
")",
")",
"{",
"$",
"usage",
"=",
"call_user_func",
"(",
"$",
"tmp",
"=",
"function",
"(",
")",
"use",
"(",
"&",
"$",
"tmp",
",",
"&",
"$",
"wanteds",
")",
":",
"string",
"{",
"$",
"param",
"=",
"array_shift",
"(",
"$",
"wanteds",
")",
";",
"$",
"out",
"=",
"' '",
";",
"if",
"(",
"$",
"param",
"->",
"isOptional",
"(",
")",
")",
"{",
"$",
"out",
".=",
"'['",
";",
"}",
"if",
"(",
"$",
"param",
"->",
"isVariadic",
"(",
")",
")",
"{",
"$",
"out",
".=",
"'...'",
";",
"}",
"$",
"out",
".=",
"strtoupper",
"(",
"$",
"param",
"->",
"getName",
"(",
")",
")",
";",
"if",
"(",
"$",
"wanteds",
")",
"{",
"$",
"out",
".=",
"$",
"tmp",
"(",
")",
";",
"}",
"if",
"(",
"$",
"param",
"->",
"isOptional",
"(",
")",
")",
"{",
"$",
"out",
".=",
"']'",
";",
"}",
"return",
"$",
"out",
";",
"}",
",",
"$",
"wanteds",
")",
";",
"fwrite",
"(",
"STDERR",
",",
"\"\\nUsage: `$ vendor/bin/codger $recipe$usage`\\n\\n\"",
")",
";",
"if",
"(",
"$",
"docComment",
"=",
"$",
"reflection",
"->",
"getDocComment",
"(",
")",
")",
"{",
"$",
"docComment",
"=",
"preg_replace",
"(",
"\"@(^/\\*\\*\\n|\\n\\s?\\*/$)@\"",
",",
"''",
",",
"$",
"docComment",
")",
";",
"$",
"docComment",
"=",
"preg_replace",
"(",
"\"@^\\s?\\*\\s?@m\"",
",",
"''",
",",
"$",
"docComment",
")",
";",
"fwrite",
"(",
"STDERR",
",",
"\"$docComment\\n\\n\"",
")",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"$",
"wanteds",
"&&",
"end",
"(",
"$",
"wanteds",
")",
"->",
"isVariadic",
"(",
")",
"&&",
"end",
"(",
"$",
"wanteds",
")",
"->",
"name",
"==",
"'options'",
")",
"{",
"$",
"copy",
"=",
"$",
"argv",
";",
"$",
"this",
"->",
"setOptions",
"(",
"array_splice",
"(",
"$",
"copy",
",",
"count",
"(",
"$",
"wanteds",
")",
"-",
"1",
")",
")",
";",
"}",
"$",
"recipefn",
"->",
"call",
"(",
"$",
"this",
",",
"...",
"$",
"argv",
")",
"->",
"process",
"(",
")",
";",
"}",
"}",
"else",
"{",
"fwrite",
"(",
"STDERR",
",",
"\"Recipe `$recipe` could not be found in `{$this->path}/recipes`, skipping...\\n\"",
")",
";",
"}",
"}"
] |
Run the recipe.
@param mixed ...$argv Arguments passed from CLI.
@return void
|
[
"Run",
"the",
"recipe",
"."
] |
89dd3bd074cef53cf85b1470c0b96b4167825416
|
https://github.com/codger-php/generate/blob/89dd3bd074cef53cf85b1470c0b96b4167825416/src/Bootstrap.php#L42-L97
|
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.