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
sequence | docstring
stringlengths 3
47.2k
| docstring_tokens
sequence | sha
stringlengths 40
40
| url
stringlengths 91
247
|
---|---|---|---|---|---|---|---|---|---|---|---|
8,200 | sebastianmonzel/webfiles-framework-php | source/core/datasystem/file/system/MDirectory.php | MDirectory.createSubDirectoryIfNotExists | public function createSubDirectoryIfNotExists($p_sName)
{
$subdirectoryPath = $this->m_sPath . "/" . $p_sName;
$subdirectory = new MDirectory($subdirectoryPath);
if (!$subdirectory->exists()) {
mkdir($subdirectoryPath);
}
return $subdirectory;
} | php | public function createSubDirectoryIfNotExists($p_sName)
{
$subdirectoryPath = $this->m_sPath . "/" . $p_sName;
$subdirectory = new MDirectory($subdirectoryPath);
if (!$subdirectory->exists()) {
mkdir($subdirectoryPath);
}
return $subdirectory;
} | [
"public",
"function",
"createSubDirectoryIfNotExists",
"(",
"$",
"p_sName",
")",
"{",
"$",
"subdirectoryPath",
"=",
"$",
"this",
"->",
"m_sPath",
".",
"\"/\"",
".",
"$",
"p_sName",
";",
"$",
"subdirectory",
"=",
"new",
"MDirectory",
"(",
"$",
"subdirectoryPath",
")",
";",
"if",
"(",
"!",
"$",
"subdirectory",
"->",
"exists",
"(",
")",
")",
"{",
"mkdir",
"(",
"$",
"subdirectoryPath",
")",
";",
"}",
"return",
"$",
"subdirectory",
";",
"}"
] | Creates a subdirectory in the present directory.
@param $p_sName
@return MDirectory | [
"Creates",
"a",
"subdirectory",
"in",
"the",
"present",
"directory",
"."
] | 5ac1fc99e8e9946080e3ba877b2320cd6a3e5b5d | https://github.com/sebastianmonzel/webfiles-framework-php/blob/5ac1fc99e8e9946080e3ba877b2320cd6a3e5b5d/source/core/datasystem/file/system/MDirectory.php#L125-L137 |
8,201 | khalyomede/matcha | src/Style/Expect.php | Expect.equalTo | public function equalTo($expected): Expect {
$this->testsTheEqualityAgainstAValue = true;
$this->expected = $expected;
return $this;
} | php | public function equalTo($expected): Expect {
$this->testsTheEqualityAgainstAValue = true;
$this->expected = $expected;
return $this;
} | [
"public",
"function",
"equalTo",
"(",
"$",
"expected",
")",
":",
"Expect",
"{",
"$",
"this",
"->",
"testsTheEqualityAgainstAValue",
"=",
"true",
";",
"$",
"this",
"->",
"expected",
"=",
"$",
"expected",
";",
"return",
"$",
"this",
";",
"}"
] | Asserts that we are testing an equality
against a particular value. | [
"Asserts",
"that",
"we",
"are",
"testing",
"an",
"equality",
"against",
"a",
"particular",
"value",
"."
] | 4bdbe0e90e13fd458694f04a2e3aeef941af7cec | https://github.com/khalyomede/matcha/blob/4bdbe0e90e13fd458694f04a2e3aeef941af7cec/src/Style/Expect.php#L145-L150 |
8,202 | Celarius/nofuzz-framework | src/Database/Drivers/Pdo/Pgsql.php | Pgsql.getDsn | public function getDsn(): string
{
// pgsql:host=<hostname>;port=26257;dbname=bank;sslmode=disable
# Build the DSN
$_dsn = $this->getDriver().':' .
'host=' . $this->GetHost().';' .
'port=' . ($this->GetPort()!=0 ? $this->GetPort() . ':' : '26257' ) .
'dbname=' . $this->GetSchema().';' .
'sslmode=' . $this->getSSLMode();
// 'charset='.$this->GetCharset();
# Set it
$this->setDsn($_dsn);
# Results
return $this->pdo_dsn;
} | php | public function getDsn(): string
{
// pgsql:host=<hostname>;port=26257;dbname=bank;sslmode=disable
# Build the DSN
$_dsn = $this->getDriver().':' .
'host=' . $this->GetHost().';' .
'port=' . ($this->GetPort()!=0 ? $this->GetPort() . ':' : '26257' ) .
'dbname=' . $this->GetSchema().';' .
'sslmode=' . $this->getSSLMode();
// 'charset='.$this->GetCharset();
# Set it
$this->setDsn($_dsn);
# Results
return $this->pdo_dsn;
} | [
"public",
"function",
"getDsn",
"(",
")",
":",
"string",
"{",
"// pgsql:host=<hostname>;port=26257;dbname=bank;sslmode=disable",
"# Build the DSN",
"$",
"_dsn",
"=",
"$",
"this",
"->",
"getDriver",
"(",
")",
".",
"':'",
".",
"'host='",
".",
"$",
"this",
"->",
"GetHost",
"(",
")",
".",
"';'",
".",
"'port='",
".",
"(",
"$",
"this",
"->",
"GetPort",
"(",
")",
"!=",
"0",
"?",
"$",
"this",
"->",
"GetPort",
"(",
")",
".",
"':'",
":",
"'26257'",
")",
".",
"'dbname='",
".",
"$",
"this",
"->",
"GetSchema",
"(",
")",
".",
"';'",
".",
"'sslmode='",
".",
"$",
"this",
"->",
"getSSLMode",
"(",
")",
";",
"// 'charset='.$this->GetCharset();",
"# Set it",
"$",
"this",
"->",
"setDsn",
"(",
"$",
"_dsn",
")",
";",
"# Results",
"return",
"$",
"this",
"->",
"pdo_dsn",
";",
"}"
] | Get DSN - CockraochDb formatting
@return string [description] | [
"Get",
"DSN",
"-",
"CockraochDb",
"formatting"
] | 867c5150baa431e8f800624a26ba80e95eebd4e5 | https://github.com/Celarius/nofuzz-framework/blob/867c5150baa431e8f800624a26ba80e95eebd4e5/src/Database/Drivers/Pdo/Pgsql.php#L58-L73 |
8,203 | EarthlingInteractive/PHPCMIPREST | lib/EarthIT/CMIPREST/RESTer.php | EarthIT_CMIPREST_RESTer.validateSimpleAction | protected function validateSimpleAction( EarthIT_CMIPREST_RESTAction $act ) {
if( $act instanceof EarthIT_CMIPREST_RESTAction_ResourceAction ) {
$rc = $act->getResourceClass();
if( !$rc->hasRestService() ) {
throw new EarthIT_CMIPREST_ResourceNotExposedViaService($act, array('message'=>"'".$rc->getName()."' records are not exposed via services"));
}
} else if( $act instanceof EarthIT_CMIPREST_RESTAction_InvalidAction ) {
throw new EarthIT_CMIPREST_ActionInvalid($act, $act->getErrorDetails());
} else {
throw new EarthIT_CMIPREST_ActionInvalid($act, array(array(
'class' => 'ClientError/ActionInvalid',
'message' => 'Unrecognized action class: '.get_class($act)
)));
}
} | php | protected function validateSimpleAction( EarthIT_CMIPREST_RESTAction $act ) {
if( $act instanceof EarthIT_CMIPREST_RESTAction_ResourceAction ) {
$rc = $act->getResourceClass();
if( !$rc->hasRestService() ) {
throw new EarthIT_CMIPREST_ResourceNotExposedViaService($act, array('message'=>"'".$rc->getName()."' records are not exposed via services"));
}
} else if( $act instanceof EarthIT_CMIPREST_RESTAction_InvalidAction ) {
throw new EarthIT_CMIPREST_ActionInvalid($act, $act->getErrorDetails());
} else {
throw new EarthIT_CMIPREST_ActionInvalid($act, array(array(
'class' => 'ClientError/ActionInvalid',
'message' => 'Unrecognized action class: '.get_class($act)
)));
}
} | [
"protected",
"function",
"validateSimpleAction",
"(",
"EarthIT_CMIPREST_RESTAction",
"$",
"act",
")",
"{",
"if",
"(",
"$",
"act",
"instanceof",
"EarthIT_CMIPREST_RESTAction_ResourceAction",
")",
"{",
"$",
"rc",
"=",
"$",
"act",
"->",
"getResourceClass",
"(",
")",
";",
"if",
"(",
"!",
"$",
"rc",
"->",
"hasRestService",
"(",
")",
")",
"{",
"throw",
"new",
"EarthIT_CMIPREST_ResourceNotExposedViaService",
"(",
"$",
"act",
",",
"array",
"(",
"'message'",
"=>",
"\"'\"",
".",
"$",
"rc",
"->",
"getName",
"(",
")",
".",
"\"' records are not exposed via services\"",
")",
")",
";",
"}",
"}",
"else",
"if",
"(",
"$",
"act",
"instanceof",
"EarthIT_CMIPREST_RESTAction_InvalidAction",
")",
"{",
"throw",
"new",
"EarthIT_CMIPREST_ActionInvalid",
"(",
"$",
"act",
",",
"$",
"act",
"->",
"getErrorDetails",
"(",
")",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"EarthIT_CMIPREST_ActionInvalid",
"(",
"$",
"act",
",",
"array",
"(",
"array",
"(",
"'class'",
"=>",
"'ClientError/ActionInvalid'",
",",
"'message'",
"=>",
"'Unrecognized action class: '",
".",
"get_class",
"(",
"$",
"act",
")",
")",
")",
")",
";",
"}",
"}"
] | Ensure that the given action is structurally valid so that
assumptions made while authorizing hold true.
Will throw an exception otherwise.
@overridable | [
"Ensure",
"that",
"the",
"given",
"action",
"is",
"structurally",
"valid",
"so",
"that",
"assumptions",
"made",
"while",
"authorizing",
"hold",
"true",
".",
"Will",
"throw",
"an",
"exception",
"otherwise",
"."
] | db0398ea4fc07fa62f2de9ba43f2f3137170d9f0 | https://github.com/EarthlingInteractive/PHPCMIPREST/blob/db0398ea4fc07fa62f2de9ba43f2f3137170d9f0/lib/EarthIT/CMIPREST/RESTer.php#L64-L78 |
8,204 | EarthlingInteractive/PHPCMIPREST | lib/EarthIT/CMIPREST/RESTer.php | EarthIT_CMIPREST_RESTer.assembleSimpleResult | protected function assembleSimpleResult($act, $rc, array $items, $ctx) {
$assembler = $act->getResultAssembler();
if( $assembler === null ) {
throw new Exception("No result assembler specified by ".get_class($act));
}
return $assembler->assembleResult(
new EarthIT_CMIPREST_StorageResult($rc, array('root'=>array()), array('root'=>$items)),
$act, $ctx );
} | php | protected function assembleSimpleResult($act, $rc, array $items, $ctx) {
$assembler = $act->getResultAssembler();
if( $assembler === null ) {
throw new Exception("No result assembler specified by ".get_class($act));
}
return $assembler->assembleResult(
new EarthIT_CMIPREST_StorageResult($rc, array('root'=>array()), array('root'=>$items)),
$act, $ctx );
} | [
"protected",
"function",
"assembleSimpleResult",
"(",
"$",
"act",
",",
"$",
"rc",
",",
"array",
"$",
"items",
",",
"$",
"ctx",
")",
"{",
"$",
"assembler",
"=",
"$",
"act",
"->",
"getResultAssembler",
"(",
")",
";",
"if",
"(",
"$",
"assembler",
"===",
"null",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"No result assembler specified by \"",
".",
"get_class",
"(",
"$",
"act",
")",
")",
";",
"}",
"return",
"$",
"assembler",
"->",
"assembleResult",
"(",
"new",
"EarthIT_CMIPREST_StorageResult",
"(",
"$",
"rc",
",",
"array",
"(",
"'root'",
"=>",
"array",
"(",
")",
")",
",",
"array",
"(",
"'root'",
"=>",
"$",
"items",
")",
")",
",",
"$",
"act",
",",
"$",
"ctx",
")",
";",
"}"
] | Assemble results with no johns. i.e. a simple collection of one type of objects | [
"Assemble",
"results",
"with",
"no",
"johns",
".",
"i",
".",
"e",
".",
"a",
"simple",
"collection",
"of",
"one",
"type",
"of",
"objects"
] | db0398ea4fc07fa62f2de9ba43f2f3137170d9f0 | https://github.com/EarthlingInteractive/PHPCMIPREST/blob/db0398ea4fc07fa62f2de9ba43f2f3137170d9f0/lib/EarthIT/CMIPREST/RESTer.php#L144-L153 |
8,205 | HouseOfAgile/dacorp-extra-bundle | Controller/PictureController.php | PictureController.uploadFormAction | public function uploadFormAction(Request $request)
{
// create task object and form
$userId = ($this->getUser() != null) ? $this->getUser()->getId() : rand();
$partner = ($this->getUser() != null) ? $this->getUser()->getPartner() : null;
/* @var $picture Picture */
$smDatas = $this->get('dacorp.manager.dacorp_media')->setupDacorpMediaManager($userId, DacorpMediaManager::PARTNER_MEDIA_ID);
if ($this->getRequest()->getMethod() != 'POST') {
// $this->get('justmoov.manager.media')->feedFiles($smDatas['editId']);
}
$pictureForm = $this->createForm(new DacorpMediaType(), $partner, array('editId' => $smDatas['editId'], 'existingFiles' => json_encode($smDatas['existingFiles'])));
//Template: JustmoovFrontBundle:Form:pictureUploadForm.html.twig
return array(
'pictureFormView' => $pictureForm->createView(),
'pictureForm' => $pictureForm->createView(),
'smDatas' => $smDatas
);
} | php | public function uploadFormAction(Request $request)
{
// create task object and form
$userId = ($this->getUser() != null) ? $this->getUser()->getId() : rand();
$partner = ($this->getUser() != null) ? $this->getUser()->getPartner() : null;
/* @var $picture Picture */
$smDatas = $this->get('dacorp.manager.dacorp_media')->setupDacorpMediaManager($userId, DacorpMediaManager::PARTNER_MEDIA_ID);
if ($this->getRequest()->getMethod() != 'POST') {
// $this->get('justmoov.manager.media')->feedFiles($smDatas['editId']);
}
$pictureForm = $this->createForm(new DacorpMediaType(), $partner, array('editId' => $smDatas['editId'], 'existingFiles' => json_encode($smDatas['existingFiles'])));
//Template: JustmoovFrontBundle:Form:pictureUploadForm.html.twig
return array(
'pictureFormView' => $pictureForm->createView(),
'pictureForm' => $pictureForm->createView(),
'smDatas' => $smDatas
);
} | [
"public",
"function",
"uploadFormAction",
"(",
"Request",
"$",
"request",
")",
"{",
"// create task object and form",
"$",
"userId",
"=",
"(",
"$",
"this",
"->",
"getUser",
"(",
")",
"!=",
"null",
")",
"?",
"$",
"this",
"->",
"getUser",
"(",
")",
"->",
"getId",
"(",
")",
":",
"rand",
"(",
")",
";",
"$",
"partner",
"=",
"(",
"$",
"this",
"->",
"getUser",
"(",
")",
"!=",
"null",
")",
"?",
"$",
"this",
"->",
"getUser",
"(",
")",
"->",
"getPartner",
"(",
")",
":",
"null",
";",
"/* @var $picture Picture */",
"$",
"smDatas",
"=",
"$",
"this",
"->",
"get",
"(",
"'dacorp.manager.dacorp_media'",
")",
"->",
"setupDacorpMediaManager",
"(",
"$",
"userId",
",",
"DacorpMediaManager",
"::",
"PARTNER_MEDIA_ID",
")",
";",
"if",
"(",
"$",
"this",
"->",
"getRequest",
"(",
")",
"->",
"getMethod",
"(",
")",
"!=",
"'POST'",
")",
"{",
"// $this->get('justmoov.manager.media')->feedFiles($smDatas['editId']);",
"}",
"$",
"pictureForm",
"=",
"$",
"this",
"->",
"createForm",
"(",
"new",
"DacorpMediaType",
"(",
")",
",",
"$",
"partner",
",",
"array",
"(",
"'editId'",
"=>",
"$",
"smDatas",
"[",
"'editId'",
"]",
",",
"'existingFiles'",
"=>",
"json_encode",
"(",
"$",
"smDatas",
"[",
"'existingFiles'",
"]",
")",
")",
")",
";",
"//Template: JustmoovFrontBundle:Form:pictureUploadForm.html.twig",
"return",
"array",
"(",
"'pictureFormView'",
"=>",
"$",
"pictureForm",
"->",
"createView",
"(",
")",
",",
"'pictureForm'",
"=>",
"$",
"pictureForm",
"->",
"createView",
"(",
")",
",",
"'smDatas'",
"=>",
"$",
"smDatas",
")",
";",
"}"
] | Simple action for form Upload rendering
@param Request $request
@return array
@Template("DacorpExtraBundle:Form:pictureUploadForm.html.twig") | [
"Simple",
"action",
"for",
"form",
"Upload",
"rendering"
] | 99fe024791e7833058908a2e5544bde948031524 | https://github.com/HouseOfAgile/dacorp-extra-bundle/blob/99fe024791e7833058908a2e5544bde948031524/Controller/PictureController.php#L22-L43 |
8,206 | nirix/radium | src/EventDispatcher.php | EventDispatcher.addListener | public static function addListener($action, $callback)
{
// Make sure it's something callable
if (!is_callable($callback) && !is_array($callback)) {
throw new Exception("Invalid callback for [{$action}]");
}
if (!isset(static::$listeners[$action])) {
static::$listeners[$action] = [];
}
static::$listeners[$action][] = $callback;
} | php | public static function addListener($action, $callback)
{
// Make sure it's something callable
if (!is_callable($callback) && !is_array($callback)) {
throw new Exception("Invalid callback for [{$action}]");
}
if (!isset(static::$listeners[$action])) {
static::$listeners[$action] = [];
}
static::$listeners[$action][] = $callback;
} | [
"public",
"static",
"function",
"addListener",
"(",
"$",
"action",
",",
"$",
"callback",
")",
"{",
"// Make sure it's something callable",
"if",
"(",
"!",
"is_callable",
"(",
"$",
"callback",
")",
"&&",
"!",
"is_array",
"(",
"$",
"callback",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"Invalid callback for [{$action}]\"",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"static",
"::",
"$",
"listeners",
"[",
"$",
"action",
"]",
")",
")",
"{",
"static",
"::",
"$",
"listeners",
"[",
"$",
"action",
"]",
"=",
"[",
"]",
";",
"}",
"static",
"::",
"$",
"listeners",
"[",
"$",
"action",
"]",
"[",
"]",
"=",
"$",
"callback",
";",
"}"
] | Add a listener to the action.
@param string $action
@param array|callable $callback | [
"Add",
"a",
"listener",
"to",
"the",
"action",
"."
] | cc6907bfee296b64a7630b0b188e233d7cdb86fd | https://github.com/nirix/radium/blob/cc6907bfee296b64a7630b0b188e233d7cdb86fd/src/EventDispatcher.php#L39-L51 |
8,207 | nirix/radium | src/EventDispatcher.php | EventDispatcher.dispatch | public static function dispatch($action, array $parameters = [])
{
if (isset(static::$listeners[$action])) {
foreach (static::$listeners[$action] as $callback) {
$response = call_user_func_array($callback, $parameters);
if ($response !== null) {
return $response;
}
}
}
} | php | public static function dispatch($action, array $parameters = [])
{
if (isset(static::$listeners[$action])) {
foreach (static::$listeners[$action] as $callback) {
$response = call_user_func_array($callback, $parameters);
if ($response !== null) {
return $response;
}
}
}
} | [
"public",
"static",
"function",
"dispatch",
"(",
"$",
"action",
",",
"array",
"$",
"parameters",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"isset",
"(",
"static",
"::",
"$",
"listeners",
"[",
"$",
"action",
"]",
")",
")",
"{",
"foreach",
"(",
"static",
"::",
"$",
"listeners",
"[",
"$",
"action",
"]",
"as",
"$",
"callback",
")",
"{",
"$",
"response",
"=",
"call_user_func_array",
"(",
"$",
"callback",
",",
"$",
"parameters",
")",
";",
"if",
"(",
"$",
"response",
"!==",
"null",
")",
"{",
"return",
"$",
"response",
";",
"}",
"}",
"}",
"}"
] | Dispatch the event name and pass the parameters to the callbacks.
@param string $action
@param array $parameters | [
"Dispatch",
"the",
"event",
"name",
"and",
"pass",
"the",
"parameters",
"to",
"the",
"callbacks",
"."
] | cc6907bfee296b64a7630b0b188e233d7cdb86fd | https://github.com/nirix/radium/blob/cc6907bfee296b64a7630b0b188e233d7cdb86fd/src/EventDispatcher.php#L59-L70 |
8,208 | SagittariusX/Beluga.Web | src/Beluga/Web/Http/Header.php | Header.SendContentType | public static function SendContentType( string $mimetype = 'text/html', string $charset = 'utf-8' )
{
if ( empty( $charset ) )
{
\header( 'Content-Type: ' . $mimetype );
}
else
{
\header( 'Content-Type: ' . $mimetype . '; charset=' . $charset );
}
} | php | public static function SendContentType( string $mimetype = 'text/html', string $charset = 'utf-8' )
{
if ( empty( $charset ) )
{
\header( 'Content-Type: ' . $mimetype );
}
else
{
\header( 'Content-Type: ' . $mimetype . '; charset=' . $charset );
}
} | [
"public",
"static",
"function",
"SendContentType",
"(",
"string",
"$",
"mimetype",
"=",
"'text/html'",
",",
"string",
"$",
"charset",
"=",
"'utf-8'",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"charset",
")",
")",
"{",
"\\",
"header",
"(",
"'Content-Type: '",
".",
"$",
"mimetype",
")",
";",
"}",
"else",
"{",
"\\",
"header",
"(",
"'Content-Type: '",
".",
"$",
"mimetype",
".",
"'; charset='",
".",
"$",
"charset",
")",
";",
"}",
"}"
] | Sends the defined Content-Type header with a optional chaset.
@param string $mimetype The MIME type.
@param string $charset The optional charset to send. (default='utf-8') | [
"Sends",
"the",
"defined",
"Content",
"-",
"Type",
"header",
"with",
"a",
"optional",
"chaset",
"."
] | 95d6094b2e536f5207291f6b3500028f34812b34 | https://github.com/SagittariusX/Beluga.Web/blob/95d6094b2e536f5207291f6b3500028f34812b34/src/Beluga/Web/Http/Header.php#L150-L162 |
8,209 | SagittariusX/Beluga.Web | src/Beluga/Web/Http/Header.php | Header.SendDownloadHeader | public static function SendDownloadHeader( string $file, int $filesize = null )
{
// Disable all caching mechanisms
\header( 'Expires: 0' );
\header( 'Cache-Control: private' );
\header( 'Pragma: cache' );
// The next header let the client download the file
\header( 'Content-Disposition: attachment; filename="' . \rawurlencode( \basename( $file ) ) . '"' );
// No we must send the associated content type
static::SendContentType( MimeTypeTool::GetByFileName( $file ), null );
// If no file size is defined but the file exists, getting the size.
if ( empty( $filesize ) && \file_exists( $file ) )
{
$filesize = \filesize( $file );
}
// If a usable file size is known send the 'Content-Length' HTTP header
if ( ! empty( $filesize ) )
{
\header( 'Content-Length: ' . $filesize );
}
} | php | public static function SendDownloadHeader( string $file, int $filesize = null )
{
// Disable all caching mechanisms
\header( 'Expires: 0' );
\header( 'Cache-Control: private' );
\header( 'Pragma: cache' );
// The next header let the client download the file
\header( 'Content-Disposition: attachment; filename="' . \rawurlencode( \basename( $file ) ) . '"' );
// No we must send the associated content type
static::SendContentType( MimeTypeTool::GetByFileName( $file ), null );
// If no file size is defined but the file exists, getting the size.
if ( empty( $filesize ) && \file_exists( $file ) )
{
$filesize = \filesize( $file );
}
// If a usable file size is known send the 'Content-Length' HTTP header
if ( ! empty( $filesize ) )
{
\header( 'Content-Length: ' . $filesize );
}
} | [
"public",
"static",
"function",
"SendDownloadHeader",
"(",
"string",
"$",
"file",
",",
"int",
"$",
"filesize",
"=",
"null",
")",
"{",
"// Disable all caching mechanisms",
"\\",
"header",
"(",
"'Expires: 0'",
")",
";",
"\\",
"header",
"(",
"'Cache-Control: private'",
")",
";",
"\\",
"header",
"(",
"'Pragma: cache'",
")",
";",
"// The next header let the client download the file",
"\\",
"header",
"(",
"'Content-Disposition: attachment; filename=\"'",
".",
"\\",
"rawurlencode",
"(",
"\\",
"basename",
"(",
"$",
"file",
")",
")",
".",
"'\"'",
")",
";",
"// No we must send the associated content type",
"static",
"::",
"SendContentType",
"(",
"MimeTypeTool",
"::",
"GetByFileName",
"(",
"$",
"file",
")",
",",
"null",
")",
";",
"// If no file size is defined but the file exists, getting the size.",
"if",
"(",
"empty",
"(",
"$",
"filesize",
")",
"&&",
"\\",
"file_exists",
"(",
"$",
"file",
")",
")",
"{",
"$",
"filesize",
"=",
"\\",
"filesize",
"(",
"$",
"file",
")",
";",
"}",
"// If a usable file size is known send the 'Content-Length' HTTP header",
"if",
"(",
"!",
"empty",
"(",
"$",
"filesize",
")",
")",
"{",
"\\",
"header",
"(",
"'Content-Length: '",
".",
"$",
"filesize",
")",
";",
"}",
"}"
] | Sends all HTTP headers required to sending a file download to current client.
Caching will be deactivated.
@param string $file Full path to download file. You can also use a file name, but if no file size is
defined the 'Content-Length' HTTP header is not send. (It means the client download
processbar can not show the right ready state percentage.
@param int $filesize A optional file size definition. If undefined and $file is not a accessible file
path, the 'Content-Length' HTTP header is not send. (default=NULL) | [
"Sends",
"all",
"HTTP",
"headers",
"required",
"to",
"sending",
"a",
"file",
"download",
"to",
"current",
"client",
"."
] | 95d6094b2e536f5207291f6b3500028f34812b34 | https://github.com/SagittariusX/Beluga.Web/blob/95d6094b2e536f5207291f6b3500028f34812b34/src/Beluga/Web/Http/Header.php#L175-L201 |
8,210 | SagittariusX/Beluga.Web | src/Beluga/Web/Http/Header.php | Header.SendRedirect | public static function SendRedirect( $url, int $waitSeconds = 3, bool $exitHere = false )
{
\header( "refresh:{$waitSeconds};url={$url}" );
if ( $exitHere ) { exit; }
} | php | public static function SendRedirect( $url, int $waitSeconds = 3, bool $exitHere = false )
{
\header( "refresh:{$waitSeconds};url={$url}" );
if ( $exitHere ) { exit; }
} | [
"public",
"static",
"function",
"SendRedirect",
"(",
"$",
"url",
",",
"int",
"$",
"waitSeconds",
"=",
"3",
",",
"bool",
"$",
"exitHere",
"=",
"false",
")",
"{",
"\\",
"header",
"(",
"\"refresh:{$waitSeconds};url={$url}\"",
")",
";",
"if",
"(",
"$",
"exitHere",
")",
"{",
"exit",
";",
"}",
"}"
] | Send a none standards conform refresh header. Most browser supports it, BUT THERE IS NO GUARANTEE that they
also handle it in newer releases!
@param string $url The redirection URL.
@param int $waitSeconds How many seconds should be waited before the redirect is executed? (default=3)
@param boolean $exitHere Exit after sending the header? (default=false) | [
"Send",
"a",
"none",
"standards",
"conform",
"refresh",
"header",
".",
"Most",
"browser",
"supports",
"it",
"BUT",
"THERE",
"IS",
"NO",
"GUARANTEE",
"that",
"they",
"also",
"handle",
"it",
"in",
"newer",
"releases!"
] | 95d6094b2e536f5207291f6b3500028f34812b34 | https://github.com/SagittariusX/Beluga.Web/blob/95d6094b2e536f5207291f6b3500028f34812b34/src/Beluga/Web/Http/Header.php#L211-L218 |
8,211 | SagittariusX/Beluga.Web | src/Beluga/Web/Http/Header.php | Header.SendLocation | public static function SendLocation( string $path, string $host = null, bool $exitHere = true )
{
if ( empty( $host ) || ! \is_string( $host ) )
{
if ( ! isset( $_SERVER[ 'HTTP_HOST' ] ) )
{
exit( 'Could not send a Location header if no host is defined!' );
}
$host = $_SERVER[ 'HTTP_HOST' ];
}
\header( 'Location: http://' . $host . '/' . \ltrim( $path, '/' ) );
if ( $exitHere )
{
exit;
}
} | php | public static function SendLocation( string $path, string $host = null, bool $exitHere = true )
{
if ( empty( $host ) || ! \is_string( $host ) )
{
if ( ! isset( $_SERVER[ 'HTTP_HOST' ] ) )
{
exit( 'Could not send a Location header if no host is defined!' );
}
$host = $_SERVER[ 'HTTP_HOST' ];
}
\header( 'Location: http://' . $host . '/' . \ltrim( $path, '/' ) );
if ( $exitHere )
{
exit;
}
} | [
"public",
"static",
"function",
"SendLocation",
"(",
"string",
"$",
"path",
",",
"string",
"$",
"host",
"=",
"null",
",",
"bool",
"$",
"exitHere",
"=",
"true",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"host",
")",
"||",
"!",
"\\",
"is_string",
"(",
"$",
"host",
")",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"_SERVER",
"[",
"'HTTP_HOST'",
"]",
")",
")",
"{",
"exit",
"(",
"'Could not send a Location header if no host is defined!'",
")",
";",
"}",
"$",
"host",
"=",
"$",
"_SERVER",
"[",
"'HTTP_HOST'",
"]",
";",
"}",
"\\",
"header",
"(",
"'Location: http://'",
".",
"$",
"host",
".",
"'/'",
".",
"\\",
"ltrim",
"(",
"$",
"path",
",",
"'/'",
")",
")",
";",
"if",
"(",
"$",
"exitHere",
")",
"{",
"exit",
";",
"}",
"}"
] | Sends a valid HTTP Location header for doing a redirect.
If you dont want to send some other HTTP headers after this header, DONT CHANGE the $exitHere parameter
to FALSE.
@param string $path e.g.: /test/probe.php (Must be a absolute URL path!)
@param string $host Optional host definition. If not defined here, $_SERVER[ 'HTTP_HOST' ] is used.
@param boolean $exitHere Exit after sending the header? (default=true) | [
"Sends",
"a",
"valid",
"HTTP",
"Location",
"header",
"for",
"doing",
"a",
"redirect",
"."
] | 95d6094b2e536f5207291f6b3500028f34812b34 | https://github.com/SagittariusX/Beluga.Web/blob/95d6094b2e536f5207291f6b3500028f34812b34/src/Beluga/Web/Http/Header.php#L230-L249 |
8,212 | SagittariusX/Beluga.Web | src/Beluga/Web/Http/Header.php | Header.SendMultipleChoice | public static function SendMultipleChoice( string $newLocation = null, bool $exitHere = false )
{
// Define the supported HTTP type
$pType = static::GetSupportedHttpVersion();
\header( "{$pType} 300 Multiple Choice" );
if ( !empty( $newLocation ) )
{
\header( "Location: {$newLocation}" );
exit();
}
if ( $exitHere )
{
exit;
}
} | php | public static function SendMultipleChoice( string $newLocation = null, bool $exitHere = false )
{
// Define the supported HTTP type
$pType = static::GetSupportedHttpVersion();
\header( "{$pType} 300 Multiple Choice" );
if ( !empty( $newLocation ) )
{
\header( "Location: {$newLocation}" );
exit();
}
if ( $exitHere )
{
exit;
}
} | [
"public",
"static",
"function",
"SendMultipleChoice",
"(",
"string",
"$",
"newLocation",
"=",
"null",
",",
"bool",
"$",
"exitHere",
"=",
"false",
")",
"{",
"// Define the supported HTTP type",
"$",
"pType",
"=",
"static",
"::",
"GetSupportedHttpVersion",
"(",
")",
";",
"\\",
"header",
"(",
"\"{$pType} 300 Multiple Choice\"",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"newLocation",
")",
")",
"{",
"\\",
"header",
"(",
"\"Location: {$newLocation}\"",
")",
";",
"exit",
"(",
")",
";",
"}",
"if",
"(",
"$",
"exitHere",
")",
"{",
"exit",
";",
"}",
"}"
] | Sends a 300 Multiple Choice HTTP-Header.
The requested resource is available by different type. The answer should contains a list of the
accepted types. If $newLocation is set to a valid URL an location was send to the address of the server
preferred representation.
@param string $newLocation Optionally a absolute URI we will redirect by a Location HTTP header
@param boolean $exitHere Exit after sending the header? Its only used if no Location header is send.
If a Location header is send its always exited after sending! (default=false) | [
"Sends",
"a",
"300",
"Multiple",
"Choice",
"HTTP",
"-",
"Header",
"."
] | 95d6094b2e536f5207291f6b3500028f34812b34 | https://github.com/SagittariusX/Beluga.Web/blob/95d6094b2e536f5207291f6b3500028f34812b34/src/Beluga/Web/Http/Header.php#L262-L281 |
8,213 | SagittariusX/Beluga.Web | src/Beluga/Web/Http/Header.php | Header.SendCacheControl | public static function SendCacheControl( bool $doCache = false, bool $mustRevalidate = true )
{
\header(
'Cache-Control: '
. ( $doCache ? 'cache' : 'no-cache' )
. ( $mustRevalidate ? ', must-revalidate' : '' )
);
} | php | public static function SendCacheControl( bool $doCache = false, bool $mustRevalidate = true )
{
\header(
'Cache-Control: '
. ( $doCache ? 'cache' : 'no-cache' )
. ( $mustRevalidate ? ', must-revalidate' : '' )
);
} | [
"public",
"static",
"function",
"SendCacheControl",
"(",
"bool",
"$",
"doCache",
"=",
"false",
",",
"bool",
"$",
"mustRevalidate",
"=",
"true",
")",
"{",
"\\",
"header",
"(",
"'Cache-Control: '",
".",
"(",
"$",
"doCache",
"?",
"'cache'",
":",
"'no-cache'",
")",
".",
"(",
"$",
"mustRevalidate",
"?",
"', must-revalidate'",
":",
"''",
")",
")",
";",
"}"
] | Sends a "Cache-Control" HTTP header.
@param boolean $doCache Use caching?
@param boolean $mustRevalidate Should be checked on each request, if a used cache is valid? | [
"Sends",
"a",
"Cache",
"-",
"Control",
"HTTP",
"header",
"."
] | 95d6094b2e536f5207291f6b3500028f34812b34 | https://github.com/SagittariusX/Beluga.Web/blob/95d6094b2e536f5207291f6b3500028f34812b34/src/Beluga/Web/Http/Header.php#L422-L431 |
8,214 | SagittariusX/Beluga.Web | src/Beluga/Web/Http/Header.php | Header.SendExpires | public static function SendExpires( $expireStamp = null )
{
if ( \is_null( $expireStamp ) || empty( $expireStamp ) )
{
$expireStamp = \time();
}
if ( \is_int( $expireStamp ) )
{
\header( 'Expires: ' . \date( 'D, d M Y H:i:s O', $expireStamp ) );
}
else if ( $expireStamp instanceof \DateTimeInterface )
{
\header( 'Expires: ' . $expireStamp->format( 'D, d M Y H:i:s O' ) );
}
else if ( TypeTool::IsInteger( $expireStamp ) )
{
\header( 'Expires: ' . \date( 'D, d M Y H:i:s O', \intval( $expireStamp ) ) );
}
else if ( TypeTool::IsStringConvertible( $expireStamp, $str ) )
{
$stamp = \strtotime( $str );
if ( $stamp > 0 )
{
\header( 'Expires: ' . \date( 'D, d M Y H:i:s O', $stamp ) );
}
}
} | php | public static function SendExpires( $expireStamp = null )
{
if ( \is_null( $expireStamp ) || empty( $expireStamp ) )
{
$expireStamp = \time();
}
if ( \is_int( $expireStamp ) )
{
\header( 'Expires: ' . \date( 'D, d M Y H:i:s O', $expireStamp ) );
}
else if ( $expireStamp instanceof \DateTimeInterface )
{
\header( 'Expires: ' . $expireStamp->format( 'D, d M Y H:i:s O' ) );
}
else if ( TypeTool::IsInteger( $expireStamp ) )
{
\header( 'Expires: ' . \date( 'D, d M Y H:i:s O', \intval( $expireStamp ) ) );
}
else if ( TypeTool::IsStringConvertible( $expireStamp, $str ) )
{
$stamp = \strtotime( $str );
if ( $stamp > 0 )
{
\header( 'Expires: ' . \date( 'D, d M Y H:i:s O', $stamp ) );
}
}
} | [
"public",
"static",
"function",
"SendExpires",
"(",
"$",
"expireStamp",
"=",
"null",
")",
"{",
"if",
"(",
"\\",
"is_null",
"(",
"$",
"expireStamp",
")",
"||",
"empty",
"(",
"$",
"expireStamp",
")",
")",
"{",
"$",
"expireStamp",
"=",
"\\",
"time",
"(",
")",
";",
"}",
"if",
"(",
"\\",
"is_int",
"(",
"$",
"expireStamp",
")",
")",
"{",
"\\",
"header",
"(",
"'Expires: '",
".",
"\\",
"date",
"(",
"'D, d M Y H:i:s O'",
",",
"$",
"expireStamp",
")",
")",
";",
"}",
"else",
"if",
"(",
"$",
"expireStamp",
"instanceof",
"\\",
"DateTimeInterface",
")",
"{",
"\\",
"header",
"(",
"'Expires: '",
".",
"$",
"expireStamp",
"->",
"format",
"(",
"'D, d M Y H:i:s O'",
")",
")",
";",
"}",
"else",
"if",
"(",
"TypeTool",
"::",
"IsInteger",
"(",
"$",
"expireStamp",
")",
")",
"{",
"\\",
"header",
"(",
"'Expires: '",
".",
"\\",
"date",
"(",
"'D, d M Y H:i:s O'",
",",
"\\",
"intval",
"(",
"$",
"expireStamp",
")",
")",
")",
";",
"}",
"else",
"if",
"(",
"TypeTool",
"::",
"IsStringConvertible",
"(",
"$",
"expireStamp",
",",
"$",
"str",
")",
")",
"{",
"$",
"stamp",
"=",
"\\",
"strtotime",
"(",
"$",
"str",
")",
";",
"if",
"(",
"$",
"stamp",
">",
"0",
")",
"{",
"\\",
"header",
"(",
"'Expires: '",
".",
"\\",
"date",
"(",
"'D, d M Y H:i:s O'",
",",
"$",
"stamp",
")",
")",
";",
"}",
"}",
"}"
] | Sends a "Expires" HTTP header.
@param int|\DateTimeInterface|string $expireStamp Optional Timestamp | [
"Sends",
"a",
"Expires",
"HTTP",
"header",
"."
] | 95d6094b2e536f5207291f6b3500028f34812b34 | https://github.com/SagittariusX/Beluga.Web/blob/95d6094b2e536f5207291f6b3500028f34812b34/src/Beluga/Web/Http/Header.php#L438-L467 |
8,215 | jmpantoja/planb-utils | src/Utils/Options/Exception/UndefinedProfileException.php | UndefinedProfileException.forProfile | public static function forProfile(string $name, ?\Throwable $previous = null): self
{
$example = self::getExample($name);
$message = sprintf("Undefined profile: %s\n%s", $name, $example);
return new static($message, $previous);
} | php | public static function forProfile(string $name, ?\Throwable $previous = null): self
{
$example = self::getExample($name);
$message = sprintf("Undefined profile: %s\n%s", $name, $example);
return new static($message, $previous);
} | [
"public",
"static",
"function",
"forProfile",
"(",
"string",
"$",
"name",
",",
"?",
"\\",
"Throwable",
"$",
"previous",
"=",
"null",
")",
":",
"self",
"{",
"$",
"example",
"=",
"self",
"::",
"getExample",
"(",
"$",
"name",
")",
";",
"$",
"message",
"=",
"sprintf",
"(",
"\"Undefined profile: %s\\n%s\"",
",",
"$",
"name",
",",
"$",
"example",
")",
";",
"return",
"new",
"static",
"(",
"$",
"message",
",",
"$",
"previous",
")",
";",
"}"
] | Crea una instancia, con un mensae que indica que el perfil indicado no existe
@param string $name
@param null|\Throwable $previous
@return \PlanB\Utils\Options\Exception\UndefinedProfileException | [
"Crea",
"una",
"instancia",
"con",
"un",
"mensae",
"que",
"indica",
"que",
"el",
"perfil",
"indicado",
"no",
"existe"
] | d17fbced4a285275928f8428ee56e269eb851690 | https://github.com/jmpantoja/planb-utils/blob/d17fbced4a285275928f8428ee56e269eb851690/src/Utils/Options/Exception/UndefinedProfileException.php#L42-L49 |
8,216 | sgtlambda/jvwp | src/common/Post.php | Post.findByExactMeta | public static function findByExactMeta ($meta_key, $meta_value, $post_type = PostTypes::ANY)
{
return get_posts(array(
'post_type' => $post_type,
'meta_key' => $meta_key,
'meta_value' => $meta_value
));
} | php | public static function findByExactMeta ($meta_key, $meta_value, $post_type = PostTypes::ANY)
{
return get_posts(array(
'post_type' => $post_type,
'meta_key' => $meta_key,
'meta_value' => $meta_value
));
} | [
"public",
"static",
"function",
"findByExactMeta",
"(",
"$",
"meta_key",
",",
"$",
"meta_value",
",",
"$",
"post_type",
"=",
"PostTypes",
"::",
"ANY",
")",
"{",
"return",
"get_posts",
"(",
"array",
"(",
"'post_type'",
"=>",
"$",
"post_type",
",",
"'meta_key'",
"=>",
"$",
"meta_key",
",",
"'meta_value'",
"=>",
"$",
"meta_value",
")",
")",
";",
"}"
] | Finds one or more pages by exactly matching the meta value
@param string $meta_key
@param string $meta_value
@param string $post_type
@return \WP_Post[] | [
"Finds",
"one",
"or",
"more",
"pages",
"by",
"exactly",
"matching",
"the",
"meta",
"value"
] | 85dba59281216ccb9cff580d26063d304350bbe0 | https://github.com/sgtlambda/jvwp/blob/85dba59281216ccb9cff580d26063d304350bbe0/src/common/Post.php#L25-L32 |
8,217 | judus/minimal-minimal | src/Apps/Maximal/MaximalApplication.php | MaximalApplication.container | public function container($name)
{
if (!isset($this->container[$name])) {
$this->container[$name] = IOC::resolve($name);
}
return $this->container[$name];
} | php | public function container($name)
{
if (!isset($this->container[$name])) {
$this->container[$name] = IOC::resolve($name);
}
return $this->container[$name];
} | [
"public",
"function",
"container",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"container",
"[",
"$",
"name",
"]",
")",
")",
"{",
"$",
"this",
"->",
"container",
"[",
"$",
"name",
"]",
"=",
"IOC",
"::",
"resolve",
"(",
"$",
"name",
")",
";",
"}",
"return",
"$",
"this",
"->",
"container",
"[",
"$",
"name",
"]",
";",
"}"
] | Gets an object from the container
Resolves it through IOC if that didn't happen yet
@param $name
@return mixed | [
"Gets",
"an",
"object",
"from",
"the",
"container",
"Resolves",
"it",
"through",
"IOC",
"if",
"that",
"didn",
"t",
"happen",
"yet"
] | 36db55c537175cead2ab412f166bf2574d0f9597 | https://github.com/judus/minimal-minimal/blob/36db55c537175cead2ab412f166bf2574d0f9597/src/Apps/Maximal/MaximalApplication.php#L112-L119 |
8,218 | judus/minimal-minimal | src/Apps/Maximal/MaximalApplication.php | MaximalApplication.load | public function load(array $files = null) : ApplicationInterface
{
$this->callLoad($files) || parent::load($files);
return $this;
} | php | public function load(array $files = null) : ApplicationInterface
{
$this->callLoad($files) || parent::load($files);
return $this;
} | [
"public",
"function",
"load",
"(",
"array",
"$",
"files",
"=",
"null",
")",
":",
"ApplicationInterface",
"{",
"$",
"this",
"->",
"callLoad",
"(",
"$",
"files",
")",
"||",
"parent",
"::",
"load",
"(",
"$",
"files",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Dispatch load event
@param array|null $files
@return ApplicationInterface | [
"Dispatch",
"load",
"event"
] | 36db55c537175cead2ab412f166bf2574d0f9597 | https://github.com/judus/minimal-minimal/blob/36db55c537175cead2ab412f166bf2574d0f9597/src/Apps/Maximal/MaximalApplication.php#L145-L150 |
8,219 | judus/minimal-minimal | src/Apps/Maximal/MaximalApplication.php | MaximalApplication.execute | public function execute(string $uri = null): ApplicationInterface
{
$this->callExecute($uri) || parent::execute($uri);
return $this;
} | php | public function execute(string $uri = null): ApplicationInterface
{
$this->callExecute($uri) || parent::execute($uri);
return $this;
} | [
"public",
"function",
"execute",
"(",
"string",
"$",
"uri",
"=",
"null",
")",
":",
"ApplicationInterface",
"{",
"$",
"this",
"->",
"callExecute",
"(",
"$",
"uri",
")",
"||",
"parent",
"::",
"execute",
"(",
"$",
"uri",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Dispatch execute event
@param string|null $uri
@return ApplicationInterface | [
"Dispatch",
"execute",
"event"
] | 36db55c537175cead2ab412f166bf2574d0f9597 | https://github.com/judus/minimal-minimal/blob/36db55c537175cead2ab412f166bf2574d0f9597/src/Apps/Maximal/MaximalApplication.php#L159-L164 |
8,220 | netcore/module-category | Http/Controllers/Admin/CategoryController.php | CategoryController.store | public function store(CategoryGroup $categoryGroup, CategoryRequest $request): JsonResponse
{
$category = $categoryGroup->categories()->create(
$request->only('icon')
);
foreach ($request->file('icons', []) as $key => $file) {
if ($categoryGroup->hasFileIcon($key) && $file) {
$category->icons()->create([
'key' => $key,
'icon' => $file,
]);
}
}
$this->modifySlugs($request);
$category->storeTranslations(
$request->input('translations')
);
if ($request->has('parent_id') && $parent = Category::find($request->input('parent_id'))) {
$parent->appendNode($category);
}
dispatch(
new RegenerateCategoryFullSlugs($category)
);
$this->clearCache();
return response()->json([
'state' => 'success',
]);
} | php | public function store(CategoryGroup $categoryGroup, CategoryRequest $request): JsonResponse
{
$category = $categoryGroup->categories()->create(
$request->only('icon')
);
foreach ($request->file('icons', []) as $key => $file) {
if ($categoryGroup->hasFileIcon($key) && $file) {
$category->icons()->create([
'key' => $key,
'icon' => $file,
]);
}
}
$this->modifySlugs($request);
$category->storeTranslations(
$request->input('translations')
);
if ($request->has('parent_id') && $parent = Category::find($request->input('parent_id'))) {
$parent->appendNode($category);
}
dispatch(
new RegenerateCategoryFullSlugs($category)
);
$this->clearCache();
return response()->json([
'state' => 'success',
]);
} | [
"public",
"function",
"store",
"(",
"CategoryGroup",
"$",
"categoryGroup",
",",
"CategoryRequest",
"$",
"request",
")",
":",
"JsonResponse",
"{",
"$",
"category",
"=",
"$",
"categoryGroup",
"->",
"categories",
"(",
")",
"->",
"create",
"(",
"$",
"request",
"->",
"only",
"(",
"'icon'",
")",
")",
";",
"foreach",
"(",
"$",
"request",
"->",
"file",
"(",
"'icons'",
",",
"[",
"]",
")",
"as",
"$",
"key",
"=>",
"$",
"file",
")",
"{",
"if",
"(",
"$",
"categoryGroup",
"->",
"hasFileIcon",
"(",
"$",
"key",
")",
"&&",
"$",
"file",
")",
"{",
"$",
"category",
"->",
"icons",
"(",
")",
"->",
"create",
"(",
"[",
"'key'",
"=>",
"$",
"key",
",",
"'icon'",
"=>",
"$",
"file",
",",
"]",
")",
";",
"}",
"}",
"$",
"this",
"->",
"modifySlugs",
"(",
"$",
"request",
")",
";",
"$",
"category",
"->",
"storeTranslations",
"(",
"$",
"request",
"->",
"input",
"(",
"'translations'",
")",
")",
";",
"if",
"(",
"$",
"request",
"->",
"has",
"(",
"'parent_id'",
")",
"&&",
"$",
"parent",
"=",
"Category",
"::",
"find",
"(",
"$",
"request",
"->",
"input",
"(",
"'parent_id'",
")",
")",
")",
"{",
"$",
"parent",
"->",
"appendNode",
"(",
"$",
"category",
")",
";",
"}",
"dispatch",
"(",
"new",
"RegenerateCategoryFullSlugs",
"(",
"$",
"category",
")",
")",
";",
"$",
"this",
"->",
"clearCache",
"(",
")",
";",
"return",
"response",
"(",
")",
"->",
"json",
"(",
"[",
"'state'",
"=>",
"'success'",
",",
"]",
")",
";",
"}"
] | Store category in the database.
@param \Modules\Category\Models\CategoryGroup $categoryGroup
@param \Modules\Category\Http\Requests\CategoryRequest $request
@return \Illuminate\Http\JsonResponse | [
"Store",
"category",
"in",
"the",
"database",
"."
] | 61a4fc2525774f8ddea730ad9f6f06644552adf7 | https://github.com/netcore/module-category/blob/61a4fc2525774f8ddea730ad9f6f06644552adf7/Http/Controllers/Admin/CategoryController.php#L51-L85 |
8,221 | netcore/module-category | Http/Controllers/Admin/CategoryController.php | CategoryController.update | public function update(CategoryRequest $request, CategoryGroup $categoryGroup, Category $category): JsonResponse
{
if ($category->category_group_id !== $categoryGroup->id) {
abort(404);
}
$category->update(
$request->only('icon')
);
foreach ($request->file('icons', []) as $key => $file) {
if ($categoryGroup->hasFileIcon($key) && $file) {
$category->icons()->updateOrCreate(
['key' => $key],
['icon' => $file]
);
}
}
$this->modifySlugs($request);
$category->updateTranslations(
$request->input('translations')
);
dispatch(
new RegenerateCategoryFullSlugs($category)
);
$this->clearCache();
return response()->json([
'state' => 'success',
]);
} | php | public function update(CategoryRequest $request, CategoryGroup $categoryGroup, Category $category): JsonResponse
{
if ($category->category_group_id !== $categoryGroup->id) {
abort(404);
}
$category->update(
$request->only('icon')
);
foreach ($request->file('icons', []) as $key => $file) {
if ($categoryGroup->hasFileIcon($key) && $file) {
$category->icons()->updateOrCreate(
['key' => $key],
['icon' => $file]
);
}
}
$this->modifySlugs($request);
$category->updateTranslations(
$request->input('translations')
);
dispatch(
new RegenerateCategoryFullSlugs($category)
);
$this->clearCache();
return response()->json([
'state' => 'success',
]);
} | [
"public",
"function",
"update",
"(",
"CategoryRequest",
"$",
"request",
",",
"CategoryGroup",
"$",
"categoryGroup",
",",
"Category",
"$",
"category",
")",
":",
"JsonResponse",
"{",
"if",
"(",
"$",
"category",
"->",
"category_group_id",
"!==",
"$",
"categoryGroup",
"->",
"id",
")",
"{",
"abort",
"(",
"404",
")",
";",
"}",
"$",
"category",
"->",
"update",
"(",
"$",
"request",
"->",
"only",
"(",
"'icon'",
")",
")",
";",
"foreach",
"(",
"$",
"request",
"->",
"file",
"(",
"'icons'",
",",
"[",
"]",
")",
"as",
"$",
"key",
"=>",
"$",
"file",
")",
"{",
"if",
"(",
"$",
"categoryGroup",
"->",
"hasFileIcon",
"(",
"$",
"key",
")",
"&&",
"$",
"file",
")",
"{",
"$",
"category",
"->",
"icons",
"(",
")",
"->",
"updateOrCreate",
"(",
"[",
"'key'",
"=>",
"$",
"key",
"]",
",",
"[",
"'icon'",
"=>",
"$",
"file",
"]",
")",
";",
"}",
"}",
"$",
"this",
"->",
"modifySlugs",
"(",
"$",
"request",
")",
";",
"$",
"category",
"->",
"updateTranslations",
"(",
"$",
"request",
"->",
"input",
"(",
"'translations'",
")",
")",
";",
"dispatch",
"(",
"new",
"RegenerateCategoryFullSlugs",
"(",
"$",
"category",
")",
")",
";",
"$",
"this",
"->",
"clearCache",
"(",
")",
";",
"return",
"response",
"(",
")",
"->",
"json",
"(",
"[",
"'state'",
"=>",
"'success'",
",",
"]",
")",
";",
"}"
] | Update category in the database.
@param \Modules\Category\Http\Requests\CategoryRequest $request
@param \Modules\Category\Models\CategoryGroup $categoryGroup
@param \Modules\Category\Models\Category $category
@return \Illuminate\Http\JsonResponse | [
"Update",
"category",
"in",
"the",
"database",
"."
] | 61a4fc2525774f8ddea730ad9f6f06644552adf7 | https://github.com/netcore/module-category/blob/61a4fc2525774f8ddea730ad9f6f06644552adf7/Http/Controllers/Admin/CategoryController.php#L95-L129 |
8,222 | netcore/module-category | Http/Controllers/Admin/CategoryController.php | CategoryController.destroy | public function destroy(CategoryGroup $categoryGroup, Category $category): JsonResponse
{
$categories = $categoryGroup->categories()->descendantsAndSelf(
$category->id
);
foreach ($categories as $item) {
$item->delete();
};
$this->clearCache();
return response()->json([
'state' => 'success',
]);
} | php | public function destroy(CategoryGroup $categoryGroup, Category $category): JsonResponse
{
$categories = $categoryGroup->categories()->descendantsAndSelf(
$category->id
);
foreach ($categories as $item) {
$item->delete();
};
$this->clearCache();
return response()->json([
'state' => 'success',
]);
} | [
"public",
"function",
"destroy",
"(",
"CategoryGroup",
"$",
"categoryGroup",
",",
"Category",
"$",
"category",
")",
":",
"JsonResponse",
"{",
"$",
"categories",
"=",
"$",
"categoryGroup",
"->",
"categories",
"(",
")",
"->",
"descendantsAndSelf",
"(",
"$",
"category",
"->",
"id",
")",
";",
"foreach",
"(",
"$",
"categories",
"as",
"$",
"item",
")",
"{",
"$",
"item",
"->",
"delete",
"(",
")",
";",
"}",
";",
"$",
"this",
"->",
"clearCache",
"(",
")",
";",
"return",
"response",
"(",
")",
"->",
"json",
"(",
"[",
"'state'",
"=>",
"'success'",
",",
"]",
")",
";",
"}"
] | Delete category and it's descendants.
@param \Modules\Category\Models\CategoryGroup $categoryGroup
@param \Modules\Category\Models\Category $category
@return \Illuminate\Http\JsonResponse | [
"Delete",
"category",
"and",
"it",
"s",
"descendants",
"."
] | 61a4fc2525774f8ddea730ad9f6f06644552adf7 | https://github.com/netcore/module-category/blob/61a4fc2525774f8ddea730ad9f6f06644552adf7/Http/Controllers/Admin/CategoryController.php#L138-L153 |
8,223 | netcore/module-category | Http/Controllers/Admin/CategoryController.php | CategoryController.updateOrder | public function updateOrder(Request $request): JsonResponse
{
Category::rebuildTree(
$request->input('tree')
);
$this->clearCache();
$movedNode = Category::findOrFail(
$request->input('moved')
);
dispatch(
new RegenerateCategoryFullSlugs($movedNode)
);
return response()->json([
'state' => 'success',
]);
} | php | public function updateOrder(Request $request): JsonResponse
{
Category::rebuildTree(
$request->input('tree')
);
$this->clearCache();
$movedNode = Category::findOrFail(
$request->input('moved')
);
dispatch(
new RegenerateCategoryFullSlugs($movedNode)
);
return response()->json([
'state' => 'success',
]);
} | [
"public",
"function",
"updateOrder",
"(",
"Request",
"$",
"request",
")",
":",
"JsonResponse",
"{",
"Category",
"::",
"rebuildTree",
"(",
"$",
"request",
"->",
"input",
"(",
"'tree'",
")",
")",
";",
"$",
"this",
"->",
"clearCache",
"(",
")",
";",
"$",
"movedNode",
"=",
"Category",
"::",
"findOrFail",
"(",
"$",
"request",
"->",
"input",
"(",
"'moved'",
")",
")",
";",
"dispatch",
"(",
"new",
"RegenerateCategoryFullSlugs",
"(",
"$",
"movedNode",
")",
")",
";",
"return",
"response",
"(",
")",
"->",
"json",
"(",
"[",
"'state'",
"=>",
"'success'",
",",
"]",
")",
";",
"}"
] | Rebuild categories tree.
@param \Illuminate\Http\Request $request
@return \Illuminate\Http\JsonResponse | [
"Rebuild",
"categories",
"tree",
"."
] | 61a4fc2525774f8ddea730ad9f6f06644552adf7 | https://github.com/netcore/module-category/blob/61a4fc2525774f8ddea730ad9f6f06644552adf7/Http/Controllers/Admin/CategoryController.php#L161-L180 |
8,224 | netcore/module-category | Http/Controllers/Admin/CategoryController.php | CategoryController.fetchCategories | public function fetchCategories(CategoryGroup $categoryGroup)
{
$isTreeOpened = config('netcore.module-category.tree.opened_by_default', false);
$suffixHelper = config('netcore.module-category.tree.name_suffix_helper_function', null);
$language = TransHelper::getLanguage();
$categories = $categoryGroup->categories()->defaultOrder()->get();
$categories = $categories->map(function (Category $category) use (
$isTreeOpened,
$suffixHelper,
$language,
$categoryGroup
) {
// Name.
$categoryName = trans_model($category, $language, 'name');
if ($suffixHelper && function_exists($suffixHelper)) {
$categoryName .= $suffixHelper($category);
}
// Icons.
$icons = [];
if ($categoryGroup->has_icons) {
$icons = $category->icons->mapWithKeys(function (CategoryIcon $categoryIcon) {
return [$categoryIcon->key => $categoryIcon->icon->url()];
});
}
return [
'id' => $category->id,
'parent' => $category->parent_id ?: '#',
'text' => $categoryName,
'icon' => $category->icon,
'li_attr' => [],
'a_attr' => [],
'translations' => $category->translations,
'state' => [
'opened' => $isTreeOpened,
'disabled' => false,
'selected' => false,
],
'icons' => $icons,
];
});
return $categories;
} | php | public function fetchCategories(CategoryGroup $categoryGroup)
{
$isTreeOpened = config('netcore.module-category.tree.opened_by_default', false);
$suffixHelper = config('netcore.module-category.tree.name_suffix_helper_function', null);
$language = TransHelper::getLanguage();
$categories = $categoryGroup->categories()->defaultOrder()->get();
$categories = $categories->map(function (Category $category) use (
$isTreeOpened,
$suffixHelper,
$language,
$categoryGroup
) {
// Name.
$categoryName = trans_model($category, $language, 'name');
if ($suffixHelper && function_exists($suffixHelper)) {
$categoryName .= $suffixHelper($category);
}
// Icons.
$icons = [];
if ($categoryGroup->has_icons) {
$icons = $category->icons->mapWithKeys(function (CategoryIcon $categoryIcon) {
return [$categoryIcon->key => $categoryIcon->icon->url()];
});
}
return [
'id' => $category->id,
'parent' => $category->parent_id ?: '#',
'text' => $categoryName,
'icon' => $category->icon,
'li_attr' => [],
'a_attr' => [],
'translations' => $category->translations,
'state' => [
'opened' => $isTreeOpened,
'disabled' => false,
'selected' => false,
],
'icons' => $icons,
];
});
return $categories;
} | [
"public",
"function",
"fetchCategories",
"(",
"CategoryGroup",
"$",
"categoryGroup",
")",
"{",
"$",
"isTreeOpened",
"=",
"config",
"(",
"'netcore.module-category.tree.opened_by_default'",
",",
"false",
")",
";",
"$",
"suffixHelper",
"=",
"config",
"(",
"'netcore.module-category.tree.name_suffix_helper_function'",
",",
"null",
")",
";",
"$",
"language",
"=",
"TransHelper",
"::",
"getLanguage",
"(",
")",
";",
"$",
"categories",
"=",
"$",
"categoryGroup",
"->",
"categories",
"(",
")",
"->",
"defaultOrder",
"(",
")",
"->",
"get",
"(",
")",
";",
"$",
"categories",
"=",
"$",
"categories",
"->",
"map",
"(",
"function",
"(",
"Category",
"$",
"category",
")",
"use",
"(",
"$",
"isTreeOpened",
",",
"$",
"suffixHelper",
",",
"$",
"language",
",",
"$",
"categoryGroup",
")",
"{",
"// Name.",
"$",
"categoryName",
"=",
"trans_model",
"(",
"$",
"category",
",",
"$",
"language",
",",
"'name'",
")",
";",
"if",
"(",
"$",
"suffixHelper",
"&&",
"function_exists",
"(",
"$",
"suffixHelper",
")",
")",
"{",
"$",
"categoryName",
".=",
"$",
"suffixHelper",
"(",
"$",
"category",
")",
";",
"}",
"// Icons.",
"$",
"icons",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"categoryGroup",
"->",
"has_icons",
")",
"{",
"$",
"icons",
"=",
"$",
"category",
"->",
"icons",
"->",
"mapWithKeys",
"(",
"function",
"(",
"CategoryIcon",
"$",
"categoryIcon",
")",
"{",
"return",
"[",
"$",
"categoryIcon",
"->",
"key",
"=>",
"$",
"categoryIcon",
"->",
"icon",
"->",
"url",
"(",
")",
"]",
";",
"}",
")",
";",
"}",
"return",
"[",
"'id'",
"=>",
"$",
"category",
"->",
"id",
",",
"'parent'",
"=>",
"$",
"category",
"->",
"parent_id",
"?",
":",
"'#'",
",",
"'text'",
"=>",
"$",
"categoryName",
",",
"'icon'",
"=>",
"$",
"category",
"->",
"icon",
",",
"'li_attr'",
"=>",
"[",
"]",
",",
"'a_attr'",
"=>",
"[",
"]",
",",
"'translations'",
"=>",
"$",
"category",
"->",
"translations",
",",
"'state'",
"=>",
"[",
"'opened'",
"=>",
"$",
"isTreeOpened",
",",
"'disabled'",
"=>",
"false",
",",
"'selected'",
"=>",
"false",
",",
"]",
",",
"'icons'",
"=>",
"$",
"icons",
",",
"]",
";",
"}",
")",
";",
"return",
"$",
"categories",
";",
"}"
] | Get data for JsTree.
@param CategoryGroup $categoryGroup
@return \Illuminate\Database\Eloquent\Collection | [
"Get",
"data",
"for",
"JsTree",
"."
] | 61a4fc2525774f8ddea730ad9f6f06644552adf7 | https://github.com/netcore/module-category/blob/61a4fc2525774f8ddea730ad9f6f06644552adf7/Http/Controllers/Admin/CategoryController.php#L188-L236 |
8,225 | diatem-net/jin-webapp | src/WebApp/WebApp.php | WebApp.getPageFolder | public static function getPageFolder()
{
$folder = self::path() . self::$pageFolder;
return rtrim(realpath($folder), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
} | php | public static function getPageFolder()
{
$folder = self::path() . self::$pageFolder;
return rtrim(realpath($folder), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
} | [
"public",
"static",
"function",
"getPageFolder",
"(",
")",
"{",
"$",
"folder",
"=",
"self",
"::",
"path",
"(",
")",
".",
"self",
"::",
"$",
"pageFolder",
";",
"return",
"rtrim",
"(",
"realpath",
"(",
"$",
"folder",
")",
",",
"DIRECTORY_SEPARATOR",
")",
".",
"DIRECTORY_SEPARATOR",
";",
"}"
] | Get the page folder
@return string | [
"Get",
"the",
"page",
"folder"
] | 43e85f780c3841a536e3a5d41929523e5aacd272 | https://github.com/diatem-net/jin-webapp/blob/43e85f780c3841a536e3a5d41929523e5aacd272/src/WebApp/WebApp.php#L119-L123 |
8,226 | diatem-net/jin-webapp | src/WebApp/WebApp.php | WebApp.getCacheFolder | public static function getCacheFolder()
{
$folder = self::path() . self::$cacheFolder;
return rtrim(realpath($folder), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
} | php | public static function getCacheFolder()
{
$folder = self::path() . self::$cacheFolder;
return rtrim(realpath($folder), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
} | [
"public",
"static",
"function",
"getCacheFolder",
"(",
")",
"{",
"$",
"folder",
"=",
"self",
"::",
"path",
"(",
")",
".",
"self",
"::",
"$",
"cacheFolder",
";",
"return",
"rtrim",
"(",
"realpath",
"(",
"$",
"folder",
")",
",",
"DIRECTORY_SEPARATOR",
")",
".",
"DIRECTORY_SEPARATOR",
";",
"}"
] | Get the cache folder
@return string | [
"Get",
"the",
"cache",
"folder"
] | 43e85f780c3841a536e3a5d41929523e5aacd272 | https://github.com/diatem-net/jin-webapp/blob/43e85f780c3841a536e3a5d41929523e5aacd272/src/WebApp/WebApp.php#L130-L134 |
8,227 | diatem-net/jin-webapp | src/WebApp/WebApp.php | WebApp.getTemplateFolder | public static function getTemplateFolder()
{
$folder = self::path() . self::$templateFolder;
return rtrim(realpath($folder), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
} | php | public static function getTemplateFolder()
{
$folder = self::path() . self::$templateFolder;
return rtrim(realpath($folder), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
} | [
"public",
"static",
"function",
"getTemplateFolder",
"(",
")",
"{",
"$",
"folder",
"=",
"self",
"::",
"path",
"(",
")",
".",
"self",
"::",
"$",
"templateFolder",
";",
"return",
"rtrim",
"(",
"realpath",
"(",
"$",
"folder",
")",
",",
"DIRECTORY_SEPARATOR",
")",
".",
"DIRECTORY_SEPARATOR",
";",
"}"
] | Get the template folder
@return string | [
"Get",
"the",
"template",
"folder"
] | 43e85f780c3841a536e3a5d41929523e5aacd272 | https://github.com/diatem-net/jin-webapp/blob/43e85f780c3841a536e3a5d41929523e5aacd272/src/WebApp/WebApp.php#L151-L155 |
8,228 | crazedsanity/core | src/core/ToolBox.class.php | ToolBox.create_list | static public function create_list($string=NULL, $addThis=NULL, $delimiter=", ") {
if(count(func_get_args()) > 3) {
trigger_error(__METHOD__ .": argument 'useSqlQuotes' is deprecated and no longer utilized");
}
if(strlen($string)) {
$retVal = $string . $delimiter . $addThis;
}
else {
$retVal = $addThis;
}
return($retVal);
} | php | static public function create_list($string=NULL, $addThis=NULL, $delimiter=", ") {
if(count(func_get_args()) > 3) {
trigger_error(__METHOD__ .": argument 'useSqlQuotes' is deprecated and no longer utilized");
}
if(strlen($string)) {
$retVal = $string . $delimiter . $addThis;
}
else {
$retVal = $addThis;
}
return($retVal);
} | [
"static",
"public",
"function",
"create_list",
"(",
"$",
"string",
"=",
"NULL",
",",
"$",
"addThis",
"=",
"NULL",
",",
"$",
"delimiter",
"=",
"\", \"",
")",
"{",
"if",
"(",
"count",
"(",
"func_get_args",
"(",
")",
")",
">",
"3",
")",
"{",
"trigger_error",
"(",
"__METHOD__",
".",
"\": argument 'useSqlQuotes' is deprecated and no longer utilized\"",
")",
";",
"}",
"if",
"(",
"strlen",
"(",
"$",
"string",
")",
")",
"{",
"$",
"retVal",
"=",
"$",
"string",
".",
"$",
"delimiter",
".",
"$",
"addThis",
";",
"}",
"else",
"{",
"$",
"retVal",
"=",
"$",
"addThis",
";",
"}",
"return",
"(",
"$",
"retVal",
")",
";",
"}"
] | Returns a list delimited by the given delimiter. Does the work of checking if the given variable has data
in it already, that needs to be added to, vs. setting the variable with the new content. | [
"Returns",
"a",
"list",
"delimited",
"by",
"the",
"given",
"delimiter",
".",
"Does",
"the",
"work",
"of",
"checking",
"if",
"the",
"given",
"variable",
"has",
"data",
"in",
"it",
"already",
"that",
"needs",
"to",
"be",
"added",
"to",
"vs",
".",
"setting",
"the",
"variable",
"with",
"the",
"new",
"content",
"."
] | f3053467edc6d105ebdaca146325b79329aa1d63 | https://github.com/crazedsanity/core/blob/f3053467edc6d105ebdaca146325b79329aa1d63/src/core/ToolBox.class.php#L522-L534 |
8,229 | crazedsanity/core | src/core/ToolBox.class.php | ToolBox.debug_print | static public function debug_print($input=NULL, $printItForMe=NULL, $removeHR=NULL, $usePreTags=true) {
if(!is_numeric($removeHR)) {
$removeHR = ToolBox::$debugRemoveHr;
}
if(!is_numeric($printItForMe)) {
$printItForMe = ToolBox::$debugPrintOpt;
}
ob_start();
print_r($input);
$output = ob_get_contents();
ob_end_clean();
if($usePreTags === true) {
$output = "<pre class='cs debug'>$output</pre>";
}
if(!isset($_SERVER['SERVER_PROTOCOL']) || !$_SERVER['SERVER_PROTOCOL']) {
$output = strip_tags($output);
$hrString = "\n***************************************************************\n";
}
else {
$hrString = "<hr>";
}
if($removeHR) {
$hrString = NULL;;
}
if($printItForMe) {
print "$output". $hrString ."\n";
}
return($output);
} | php | static public function debug_print($input=NULL, $printItForMe=NULL, $removeHR=NULL, $usePreTags=true) {
if(!is_numeric($removeHR)) {
$removeHR = ToolBox::$debugRemoveHr;
}
if(!is_numeric($printItForMe)) {
$printItForMe = ToolBox::$debugPrintOpt;
}
ob_start();
print_r($input);
$output = ob_get_contents();
ob_end_clean();
if($usePreTags === true) {
$output = "<pre class='cs debug'>$output</pre>";
}
if(!isset($_SERVER['SERVER_PROTOCOL']) || !$_SERVER['SERVER_PROTOCOL']) {
$output = strip_tags($output);
$hrString = "\n***************************************************************\n";
}
else {
$hrString = "<hr>";
}
if($removeHR) {
$hrString = NULL;;
}
if($printItForMe) {
print "$output". $hrString ."\n";
}
return($output);
} | [
"static",
"public",
"function",
"debug_print",
"(",
"$",
"input",
"=",
"NULL",
",",
"$",
"printItForMe",
"=",
"NULL",
",",
"$",
"removeHR",
"=",
"NULL",
",",
"$",
"usePreTags",
"=",
"true",
")",
"{",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"removeHR",
")",
")",
"{",
"$",
"removeHR",
"=",
"ToolBox",
"::",
"$",
"debugRemoveHr",
";",
"}",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"printItForMe",
")",
")",
"{",
"$",
"printItForMe",
"=",
"ToolBox",
"::",
"$",
"debugPrintOpt",
";",
"}",
"ob_start",
"(",
")",
";",
"print_r",
"(",
"$",
"input",
")",
";",
"$",
"output",
"=",
"ob_get_contents",
"(",
")",
";",
"ob_end_clean",
"(",
")",
";",
"if",
"(",
"$",
"usePreTags",
"===",
"true",
")",
"{",
"$",
"output",
"=",
"\"<pre class='cs debug'>$output</pre>\"",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"_SERVER",
"[",
"'SERVER_PROTOCOL'",
"]",
")",
"||",
"!",
"$",
"_SERVER",
"[",
"'SERVER_PROTOCOL'",
"]",
")",
"{",
"$",
"output",
"=",
"strip_tags",
"(",
"$",
"output",
")",
";",
"$",
"hrString",
"=",
"\"\\n***************************************************************\\n\"",
";",
"}",
"else",
"{",
"$",
"hrString",
"=",
"\"<hr>\"",
";",
"}",
"if",
"(",
"$",
"removeHR",
")",
"{",
"$",
"hrString",
"=",
"NULL",
";",
";",
"}",
"if",
"(",
"$",
"printItForMe",
")",
"{",
"print",
"\"$output\"",
".",
"$",
"hrString",
".",
"\"\\n\"",
";",
"}",
"return",
"(",
"$",
"output",
")",
";",
"}"
] | A way of printing out human-readable information, especially arrays & objects, either to a web browser or via
the command line.
@param $input (mixed,optional) data to print/return
@param $printItForMe (bool,optional) whether it should be printed or just returned.
@return (string) printed data.
@codeCoverageIgnore | [
"A",
"way",
"of",
"printing",
"out",
"human",
"-",
"readable",
"information",
"especially",
"arrays",
"&",
"objects",
"either",
"to",
"a",
"web",
"browser",
"or",
"via",
"the",
"command",
"line",
"."
] | f3053467edc6d105ebdaca146325b79329aa1d63 | https://github.com/crazedsanity/core/blob/f3053467edc6d105ebdaca146325b79329aa1d63/src/core/ToolBox.class.php#L550-L584 |
8,230 | crazedsanity/core | src/core/ToolBox.class.php | ToolBox.clean_url | static public function clean_url($url=NULL) {
//make sure we've still got something valid to work with.
if(strlen($url)) {
//if there's an "APPURL" constant, drop that from the url.
if(defined('APPURL') && strlen(constant('APPURL'))) {
$dropThis = preg_replace('/^\//', '', constant('APPURL'));
$dropThis = preg_replace('/\//', '\\/', $dropThis);
$url = preg_replace('/^'. $dropThis .'/', '', $url);
}
//check the string to make sure it doesn't begin with a "/"
if($url[0] == '/') {
$url = substr($url, 1, strlen($url));
}
//check the last char for a "/"...
if($url[strlen($url) -1] == '/') {
//last char is a '/'... kill it.
$url = substr($url, 0, strlen($url) -1);
}
//if we've been sent a query, kill it off the string...
if(preg_match('/\?/', $url)) {
$url = preg_split('/\?/', $url);
$url = $url[0];
}
if(preg_match("/\./", $url)) {
//disregard file extensions, but keep everything else...
// i.e. "index.php/yermom.html" becomes "index/yermom"
$tArr = explode('/', $url);
$tUrl = null;
foreach($tArr as $tUrlPart) {
$temp = explode(".", $tUrlPart);
if(strlen($temp[0])) {
$tUrlPart = $temp[0];
}
$tUrl = ToolBox::create_list($tUrl, $tUrlPart, '/');
}
$url = $tUrl;
}
}
else {
$url = null;
}
return($url);
} | php | static public function clean_url($url=NULL) {
//make sure we've still got something valid to work with.
if(strlen($url)) {
//if there's an "APPURL" constant, drop that from the url.
if(defined('APPURL') && strlen(constant('APPURL'))) {
$dropThis = preg_replace('/^\//', '', constant('APPURL'));
$dropThis = preg_replace('/\//', '\\/', $dropThis);
$url = preg_replace('/^'. $dropThis .'/', '', $url);
}
//check the string to make sure it doesn't begin with a "/"
if($url[0] == '/') {
$url = substr($url, 1, strlen($url));
}
//check the last char for a "/"...
if($url[strlen($url) -1] == '/') {
//last char is a '/'... kill it.
$url = substr($url, 0, strlen($url) -1);
}
//if we've been sent a query, kill it off the string...
if(preg_match('/\?/', $url)) {
$url = preg_split('/\?/', $url);
$url = $url[0];
}
if(preg_match("/\./", $url)) {
//disregard file extensions, but keep everything else...
// i.e. "index.php/yermom.html" becomes "index/yermom"
$tArr = explode('/', $url);
$tUrl = null;
foreach($tArr as $tUrlPart) {
$temp = explode(".", $tUrlPart);
if(strlen($temp[0])) {
$tUrlPart = $temp[0];
}
$tUrl = ToolBox::create_list($tUrl, $tUrlPart, '/');
}
$url = $tUrl;
}
}
else {
$url = null;
}
return($url);
} | [
"static",
"public",
"function",
"clean_url",
"(",
"$",
"url",
"=",
"NULL",
")",
"{",
"//make sure we've still got something valid to work with.",
"if",
"(",
"strlen",
"(",
"$",
"url",
")",
")",
"{",
"//if there's an \"APPURL\" constant, drop that from the url.",
"if",
"(",
"defined",
"(",
"'APPURL'",
")",
"&&",
"strlen",
"(",
"constant",
"(",
"'APPURL'",
")",
")",
")",
"{",
"$",
"dropThis",
"=",
"preg_replace",
"(",
"'/^\\//'",
",",
"''",
",",
"constant",
"(",
"'APPURL'",
")",
")",
";",
"$",
"dropThis",
"=",
"preg_replace",
"(",
"'/\\//'",
",",
"'\\\\/'",
",",
"$",
"dropThis",
")",
";",
"$",
"url",
"=",
"preg_replace",
"(",
"'/^'",
".",
"$",
"dropThis",
".",
"'/'",
",",
"''",
",",
"$",
"url",
")",
";",
"}",
"//check the string to make sure it doesn't begin with a \"/\"",
"if",
"(",
"$",
"url",
"[",
"0",
"]",
"==",
"'/'",
")",
"{",
"$",
"url",
"=",
"substr",
"(",
"$",
"url",
",",
"1",
",",
"strlen",
"(",
"$",
"url",
")",
")",
";",
"}",
"//check the last char for a \"/\"...",
"if",
"(",
"$",
"url",
"[",
"strlen",
"(",
"$",
"url",
")",
"-",
"1",
"]",
"==",
"'/'",
")",
"{",
"//last char is a '/'... kill it.",
"$",
"url",
"=",
"substr",
"(",
"$",
"url",
",",
"0",
",",
"strlen",
"(",
"$",
"url",
")",
"-",
"1",
")",
";",
"}",
"//if we've been sent a query, kill it off the string...",
"if",
"(",
"preg_match",
"(",
"'/\\?/'",
",",
"$",
"url",
")",
")",
"{",
"$",
"url",
"=",
"preg_split",
"(",
"'/\\?/'",
",",
"$",
"url",
")",
";",
"$",
"url",
"=",
"$",
"url",
"[",
"0",
"]",
";",
"}",
"if",
"(",
"preg_match",
"(",
"\"/\\./\"",
",",
"$",
"url",
")",
")",
"{",
"//disregard file extensions, but keep everything else...",
"//\ti.e. \"index.php/yermom.html\" becomes \"index/yermom\"",
"$",
"tArr",
"=",
"explode",
"(",
"'/'",
",",
"$",
"url",
")",
";",
"$",
"tUrl",
"=",
"null",
";",
"foreach",
"(",
"$",
"tArr",
"as",
"$",
"tUrlPart",
")",
"{",
"$",
"temp",
"=",
"explode",
"(",
"\".\"",
",",
"$",
"tUrlPart",
")",
";",
"if",
"(",
"strlen",
"(",
"$",
"temp",
"[",
"0",
"]",
")",
")",
"{",
"$",
"tUrlPart",
"=",
"$",
"temp",
"[",
"0",
"]",
";",
"}",
"$",
"tUrl",
"=",
"ToolBox",
"::",
"create_list",
"(",
"$",
"tUrl",
",",
"$",
"tUrlPart",
",",
"'/'",
")",
";",
"}",
"$",
"url",
"=",
"$",
"tUrl",
";",
"}",
"}",
"else",
"{",
"$",
"url",
"=",
"null",
";",
"}",
"return",
"(",
"$",
"url",
")",
";",
"}"
] | Removes all the crap from the url, so we can figure out what section we
need to load templates & includes for. | [
"Removes",
"all",
"the",
"crap",
"from",
"the",
"url",
"so",
"we",
"can",
"figure",
"out",
"what",
"section",
"we",
"need",
"to",
"load",
"templates",
"&",
"includes",
"for",
"."
] | f3053467edc6d105ebdaca146325b79329aa1d63 | https://github.com/crazedsanity/core/blob/f3053467edc6d105ebdaca146325b79329aa1d63/src/core/ToolBox.class.php#L819-L866 |
8,231 | aedart/overload | src/Traits/SetterInvokerTrait.php | SetterInvokerTrait.invokeSetter | protected function invokeSetter(ReflectionProperty $property, $value) : void
{
$methodName = $this->generateSetterName($property->getName());
if ($this->hasInternalMethod($methodName)) {
$this->$methodName($value);
return;
}
throw new UndefinedPropertyException(sprintf(
'No "%s"() method available for property "%s"', $methodName,
$property->getName()
));
} | php | protected function invokeSetter(ReflectionProperty $property, $value) : void
{
$methodName = $this->generateSetterName($property->getName());
if ($this->hasInternalMethod($methodName)) {
$this->$methodName($value);
return;
}
throw new UndefinedPropertyException(sprintf(
'No "%s"() method available for property "%s"', $methodName,
$property->getName()
));
} | [
"protected",
"function",
"invokeSetter",
"(",
"ReflectionProperty",
"$",
"property",
",",
"$",
"value",
")",
":",
"void",
"{",
"$",
"methodName",
"=",
"$",
"this",
"->",
"generateSetterName",
"(",
"$",
"property",
"->",
"getName",
"(",
")",
")",
";",
"if",
"(",
"$",
"this",
"->",
"hasInternalMethod",
"(",
"$",
"methodName",
")",
")",
"{",
"$",
"this",
"->",
"$",
"methodName",
"(",
"$",
"value",
")",
";",
"return",
";",
"}",
"throw",
"new",
"UndefinedPropertyException",
"(",
"sprintf",
"(",
"'No \"%s\"() method available for property \"%s\"'",
",",
"$",
"methodName",
",",
"$",
"property",
"->",
"getName",
"(",
")",
")",
")",
";",
"}"
] | Invoke the given property's setter-method
@param ReflectionProperty $property The property in question
@param mixed $value The property's value
@return void;
@throws UndefinedPropertyException If given property doesn't have a corresponding get | [
"Invoke",
"the",
"given",
"property",
"s",
"setter",
"-",
"method"
] | 530a5f71454e69c58107ae864d2aa473277dcdfd | https://github.com/aedart/overload/blob/530a5f71454e69c58107ae864d2aa473277dcdfd/src/Traits/SetterInvokerTrait.php#L72-L84 |
8,232 | mszewcz/php-light-framework | src/Html/Controlls/DateAndTime.php | DateAndTime.getYears | private static function getYears(): array
{
$years = [-1 => static::getConstant('TXT_DATETIME_YYYY', 'TXT_DATETIME_YYYY')];
for ($i = 1978; $i <= 2037; $i++) {
$years[$i] = $i;
}
return $years;
} | php | private static function getYears(): array
{
$years = [-1 => static::getConstant('TXT_DATETIME_YYYY', 'TXT_DATETIME_YYYY')];
for ($i = 1978; $i <= 2037; $i++) {
$years[$i] = $i;
}
return $years;
} | [
"private",
"static",
"function",
"getYears",
"(",
")",
":",
"array",
"{",
"$",
"years",
"=",
"[",
"-",
"1",
"=>",
"static",
"::",
"getConstant",
"(",
"'TXT_DATETIME_YYYY'",
",",
"'TXT_DATETIME_YYYY'",
")",
"]",
";",
"for",
"(",
"$",
"i",
"=",
"1978",
";",
"$",
"i",
"<=",
"2037",
";",
"$",
"i",
"++",
")",
"{",
"$",
"years",
"[",
"$",
"i",
"]",
"=",
"$",
"i",
";",
"}",
"return",
"$",
"years",
";",
"}"
] | Returns years array
@return array | [
"Returns",
"years",
"array"
] | 4d3b46781c387202c2dfbdb8760151b3ae8ef49c | https://github.com/mszewcz/php-light-framework/blob/4d3b46781c387202c2dfbdb8760151b3ae8ef49c/src/Html/Controlls/DateAndTime.php#L27-L34 |
8,233 | mszewcz/php-light-framework | src/Html/Controlls/DateAndTime.php | DateAndTime.getMonths | private static function getMonths(): array
{
$months = [-1 => static::getConstant('TXT_DATETIME_MMM', 'TXT_DATETIME_MMM')];
for ($i = 1; $i <= 12; $i++) {
$months[$i] = static::getConstant('TXT_DATETIME_MONTH_'.$i.'_SHORT', 'TXT_DATETIME_MONTH_'.$i.'_SHORT');
}
return $months;
} | php | private static function getMonths(): array
{
$months = [-1 => static::getConstant('TXT_DATETIME_MMM', 'TXT_DATETIME_MMM')];
for ($i = 1; $i <= 12; $i++) {
$months[$i] = static::getConstant('TXT_DATETIME_MONTH_'.$i.'_SHORT', 'TXT_DATETIME_MONTH_'.$i.'_SHORT');
}
return $months;
} | [
"private",
"static",
"function",
"getMonths",
"(",
")",
":",
"array",
"{",
"$",
"months",
"=",
"[",
"-",
"1",
"=>",
"static",
"::",
"getConstant",
"(",
"'TXT_DATETIME_MMM'",
",",
"'TXT_DATETIME_MMM'",
")",
"]",
";",
"for",
"(",
"$",
"i",
"=",
"1",
";",
"$",
"i",
"<=",
"12",
";",
"$",
"i",
"++",
")",
"{",
"$",
"months",
"[",
"$",
"i",
"]",
"=",
"static",
"::",
"getConstant",
"(",
"'TXT_DATETIME_MONTH_'",
".",
"$",
"i",
".",
"'_SHORT'",
",",
"'TXT_DATETIME_MONTH_'",
".",
"$",
"i",
".",
"'_SHORT'",
")",
";",
"}",
"return",
"$",
"months",
";",
"}"
] | Returns months array
@return array | [
"Returns",
"months",
"array"
] | 4d3b46781c387202c2dfbdb8760151b3ae8ef49c | https://github.com/mszewcz/php-light-framework/blob/4d3b46781c387202c2dfbdb8760151b3ae8ef49c/src/Html/Controlls/DateAndTime.php#L41-L48 |
8,234 | mszewcz/php-light-framework | src/Html/Controlls/DateAndTime.php | DateAndTime.getDays | private static function getDays(int $maxDays = 31): array
{
$days = [-1 => static::getConstant('TXT_DATETIME_DD', 'TXT_DATETIME_DD')];
for ($i = 1; $i <= $maxDays; $i++) {
$days[$i] = \sprintf('%02s', $i);
}
return $days;
} | php | private static function getDays(int $maxDays = 31): array
{
$days = [-1 => static::getConstant('TXT_DATETIME_DD', 'TXT_DATETIME_DD')];
for ($i = 1; $i <= $maxDays; $i++) {
$days[$i] = \sprintf('%02s', $i);
}
return $days;
} | [
"private",
"static",
"function",
"getDays",
"(",
"int",
"$",
"maxDays",
"=",
"31",
")",
":",
"array",
"{",
"$",
"days",
"=",
"[",
"-",
"1",
"=>",
"static",
"::",
"getConstant",
"(",
"'TXT_DATETIME_DD'",
",",
"'TXT_DATETIME_DD'",
")",
"]",
";",
"for",
"(",
"$",
"i",
"=",
"1",
";",
"$",
"i",
"<=",
"$",
"maxDays",
";",
"$",
"i",
"++",
")",
"{",
"$",
"days",
"[",
"$",
"i",
"]",
"=",
"\\",
"sprintf",
"(",
"'%02s'",
",",
"$",
"i",
")",
";",
"}",
"return",
"$",
"days",
";",
"}"
] | Returns days array
@param int $maxDays
@return array | [
"Returns",
"days",
"array"
] | 4d3b46781c387202c2dfbdb8760151b3ae8ef49c | https://github.com/mszewcz/php-light-framework/blob/4d3b46781c387202c2dfbdb8760151b3ae8ef49c/src/Html/Controlls/DateAndTime.php#L56-L63 |
8,235 | mszewcz/php-light-framework | src/Html/Controlls/DateAndTime.php | DateAndTime.getHours | private static function getHours(): array
{
$hours = [-1 => static::getConstant('TXT_DATETIME_HH', 'TXT_DATETIME_HH')];
for ($i = 0; $i <= 23; $i++) {
$hours[$i] = \sprintf('%02s', $i);
}
return $hours;
} | php | private static function getHours(): array
{
$hours = [-1 => static::getConstant('TXT_DATETIME_HH', 'TXT_DATETIME_HH')];
for ($i = 0; $i <= 23; $i++) {
$hours[$i] = \sprintf('%02s', $i);
}
return $hours;
} | [
"private",
"static",
"function",
"getHours",
"(",
")",
":",
"array",
"{",
"$",
"hours",
"=",
"[",
"-",
"1",
"=>",
"static",
"::",
"getConstant",
"(",
"'TXT_DATETIME_HH'",
",",
"'TXT_DATETIME_HH'",
")",
"]",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<=",
"23",
";",
"$",
"i",
"++",
")",
"{",
"$",
"hours",
"[",
"$",
"i",
"]",
"=",
"\\",
"sprintf",
"(",
"'%02s'",
",",
"$",
"i",
")",
";",
"}",
"return",
"$",
"hours",
";",
"}"
] | Returns hours array
@return array | [
"Returns",
"hours",
"array"
] | 4d3b46781c387202c2dfbdb8760151b3ae8ef49c | https://github.com/mszewcz/php-light-framework/blob/4d3b46781c387202c2dfbdb8760151b3ae8ef49c/src/Html/Controlls/DateAndTime.php#L70-L77 |
8,236 | mszewcz/php-light-framework | src/Html/Controlls/DateAndTime.php | DateAndTime.getMinutes | private static function getMinutes(): array
{
$minutes = [-1 => static::getConstant('TXT_DATETIME_II', 'TXT_DATETIME_II')];
for ($i = 0; $i <= 59; $i++) {
$minutes[$i] = \sprintf('%02s', $i);
}
return $minutes;
} | php | private static function getMinutes(): array
{
$minutes = [-1 => static::getConstant('TXT_DATETIME_II', 'TXT_DATETIME_II')];
for ($i = 0; $i <= 59; $i++) {
$minutes[$i] = \sprintf('%02s', $i);
}
return $minutes;
} | [
"private",
"static",
"function",
"getMinutes",
"(",
")",
":",
"array",
"{",
"$",
"minutes",
"=",
"[",
"-",
"1",
"=>",
"static",
"::",
"getConstant",
"(",
"'TXT_DATETIME_II'",
",",
"'TXT_DATETIME_II'",
")",
"]",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<=",
"59",
";",
"$",
"i",
"++",
")",
"{",
"$",
"minutes",
"[",
"$",
"i",
"]",
"=",
"\\",
"sprintf",
"(",
"'%02s'",
",",
"$",
"i",
")",
";",
"}",
"return",
"$",
"minutes",
";",
"}"
] | Returns minutes array
@return array | [
"Returns",
"minutes",
"array"
] | 4d3b46781c387202c2dfbdb8760151b3ae8ef49c | https://github.com/mszewcz/php-light-framework/blob/4d3b46781c387202c2dfbdb8760151b3ae8ef49c/src/Html/Controlls/DateAndTime.php#L84-L91 |
8,237 | mszewcz/php-light-framework | src/Html/Controlls/DateAndTime.php | DateAndTime.getSeconds | private static function getSeconds(): array
{
$seconds = [-1 => static::getConstant('TXT_DATETIME_SS', 'TXT_DATETIME_SS')];
for ($i = 0; $i <= 59; $i++) {
$seconds[$i] = \sprintf('%02s', $i);
}
return $seconds;
} | php | private static function getSeconds(): array
{
$seconds = [-1 => static::getConstant('TXT_DATETIME_SS', 'TXT_DATETIME_SS')];
for ($i = 0; $i <= 59; $i++) {
$seconds[$i] = \sprintf('%02s', $i);
}
return $seconds;
} | [
"private",
"static",
"function",
"getSeconds",
"(",
")",
":",
"array",
"{",
"$",
"seconds",
"=",
"[",
"-",
"1",
"=>",
"static",
"::",
"getConstant",
"(",
"'TXT_DATETIME_SS'",
",",
"'TXT_DATETIME_SS'",
")",
"]",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<=",
"59",
";",
"$",
"i",
"++",
")",
"{",
"$",
"seconds",
"[",
"$",
"i",
"]",
"=",
"\\",
"sprintf",
"(",
"'%02s'",
",",
"$",
"i",
")",
";",
"}",
"return",
"$",
"seconds",
";",
"}"
] | Returns seconds array
@return array | [
"Returns",
"seconds",
"array"
] | 4d3b46781c387202c2dfbdb8760151b3ae8ef49c | https://github.com/mszewcz/php-light-framework/blob/4d3b46781c387202c2dfbdb8760151b3ae8ef49c/src/Html/Controlls/DateAndTime.php#L98-L105 |
8,238 | vinala/kernel | src/Mailing/SMTP.php | SMTP.getDefault | public static function getDefault()
{
$smtp = new self(
config('mail.host'),
config('mail.port'),
config('mail.encryption'),
config('mail.username'),
config('mail.password'),
config('mail.from')['adresse'],
config('mail.from')['name']
);
// static::check($smtp);
return $smtp;
} | php | public static function getDefault()
{
$smtp = new self(
config('mail.host'),
config('mail.port'),
config('mail.encryption'),
config('mail.username'),
config('mail.password'),
config('mail.from')['adresse'],
config('mail.from')['name']
);
// static::check($smtp);
return $smtp;
} | [
"public",
"static",
"function",
"getDefault",
"(",
")",
"{",
"$",
"smtp",
"=",
"new",
"self",
"(",
"config",
"(",
"'mail.host'",
")",
",",
"config",
"(",
"'mail.port'",
")",
",",
"config",
"(",
"'mail.encryption'",
")",
",",
"config",
"(",
"'mail.username'",
")",
",",
"config",
"(",
"'mail.password'",
")",
",",
"config",
"(",
"'mail.from'",
")",
"[",
"'adresse'",
"]",
",",
"config",
"(",
"'mail.from'",
")",
"[",
"'name'",
"]",
")",
";",
"// static::check($smtp);",
"return",
"$",
"smtp",
";",
"}"
] | Init the SMTP class by getting gefualt values from Config surface.
@return Vinala\Kernel\Mailing | [
"Init",
"the",
"SMTP",
"class",
"by",
"getting",
"gefualt",
"values",
"from",
"Config",
"surface",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Mailing/SMTP.php#L109-L124 |
8,239 | vinala/kernel | src/Mailing/SMTP.php | SMTP.check | private static function check($smtp)
{
exception_if(empty($smtp->host), SmtpParameterNotFoundException::class, 'host');
exception_if(empty($smtp->port), SmtpParameterNotFoundException::class, 'port');
exception_if(empty($smtp->encryption), SmtpParameterNotFoundException::class, 'encryption');
exception_if(empty($smtp->username), SmtpParameterNotFoundException::class, 'username');
exception_if(empty($smtp->password), SmtpParameterNotFoundException::class, 'password');
exception_if(empty($smtp->sender_email), SmtpParameterNotFoundException::class, 'sender email');
exception_if(empty($smtp->sender_name), SmtpParameterNotFoundException::class, 'sender name');
return true;
} | php | private static function check($smtp)
{
exception_if(empty($smtp->host), SmtpParameterNotFoundException::class, 'host');
exception_if(empty($smtp->port), SmtpParameterNotFoundException::class, 'port');
exception_if(empty($smtp->encryption), SmtpParameterNotFoundException::class, 'encryption');
exception_if(empty($smtp->username), SmtpParameterNotFoundException::class, 'username');
exception_if(empty($smtp->password), SmtpParameterNotFoundException::class, 'password');
exception_if(empty($smtp->sender_email), SmtpParameterNotFoundException::class, 'sender email');
exception_if(empty($smtp->sender_name), SmtpParameterNotFoundException::class, 'sender name');
return true;
} | [
"private",
"static",
"function",
"check",
"(",
"$",
"smtp",
")",
"{",
"exception_if",
"(",
"empty",
"(",
"$",
"smtp",
"->",
"host",
")",
",",
"SmtpParameterNotFoundException",
"::",
"class",
",",
"'host'",
")",
";",
"exception_if",
"(",
"empty",
"(",
"$",
"smtp",
"->",
"port",
")",
",",
"SmtpParameterNotFoundException",
"::",
"class",
",",
"'port'",
")",
";",
"exception_if",
"(",
"empty",
"(",
"$",
"smtp",
"->",
"encryption",
")",
",",
"SmtpParameterNotFoundException",
"::",
"class",
",",
"'encryption'",
")",
";",
"exception_if",
"(",
"empty",
"(",
"$",
"smtp",
"->",
"username",
")",
",",
"SmtpParameterNotFoundException",
"::",
"class",
",",
"'username'",
")",
";",
"exception_if",
"(",
"empty",
"(",
"$",
"smtp",
"->",
"password",
")",
",",
"SmtpParameterNotFoundException",
"::",
"class",
",",
"'password'",
")",
";",
"exception_if",
"(",
"empty",
"(",
"$",
"smtp",
"->",
"sender_email",
")",
",",
"SmtpParameterNotFoundException",
"::",
"class",
",",
"'sender email'",
")",
";",
"exception_if",
"(",
"empty",
"(",
"$",
"smtp",
"->",
"sender_name",
")",
",",
"SmtpParameterNotFoundException",
"::",
"class",
",",
"'sender name'",
")",
";",
"return",
"true",
";",
"}"
] | Check if SMTP configurated.
@return bool | [
"Check",
"if",
"SMTP",
"configurated",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Mailing/SMTP.php#L131-L142 |
8,240 | flowcode/AmulenClassificationBundle | src/Flowcode/ClassificationBundle/Controller/CategoryController.php | CategoryController.createEditForm | private function createEditForm(Category $entity)
{
$form = $this->createForm($this->get("amulen.classification.form.category"), $entity, array(
'action' => $this->generateUrl('admin_category_update', array('id' => $entity->getId())),
'method' => 'PUT',
));
$form->add('submit', 'submit', array('label' => 'Update'));
return $form;
} | php | private function createEditForm(Category $entity)
{
$form = $this->createForm($this->get("amulen.classification.form.category"), $entity, array(
'action' => $this->generateUrl('admin_category_update', array('id' => $entity->getId())),
'method' => 'PUT',
));
$form->add('submit', 'submit', array('label' => 'Update'));
return $form;
} | [
"private",
"function",
"createEditForm",
"(",
"Category",
"$",
"entity",
")",
"{",
"$",
"form",
"=",
"$",
"this",
"->",
"createForm",
"(",
"$",
"this",
"->",
"get",
"(",
"\"amulen.classification.form.category\"",
")",
",",
"$",
"entity",
",",
"array",
"(",
"'action'",
"=>",
"$",
"this",
"->",
"generateUrl",
"(",
"'admin_category_update'",
",",
"array",
"(",
"'id'",
"=>",
"$",
"entity",
"->",
"getId",
"(",
")",
")",
")",
",",
"'method'",
"=>",
"'PUT'",
",",
")",
")",
";",
"$",
"form",
"->",
"add",
"(",
"'submit'",
",",
"'submit'",
",",
"array",
"(",
"'label'",
"=>",
"'Update'",
")",
")",
";",
"return",
"$",
"form",
";",
"}"
] | Creates a form to edit a Category entity.
@param Category $entity The entity
@return \Symfony\Component\Form\Form The form | [
"Creates",
"a",
"form",
"to",
"edit",
"a",
"Category",
"entity",
"."
] | e280537c47f85e7da614ccd00a6993ff9ed86e18 | https://github.com/flowcode/AmulenClassificationBundle/blob/e280537c47f85e7da614ccd00a6993ff9ed86e18/src/Flowcode/ClassificationBundle/Controller/CategoryController.php#L160-L170 |
8,241 | bugotech/http | src/HttpServiceProvider.php | HttpServiceProvider.mapRoutes | protected function mapRoutes()
{
$this->app['events']->listen('kernel.handling', function () {
// Gatilho para arquivo routes.php
$file_route = app_path('routes.php');
if (files()->exists($file_route)) {
require $file_route;
}
// Web
router()->group(['middleware' => ['web']], function (Router $router) {
event()->fire(new PublicRegisterRoutes($router));
event()->fire(new PublicTenantRegisterRoutes($router));
event()->fire(new PrivateRegisterRoutes($router));
});
// Api
router()->group(['middleware' => ['api'], 'prefix' => 'api'], function (Router $router) {
event()->fire(new ApiRegisterRoutes($router));
});
});
} | php | protected function mapRoutes()
{
$this->app['events']->listen('kernel.handling', function () {
// Gatilho para arquivo routes.php
$file_route = app_path('routes.php');
if (files()->exists($file_route)) {
require $file_route;
}
// Web
router()->group(['middleware' => ['web']], function (Router $router) {
event()->fire(new PublicRegisterRoutes($router));
event()->fire(new PublicTenantRegisterRoutes($router));
event()->fire(new PrivateRegisterRoutes($router));
});
// Api
router()->group(['middleware' => ['api'], 'prefix' => 'api'], function (Router $router) {
event()->fire(new ApiRegisterRoutes($router));
});
});
} | [
"protected",
"function",
"mapRoutes",
"(",
")",
"{",
"$",
"this",
"->",
"app",
"[",
"'events'",
"]",
"->",
"listen",
"(",
"'kernel.handling'",
",",
"function",
"(",
")",
"{",
"// Gatilho para arquivo routes.php",
"$",
"file_route",
"=",
"app_path",
"(",
"'routes.php'",
")",
";",
"if",
"(",
"files",
"(",
")",
"->",
"exists",
"(",
"$",
"file_route",
")",
")",
"{",
"require",
"$",
"file_route",
";",
"}",
"// Web",
"router",
"(",
")",
"->",
"group",
"(",
"[",
"'middleware'",
"=>",
"[",
"'web'",
"]",
"]",
",",
"function",
"(",
"Router",
"$",
"router",
")",
"{",
"event",
"(",
")",
"->",
"fire",
"(",
"new",
"PublicRegisterRoutes",
"(",
"$",
"router",
")",
")",
";",
"event",
"(",
")",
"->",
"fire",
"(",
"new",
"PublicTenantRegisterRoutes",
"(",
"$",
"router",
")",
")",
";",
"event",
"(",
")",
"->",
"fire",
"(",
"new",
"PrivateRegisterRoutes",
"(",
"$",
"router",
")",
")",
";",
"}",
")",
";",
"// Api",
"router",
"(",
")",
"->",
"group",
"(",
"[",
"'middleware'",
"=>",
"[",
"'api'",
"]",
",",
"'prefix'",
"=>",
"'api'",
"]",
",",
"function",
"(",
"Router",
"$",
"router",
")",
"{",
"event",
"(",
")",
"->",
"fire",
"(",
"new",
"ApiRegisterRoutes",
"(",
"$",
"router",
")",
")",
";",
"}",
")",
";",
"}",
")",
";",
"}"
] | Mapear as rotas do sistema. | [
"Mapear",
"as",
"rotas",
"do",
"sistema",
"."
] | 68c2e8a28eaa2e53f98a55d2f2ec0e33c83fd486 | https://github.com/bugotech/http/blob/68c2e8a28eaa2e53f98a55d2f2ec0e33c83fd486/src/HttpServiceProvider.php#L100-L121 |
8,242 | bugotech/http | src/HttpServiceProvider.php | HttpServiceProvider.shareRequestInUrl | protected function shareRequestInUrl()
{
$this->app['events']->listen('Illuminate\Routing\Events\RouteMatched', function (RouteMatched $event) {
foreach ($event->route->parameters() as $k => $v) {
$this->app['url']->share($k, $v);
}
});
} | php | protected function shareRequestInUrl()
{
$this->app['events']->listen('Illuminate\Routing\Events\RouteMatched', function (RouteMatched $event) {
foreach ($event->route->parameters() as $k => $v) {
$this->app['url']->share($k, $v);
}
});
} | [
"protected",
"function",
"shareRequestInUrl",
"(",
")",
"{",
"$",
"this",
"->",
"app",
"[",
"'events'",
"]",
"->",
"listen",
"(",
"'Illuminate\\Routing\\Events\\RouteMatched'",
",",
"function",
"(",
"RouteMatched",
"$",
"event",
")",
"{",
"foreach",
"(",
"$",
"event",
"->",
"route",
"->",
"parameters",
"(",
")",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"$",
"this",
"->",
"app",
"[",
"'url'",
"]",
"->",
"share",
"(",
"$",
"k",
",",
"$",
"v",
")",
";",
"}",
"}",
")",
";",
"}"
] | Register request params in url. | [
"Register",
"request",
"params",
"in",
"url",
"."
] | 68c2e8a28eaa2e53f98a55d2f2ec0e33c83fd486 | https://github.com/bugotech/http/blob/68c2e8a28eaa2e53f98a55d2f2ec0e33c83fd486/src/HttpServiceProvider.php#L126-L133 |
8,243 | deasilworks/cef | src/EntityCollection.php | EntityCollection.getModel | public function getModel()
{
$namePath = $this->getModelClass();
$model = new $namePath();
if (!($model instanceof EntityDataModel)) {
throw new \Exception($this->valueClass.' is not an instance of EntityModel.');
}
return $model;
} | php | public function getModel()
{
$namePath = $this->getModelClass();
$model = new $namePath();
if (!($model instanceof EntityDataModel)) {
throw new \Exception($this->valueClass.' is not an instance of EntityModel.');
}
return $model;
} | [
"public",
"function",
"getModel",
"(",
")",
"{",
"$",
"namePath",
"=",
"$",
"this",
"->",
"getModelClass",
"(",
")",
";",
"$",
"model",
"=",
"new",
"$",
"namePath",
"(",
")",
";",
"if",
"(",
"!",
"(",
"$",
"model",
"instanceof",
"EntityDataModel",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"$",
"this",
"->",
"valueClass",
".",
"' is not an instance of EntityModel.'",
")",
";",
"}",
"return",
"$",
"model",
";",
"}"
] | Model Factory.
@throws \Exception
@return mixed | [
"Model",
"Factory",
"."
] | 18c65f2b123512bba2208975dc655354f57670be | https://github.com/deasilworks/cef/blob/18c65f2b123512bba2208975dc655354f57670be/src/EntityCollection.php#L348-L358 |
8,244 | deasilworks/cef | src/EntityCollection.php | EntityCollection.addEntity | public function addEntity($entity)
{
$this->collection[] = $entity;
$this->setCount(count($this->collection));
return $this;
} | php | public function addEntity($entity)
{
$this->collection[] = $entity;
$this->setCount(count($this->collection));
return $this;
} | [
"public",
"function",
"addEntity",
"(",
"$",
"entity",
")",
"{",
"$",
"this",
"->",
"collection",
"[",
"]",
"=",
"$",
"entity",
";",
"$",
"this",
"->",
"setCount",
"(",
"count",
"(",
"$",
"this",
"->",
"collection",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Adds a single entity.
@param array $entity
@return EntityCollection | [
"Adds",
"a",
"single",
"entity",
"."
] | 18c65f2b123512bba2208975dc655354f57670be | https://github.com/deasilworks/cef/blob/18c65f2b123512bba2208975dc655354f57670be/src/EntityCollection.php#L419-L425 |
8,245 | dankempster/axstrad-common | src/Util/Debug.php | Debug.summariseArray | private static function summariseArray(array $var, $depth = 1)
{
static $depth = 1;
if ($depth == 2) {
return 'Array('.count($var).')';
}
elseif (($count = count($var)) > 0) {
$key = array_keys($var);
$key = $key[0];
$value = array_values($var);
$value = $value[0];
$mask = 'Array(%1$s){';
if (is_string($key)) {
$mask .= '%2$s: ';
}
$mask .= '%3$s}';
$depth = 2;
$return = sprintf(
$mask,
$count,
$key,
self::summarise($value)
);
$depth = 1;
return $return;
}
return 'Array(0){}';
} | php | private static function summariseArray(array $var, $depth = 1)
{
static $depth = 1;
if ($depth == 2) {
return 'Array('.count($var).')';
}
elseif (($count = count($var)) > 0) {
$key = array_keys($var);
$key = $key[0];
$value = array_values($var);
$value = $value[0];
$mask = 'Array(%1$s){';
if (is_string($key)) {
$mask .= '%2$s: ';
}
$mask .= '%3$s}';
$depth = 2;
$return = sprintf(
$mask,
$count,
$key,
self::summarise($value)
);
$depth = 1;
return $return;
}
return 'Array(0){}';
} | [
"private",
"static",
"function",
"summariseArray",
"(",
"array",
"$",
"var",
",",
"$",
"depth",
"=",
"1",
")",
"{",
"static",
"$",
"depth",
"=",
"1",
";",
"if",
"(",
"$",
"depth",
"==",
"2",
")",
"{",
"return",
"'Array('",
".",
"count",
"(",
"$",
"var",
")",
".",
"')'",
";",
"}",
"elseif",
"(",
"(",
"$",
"count",
"=",
"count",
"(",
"$",
"var",
")",
")",
">",
"0",
")",
"{",
"$",
"key",
"=",
"array_keys",
"(",
"$",
"var",
")",
";",
"$",
"key",
"=",
"$",
"key",
"[",
"0",
"]",
";",
"$",
"value",
"=",
"array_values",
"(",
"$",
"var",
")",
";",
"$",
"value",
"=",
"$",
"value",
"[",
"0",
"]",
";",
"$",
"mask",
"=",
"'Array(%1$s){'",
";",
"if",
"(",
"is_string",
"(",
"$",
"key",
")",
")",
"{",
"$",
"mask",
".=",
"'%2$s: '",
";",
"}",
"$",
"mask",
".=",
"'%3$s}'",
";",
"$",
"depth",
"=",
"2",
";",
"$",
"return",
"=",
"sprintf",
"(",
"$",
"mask",
",",
"$",
"count",
",",
"$",
"key",
",",
"self",
"::",
"summarise",
"(",
"$",
"value",
")",
")",
";",
"$",
"depth",
"=",
"1",
";",
"return",
"$",
"return",
";",
"}",
"return",
"'Array(0){}'",
";",
"}"
] | Summarises an array
@param array $var
@return string | [
"Summarises",
"an",
"array"
] | 900ae03199aa027750d9fa8375d376e3754a5abd | https://github.com/dankempster/axstrad-common/blob/900ae03199aa027750d9fa8375d376e3754a5abd/src/Util/Debug.php#L93-L125 |
8,246 | afonzeca/arun-core | src/ArunCore/Core/IO/FileContentGenerator.php | FileContentGenerator.loadDomainCode | public function loadDomainCode(string $domainName)
{
$domainClassName = DomainActionNameGenerator::getDomainClassName($domainName);
return $this->load($this->domainsPath . "/" . $domainClassName.".php");
} | php | public function loadDomainCode(string $domainName)
{
$domainClassName = DomainActionNameGenerator::getDomainClassName($domainName);
return $this->load($this->domainsPath . "/" . $domainClassName.".php");
} | [
"public",
"function",
"loadDomainCode",
"(",
"string",
"$",
"domainName",
")",
"{",
"$",
"domainClassName",
"=",
"DomainActionNameGenerator",
"::",
"getDomainClassName",
"(",
"$",
"domainName",
")",
";",
"return",
"$",
"this",
"->",
"load",
"(",
"$",
"this",
"->",
"domainsPath",
".",
"\"/\"",
".",
"$",
"domainClassName",
".",
"\".php\"",
")",
";",
"}"
] | Load code from a specified ClassDomain
@param string $domainName
@return bool|null|string | [
"Load",
"code",
"from",
"a",
"specified",
"ClassDomain"
] | 7a8af37e326187ff9ed7e2ff7bde6a489a9803a2 | https://github.com/afonzeca/arun-core/blob/7a8af37e326187ff9ed7e2ff7bde6a489a9803a2/src/ArunCore/Core/IO/FileContentGenerator.php#L73-L78 |
8,247 | Atipik/Hoa-WebSocket-Bundle | WebSocket/Runner.php | Runner.addEvent | public function addEvent($event, $callable)
{
if (!is_callable($callable)) {
throw new \InvalidArgumentException(
sprintf(
'%s expects parameter 2 to be callable, %s given: %s',
__METHOD__,
gettype($callable),
print_r($callable, true)
)
);
}
if (!isset($this->events[$event])) {
$this->events[$event] = array();
}
$this->events[$event][] = $callable;
} | php | public function addEvent($event, $callable)
{
if (!is_callable($callable)) {
throw new \InvalidArgumentException(
sprintf(
'%s expects parameter 2 to be callable, %s given: %s',
__METHOD__,
gettype($callable),
print_r($callable, true)
)
);
}
if (!isset($this->events[$event])) {
$this->events[$event] = array();
}
$this->events[$event][] = $callable;
} | [
"public",
"function",
"addEvent",
"(",
"$",
"event",
",",
"$",
"callable",
")",
"{",
"if",
"(",
"!",
"is_callable",
"(",
"$",
"callable",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'%s expects parameter 2 to be callable, %s given: %s'",
",",
"__METHOD__",
",",
"gettype",
"(",
"$",
"callable",
")",
",",
"print_r",
"(",
"$",
"callable",
",",
"true",
")",
")",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"events",
"[",
"$",
"event",
"]",
")",
")",
"{",
"$",
"this",
"->",
"events",
"[",
"$",
"event",
"]",
"=",
"array",
"(",
")",
";",
"}",
"$",
"this",
"->",
"events",
"[",
"$",
"event",
"]",
"[",
"]",
"=",
"$",
"callable",
";",
"}"
] | Add an event and its callback
@param string $event
@param callable $callable | [
"Add",
"an",
"event",
"and",
"its",
"callback"
] | 5961ba1fd808bae8ab4f96f76fb7a4db90edf76f | https://github.com/Atipik/Hoa-WebSocket-Bundle/blob/5961ba1fd808bae8ab4f96f76fb7a4db90edf76f/WebSocket/Runner.php#L53-L71 |
8,248 | Atipik/Hoa-WebSocket-Bundle | WebSocket/Runner.php | Runner.initWebSocketServer | public function initWebSocketServer()
{
$webSocketServer = $this->getWebSocketServer();
$webSocketServer->setLogger(
$this->getLogger()
);
if ($this->getNodeClass() !== null) {
$webSocketServer->getConnection()->setNodeName(
$this->getNodeClass()
);
}
$socket = $webSocketServer->getConnection()->getSocket();
$this->getLogger()->log('<fg=yellow>Starting server...</fg=yellow>');
$this->getLogger()->log('Environment: <fg=green>%s</fg=green>', $this->kernelEnvironment);
$this->getLogger()->log('Class used:');
$this->getLogger()->log(' Logger : %s', get_class($this->getLogger()));
$this->getLogger()->log(' Runner : %s', get_class($this));
$this->getLogger()->log(' WebSocket Server : %s', get_class($webSocketServer));
$this->getLogger()->log(' Socket Server : %s', get_class($socket));
$this->getLogger()->log(' Node : %s', ltrim($webSocketServer->getConnection()->getNodeName(), '\\'));
$this->getLogger()->log(
'<fg=yellow>Listening on %s:%d</fg=yellow>',
$socket->getAddress(),
$socket->getPort()
);
$webSocketServer->on('open', xcallable($this, 'onOpen'));
$webSocketServer->on('message', xcallable($this, 'onMessage'));
$webSocketServer->on('binary-message', xcallable($this, 'onBinaryMessage'));
$webSocketServer->on('ping', xcallable($this, 'onPing'));
$webSocketServer->on('error', xcallable($this, 'onError'));
$webSocketServer->on('close', xcallable($this, 'onClose'));
$this->loadEvents();
return $webSocketServer;
} | php | public function initWebSocketServer()
{
$webSocketServer = $this->getWebSocketServer();
$webSocketServer->setLogger(
$this->getLogger()
);
if ($this->getNodeClass() !== null) {
$webSocketServer->getConnection()->setNodeName(
$this->getNodeClass()
);
}
$socket = $webSocketServer->getConnection()->getSocket();
$this->getLogger()->log('<fg=yellow>Starting server...</fg=yellow>');
$this->getLogger()->log('Environment: <fg=green>%s</fg=green>', $this->kernelEnvironment);
$this->getLogger()->log('Class used:');
$this->getLogger()->log(' Logger : %s', get_class($this->getLogger()));
$this->getLogger()->log(' Runner : %s', get_class($this));
$this->getLogger()->log(' WebSocket Server : %s', get_class($webSocketServer));
$this->getLogger()->log(' Socket Server : %s', get_class($socket));
$this->getLogger()->log(' Node : %s', ltrim($webSocketServer->getConnection()->getNodeName(), '\\'));
$this->getLogger()->log(
'<fg=yellow>Listening on %s:%d</fg=yellow>',
$socket->getAddress(),
$socket->getPort()
);
$webSocketServer->on('open', xcallable($this, 'onOpen'));
$webSocketServer->on('message', xcallable($this, 'onMessage'));
$webSocketServer->on('binary-message', xcallable($this, 'onBinaryMessage'));
$webSocketServer->on('ping', xcallable($this, 'onPing'));
$webSocketServer->on('error', xcallable($this, 'onError'));
$webSocketServer->on('close', xcallable($this, 'onClose'));
$this->loadEvents();
return $webSocketServer;
} | [
"public",
"function",
"initWebSocketServer",
"(",
")",
"{",
"$",
"webSocketServer",
"=",
"$",
"this",
"->",
"getWebSocketServer",
"(",
")",
";",
"$",
"webSocketServer",
"->",
"setLogger",
"(",
"$",
"this",
"->",
"getLogger",
"(",
")",
")",
";",
"if",
"(",
"$",
"this",
"->",
"getNodeClass",
"(",
")",
"!==",
"null",
")",
"{",
"$",
"webSocketServer",
"->",
"getConnection",
"(",
")",
"->",
"setNodeName",
"(",
"$",
"this",
"->",
"getNodeClass",
"(",
")",
")",
";",
"}",
"$",
"socket",
"=",
"$",
"webSocketServer",
"->",
"getConnection",
"(",
")",
"->",
"getSocket",
"(",
")",
";",
"$",
"this",
"->",
"getLogger",
"(",
")",
"->",
"log",
"(",
"'<fg=yellow>Starting server...</fg=yellow>'",
")",
";",
"$",
"this",
"->",
"getLogger",
"(",
")",
"->",
"log",
"(",
"'Environment: <fg=green>%s</fg=green>'",
",",
"$",
"this",
"->",
"kernelEnvironment",
")",
";",
"$",
"this",
"->",
"getLogger",
"(",
")",
"->",
"log",
"(",
"'Class used:'",
")",
";",
"$",
"this",
"->",
"getLogger",
"(",
")",
"->",
"log",
"(",
"' Logger : %s'",
",",
"get_class",
"(",
"$",
"this",
"->",
"getLogger",
"(",
")",
")",
")",
";",
"$",
"this",
"->",
"getLogger",
"(",
")",
"->",
"log",
"(",
"' Runner : %s'",
",",
"get_class",
"(",
"$",
"this",
")",
")",
";",
"$",
"this",
"->",
"getLogger",
"(",
")",
"->",
"log",
"(",
"' WebSocket Server : %s'",
",",
"get_class",
"(",
"$",
"webSocketServer",
")",
")",
";",
"$",
"this",
"->",
"getLogger",
"(",
")",
"->",
"log",
"(",
"' Socket Server : %s'",
",",
"get_class",
"(",
"$",
"socket",
")",
")",
";",
"$",
"this",
"->",
"getLogger",
"(",
")",
"->",
"log",
"(",
"' Node : %s'",
",",
"ltrim",
"(",
"$",
"webSocketServer",
"->",
"getConnection",
"(",
")",
"->",
"getNodeName",
"(",
")",
",",
"'\\\\'",
")",
")",
";",
"$",
"this",
"->",
"getLogger",
"(",
")",
"->",
"log",
"(",
"'<fg=yellow>Listening on %s:%d</fg=yellow>'",
",",
"$",
"socket",
"->",
"getAddress",
"(",
")",
",",
"$",
"socket",
"->",
"getPort",
"(",
")",
")",
";",
"$",
"webSocketServer",
"->",
"on",
"(",
"'open'",
",",
"xcallable",
"(",
"$",
"this",
",",
"'onOpen'",
")",
")",
";",
"$",
"webSocketServer",
"->",
"on",
"(",
"'message'",
",",
"xcallable",
"(",
"$",
"this",
",",
"'onMessage'",
")",
")",
";",
"$",
"webSocketServer",
"->",
"on",
"(",
"'binary-message'",
",",
"xcallable",
"(",
"$",
"this",
",",
"'onBinaryMessage'",
")",
")",
";",
"$",
"webSocketServer",
"->",
"on",
"(",
"'ping'",
",",
"xcallable",
"(",
"$",
"this",
",",
"'onPing'",
")",
")",
";",
"$",
"webSocketServer",
"->",
"on",
"(",
"'error'",
",",
"xcallable",
"(",
"$",
"this",
",",
"'onError'",
")",
")",
";",
"$",
"webSocketServer",
"->",
"on",
"(",
"'close'",
",",
"xcallable",
"(",
"$",
"this",
",",
"'onClose'",
")",
")",
";",
"$",
"this",
"->",
"loadEvents",
"(",
")",
";",
"return",
"$",
"webSocketServer",
";",
"}"
] | Initialize WebSocket server
@return Hoa\Websocket\Server | [
"Initialize",
"WebSocket",
"server"
] | 5961ba1fd808bae8ab4f96f76fb7a4db90edf76f | https://github.com/Atipik/Hoa-WebSocket-Bundle/blob/5961ba1fd808bae8ab4f96f76fb7a4db90edf76f/WebSocket/Runner.php#L196-L237 |
8,249 | Atipik/Hoa-WebSocket-Bundle | WebSocket/Runner.php | Runner.launchModuleAction | public function launchModuleAction($event, Module\ModuleInterface $module, $method, Bucket $bucket, $additionnalData = null)
{
$module->setBucket($bucket);
return call_user_func(
array(
$module,
$method
),
$additionnalData
);
} | php | public function launchModuleAction($event, Module\ModuleInterface $module, $method, Bucket $bucket, $additionnalData = null)
{
$module->setBucket($bucket);
return call_user_func(
array(
$module,
$method
),
$additionnalData
);
} | [
"public",
"function",
"launchModuleAction",
"(",
"$",
"event",
",",
"Module",
"\\",
"ModuleInterface",
"$",
"module",
",",
"$",
"method",
",",
"Bucket",
"$",
"bucket",
",",
"$",
"additionnalData",
"=",
"null",
")",
"{",
"$",
"module",
"->",
"setBucket",
"(",
"$",
"bucket",
")",
";",
"return",
"call_user_func",
"(",
"array",
"(",
"$",
"module",
",",
"$",
"method",
")",
",",
"$",
"additionnalData",
")",
";",
"}"
] | Launch module action
@param string $event
@param Module\ModuleInterface $module
@param string $method
@param Bucket $bucket
@param mixed $additionnalData
@return boolean | [
"Launch",
"module",
"action"
] | 5961ba1fd808bae8ab4f96f76fb7a4db90edf76f | https://github.com/Atipik/Hoa-WebSocket-Bundle/blob/5961ba1fd808bae8ab4f96f76fb7a4db90edf76f/WebSocket/Runner.php#L250-L261 |
8,250 | Atipik/Hoa-WebSocket-Bundle | WebSocket/Runner.php | Runner.onError | public function onError(Bucket $bucket)
{
$data = $bucket->getData();
if (isset($data['exception']) && $data['exception'] instanceof Quit) {
throw $data['exception'];
}
$this->onEvent('error', $bucket);
} | php | public function onError(Bucket $bucket)
{
$data = $bucket->getData();
if (isset($data['exception']) && $data['exception'] instanceof Quit) {
throw $data['exception'];
}
$this->onEvent('error', $bucket);
} | [
"public",
"function",
"onError",
"(",
"Bucket",
"$",
"bucket",
")",
"{",
"$",
"data",
"=",
"$",
"bucket",
"->",
"getData",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"'exception'",
"]",
")",
"&&",
"$",
"data",
"[",
"'exception'",
"]",
"instanceof",
"Quit",
")",
"{",
"throw",
"$",
"data",
"[",
"'exception'",
"]",
";",
"}",
"$",
"this",
"->",
"onEvent",
"(",
"'error'",
",",
"$",
"bucket",
")",
";",
"}"
] | Fire a "error" event
@param Hoa\Event\Bucket $bucket | [
"Fire",
"a",
"error",
"event"
] | 5961ba1fd808bae8ab4f96f76fb7a4db90edf76f | https://github.com/Atipik/Hoa-WebSocket-Bundle/blob/5961ba1fd808bae8ab4f96f76fb7a4db90edf76f/WebSocket/Runner.php#L338-L347 |
8,251 | Atipik/Hoa-WebSocket-Bundle | WebSocket/Runner.php | Runner.run | public function run()
{
try {
$this->initWebSocketServer()->run();
return true;
} catch (Exception\Quit $e) {
$this->getLogger()->success(
$e->getMessage()
);
return true;
} catch (\Exception $e) {
$traces = array_reverse(explode(PHP_EOL, $e->getTraceAsString()));
foreach ($traces as $key => $trace) {
$trace = explode(' ', $trace, 2);
$traces[$key] = sprintf(
'#%s > %s',
str_pad($key + 1, strlen(count($traces)), '0', STR_PAD_LEFT),
$trace[1]
);
}
$this->getLogger()->error(
"%s: %s\n%s",
get_class($e),
$e->getMessage(),
implode("\n", $traces)
);
return false;
}
} | php | public function run()
{
try {
$this->initWebSocketServer()->run();
return true;
} catch (Exception\Quit $e) {
$this->getLogger()->success(
$e->getMessage()
);
return true;
} catch (\Exception $e) {
$traces = array_reverse(explode(PHP_EOL, $e->getTraceAsString()));
foreach ($traces as $key => $trace) {
$trace = explode(' ', $trace, 2);
$traces[$key] = sprintf(
'#%s > %s',
str_pad($key + 1, strlen(count($traces)), '0', STR_PAD_LEFT),
$trace[1]
);
}
$this->getLogger()->error(
"%s: %s\n%s",
get_class($e),
$e->getMessage(),
implode("\n", $traces)
);
return false;
}
} | [
"public",
"function",
"run",
"(",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"initWebSocketServer",
"(",
")",
"->",
"run",
"(",
")",
";",
"return",
"true",
";",
"}",
"catch",
"(",
"Exception",
"\\",
"Quit",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"getLogger",
"(",
")",
"->",
"success",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"return",
"true",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"$",
"traces",
"=",
"array_reverse",
"(",
"explode",
"(",
"PHP_EOL",
",",
"$",
"e",
"->",
"getTraceAsString",
"(",
")",
")",
")",
";",
"foreach",
"(",
"$",
"traces",
"as",
"$",
"key",
"=>",
"$",
"trace",
")",
"{",
"$",
"trace",
"=",
"explode",
"(",
"' '",
",",
"$",
"trace",
",",
"2",
")",
";",
"$",
"traces",
"[",
"$",
"key",
"]",
"=",
"sprintf",
"(",
"'#%s > %s'",
",",
"str_pad",
"(",
"$",
"key",
"+",
"1",
",",
"strlen",
"(",
"count",
"(",
"$",
"traces",
")",
")",
",",
"'0'",
",",
"STR_PAD_LEFT",
")",
",",
"$",
"trace",
"[",
"1",
"]",
")",
";",
"}",
"$",
"this",
"->",
"getLogger",
"(",
")",
"->",
"error",
"(",
"\"%s: %s\\n%s\"",
",",
"get_class",
"(",
"$",
"e",
")",
",",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"implode",
"(",
"\"\\n\"",
",",
"$",
"traces",
")",
")",
";",
"return",
"false",
";",
"}",
"}"
] | Run this server
@return boolean | [
"Run",
"this",
"server"
] | 5961ba1fd808bae8ab4f96f76fb7a4db90edf76f | https://github.com/Atipik/Hoa-WebSocket-Bundle/blob/5961ba1fd808bae8ab4f96f76fb7a4db90edf76f/WebSocket/Runner.php#L422-L456 |
8,252 | phn-io/compilation | src/Phn/Compilation/Compiler.php | Compiler.write | public function write($content = '')
{
$content = preg_split('/\R/', $content);
foreach ($content as $line) {
$this->source .= PHP_EOL.str_repeat(' ', $this->depth).$line;
}
return $this;
} | php | public function write($content = '')
{
$content = preg_split('/\R/', $content);
foreach ($content as $line) {
$this->source .= PHP_EOL.str_repeat(' ', $this->depth).$line;
}
return $this;
} | [
"public",
"function",
"write",
"(",
"$",
"content",
"=",
"''",
")",
"{",
"$",
"content",
"=",
"preg_split",
"(",
"'/\\R/'",
",",
"$",
"content",
")",
";",
"foreach",
"(",
"$",
"content",
"as",
"$",
"line",
")",
"{",
"$",
"this",
"->",
"source",
".=",
"PHP_EOL",
".",
"str_repeat",
"(",
"' '",
",",
"$",
"this",
"->",
"depth",
")",
".",
"$",
"line",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Write a new line of code. The new line is added before the content. A block of code can also be wrote in one
shot.
The following code:
$block = <<<PHP
echo " ";
echo "World";
PHP;
$compiler
->write('echo "Hello";')
->write($block)
;
Compiles into:
<?php
echo "Hello";
echo " ";
echo "World";
@param string $content The code to write.
@return $this The current compiler. | [
"Write",
"a",
"new",
"line",
"of",
"code",
".",
"The",
"new",
"line",
"is",
"added",
"before",
"the",
"content",
".",
"A",
"block",
"of",
"code",
"can",
"also",
"be",
"wrote",
"in",
"one",
"shot",
"."
] | 202e1816cc0039c08ad7ab3eb914e91e51d77320 | https://github.com/phn-io/compilation/blob/202e1816cc0039c08ad7ab3eb914e91e51d77320/src/Phn/Compilation/Compiler.php#L109-L118 |
8,253 | phn-io/compilation | src/Phn/Compilation/Compiler.php | Compiler.string | public function string($string, $singleLine = false)
{
$string = sprintf('"%s"', addcslashes($string, "\0\t\"\$\\"));
if ($singleLine === true) {
$string = preg_replace('/\n/', '\n', $string);
}
$this->source .= $string;
return $this;
} | php | public function string($string, $singleLine = false)
{
$string = sprintf('"%s"', addcslashes($string, "\0\t\"\$\\"));
if ($singleLine === true) {
$string = preg_replace('/\n/', '\n', $string);
}
$this->source .= $string;
return $this;
} | [
"public",
"function",
"string",
"(",
"$",
"string",
",",
"$",
"singleLine",
"=",
"false",
")",
"{",
"$",
"string",
"=",
"sprintf",
"(",
"'\"%s\"'",
",",
"addcslashes",
"(",
"$",
"string",
",",
"\"\\0\\t\\\"\\$\\\\\"",
")",
")",
";",
"if",
"(",
"$",
"singleLine",
"===",
"true",
")",
"{",
"$",
"string",
"=",
"preg_replace",
"(",
"'/\\n/'",
",",
"'\\n'",
",",
"$",
"string",
")",
";",
"}",
"$",
"this",
"->",
"source",
".=",
"$",
"string",
";",
"return",
"$",
"this",
";",
"}"
] | Adds a string to the source code.
The following code:
$compiler
->nl()->string('Hello world')->raw(';')
;
Compiles into:
<?php
"Hello World";
@param string $string The string to add.
@param bool $singleLine Specifies if the given string should be represented inline or not. false per default.
@return $this The current compiler. | [
"Adds",
"a",
"string",
"to",
"the",
"source",
"code",
"."
] | 202e1816cc0039c08ad7ab3eb914e91e51d77320 | https://github.com/phn-io/compilation/blob/202e1816cc0039c08ad7ab3eb914e91e51d77320/src/Phn/Compilation/Compiler.php#L245-L256 |
8,254 | cityware/city-wmi | src/Models/Variants/HardDisk.php | HardDisk.checkDisk | public function checkDisk($fixErrors = false, $vigorousIndexCheck = true, $skipFolderCycle = true, $forceDismount = false, $recoverBadSectors = false, $runAtBootup = false)
{
$result = $this->variant->chkdsk($fixErrors, $vigorousIndexCheck, $skipFolderCycle, $forceDismount, $recoverBadSectors, $runAtBootup);
switch($result) {
case 0:
return true;
case 1:
return true;
}
return false;
} | php | public function checkDisk($fixErrors = false, $vigorousIndexCheck = true, $skipFolderCycle = true, $forceDismount = false, $recoverBadSectors = false, $runAtBootup = false)
{
$result = $this->variant->chkdsk($fixErrors, $vigorousIndexCheck, $skipFolderCycle, $forceDismount, $recoverBadSectors, $runAtBootup);
switch($result) {
case 0:
return true;
case 1:
return true;
}
return false;
} | [
"public",
"function",
"checkDisk",
"(",
"$",
"fixErrors",
"=",
"false",
",",
"$",
"vigorousIndexCheck",
"=",
"true",
",",
"$",
"skipFolderCycle",
"=",
"true",
",",
"$",
"forceDismount",
"=",
"false",
",",
"$",
"recoverBadSectors",
"=",
"false",
",",
"$",
"runAtBootup",
"=",
"false",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"variant",
"->",
"chkdsk",
"(",
"$",
"fixErrors",
",",
"$",
"vigorousIndexCheck",
",",
"$",
"skipFolderCycle",
",",
"$",
"forceDismount",
",",
"$",
"recoverBadSectors",
",",
"$",
"runAtBootup",
")",
";",
"switch",
"(",
"$",
"result",
")",
"{",
"case",
"0",
":",
"return",
"true",
";",
"case",
"1",
":",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Invokes the Chkdsk operation on the current volume.
@param bool|false $fixErrors If true, errors found on the disk are fixed. The default is false.
@param bool|true $vigorousIndexCheck If true, a vigorous check of index entries is performed. The default is true.
@param bool|true $skipFolderCycle If true, the folder cycle checking should be skipped. The default is true.
@param bool|false $forceDismount If true, the volume is dismounted before checking. The default is false.
@param bool|false $recoverBadSectors If true, the bad sectors are located and the readable information is recovered. The default is false.
@param bool|false $runAtBootup If true, the Chkdsk operation is performed at the next boot up. The default is false.
@return bool | [
"Invokes",
"the",
"Chkdsk",
"operation",
"on",
"the",
"current",
"volume",
"."
] | c7296e6855b6719f537ff5c2dc19d521ce1415d8 | https://github.com/cityware/city-wmi/blob/c7296e6855b6719f537ff5c2dc19d521ce1415d8/src/Models/Variants/HardDisk.php#L228-L240 |
8,255 | vworldat/SimpleContentBundle | Twig/Extension/SimpleContentExtension.php | SimpleContentExtension.contentBlockFilter | public function contentBlockFilter($defaultContent, $name, $type = 'line', $locale = null, $useLocaleFallback = null)
{
$block = $this->contentService->getOrCreateContentBlock($name, $locale, $useLocaleFallback, $type, $defaultContent);
if (null === $locale || (null !== $this->translator && $this->translator->getLocale() == $locale))
{
return $this->renderContent($block);
}
return '';
} | php | public function contentBlockFilter($defaultContent, $name, $type = 'line', $locale = null, $useLocaleFallback = null)
{
$block = $this->contentService->getOrCreateContentBlock($name, $locale, $useLocaleFallback, $type, $defaultContent);
if (null === $locale || (null !== $this->translator && $this->translator->getLocale() == $locale))
{
return $this->renderContent($block);
}
return '';
} | [
"public",
"function",
"contentBlockFilter",
"(",
"$",
"defaultContent",
",",
"$",
"name",
",",
"$",
"type",
"=",
"'line'",
",",
"$",
"locale",
"=",
"null",
",",
"$",
"useLocaleFallback",
"=",
"null",
")",
"{",
"$",
"block",
"=",
"$",
"this",
"->",
"contentService",
"->",
"getOrCreateContentBlock",
"(",
"$",
"name",
",",
"$",
"locale",
",",
"$",
"useLocaleFallback",
",",
"$",
"type",
",",
"$",
"defaultContent",
")",
";",
"if",
"(",
"null",
"===",
"$",
"locale",
"||",
"(",
"null",
"!==",
"$",
"this",
"->",
"translator",
"&&",
"$",
"this",
"->",
"translator",
"->",
"getLocale",
"(",
")",
"==",
"$",
"locale",
")",
")",
"{",
"return",
"$",
"this",
"->",
"renderContent",
"(",
"$",
"block",
")",
";",
"}",
"return",
"''",
";",
"}"
] | Fetch content block with the given default content and name.
This allows to wrap existing content with a filter block.
If a locale different from the current locale is given, the block is fetched/created,
but not displayed.
Implemented / allowed types so far:
* line Single line, escaped (default)
* text Multiline, escaped
* markdown Markdown, not escaped
* html HTML, not escaped
@throws \InvalidArgumentException If given type is unknown
@param string $defaultContent Default content to assign if block has to be created
@param string $name Block name
@param string $type Block type (defaults to 'line')
@param string $locale Specific locale to use instead of current locale
@param string $useLocaleFallback Override global use_locale_fallback setting
@return string | [
"Fetch",
"content",
"block",
"with",
"the",
"given",
"default",
"content",
"and",
"name",
".",
"This",
"allows",
"to",
"wrap",
"existing",
"content",
"with",
"a",
"filter",
"block",
"."
] | cca691609c9e7850969f27dac524865342042c68 | https://github.com/vworldat/SimpleContentBundle/blob/cca691609c9e7850969f27dac524865342042c68/Twig/Extension/SimpleContentExtension.php#L98-L108 |
8,256 | vworldat/SimpleContentBundle | Twig/Extension/SimpleContentExtension.php | SimpleContentExtension.renderContent | protected function renderContent(ContentBlock $block)
{
$content = $block->getContent();
switch ($block->getType())
{
case 'line':
$content = htmlspecialchars($content);
break;
case 'text':
$content = htmlspecialchars($content);
$content = str_replace("\n", '<br>', $content);
break;
case 'markdown':
$content = $this->markdownHelper->transform($content);
break;
case 'html':
break;
default:
throw new \InvalidArgumentException('Unknown content block type: ' . $block->getType());
}
return $content;
} | php | protected function renderContent(ContentBlock $block)
{
$content = $block->getContent();
switch ($block->getType())
{
case 'line':
$content = htmlspecialchars($content);
break;
case 'text':
$content = htmlspecialchars($content);
$content = str_replace("\n", '<br>', $content);
break;
case 'markdown':
$content = $this->markdownHelper->transform($content);
break;
case 'html':
break;
default:
throw new \InvalidArgumentException('Unknown content block type: ' . $block->getType());
}
return $content;
} | [
"protected",
"function",
"renderContent",
"(",
"ContentBlock",
"$",
"block",
")",
"{",
"$",
"content",
"=",
"$",
"block",
"->",
"getContent",
"(",
")",
";",
"switch",
"(",
"$",
"block",
"->",
"getType",
"(",
")",
")",
"{",
"case",
"'line'",
":",
"$",
"content",
"=",
"htmlspecialchars",
"(",
"$",
"content",
")",
";",
"break",
";",
"case",
"'text'",
":",
"$",
"content",
"=",
"htmlspecialchars",
"(",
"$",
"content",
")",
";",
"$",
"content",
"=",
"str_replace",
"(",
"\"\\n\"",
",",
"'<br>'",
",",
"$",
"content",
")",
";",
"break",
";",
"case",
"'markdown'",
":",
"$",
"content",
"=",
"$",
"this",
"->",
"markdownHelper",
"->",
"transform",
"(",
"$",
"content",
")",
";",
"break",
";",
"case",
"'html'",
":",
"break",
";",
"default",
":",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Unknown content block type: '",
".",
"$",
"block",
"->",
"getType",
"(",
")",
")",
";",
"}",
"return",
"$",
"content",
";",
"}"
] | Render the given ContentBlock, HTML-escaping the content where necessary.
@throws \InvalidArgumentException If given type is unknown
@param ContentBlock $block
@return string | [
"Render",
"the",
"given",
"ContentBlock",
"HTML",
"-",
"escaping",
"the",
"content",
"where",
"necessary",
"."
] | cca691609c9e7850969f27dac524865342042c68 | https://github.com/vworldat/SimpleContentBundle/blob/cca691609c9e7850969f27dac524865342042c68/Twig/Extension/SimpleContentExtension.php#L119-L146 |
8,257 | vworldat/SimpleContentBundle | Twig/Extension/SimpleContentExtension.php | SimpleContentExtension.contentBlockFilterLine | public function contentBlockFilterLine($defaultContent, $name, $locale = null, $useLocaleFallback = null)
{
return $this->contentBlockFilter($defaultContent, $name, 'line', $locale, $useLocaleFallback);
} | php | public function contentBlockFilterLine($defaultContent, $name, $locale = null, $useLocaleFallback = null)
{
return $this->contentBlockFilter($defaultContent, $name, 'line', $locale, $useLocaleFallback);
} | [
"public",
"function",
"contentBlockFilterLine",
"(",
"$",
"defaultContent",
",",
"$",
"name",
",",
"$",
"locale",
"=",
"null",
",",
"$",
"useLocaleFallback",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"contentBlockFilter",
"(",
"$",
"defaultContent",
",",
"$",
"name",
",",
"'line'",
",",
"$",
"locale",
",",
"$",
"useLocaleFallback",
")",
";",
"}"
] | Shortcut to contentBlockFilter using "line" rendering.
@param string $defaultContent Default content to assign if block has to be created
@param string $name Block name
@param string $locale Specific locale to use instead of current locale
@param string $useLocaleFallback Override global use_locale_fallback setting
@return string | [
"Shortcut",
"to",
"contentBlockFilter",
"using",
"line",
"rendering",
"."
] | cca691609c9e7850969f27dac524865342042c68 | https://github.com/vworldat/SimpleContentBundle/blob/cca691609c9e7850969f27dac524865342042c68/Twig/Extension/SimpleContentExtension.php#L158-L161 |
8,258 | vworldat/SimpleContentBundle | Twig/Extension/SimpleContentExtension.php | SimpleContentExtension.contentBlockFilterText | public function contentBlockFilterText($defaultContent, $name, $locale = null, $useLocaleFallback = null)
{
return $this->contentBlockFilter($defaultContent, $name, 'text', $locale, $useLocaleFallback);
} | php | public function contentBlockFilterText($defaultContent, $name, $locale = null, $useLocaleFallback = null)
{
return $this->contentBlockFilter($defaultContent, $name, 'text', $locale, $useLocaleFallback);
} | [
"public",
"function",
"contentBlockFilterText",
"(",
"$",
"defaultContent",
",",
"$",
"name",
",",
"$",
"locale",
"=",
"null",
",",
"$",
"useLocaleFallback",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"contentBlockFilter",
"(",
"$",
"defaultContent",
",",
"$",
"name",
",",
"'text'",
",",
"$",
"locale",
",",
"$",
"useLocaleFallback",
")",
";",
"}"
] | Shortcut to contentBlockFilter using "text" rendering.
@param string $defaultContent Default content to assign if block has to be created
@param string $name Block name
@param string $locale Specific locale to use instead of current locale
@param string $useLocaleFallback Override global use_locale_fallback setting
@return string | [
"Shortcut",
"to",
"contentBlockFilter",
"using",
"text",
"rendering",
"."
] | cca691609c9e7850969f27dac524865342042c68 | https://github.com/vworldat/SimpleContentBundle/blob/cca691609c9e7850969f27dac524865342042c68/Twig/Extension/SimpleContentExtension.php#L173-L176 |
8,259 | vworldat/SimpleContentBundle | Twig/Extension/SimpleContentExtension.php | SimpleContentExtension.contentBlockFilterMarkdown | public function contentBlockFilterMarkdown($defaultContent, $name, $locale = null, $useLocaleFallback = null)
{
return $this->contentBlockFilter($defaultContent, $name, 'markdown', $locale, $useLocaleFallback);
} | php | public function contentBlockFilterMarkdown($defaultContent, $name, $locale = null, $useLocaleFallback = null)
{
return $this->contentBlockFilter($defaultContent, $name, 'markdown', $locale, $useLocaleFallback);
} | [
"public",
"function",
"contentBlockFilterMarkdown",
"(",
"$",
"defaultContent",
",",
"$",
"name",
",",
"$",
"locale",
"=",
"null",
",",
"$",
"useLocaleFallback",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"contentBlockFilter",
"(",
"$",
"defaultContent",
",",
"$",
"name",
",",
"'markdown'",
",",
"$",
"locale",
",",
"$",
"useLocaleFallback",
")",
";",
"}"
] | Shortcut to contentBlockFilter using "markdown" rendering.
@param string $defaultContent Default content to assign if block has to be created
@param string $name Block name
@param string $locale Specific locale to use instead of current locale
@param string $useLocaleFallback Override global use_locale_fallback setting
@return string | [
"Shortcut",
"to",
"contentBlockFilter",
"using",
"markdown",
"rendering",
"."
] | cca691609c9e7850969f27dac524865342042c68 | https://github.com/vworldat/SimpleContentBundle/blob/cca691609c9e7850969f27dac524865342042c68/Twig/Extension/SimpleContentExtension.php#L188-L191 |
8,260 | vworldat/SimpleContentBundle | Twig/Extension/SimpleContentExtension.php | SimpleContentExtension.contentBlockFilterHtml | public function contentBlockFilterHtml($defaultContent, $name, $locale = null, $useLocaleFallback = null)
{
return $this->contentBlockFilter($defaultContent, $name, 'html', $locale, $useLocaleFallback);
} | php | public function contentBlockFilterHtml($defaultContent, $name, $locale = null, $useLocaleFallback = null)
{
return $this->contentBlockFilter($defaultContent, $name, 'html', $locale, $useLocaleFallback);
} | [
"public",
"function",
"contentBlockFilterHtml",
"(",
"$",
"defaultContent",
",",
"$",
"name",
",",
"$",
"locale",
"=",
"null",
",",
"$",
"useLocaleFallback",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"contentBlockFilter",
"(",
"$",
"defaultContent",
",",
"$",
"name",
",",
"'html'",
",",
"$",
"locale",
",",
"$",
"useLocaleFallback",
")",
";",
"}"
] | Shortcut to contentBlockFilter using "html" rendering.
@param string $defaultContent Default content to assign if block has to be created
@param string $name Block name
@param string $locale Specific locale to use instead of current locale
@param string $useLocaleFallback Override global use_locale_fallback setting
@return string | [
"Shortcut",
"to",
"contentBlockFilter",
"using",
"html",
"rendering",
"."
] | cca691609c9e7850969f27dac524865342042c68 | https://github.com/vworldat/SimpleContentBundle/blob/cca691609c9e7850969f27dac524865342042c68/Twig/Extension/SimpleContentExtension.php#L203-L206 |
8,261 | sebardo/ecommerce | EcommerceBundle/Entity/Repository/InvoiceRepository.php | InvoiceRepository.getNextNumber | public function getNextNumber()
{
if (0 === (int) $this->countTotal()) {
return 1;
}
$qb = $this->getQueryBuilder()
->select('MAX(i.invoiceNumber) + 1');
return $qb->getQuery()
->getSingleScalarResult();
} | php | public function getNextNumber()
{
if (0 === (int) $this->countTotal()) {
return 1;
}
$qb = $this->getQueryBuilder()
->select('MAX(i.invoiceNumber) + 1');
return $qb->getQuery()
->getSingleScalarResult();
} | [
"public",
"function",
"getNextNumber",
"(",
")",
"{",
"if",
"(",
"0",
"===",
"(",
"int",
")",
"$",
"this",
"->",
"countTotal",
"(",
")",
")",
"{",
"return",
"1",
";",
"}",
"$",
"qb",
"=",
"$",
"this",
"->",
"getQueryBuilder",
"(",
")",
"->",
"select",
"(",
"'MAX(i.invoiceNumber) + 1'",
")",
";",
"return",
"$",
"qb",
"->",
"getQuery",
"(",
")",
"->",
"getSingleScalarResult",
"(",
")",
";",
"}"
] | Get next invoice number
@return int | [
"Get",
"next",
"invoice",
"number"
] | 3e17545e69993f10a1df17f9887810c7378fc7f9 | https://github.com/sebardo/ecommerce/blob/3e17545e69993f10a1df17f9887810c7378fc7f9/EcommerceBundle/Entity/Repository/InvoiceRepository.php#L82-L93 |
8,262 | bruery/platform-core | src/bundles/BlockBundle/Controller/BlockController.php | BlockController.renderAction | public function renderAction(Request $request)
{
//TODO: render initial block via ajax
$blockType = $request->get('blockType', null);
$action = $request->get('action', null);
// merge all parameters
$params = array_merge($request->request->all(), $request->query->all());
// load block service
$block = $this->getBlockServiceManager()->getService($blockType);
if (!$block) {
throw $this->createNotFoundException(sprintf('Cannot find block service "%s"', $blockType));
}
if(!$block instanceof AbstractAdminBlockService) {
throw new \Exception('Block should be an instance of AbstractAdminBlockService');
}
$params['block'] = $block;
$methodName = sprintf("%sAction", $action);
if (!is_callable(array($block, $methodName), false)) {
throw $this->createNotFoundException(sprintf('Cannot find method "%s" in block service "%s"', $methodName, $blockType));
}
return call_user_func_array(array($block, $methodName), array($request, $params));
} | php | public function renderAction(Request $request)
{
//TODO: render initial block via ajax
$blockType = $request->get('blockType', null);
$action = $request->get('action', null);
// merge all parameters
$params = array_merge($request->request->all(), $request->query->all());
// load block service
$block = $this->getBlockServiceManager()->getService($blockType);
if (!$block) {
throw $this->createNotFoundException(sprintf('Cannot find block service "%s"', $blockType));
}
if(!$block instanceof AbstractAdminBlockService) {
throw new \Exception('Block should be an instance of AbstractAdminBlockService');
}
$params['block'] = $block;
$methodName = sprintf("%sAction", $action);
if (!is_callable(array($block, $methodName), false)) {
throw $this->createNotFoundException(sprintf('Cannot find method "%s" in block service "%s"', $methodName, $blockType));
}
return call_user_func_array(array($block, $methodName), array($request, $params));
} | [
"public",
"function",
"renderAction",
"(",
"Request",
"$",
"request",
")",
"{",
"//TODO: render initial block via ajax",
"$",
"blockType",
"=",
"$",
"request",
"->",
"get",
"(",
"'blockType'",
",",
"null",
")",
";",
"$",
"action",
"=",
"$",
"request",
"->",
"get",
"(",
"'action'",
",",
"null",
")",
";",
"// merge all parameters",
"$",
"params",
"=",
"array_merge",
"(",
"$",
"request",
"->",
"request",
"->",
"all",
"(",
")",
",",
"$",
"request",
"->",
"query",
"->",
"all",
"(",
")",
")",
";",
"// load block service",
"$",
"block",
"=",
"$",
"this",
"->",
"getBlockServiceManager",
"(",
")",
"->",
"getService",
"(",
"$",
"blockType",
")",
";",
"if",
"(",
"!",
"$",
"block",
")",
"{",
"throw",
"$",
"this",
"->",
"createNotFoundException",
"(",
"sprintf",
"(",
"'Cannot find block service \"%s\"'",
",",
"$",
"blockType",
")",
")",
";",
"}",
"if",
"(",
"!",
"$",
"block",
"instanceof",
"AbstractAdminBlockService",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Block should be an instance of AbstractAdminBlockService'",
")",
";",
"}",
"$",
"params",
"[",
"'block'",
"]",
"=",
"$",
"block",
";",
"$",
"methodName",
"=",
"sprintf",
"(",
"\"%sAction\"",
",",
"$",
"action",
")",
";",
"if",
"(",
"!",
"is_callable",
"(",
"array",
"(",
"$",
"block",
",",
"$",
"methodName",
")",
",",
"false",
")",
")",
"{",
"throw",
"$",
"this",
"->",
"createNotFoundException",
"(",
"sprintf",
"(",
"'Cannot find method \"%s\" in block service \"%s\"'",
",",
"$",
"methodName",
",",
"$",
"blockType",
")",
")",
";",
"}",
"return",
"call_user_func_array",
"(",
"array",
"(",
"$",
"block",
",",
"$",
"methodName",
")",
",",
"array",
"(",
"$",
"request",
",",
"$",
"params",
")",
")",
";",
"}"
] | Default render action
@param Request $request
@return mixed
@throws \Exception | [
"Default",
"render",
"action"
] | 46153c181b2d852763afa30f7378bcbc1b2f4ef3 | https://github.com/bruery/platform-core/blob/46153c181b2d852763afa30f7378bcbc1b2f4ef3/src/bundles/BlockBundle/Controller/BlockController.php#L30-L59 |
8,263 | jeromeklam/freefw | src/FreeFW/JsonApi/V1/Decoder.php | Decoder.decode | public function decode(
\FreeFW\JsonApi\V1\Model\Document $p_document
) : \FreeFW\Core\Model {
if ($p_document->isSimpleResource()) {
$resource = $p_document->getData();
$cls = $resource->getType();
$class = str_replace('_', '::Model::', $cls);
/**
* @var \FreeFW\Core\Model $obj
*/
$obj = \FreeFW\DI\DI::get($class);
$attr = $resource->getAttributes();
$obj->initWithJson($attr->__toArray());
return $obj;
}
die('decoder');
return null;
} | php | public function decode(
\FreeFW\JsonApi\V1\Model\Document $p_document
) : \FreeFW\Core\Model {
if ($p_document->isSimpleResource()) {
$resource = $p_document->getData();
$cls = $resource->getType();
$class = str_replace('_', '::Model::', $cls);
/**
* @var \FreeFW\Core\Model $obj
*/
$obj = \FreeFW\DI\DI::get($class);
$attr = $resource->getAttributes();
$obj->initWithJson($attr->__toArray());
return $obj;
}
die('decoder');
return null;
} | [
"public",
"function",
"decode",
"(",
"\\",
"FreeFW",
"\\",
"JsonApi",
"\\",
"V1",
"\\",
"Model",
"\\",
"Document",
"$",
"p_document",
")",
":",
"\\",
"FreeFW",
"\\",
"Core",
"\\",
"Model",
"{",
"if",
"(",
"$",
"p_document",
"->",
"isSimpleResource",
"(",
")",
")",
"{",
"$",
"resource",
"=",
"$",
"p_document",
"->",
"getData",
"(",
")",
";",
"$",
"cls",
"=",
"$",
"resource",
"->",
"getType",
"(",
")",
";",
"$",
"class",
"=",
"str_replace",
"(",
"'_'",
",",
"'::Model::'",
",",
"$",
"cls",
")",
";",
"/**\n * @var \\FreeFW\\Core\\Model $obj\n */",
"$",
"obj",
"=",
"\\",
"FreeFW",
"\\",
"DI",
"\\",
"DI",
"::",
"get",
"(",
"$",
"class",
")",
";",
"$",
"attr",
"=",
"$",
"resource",
"->",
"getAttributes",
"(",
")",
";",
"$",
"obj",
"->",
"initWithJson",
"(",
"$",
"attr",
"->",
"__toArray",
"(",
")",
")",
";",
"return",
"$",
"obj",
";",
"}",
"die",
"(",
"'decoder'",
")",
";",
"return",
"null",
";",
"}"
] | Decode a ApiResponseInterface
@param \FreeFW\JsonApi\V1\Model\Document $p_document
@return \FreeFW\Core\Model | [
"Decode",
"a",
"ApiResponseInterface"
] | 16ecf24192375c920a070296f396b9d3fd994a1e | https://github.com/jeromeklam/freefw/blob/16ecf24192375c920a070296f396b9d3fd994a1e/src/FreeFW/JsonApi/V1/Decoder.php#L19-L36 |
8,264 | jagilpe/entity-list-bundle | EntityList/EntityList.php | EntityList.getFields | public function getFields()
{
$fields = array();
foreach ($this->columns as $column) {
$fields = array_merge($fields, $column->getFields());
}
return $fields;
} | php | public function getFields()
{
$fields = array();
foreach ($this->columns as $column) {
$fields = array_merge($fields, $column->getFields());
}
return $fields;
} | [
"public",
"function",
"getFields",
"(",
")",
"{",
"$",
"fields",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"columns",
"as",
"$",
"column",
")",
"{",
"$",
"fields",
"=",
"array_merge",
"(",
"$",
"fields",
",",
"$",
"column",
"->",
"getFields",
"(",
")",
")",
";",
"}",
"return",
"$",
"fields",
";",
"}"
] | Returns the fields used in the different cells of the list
@return string[] | [
"Returns",
"the",
"fields",
"used",
"in",
"the",
"different",
"cells",
"of",
"the",
"list"
] | 54331a4de7e7916894fb4a7a3156d8e7c1b0e0dc | https://github.com/jagilpe/entity-list-bundle/blob/54331a4de7e7916894fb4a7a3156d8e7c1b0e0dc/EntityList/EntityList.php#L94-L102 |
8,265 | OWeb/OWeb-Framework | OWeb/manage/SubViews.php | SubViews.getSubView | public function getSubView($name){
if(isset($this->subViews[$name]))
return $this->subViews[$name];
else
return $this->getNewSubView($name);
} | php | public function getSubView($name){
if(isset($this->subViews[$name]))
return $this->subViews[$name];
else
return $this->getNewSubView($name);
} | [
"public",
"function",
"getSubView",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"subViews",
"[",
"$",
"name",
"]",
")",
")",
"return",
"$",
"this",
"->",
"subViews",
"[",
"$",
"name",
"]",
";",
"else",
"return",
"$",
"this",
"->",
"getNewSubView",
"(",
"$",
"name",
")",
";",
"}"
] | Will return an instance of the Controller required as a subview.
!! A controller can also be initiated throught manually with new <name> but
it might then need manual initialisation
!! since OWeb 0.3.2 this will generate only Singletons.
To get a new instance every time you may create the controller yourself
or use getNewSubView
@param type $name Name of the controller you want to use as a sub view.
@return \Controller The controller that was asked.
@throws \OWeb\manage\exceptions\Controller | [
"Will",
"return",
"an",
"instance",
"of",
"the",
"Controller",
"required",
"as",
"a",
"subview",
"."
] | fb441f51afb16860b0c946a55c36c789fbb125fa | https://github.com/OWeb/OWeb-Framework/blob/fb441f51afb16860b0c946a55c36c789fbb125fa/OWeb/manage/SubViews.php#L58-L63 |
8,266 | OWeb/OWeb-Framework | OWeb/manage/SubViews.php | SubViews.getNewSubView | public function getNewSubView($name){
try{
$controller = new $name();
if(! ($controller instanceof \OWeb\types\Controller))
throw new \OWeb\manage\exceptions\Controller("The class \"".$name."\" isn't an instance of \OWeb\Types\Controller");
if(!isset($this->subViews[$name]))
$this->subViews[$name] = $controller;
\OWeb\manage\Events::getInstance()->sendEvent('loaded@OWeb\manage\SubViews',$controller);
$controller->init();
return $controller;
}catch(\Exception $ex){
throw new \OWeb\manage\exceptions\Controller("The SubView : \"".$name."\"couldn't be loaded due to Errors",0,$ex);
}
} | php | public function getNewSubView($name){
try{
$controller = new $name();
if(! ($controller instanceof \OWeb\types\Controller))
throw new \OWeb\manage\exceptions\Controller("The class \"".$name."\" isn't an instance of \OWeb\Types\Controller");
if(!isset($this->subViews[$name]))
$this->subViews[$name] = $controller;
\OWeb\manage\Events::getInstance()->sendEvent('loaded@OWeb\manage\SubViews',$controller);
$controller->init();
return $controller;
}catch(\Exception $ex){
throw new \OWeb\manage\exceptions\Controller("The SubView : \"".$name."\"couldn't be loaded due to Errors",0,$ex);
}
} | [
"public",
"function",
"getNewSubView",
"(",
"$",
"name",
")",
"{",
"try",
"{",
"$",
"controller",
"=",
"new",
"$",
"name",
"(",
")",
";",
"if",
"(",
"!",
"(",
"$",
"controller",
"instanceof",
"\\",
"OWeb",
"\\",
"types",
"\\",
"Controller",
")",
")",
"throw",
"new",
"\\",
"OWeb",
"\\",
"manage",
"\\",
"exceptions",
"\\",
"Controller",
"(",
"\"The class \\\"\"",
".",
"$",
"name",
".",
"\"\\\" isn't an instance of \\OWeb\\Types\\Controller\"",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"subViews",
"[",
"$",
"name",
"]",
")",
")",
"$",
"this",
"->",
"subViews",
"[",
"$",
"name",
"]",
"=",
"$",
"controller",
";",
"\\",
"OWeb",
"\\",
"manage",
"\\",
"Events",
"::",
"getInstance",
"(",
")",
"->",
"sendEvent",
"(",
"'loaded@OWeb\\manage\\SubViews'",
",",
"$",
"controller",
")",
";",
"$",
"controller",
"->",
"init",
"(",
")",
";",
"return",
"$",
"controller",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"ex",
")",
"{",
"throw",
"new",
"\\",
"OWeb",
"\\",
"manage",
"\\",
"exceptions",
"\\",
"Controller",
"(",
"\"The SubView : \\\"\"",
".",
"$",
"name",
".",
"\"\\\"couldn't be loaded due to Errors\"",
",",
"0",
",",
"$",
"ex",
")",
";",
"}",
"}"
] | Will return a new instance of the Controller required as a subview. After
having initialized it.
!! A controller can also be initiated throught manually with new <name> but
it might then need manual initialisation
@param type $name Name of the controller you want to use as a sub view.
@return \Controller The controller that was asked.
@throws \OWeb\manage\exceptions\Controller | [
"Will",
"return",
"a",
"new",
"instance",
"of",
"the",
"Controller",
"required",
"as",
"a",
"subview",
".",
"After",
"having",
"initialized",
"it",
"."
] | fb441f51afb16860b0c946a55c36c789fbb125fa | https://github.com/OWeb/OWeb-Framework/blob/fb441f51afb16860b0c946a55c36c789fbb125fa/OWeb/manage/SubViews.php#L76-L93 |
8,267 | tenside/core | src/Util/HomePathDeterminator.php | HomePathDeterminator.detectHomeDirectory | private function detectHomeDirectory()
{
// Environment variable COMPOSER points to the composer.json we should use.
if (false !== ($home = getenv('COMPOSER'))) {
return dirname($home);
}
if ('' !== \Phar::running()) {
// Strip scheme "phar://" prefix and "tenside.phar" suffix.
$home = dirname(substr(\Phar::running(), 7));
} else {
$home = getcwd();
}
if ((PHP_SAPI !== 'cli') && (substr($home, -4) !== DIRECTORY_SEPARATOR . 'web')) {
throw new \RuntimeException(
'Tenside is intended to be run from within the web directory but it appears you are running it from ' .
basename($home)
);
}
return dirname($home);
} | php | private function detectHomeDirectory()
{
// Environment variable COMPOSER points to the composer.json we should use.
if (false !== ($home = getenv('COMPOSER'))) {
return dirname($home);
}
if ('' !== \Phar::running()) {
// Strip scheme "phar://" prefix and "tenside.phar" suffix.
$home = dirname(substr(\Phar::running(), 7));
} else {
$home = getcwd();
}
if ((PHP_SAPI !== 'cli') && (substr($home, -4) !== DIRECTORY_SEPARATOR . 'web')) {
throw new \RuntimeException(
'Tenside is intended to be run from within the web directory but it appears you are running it from ' .
basename($home)
);
}
return dirname($home);
} | [
"private",
"function",
"detectHomeDirectory",
"(",
")",
"{",
"// Environment variable COMPOSER points to the composer.json we should use.",
"if",
"(",
"false",
"!==",
"(",
"$",
"home",
"=",
"getenv",
"(",
"'COMPOSER'",
")",
")",
")",
"{",
"return",
"dirname",
"(",
"$",
"home",
")",
";",
"}",
"if",
"(",
"''",
"!==",
"\\",
"Phar",
"::",
"running",
"(",
")",
")",
"{",
"// Strip scheme \"phar://\" prefix and \"tenside.phar\" suffix.",
"$",
"home",
"=",
"dirname",
"(",
"substr",
"(",
"\\",
"Phar",
"::",
"running",
"(",
")",
",",
"7",
")",
")",
";",
"}",
"else",
"{",
"$",
"home",
"=",
"getcwd",
"(",
")",
";",
"}",
"if",
"(",
"(",
"PHP_SAPI",
"!==",
"'cli'",
")",
"&&",
"(",
"substr",
"(",
"$",
"home",
",",
"-",
"4",
")",
"!==",
"DIRECTORY_SEPARATOR",
".",
"'web'",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'Tenside is intended to be run from within the web directory but it appears you are running it from '",
".",
"basename",
"(",
"$",
"home",
")",
")",
";",
"}",
"return",
"dirname",
"(",
"$",
"home",
")",
";",
"}"
] | Determine the correct working directory.
@return string
@throws \RuntimeException When the home directory is not /web. | [
"Determine",
"the",
"correct",
"working",
"directory",
"."
] | 56422fa8cdecf03cb431bb6654c2942ade39bf7b | https://github.com/tenside/core/blob/56422fa8cdecf03cb431bb6654c2942ade39bf7b/src/Util/HomePathDeterminator.php#L76-L98 |
8,268 | gossi/trixionary | src/model/Map/SkillDependencyTableMap.php | SkillDependencyTableMap.doInsert | public static function doInsert($criteria, ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(SkillDependencyTableMap::DATABASE_NAME);
}
if ($criteria instanceof Criteria) {
$criteria = clone $criteria; // rename for clarity
} else {
$criteria = $criteria->buildCriteria(); // build Criteria from SkillDependency object
}
// Set the correct dbName
$query = SkillDependencyQuery::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(SkillDependencyTableMap::DATABASE_NAME);
}
if ($criteria instanceof Criteria) {
$criteria = clone $criteria; // rename for clarity
} else {
$criteria = $criteria->buildCriteria(); // build Criteria from SkillDependency object
}
// Set the correct dbName
$query = SkillDependencyQuery::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",
"(",
"SkillDependencyTableMap",
"::",
"DATABASE_NAME",
")",
";",
"}",
"if",
"(",
"$",
"criteria",
"instanceof",
"Criteria",
")",
"{",
"$",
"criteria",
"=",
"clone",
"$",
"criteria",
";",
"// rename for clarity",
"}",
"else",
"{",
"$",
"criteria",
"=",
"$",
"criteria",
"->",
"buildCriteria",
"(",
")",
";",
"// build Criteria from SkillDependency object",
"}",
"// Set the correct dbName",
"$",
"query",
"=",
"SkillDependencyQuery",
"::",
"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 SkillDependency or Criteria object.
@param mixed $criteria Criteria or SkillDependency 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",
"SkillDependency",
"or",
"Criteria",
"object",
"."
] | 221a6c5322473d7d7f8e322958a3ee46d87da150 | https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Map/SkillDependencyTableMap.php#L465-L486 |
8,269 | davidyell/CakePHP3-NumbersToWords | src/View/Helper/NumbersToWordsHelper.php | NumbersToWordsHelper.spell | public function spell($item)
{
$formatter = new NumberFormatter($this->config['locale'], NumberFormatter::SPELLOUT);
if (is_int($item)) {
return $formatter->format($item);
}
return preg_replace_callback('/([0-9]+)/', function ($matches) use ($formatter) {
return $formatter->format($matches[0]);
}, $item);
} | php | public function spell($item)
{
$formatter = new NumberFormatter($this->config['locale'], NumberFormatter::SPELLOUT);
if (is_int($item)) {
return $formatter->format($item);
}
return preg_replace_callback('/([0-9]+)/', function ($matches) use ($formatter) {
return $formatter->format($matches[0]);
}, $item);
} | [
"public",
"function",
"spell",
"(",
"$",
"item",
")",
"{",
"$",
"formatter",
"=",
"new",
"NumberFormatter",
"(",
"$",
"this",
"->",
"config",
"[",
"'locale'",
"]",
",",
"NumberFormatter",
"::",
"SPELLOUT",
")",
";",
"if",
"(",
"is_int",
"(",
"$",
"item",
")",
")",
"{",
"return",
"$",
"formatter",
"->",
"format",
"(",
"$",
"item",
")",
";",
"}",
"return",
"preg_replace_callback",
"(",
"'/([0-9]+)/'",
",",
"function",
"(",
"$",
"matches",
")",
"use",
"(",
"$",
"formatter",
")",
"{",
"return",
"$",
"formatter",
"->",
"format",
"(",
"$",
"matches",
"[",
"0",
"]",
")",
";",
"}",
",",
"$",
"item",
")",
";",
"}"
] | Convert a number into a word
@param int|string $item An integer number to convert or a string containing an integer
@return string | [
"Convert",
"a",
"number",
"into",
"a",
"word"
] | 6d4e39bc0d670aa15839eec51c2e6e06d7c7b921 | https://github.com/davidyell/CakePHP3-NumbersToWords/blob/6d4e39bc0d670aa15839eec51c2e6e06d7c7b921/src/View/Helper/NumbersToWordsHelper.php#L34-L45 |
8,270 | davidyell/CakePHP3-NumbersToWords | src/View/Helper/NumbersToWordsHelper.php | NumbersToWordsHelper.ordinal | public function ordinal($item)
{
$formatter = new NumberFormatter($this->config['locale'], NumberFormatter::ORDINAL);
if (is_int($item)) {
return $formatter->format($item);
}
return preg_replace_callback('/([0-9]+)/', function ($matches) use ($formatter) {
return $formatter->format($matches[0]);
}, $item);
} | php | public function ordinal($item)
{
$formatter = new NumberFormatter($this->config['locale'], NumberFormatter::ORDINAL);
if (is_int($item)) {
return $formatter->format($item);
}
return preg_replace_callback('/([0-9]+)/', function ($matches) use ($formatter) {
return $formatter->format($matches[0]);
}, $item);
} | [
"public",
"function",
"ordinal",
"(",
"$",
"item",
")",
"{",
"$",
"formatter",
"=",
"new",
"NumberFormatter",
"(",
"$",
"this",
"->",
"config",
"[",
"'locale'",
"]",
",",
"NumberFormatter",
"::",
"ORDINAL",
")",
";",
"if",
"(",
"is_int",
"(",
"$",
"item",
")",
")",
"{",
"return",
"$",
"formatter",
"->",
"format",
"(",
"$",
"item",
")",
";",
"}",
"return",
"preg_replace_callback",
"(",
"'/([0-9]+)/'",
",",
"function",
"(",
"$",
"matches",
")",
"use",
"(",
"$",
"formatter",
")",
"{",
"return",
"$",
"formatter",
"->",
"format",
"(",
"$",
"matches",
"[",
"0",
"]",
")",
";",
"}",
",",
"$",
"item",
")",
";",
"}"
] | Convert a number into it's ordinal type
eg, 1 -> 1st, 2 -> 2nd
@param int|string $item An integer number to convert or a string containing a number
@return string | [
"Convert",
"a",
"number",
"into",
"it",
"s",
"ordinal",
"type",
"eg",
"1",
"-",
">",
"1st",
"2",
"-",
">",
"2nd"
] | 6d4e39bc0d670aa15839eec51c2e6e06d7c7b921 | https://github.com/davidyell/CakePHP3-NumbersToWords/blob/6d4e39bc0d670aa15839eec51c2e6e06d7c7b921/src/View/Helper/NumbersToWordsHelper.php#L55-L66 |
8,271 | bishopb/vanilla | library/database/class.sqldriver.php | Gdn_SQLDriver.ConditionExpr | public function ConditionExpr($Field, $Value, $EscapeFieldSql = TRUE, $EscapeValueSql = TRUE) {
// Change some variables from the old parameter style to the new one.
// THIS PART OF THE FUNCTION SHOULD EVENTUALLY BE REMOVED.
if($EscapeFieldSql === FALSE) {
$Field = '@' . $Field;
}
if(is_array($Value)) {
//$ValueStr = var_export($Value, TRUE);
$ValueStr = 'ARRAY';
Deprecated("Gdn_SQL->ConditionExpr(VALUE, {$ValueStr})", 'Gdn_SQL->ConditionExpr(VALUE, VALUE)');
if ($EscapeValueSql)
throw new Gdn_UserException('Invalid function call.');
$FunctionCall = array_keys($Value);
$FunctionCall = $FunctionCall[0];
$FunctionArg = $Value[$FunctionCall];
if($EscapeValueSql)
$FunctionArg = '[' . $FunctionArg . ']';
if(stripos($FunctionCall, '%s') === FALSE)
$Value = '=' . $FunctionCall . '(' . $FunctionArg . ')';
else
$Value = '=' . sprintf($FunctionCall, $FunctionArg);
$EscapeValueSql = FALSE;
} else if(!$EscapeValueSql && !is_null($Value)) {
$Value = '@' . $Value;
}
// Check for a straight literal field expression.
if(!$EscapeFieldSql && !$EscapeValueSql && is_null($Value))
return substr($Field, 1); // warning: might not be portable across different drivers
$Expr = ''; // final expression which is built up
$Op = ''; // logical operator
// Try and split an operator out of $Field.
$FieldOpRegex = "/(?:\s*(=|<>|>|<|>=|<=)\s*$)|\s+(like|not\s+like)\s*$|\s+(?:(is)\s+(null)|(is\s+not)\s+(null))\s*$/i";
$Split = preg_split($FieldOpRegex, $Field, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);
if(count($Split) > 1) {
$Field = $Split[0];
$Op = $Split[1];
if (count($Split) > 2) {
$Value = null;
}
} else {
$Op = '=';
}
if($Op == '=' && is_null($Value)) {
// This is a special case where the value SQL is checking for an is null operation.
$Op = 'is';
$Value = '@null';
$EscapeValueSql = FALSE;
}
// Add the left hand side of the expression.
$Expr .= $this->_ParseExpr($Field, NULL, $EscapeFieldSql);
// Add the expression operator.
$Expr .= ' '.$Op.' ';
if ($Op == 'is' || $Op == 'is not' && is_null($Value)) {
$Expr .= 'null';
} else {
// Add the right side of the expression.
$Expr .= $this->_ParseExpr($Value, $Field, $EscapeValueSql);
}
return $Expr;
} | php | public function ConditionExpr($Field, $Value, $EscapeFieldSql = TRUE, $EscapeValueSql = TRUE) {
// Change some variables from the old parameter style to the new one.
// THIS PART OF THE FUNCTION SHOULD EVENTUALLY BE REMOVED.
if($EscapeFieldSql === FALSE) {
$Field = '@' . $Field;
}
if(is_array($Value)) {
//$ValueStr = var_export($Value, TRUE);
$ValueStr = 'ARRAY';
Deprecated("Gdn_SQL->ConditionExpr(VALUE, {$ValueStr})", 'Gdn_SQL->ConditionExpr(VALUE, VALUE)');
if ($EscapeValueSql)
throw new Gdn_UserException('Invalid function call.');
$FunctionCall = array_keys($Value);
$FunctionCall = $FunctionCall[0];
$FunctionArg = $Value[$FunctionCall];
if($EscapeValueSql)
$FunctionArg = '[' . $FunctionArg . ']';
if(stripos($FunctionCall, '%s') === FALSE)
$Value = '=' . $FunctionCall . '(' . $FunctionArg . ')';
else
$Value = '=' . sprintf($FunctionCall, $FunctionArg);
$EscapeValueSql = FALSE;
} else if(!$EscapeValueSql && !is_null($Value)) {
$Value = '@' . $Value;
}
// Check for a straight literal field expression.
if(!$EscapeFieldSql && !$EscapeValueSql && is_null($Value))
return substr($Field, 1); // warning: might not be portable across different drivers
$Expr = ''; // final expression which is built up
$Op = ''; // logical operator
// Try and split an operator out of $Field.
$FieldOpRegex = "/(?:\s*(=|<>|>|<|>=|<=)\s*$)|\s+(like|not\s+like)\s*$|\s+(?:(is)\s+(null)|(is\s+not)\s+(null))\s*$/i";
$Split = preg_split($FieldOpRegex, $Field, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);
if(count($Split) > 1) {
$Field = $Split[0];
$Op = $Split[1];
if (count($Split) > 2) {
$Value = null;
}
} else {
$Op = '=';
}
if($Op == '=' && is_null($Value)) {
// This is a special case where the value SQL is checking for an is null operation.
$Op = 'is';
$Value = '@null';
$EscapeValueSql = FALSE;
}
// Add the left hand side of the expression.
$Expr .= $this->_ParseExpr($Field, NULL, $EscapeFieldSql);
// Add the expression operator.
$Expr .= ' '.$Op.' ';
if ($Op == 'is' || $Op == 'is not' && is_null($Value)) {
$Expr .= 'null';
} else {
// Add the right side of the expression.
$Expr .= $this->_ParseExpr($Value, $Field, $EscapeValueSql);
}
return $Expr;
} | [
"public",
"function",
"ConditionExpr",
"(",
"$",
"Field",
",",
"$",
"Value",
",",
"$",
"EscapeFieldSql",
"=",
"TRUE",
",",
"$",
"EscapeValueSql",
"=",
"TRUE",
")",
"{",
"// Change some variables from the old parameter style to the new one.",
"// THIS PART OF THE FUNCTION SHOULD EVENTUALLY BE REMOVED.",
"if",
"(",
"$",
"EscapeFieldSql",
"===",
"FALSE",
")",
"{",
"$",
"Field",
"=",
"'@'",
".",
"$",
"Field",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"Value",
")",
")",
"{",
"//$ValueStr = var_export($Value, TRUE);",
"$",
"ValueStr",
"=",
"'ARRAY'",
";",
"Deprecated",
"(",
"\"Gdn_SQL->ConditionExpr(VALUE, {$ValueStr})\"",
",",
"'Gdn_SQL->ConditionExpr(VALUE, VALUE)'",
")",
";",
"if",
"(",
"$",
"EscapeValueSql",
")",
"throw",
"new",
"Gdn_UserException",
"(",
"'Invalid function call.'",
")",
";",
"$",
"FunctionCall",
"=",
"array_keys",
"(",
"$",
"Value",
")",
";",
"$",
"FunctionCall",
"=",
"$",
"FunctionCall",
"[",
"0",
"]",
";",
"$",
"FunctionArg",
"=",
"$",
"Value",
"[",
"$",
"FunctionCall",
"]",
";",
"if",
"(",
"$",
"EscapeValueSql",
")",
"$",
"FunctionArg",
"=",
"'['",
".",
"$",
"FunctionArg",
".",
"']'",
";",
"if",
"(",
"stripos",
"(",
"$",
"FunctionCall",
",",
"'%s'",
")",
"===",
"FALSE",
")",
"$",
"Value",
"=",
"'='",
".",
"$",
"FunctionCall",
".",
"'('",
".",
"$",
"FunctionArg",
".",
"')'",
";",
"else",
"$",
"Value",
"=",
"'='",
".",
"sprintf",
"(",
"$",
"FunctionCall",
",",
"$",
"FunctionArg",
")",
";",
"$",
"EscapeValueSql",
"=",
"FALSE",
";",
"}",
"else",
"if",
"(",
"!",
"$",
"EscapeValueSql",
"&&",
"!",
"is_null",
"(",
"$",
"Value",
")",
")",
"{",
"$",
"Value",
"=",
"'@'",
".",
"$",
"Value",
";",
"}",
"// Check for a straight literal field expression.",
"if",
"(",
"!",
"$",
"EscapeFieldSql",
"&&",
"!",
"$",
"EscapeValueSql",
"&&",
"is_null",
"(",
"$",
"Value",
")",
")",
"return",
"substr",
"(",
"$",
"Field",
",",
"1",
")",
";",
"// warning: might not be portable across different drivers",
"$",
"Expr",
"=",
"''",
";",
"// final expression which is built up",
"$",
"Op",
"=",
"''",
";",
"// logical operator",
"// Try and split an operator out of $Field.",
"$",
"FieldOpRegex",
"=",
"\"/(?:\\s*(=|<>|>|<|>=|<=)\\s*$)|\\s+(like|not\\s+like)\\s*$|\\s+(?:(is)\\s+(null)|(is\\s+not)\\s+(null))\\s*$/i\"",
";",
"$",
"Split",
"=",
"preg_split",
"(",
"$",
"FieldOpRegex",
",",
"$",
"Field",
",",
"-",
"1",
",",
"PREG_SPLIT_NO_EMPTY",
"|",
"PREG_SPLIT_DELIM_CAPTURE",
")",
";",
"if",
"(",
"count",
"(",
"$",
"Split",
")",
">",
"1",
")",
"{",
"$",
"Field",
"=",
"$",
"Split",
"[",
"0",
"]",
";",
"$",
"Op",
"=",
"$",
"Split",
"[",
"1",
"]",
";",
"if",
"(",
"count",
"(",
"$",
"Split",
")",
">",
"2",
")",
"{",
"$",
"Value",
"=",
"null",
";",
"}",
"}",
"else",
"{",
"$",
"Op",
"=",
"'='",
";",
"}",
"if",
"(",
"$",
"Op",
"==",
"'='",
"&&",
"is_null",
"(",
"$",
"Value",
")",
")",
"{",
"// This is a special case where the value SQL is checking for an is null operation.",
"$",
"Op",
"=",
"'is'",
";",
"$",
"Value",
"=",
"'@null'",
";",
"$",
"EscapeValueSql",
"=",
"FALSE",
";",
"}",
"// Add the left hand side of the expression.",
"$",
"Expr",
".=",
"$",
"this",
"->",
"_ParseExpr",
"(",
"$",
"Field",
",",
"NULL",
",",
"$",
"EscapeFieldSql",
")",
";",
"// Add the expression operator.",
"$",
"Expr",
".=",
"' '",
".",
"$",
"Op",
".",
"' '",
";",
"if",
"(",
"$",
"Op",
"==",
"'is'",
"||",
"$",
"Op",
"==",
"'is not'",
"&&",
"is_null",
"(",
"$",
"Value",
")",
")",
"{",
"$",
"Expr",
".=",
"'null'",
";",
"}",
"else",
"{",
"// Add the right side of the expression.",
"$",
"Expr",
".=",
"$",
"this",
"->",
"_ParseExpr",
"(",
"$",
"Value",
",",
"$",
"Field",
",",
"$",
"EscapeValueSql",
")",
";",
"}",
"return",
"$",
"Expr",
";",
"}"
] | Returns a single Condition Expression for use in a 'where' or an 'on' clause.
@param string $Field The name of the field on the left hand side of the expression.
If $Field ends with an operator, then it used for the comparison. Otherwise '=' will be used.
@param mixed $Value The value on the right side of the expression. This has different behaviour depending on the type.
<b>string</b>: The value will be used. If $EscapeValueSql is true then it will end up in a parameter.
<b>array</b>: DatabaseFunction => Value will be used. if DatabaseFunction contains a "%s" then sprintf will be used.
In this case Value will be assumed to be a string.
<b>New Syntax</b>
The $Field and Value expressions can begin with special characters to do certain things.
<ul>
<li><b>=</b>: This means that the argument is a function call.
If you want to pass field reference arguments into the function then enclose them in square brackets.
ex. <code>'=LEFT([u.Name], 4)'</code> will call the LEFT database function on the u.Name column.</li>
<li><b>@</b>: This means that the argument is a literal.
This is useful for passing in literal numbers.</li>
<li><b>no prefix></b>: This will treat the argument differently depending on the argument.
- <b>$Field</b> - The argument is a column reference.
- <b>$Value</b> - The argument will become a named parameter.
</li></ul>
@return string The single expression. | [
"Returns",
"a",
"single",
"Condition",
"Expression",
"for",
"use",
"in",
"a",
"where",
"or",
"an",
"on",
"clause",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/database/class.sqldriver.php#L293-L364 |
8,272 | bishopb/vanilla | library/database/class.sqldriver.php | Gdn_SQLDriver.Cache | public function Cache($Key, $Operation = NULL, $Options = NULL) {
if (!$Key) {
$this->_CacheKey = NULL;
$this->_CacheOperation = NULL;
$this->_CacheOptions = NULL;
return $this;
}
$this->_CacheKey = $Key;
if (!is_null($Operation))
$this->_CacheOperation = $Operation;
if (!is_null($Options))
$this->_CacheOptions = $Options;
return $this;
} | php | public function Cache($Key, $Operation = NULL, $Options = NULL) {
if (!$Key) {
$this->_CacheKey = NULL;
$this->_CacheOperation = NULL;
$this->_CacheOptions = NULL;
return $this;
}
$this->_CacheKey = $Key;
if (!is_null($Operation))
$this->_CacheOperation = $Operation;
if (!is_null($Options))
$this->_CacheOptions = $Options;
return $this;
} | [
"public",
"function",
"Cache",
"(",
"$",
"Key",
",",
"$",
"Operation",
"=",
"NULL",
",",
"$",
"Options",
"=",
"NULL",
")",
"{",
"if",
"(",
"!",
"$",
"Key",
")",
"{",
"$",
"this",
"->",
"_CacheKey",
"=",
"NULL",
";",
"$",
"this",
"->",
"_CacheOperation",
"=",
"NULL",
";",
"$",
"this",
"->",
"_CacheOptions",
"=",
"NULL",
";",
"return",
"$",
"this",
";",
"}",
"$",
"this",
"->",
"_CacheKey",
"=",
"$",
"Key",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"Operation",
")",
")",
"$",
"this",
"->",
"_CacheOperation",
"=",
"$",
"Operation",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"Options",
")",
")",
"$",
"this",
"->",
"_CacheOptions",
"=",
"$",
"Options",
";",
"return",
"$",
"this",
";",
"}"
] | Set the cache key for this transaction
@param string|array $Key The cache key (or array of keys) that this query will save into.
@param string $Operation The cache operation as a hint to the db.
@param array $Options The cache options as passed into Gdn_Cache::Store().
@return Gdn_SQLDriver $this | [
"Set",
"the",
"cache",
"key",
"for",
"this",
"transaction"
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/database/class.sqldriver.php#L374-L392 |
8,273 | bishopb/vanilla | library/database/class.sqldriver.php | Gdn_SQLDriver.Delete | public function Delete($Table = '', $Where = '', $Limit = FALSE) {
if ($Table == '') {
if (!isset($this->_Froms[0]))
return FALSE;
$Table = $this->_Froms[0];
} elseif (is_array($Table)) {
foreach ($Table as $t) {
$this->Delete($t, $Where, $Limit, FALSE);
}
return;
} else {
$Table = $this->EscapeIdentifier($this->Database->DatabasePrefix.$Table);
}
if ($Where != '')
$this->Where($Where);
if ($Limit !== FALSE)
$this->Limit($Limit);
if (count($this->_Wheres) == 0)
return FALSE;
$Sql = $this->GetDelete($Table, $this->_Wheres, $this->_Limit);
return $this->Query($Sql, 'delete');
} | php | public function Delete($Table = '', $Where = '', $Limit = FALSE) {
if ($Table == '') {
if (!isset($this->_Froms[0]))
return FALSE;
$Table = $this->_Froms[0];
} elseif (is_array($Table)) {
foreach ($Table as $t) {
$this->Delete($t, $Where, $Limit, FALSE);
}
return;
} else {
$Table = $this->EscapeIdentifier($this->Database->DatabasePrefix.$Table);
}
if ($Where != '')
$this->Where($Where);
if ($Limit !== FALSE)
$this->Limit($Limit);
if (count($this->_Wheres) == 0)
return FALSE;
$Sql = $this->GetDelete($Table, $this->_Wheres, $this->_Limit);
return $this->Query($Sql, 'delete');
} | [
"public",
"function",
"Delete",
"(",
"$",
"Table",
"=",
"''",
",",
"$",
"Where",
"=",
"''",
",",
"$",
"Limit",
"=",
"FALSE",
")",
"{",
"if",
"(",
"$",
"Table",
"==",
"''",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_Froms",
"[",
"0",
"]",
")",
")",
"return",
"FALSE",
";",
"$",
"Table",
"=",
"$",
"this",
"->",
"_Froms",
"[",
"0",
"]",
";",
"}",
"elseif",
"(",
"is_array",
"(",
"$",
"Table",
")",
")",
"{",
"foreach",
"(",
"$",
"Table",
"as",
"$",
"t",
")",
"{",
"$",
"this",
"->",
"Delete",
"(",
"$",
"t",
",",
"$",
"Where",
",",
"$",
"Limit",
",",
"FALSE",
")",
";",
"}",
"return",
";",
"}",
"else",
"{",
"$",
"Table",
"=",
"$",
"this",
"->",
"EscapeIdentifier",
"(",
"$",
"this",
"->",
"Database",
"->",
"DatabasePrefix",
".",
"$",
"Table",
")",
";",
"}",
"if",
"(",
"$",
"Where",
"!=",
"''",
")",
"$",
"this",
"->",
"Where",
"(",
"$",
"Where",
")",
";",
"if",
"(",
"$",
"Limit",
"!==",
"FALSE",
")",
"$",
"this",
"->",
"Limit",
"(",
"$",
"Limit",
")",
";",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"_Wheres",
")",
"==",
"0",
")",
"return",
"FALSE",
";",
"$",
"Sql",
"=",
"$",
"this",
"->",
"GetDelete",
"(",
"$",
"Table",
",",
"$",
"this",
"->",
"_Wheres",
",",
"$",
"this",
"->",
"_Limit",
")",
";",
"return",
"$",
"this",
"->",
"Query",
"(",
"$",
"Sql",
",",
"'delete'",
")",
";",
"}"
] | Builds and executes a delete from query.
@param mixed $Table The table (or array of table names) to delete from.
@param mixed $Where The string on the left side of the where comparison, or an associative
array of Field => Value items to compare.
@param int $Limit The number of records to limit the query to. | [
"Builds",
"and",
"executes",
"a",
"delete",
"from",
"query",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/database/class.sqldriver.php#L409-L437 |
8,274 | bishopb/vanilla | library/database/class.sqldriver.php | Gdn_SQLDriver.Distinct | public function Distinct($Bool = TRUE) {
$this->_Distinct = (is_bool($Bool)) ? $Bool : TRUE;
return $this;
} | php | public function Distinct($Bool = TRUE) {
$this->_Distinct = (is_bool($Bool)) ? $Bool : TRUE;
return $this;
} | [
"public",
"function",
"Distinct",
"(",
"$",
"Bool",
"=",
"TRUE",
")",
"{",
"$",
"this",
"->",
"_Distinct",
"=",
"(",
"is_bool",
"(",
"$",
"Bool",
")",
")",
"?",
"$",
"Bool",
":",
"TRUE",
";",
"return",
"$",
"this",
";",
"}"
] | Specifies that the query should be run as a distinct so that duplicate
columns are grouped together. Returns this object for chaining purposes.
@param boolean $Bool A boolean value indicating if the query should be distinct or not. | [
"Specifies",
"that",
"the",
"query",
"should",
"be",
"run",
"as",
"a",
"distinct",
"so",
"that",
"duplicate",
"columns",
"are",
"grouped",
"together",
".",
"Returns",
"this",
"object",
"for",
"chaining",
"purposes",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/database/class.sqldriver.php#L445-L448 |
8,275 | bishopb/vanilla | library/database/class.sqldriver.php | Gdn_SQLDriver.EmptyTable | public function EmptyTable($Table = '') {
if ($Table == '') {
if (!isset($this->_Froms[0]))
return FALSE;
$Table = $this->_Froms[0];
} else {
$Table = $this->EscapeIdentifier($this->Database->DatabasePrefix.$Table);
}
$Sql = $this->GetDelete($Table);
return $this->Query($Sql, 'delete');
} | php | public function EmptyTable($Table = '') {
if ($Table == '') {
if (!isset($this->_Froms[0]))
return FALSE;
$Table = $this->_Froms[0];
} else {
$Table = $this->EscapeIdentifier($this->Database->DatabasePrefix.$Table);
}
$Sql = $this->GetDelete($Table);
return $this->Query($Sql, 'delete');
} | [
"public",
"function",
"EmptyTable",
"(",
"$",
"Table",
"=",
"''",
")",
"{",
"if",
"(",
"$",
"Table",
"==",
"''",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_Froms",
"[",
"0",
"]",
")",
")",
"return",
"FALSE",
";",
"$",
"Table",
"=",
"$",
"this",
"->",
"_Froms",
"[",
"0",
"]",
";",
"}",
"else",
"{",
"$",
"Table",
"=",
"$",
"this",
"->",
"EscapeIdentifier",
"(",
"$",
"this",
"->",
"Database",
"->",
"DatabasePrefix",
".",
"$",
"Table",
")",
";",
"}",
"$",
"Sql",
"=",
"$",
"this",
"->",
"GetDelete",
"(",
"$",
"Table",
")",
";",
"return",
"$",
"this",
"->",
"Query",
"(",
"$",
"Sql",
",",
"'delete'",
")",
";",
"}"
] | Removes all data from a table.
@param string $Table The table to empty. | [
"Removes",
"all",
"data",
"from",
"a",
"table",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/database/class.sqldriver.php#L455-L469 |
8,276 | bishopb/vanilla | library/database/class.sqldriver.php | Gdn_SQLDriver.FetchTables | public function FetchTables($LimitToPrefix = FALSE) {
$Sql = $this->FetchTableSql($LimitToPrefix);
$Data = $this->Query($Sql);
$Return = array();
foreach($Data->ResultArray() as $Row) {
if (isset($Row['TABLE_NAME']))
$Return[] = $Row['TABLE_NAME'];
else
$Return[] = array_shift($Row);
}
return $Return;
} | php | public function FetchTables($LimitToPrefix = FALSE) {
$Sql = $this->FetchTableSql($LimitToPrefix);
$Data = $this->Query($Sql);
$Return = array();
foreach($Data->ResultArray() as $Row) {
if (isset($Row['TABLE_NAME']))
$Return[] = $Row['TABLE_NAME'];
else
$Return[] = array_shift($Row);
}
return $Return;
} | [
"public",
"function",
"FetchTables",
"(",
"$",
"LimitToPrefix",
"=",
"FALSE",
")",
"{",
"$",
"Sql",
"=",
"$",
"this",
"->",
"FetchTableSql",
"(",
"$",
"LimitToPrefix",
")",
";",
"$",
"Data",
"=",
"$",
"this",
"->",
"Query",
"(",
"$",
"Sql",
")",
";",
"$",
"Return",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"Data",
"->",
"ResultArray",
"(",
")",
"as",
"$",
"Row",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"Row",
"[",
"'TABLE_NAME'",
"]",
")",
")",
"$",
"Return",
"[",
"]",
"=",
"$",
"Row",
"[",
"'TABLE_NAME'",
"]",
";",
"else",
"$",
"Return",
"[",
"]",
"=",
"array_shift",
"(",
"$",
"Row",
")",
";",
"}",
"return",
"$",
"Return",
";",
"}"
] | Returns an array containing table names in the database.
@param mixed $LimitToPrefix Whether or not to limit the search to tables with the database prefix or a specific table name. The following types can be given for this parameter:
- <b>TRUE</b>: The search will be limited to the database prefix.
- <b>FALSE</b>: All tables will be fetched. Default.
- <b>string</b>: The search will be limited to a like clause. The ':_' will be replaced with the database prefix.
@return array | [
"Returns",
"an",
"array",
"containing",
"table",
"names",
"in",
"the",
"database",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/database/class.sqldriver.php#L552-L564 |
8,277 | bishopb/vanilla | library/database/class.sqldriver.php | Gdn_SQLDriver.Get | public function Get($Table = '', $OrderFields = '', $OrderDirection = 'asc', $Limit = FALSE, $PageNumber = FALSE) {
if ($Table != '') {
//$this->MapAliases($Table);
$this->From($Table);
}
if ($OrderFields != '')
$this->OrderBy($OrderFields, $OrderDirection);
if ($Limit !== FALSE) {
if ($PageNumber == FALSE || $PageNumber < 1)
$PageNumber = 1;
$Offset = ($PageNumber - 1) * $Limit;
$this->Limit($Limit, $Offset);
}
$Result = $this->Query($this->GetSelect());
return $Result;
} | php | public function Get($Table = '', $OrderFields = '', $OrderDirection = 'asc', $Limit = FALSE, $PageNumber = FALSE) {
if ($Table != '') {
//$this->MapAliases($Table);
$this->From($Table);
}
if ($OrderFields != '')
$this->OrderBy($OrderFields, $OrderDirection);
if ($Limit !== FALSE) {
if ($PageNumber == FALSE || $PageNumber < 1)
$PageNumber = 1;
$Offset = ($PageNumber - 1) * $Limit;
$this->Limit($Limit, $Offset);
}
$Result = $this->Query($this->GetSelect());
return $Result;
} | [
"public",
"function",
"Get",
"(",
"$",
"Table",
"=",
"''",
",",
"$",
"OrderFields",
"=",
"''",
",",
"$",
"OrderDirection",
"=",
"'asc'",
",",
"$",
"Limit",
"=",
"FALSE",
",",
"$",
"PageNumber",
"=",
"FALSE",
")",
"{",
"if",
"(",
"$",
"Table",
"!=",
"''",
")",
"{",
"//$this->MapAliases($Table);",
"$",
"this",
"->",
"From",
"(",
"$",
"Table",
")",
";",
"}",
"if",
"(",
"$",
"OrderFields",
"!=",
"''",
")",
"$",
"this",
"->",
"OrderBy",
"(",
"$",
"OrderFields",
",",
"$",
"OrderDirection",
")",
";",
"if",
"(",
"$",
"Limit",
"!==",
"FALSE",
")",
"{",
"if",
"(",
"$",
"PageNumber",
"==",
"FALSE",
"||",
"$",
"PageNumber",
"<",
"1",
")",
"$",
"PageNumber",
"=",
"1",
";",
"$",
"Offset",
"=",
"(",
"$",
"PageNumber",
"-",
"1",
")",
"*",
"$",
"Limit",
";",
"$",
"this",
"->",
"Limit",
"(",
"$",
"Limit",
",",
"$",
"Offset",
")",
";",
"}",
"$",
"Result",
"=",
"$",
"this",
"->",
"Query",
"(",
"$",
"this",
"->",
"GetSelect",
"(",
")",
")",
";",
"return",
"$",
"Result",
";",
"}"
] | Builds the select statement and runs the query, returning a result object.
@param string $Table The table from which to select data. Adds to the $this->_Froms collection.
@param string $OrderFields A string of fields to be ordered.
@param string $OrderDirection The direction of the sort.
@param int $Limit Adds a limit to the query.
@param int $PageNumber The page of data to retrieve.
@return Gdn_DataSet | [
"Builds",
"the",
"select",
"statement",
"and",
"runs",
"the",
"query",
"returning",
"a",
"result",
"object",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/database/class.sqldriver.php#L657-L676 |
8,278 | bishopb/vanilla | library/database/class.sqldriver.php | Gdn_SQLDriver._GetIdentifierTokens | protected function _GetIdentifierTokens($Sql) {
$Tokens = preg_split('/`/', $Sql, -1, PREG_SPLIT_DELIM_CAPTURE);
$Result = array();
$InIdent = FALSE;
$CurrentToken = '';
for($i = 0; $i < count($Tokens); $i++) {
$Token = $Tokens[i];
$Result .= $Token;
if($Token == '`') {
if($InIdent && $i < count($Tokens) - 1 && $Tokens[$i + 1] == '`') {
// This is an escaped back tick.
$i++; // skip next token
} else if($InIdent) {
$Result[] = $CurrentToken;
$CurrentToken = $CurrentToken;
$InIdent = false;
} else {
$InIdent = true;
}
} else if(!$InIdent) {
$Result[] = $CurrentToken;
$CurrentToken = '';
}
}
return $Result;
} | php | protected function _GetIdentifierTokens($Sql) {
$Tokens = preg_split('/`/', $Sql, -1, PREG_SPLIT_DELIM_CAPTURE);
$Result = array();
$InIdent = FALSE;
$CurrentToken = '';
for($i = 0; $i < count($Tokens); $i++) {
$Token = $Tokens[i];
$Result .= $Token;
if($Token == '`') {
if($InIdent && $i < count($Tokens) - 1 && $Tokens[$i + 1] == '`') {
// This is an escaped back tick.
$i++; // skip next token
} else if($InIdent) {
$Result[] = $CurrentToken;
$CurrentToken = $CurrentToken;
$InIdent = false;
} else {
$InIdent = true;
}
} else if(!$InIdent) {
$Result[] = $CurrentToken;
$CurrentToken = '';
}
}
return $Result;
} | [
"protected",
"function",
"_GetIdentifierTokens",
"(",
"$",
"Sql",
")",
"{",
"$",
"Tokens",
"=",
"preg_split",
"(",
"'/`/'",
",",
"$",
"Sql",
",",
"-",
"1",
",",
"PREG_SPLIT_DELIM_CAPTURE",
")",
";",
"$",
"Result",
"=",
"array",
"(",
")",
";",
"$",
"InIdent",
"=",
"FALSE",
";",
"$",
"CurrentToken",
"=",
"''",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"count",
"(",
"$",
"Tokens",
")",
";",
"$",
"i",
"++",
")",
"{",
"$",
"Token",
"=",
"$",
"Tokens",
"[",
"i",
"]",
";",
"$",
"Result",
".=",
"$",
"Token",
";",
"if",
"(",
"$",
"Token",
"==",
"'`'",
")",
"{",
"if",
"(",
"$",
"InIdent",
"&&",
"$",
"i",
"<",
"count",
"(",
"$",
"Tokens",
")",
"-",
"1",
"&&",
"$",
"Tokens",
"[",
"$",
"i",
"+",
"1",
"]",
"==",
"'`'",
")",
"{",
"// This is an escaped back tick.",
"$",
"i",
"++",
";",
"// skip next token",
"}",
"else",
"if",
"(",
"$",
"InIdent",
")",
"{",
"$",
"Result",
"[",
"]",
"=",
"$",
"CurrentToken",
";",
"$",
"CurrentToken",
"=",
"$",
"CurrentToken",
";",
"$",
"InIdent",
"=",
"false",
";",
"}",
"else",
"{",
"$",
"InIdent",
"=",
"true",
";",
"}",
"}",
"else",
"if",
"(",
"!",
"$",
"InIdent",
")",
"{",
"$",
"Result",
"[",
"]",
"=",
"$",
"CurrentToken",
";",
"$",
"CurrentToken",
"=",
"''",
";",
"}",
"}",
"return",
"$",
"Result",
";",
"}"
] | A helper function for escaping sql identifiers.
@param string The sql containing identifiers to escape in a different language.
All identifiers requiring escaping should be enclosed in back ticks (`).
@return array All of the tokens in the sql. The tokens that require escaping will still have back ticks. | [
"A",
"helper",
"function",
"for",
"escaping",
"sql",
"identifiers",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/database/class.sqldriver.php#L684-L711 |
8,279 | bishopb/vanilla | library/database/class.sqldriver.php | Gdn_SQLDriver.GetWhere | public function GetWhere($Table = '', $Where = FALSE, $OrderFields = '', $OrderDirection = 'asc', $Limit = FALSE, $Offset = 0) {
if ($Table != '') {
//$this->MapAliases($Table);
$this->From($Table);
}
if ($Where !== FALSE)
$this->Where($Where);
if ($OrderFields != '')
$this->OrderBy($OrderFields, $OrderDirection);
if ($Limit !== FALSE)
$this->Limit($Limit, $Offset);
$Result = $this->Query($this->GetSelect());
return $Result;
} | php | public function GetWhere($Table = '', $Where = FALSE, $OrderFields = '', $OrderDirection = 'asc', $Limit = FALSE, $Offset = 0) {
if ($Table != '') {
//$this->MapAliases($Table);
$this->From($Table);
}
if ($Where !== FALSE)
$this->Where($Where);
if ($OrderFields != '')
$this->OrderBy($OrderFields, $OrderDirection);
if ($Limit !== FALSE)
$this->Limit($Limit, $Offset);
$Result = $this->Query($this->GetSelect());
return $Result;
} | [
"public",
"function",
"GetWhere",
"(",
"$",
"Table",
"=",
"''",
",",
"$",
"Where",
"=",
"FALSE",
",",
"$",
"OrderFields",
"=",
"''",
",",
"$",
"OrderDirection",
"=",
"'asc'",
",",
"$",
"Limit",
"=",
"FALSE",
",",
"$",
"Offset",
"=",
"0",
")",
"{",
"if",
"(",
"$",
"Table",
"!=",
"''",
")",
"{",
"//$this->MapAliases($Table);",
"$",
"this",
"->",
"From",
"(",
"$",
"Table",
")",
";",
"}",
"if",
"(",
"$",
"Where",
"!==",
"FALSE",
")",
"$",
"this",
"->",
"Where",
"(",
"$",
"Where",
")",
";",
"if",
"(",
"$",
"OrderFields",
"!=",
"''",
")",
"$",
"this",
"->",
"OrderBy",
"(",
"$",
"OrderFields",
",",
"$",
"OrderDirection",
")",
";",
"if",
"(",
"$",
"Limit",
"!==",
"FALSE",
")",
"$",
"this",
"->",
"Limit",
"(",
"$",
"Limit",
",",
"$",
"Offset",
")",
";",
"$",
"Result",
"=",
"$",
"this",
"->",
"Query",
"(",
"$",
"this",
"->",
"GetSelect",
"(",
")",
")",
";",
"return",
"$",
"Result",
";",
"}"
] | Builds the select statement and runs the query, returning a result
object. Allows a where clause, limit, and offset to be added directly.
@param string $Table The table from which to select data. Adds to the $this->_Froms collection.
@param mixed $Where Adds to the $this->_Wheres collection using $this->Where();
@param string $OrderFields A string of fields to be ordered.
@param string $OrderDirection The direction of the sort.
@param int $Limit The number of records to limit the query to.
@param int $Offset The offset where the query results should begin.
@return Gdn_DataSet The data returned by the query. | [
"Builds",
"the",
"select",
"statement",
"and",
"runs",
"the",
"query",
"returning",
"a",
"result",
"object",
".",
"Allows",
"a",
"where",
"clause",
"limit",
"and",
"offset",
"to",
"be",
"added",
"directly",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/database/class.sqldriver.php#L912-L930 |
8,280 | bishopb/vanilla | library/database/class.sqldriver.php | Gdn_SQLDriver.GetWhereLike | public function GetWhereLike($Table = '', $Like = FALSE, $OrderFields = '', $OrderDirection = 'asc', $Limit = FALSE, $PageNumber = FALSE) {
if ($Table != '') {
$this->MapAliases($Table);
$this->From($Table);
}
if ($Like !== FALSE)
$this->Like($Like);
if ($OrderFields != '')
$this->OrderBy($OrderFields, $OrderDirection);
if ($Limit !== FALSE) {
if ($PageNumber == FALSE || $PageNumber < 1)
$PageNumber = 1;
$Offset = ($PageNumber - 1) * $Limit;
$this->Limit($Limit, $Offset);
}
$Result = $this->Query($this->GetSelect());
return $Result;
} | php | public function GetWhereLike($Table = '', $Like = FALSE, $OrderFields = '', $OrderDirection = 'asc', $Limit = FALSE, $PageNumber = FALSE) {
if ($Table != '') {
$this->MapAliases($Table);
$this->From($Table);
}
if ($Like !== FALSE)
$this->Like($Like);
if ($OrderFields != '')
$this->OrderBy($OrderFields, $OrderDirection);
if ($Limit !== FALSE) {
if ($PageNumber == FALSE || $PageNumber < 1)
$PageNumber = 1;
$Offset = ($PageNumber - 1) * $Limit;
$this->Limit($Limit, $Offset);
}
$Result = $this->Query($this->GetSelect());
return $Result;
} | [
"public",
"function",
"GetWhereLike",
"(",
"$",
"Table",
"=",
"''",
",",
"$",
"Like",
"=",
"FALSE",
",",
"$",
"OrderFields",
"=",
"''",
",",
"$",
"OrderDirection",
"=",
"'asc'",
",",
"$",
"Limit",
"=",
"FALSE",
",",
"$",
"PageNumber",
"=",
"FALSE",
")",
"{",
"if",
"(",
"$",
"Table",
"!=",
"''",
")",
"{",
"$",
"this",
"->",
"MapAliases",
"(",
"$",
"Table",
")",
";",
"$",
"this",
"->",
"From",
"(",
"$",
"Table",
")",
";",
"}",
"if",
"(",
"$",
"Like",
"!==",
"FALSE",
")",
"$",
"this",
"->",
"Like",
"(",
"$",
"Like",
")",
";",
"if",
"(",
"$",
"OrderFields",
"!=",
"''",
")",
"$",
"this",
"->",
"OrderBy",
"(",
"$",
"OrderFields",
",",
"$",
"OrderDirection",
")",
";",
"if",
"(",
"$",
"Limit",
"!==",
"FALSE",
")",
"{",
"if",
"(",
"$",
"PageNumber",
"==",
"FALSE",
"||",
"$",
"PageNumber",
"<",
"1",
")",
"$",
"PageNumber",
"=",
"1",
";",
"$",
"Offset",
"=",
"(",
"$",
"PageNumber",
"-",
"1",
")",
"*",
"$",
"Limit",
";",
"$",
"this",
"->",
"Limit",
"(",
"$",
"Limit",
",",
"$",
"Offset",
")",
";",
"}",
"$",
"Result",
"=",
"$",
"this",
"->",
"Query",
"(",
"$",
"this",
"->",
"GetSelect",
"(",
")",
")",
";",
"return",
"$",
"Result",
";",
"}"
] | Builds the select statement and runs the query, returning a result
object. Allows a like clause, limit, and offset to be added directly.
@param string $Table The table from which to select data. Adds to the $this->_Froms collection.
@param mixed $Like Adds to the $this->_Wheres collection using $this->Like();
@param string $OrderFields A string of fields to be ordered.
@param string $OrderDirection The direction of the sort.
@param int $Limit The number of records to limit the query to.
@param int $PageNumber The offset where the query results should begin. | [
"Builds",
"the",
"select",
"statement",
"and",
"runs",
"the",
"query",
"returning",
"a",
"result",
"object",
".",
"Allows",
"a",
"like",
"clause",
"limit",
"and",
"offset",
"to",
"be",
"added",
"directly",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/database/class.sqldriver.php#L943-L966 |
8,281 | bishopb/vanilla | library/database/class.sqldriver.php | Gdn_SQLDriver.Insert | public function Insert($Table = '', $Set = NULL, $Select = '') {
if (count($Set) == 0 && count($this->_Sets) == 0) {
return FALSE;
}
if (!is_null($Set) && $Select == '' && !array_key_exists(0, $Set)) {
$this->Set($Set);
$Set = $this->_Sets;
}
if ($Table == '') {
if (!isset($this->_Froms[0]))
return FALSE;
$Table = $this->_Froms[0];
}
$Sql = $this->GetInsert($this->EscapeIdentifier($this->Database->DatabasePrefix.$Table), $Set, $Select);
$Result = $this->Query($Sql, 'insert');
return $Result;
} | php | public function Insert($Table = '', $Set = NULL, $Select = '') {
if (count($Set) == 0 && count($this->_Sets) == 0) {
return FALSE;
}
if (!is_null($Set) && $Select == '' && !array_key_exists(0, $Set)) {
$this->Set($Set);
$Set = $this->_Sets;
}
if ($Table == '') {
if (!isset($this->_Froms[0]))
return FALSE;
$Table = $this->_Froms[0];
}
$Sql = $this->GetInsert($this->EscapeIdentifier($this->Database->DatabasePrefix.$Table), $Set, $Select);
$Result = $this->Query($Sql, 'insert');
return $Result;
} | [
"public",
"function",
"Insert",
"(",
"$",
"Table",
"=",
"''",
",",
"$",
"Set",
"=",
"NULL",
",",
"$",
"Select",
"=",
"''",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"Set",
")",
"==",
"0",
"&&",
"count",
"(",
"$",
"this",
"->",
"_Sets",
")",
"==",
"0",
")",
"{",
"return",
"FALSE",
";",
"}",
"if",
"(",
"!",
"is_null",
"(",
"$",
"Set",
")",
"&&",
"$",
"Select",
"==",
"''",
"&&",
"!",
"array_key_exists",
"(",
"0",
",",
"$",
"Set",
")",
")",
"{",
"$",
"this",
"->",
"Set",
"(",
"$",
"Set",
")",
";",
"$",
"Set",
"=",
"$",
"this",
"->",
"_Sets",
";",
"}",
"if",
"(",
"$",
"Table",
"==",
"''",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_Froms",
"[",
"0",
"]",
")",
")",
"return",
"FALSE",
";",
"$",
"Table",
"=",
"$",
"this",
"->",
"_Froms",
"[",
"0",
"]",
";",
"}",
"$",
"Sql",
"=",
"$",
"this",
"->",
"GetInsert",
"(",
"$",
"this",
"->",
"EscapeIdentifier",
"(",
"$",
"this",
"->",
"Database",
"->",
"DatabasePrefix",
".",
"$",
"Table",
")",
",",
"$",
"Set",
",",
"$",
"Select",
")",
";",
"$",
"Result",
"=",
"$",
"this",
"->",
"Query",
"(",
"$",
"Sql",
",",
"'insert'",
")",
";",
"return",
"$",
"Result",
";",
"}"
] | Builds the insert statement and runs the query, returning a result
object.
@param string $Table The table to which data should be inserted.
@param mixed $Set An associative array (or object) of FieldName => Value pairs that should
be inserted, or an array of FieldName values that should have values
inserted from $Select.
@param string $Select A select query that will fill the FieldNames specified in $Set. | [
"Builds",
"the",
"insert",
"statement",
"and",
"runs",
"the",
"query",
"returning",
"a",
"result",
"object",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/database/class.sqldriver.php#L1096-L1117 |
8,282 | bishopb/vanilla | library/database/class.sqldriver.php | Gdn_SQLDriver.Replace | public function Replace($Table = '', $Set = NULL, $Where, $CheckExisting = FALSE) {
if(count($this->_Sets) > 0) {
foreach($this->_Sets as $Key => $Value) {
if(array_key_exists($Value, $this->_NamedParameters)) {
$Set[$Key] = $this->_NamedParameters[$Value];
unset($this->_NamedParameters[$Value]);
} else {
$Set[$Key] = $Value;
}
}
$this->_Sets = array();
}
// Check to see if there is a row in the table like this.
if ($CheckExisting) {
$Row = $this->GetWhere($Table, $Where)->FirstRow(DATASET_TYPE_ARRAY);
$Update = FALSE;
if ($Row) {
$Update = TRUE;
foreach ($Set as $Key => $Value) {
unset($Set[$Key]);
$Key = trim($Key, '`');
if (!$this->CaptureModifications && !array_key_exists($Key,$Row))
continue;
if (in_array($Key, array('DateInserted', 'InsertUserID', 'DateUpdated', 'UpdateUserID')))
continue;
// We are assuming here that if the existing record doesn't contain the column then it's just been added.
if (preg_match('/^`(.+)`$/', $Value, $Matches)) {
if (!array_key_exists($Key, $Row) || $Row[$Key] != $Row[$Matches[1]])
$this->Set('`'.$Key.'`', $Value, FALSE);
} elseif (!array_key_exists($Key, $Row) || $Row[$Key] != $Value) {
$this->Set('`'.$Key.'`', $Value);
}
}
if (count($this->_Sets) == 0) {
$this->Reset();
return;
}
}
} else {
$Count = $this->GetCount($Table, $Where);
$Update = $Count > 0;
}
if($Update) {
// Update the table.
$this->Put($Table, $Set, $Where);
} else {
// Insert the table.
$Set = array_merge($Set, $Where);
$this->Insert($Table, $Set);
}
} | php | public function Replace($Table = '', $Set = NULL, $Where, $CheckExisting = FALSE) {
if(count($this->_Sets) > 0) {
foreach($this->_Sets as $Key => $Value) {
if(array_key_exists($Value, $this->_NamedParameters)) {
$Set[$Key] = $this->_NamedParameters[$Value];
unset($this->_NamedParameters[$Value]);
} else {
$Set[$Key] = $Value;
}
}
$this->_Sets = array();
}
// Check to see if there is a row in the table like this.
if ($CheckExisting) {
$Row = $this->GetWhere($Table, $Where)->FirstRow(DATASET_TYPE_ARRAY);
$Update = FALSE;
if ($Row) {
$Update = TRUE;
foreach ($Set as $Key => $Value) {
unset($Set[$Key]);
$Key = trim($Key, '`');
if (!$this->CaptureModifications && !array_key_exists($Key,$Row))
continue;
if (in_array($Key, array('DateInserted', 'InsertUserID', 'DateUpdated', 'UpdateUserID')))
continue;
// We are assuming here that if the existing record doesn't contain the column then it's just been added.
if (preg_match('/^`(.+)`$/', $Value, $Matches)) {
if (!array_key_exists($Key, $Row) || $Row[$Key] != $Row[$Matches[1]])
$this->Set('`'.$Key.'`', $Value, FALSE);
} elseif (!array_key_exists($Key, $Row) || $Row[$Key] != $Value) {
$this->Set('`'.$Key.'`', $Value);
}
}
if (count($this->_Sets) == 0) {
$this->Reset();
return;
}
}
} else {
$Count = $this->GetCount($Table, $Where);
$Update = $Count > 0;
}
if($Update) {
// Update the table.
$this->Put($Table, $Set, $Where);
} else {
// Insert the table.
$Set = array_merge($Set, $Where);
$this->Insert($Table, $Set);
}
} | [
"public",
"function",
"Replace",
"(",
"$",
"Table",
"=",
"''",
",",
"$",
"Set",
"=",
"NULL",
",",
"$",
"Where",
",",
"$",
"CheckExisting",
"=",
"FALSE",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"_Sets",
")",
">",
"0",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"_Sets",
"as",
"$",
"Key",
"=>",
"$",
"Value",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"Value",
",",
"$",
"this",
"->",
"_NamedParameters",
")",
")",
"{",
"$",
"Set",
"[",
"$",
"Key",
"]",
"=",
"$",
"this",
"->",
"_NamedParameters",
"[",
"$",
"Value",
"]",
";",
"unset",
"(",
"$",
"this",
"->",
"_NamedParameters",
"[",
"$",
"Value",
"]",
")",
";",
"}",
"else",
"{",
"$",
"Set",
"[",
"$",
"Key",
"]",
"=",
"$",
"Value",
";",
"}",
"}",
"$",
"this",
"->",
"_Sets",
"=",
"array",
"(",
")",
";",
"}",
"// Check to see if there is a row in the table like this.",
"if",
"(",
"$",
"CheckExisting",
")",
"{",
"$",
"Row",
"=",
"$",
"this",
"->",
"GetWhere",
"(",
"$",
"Table",
",",
"$",
"Where",
")",
"->",
"FirstRow",
"(",
"DATASET_TYPE_ARRAY",
")",
";",
"$",
"Update",
"=",
"FALSE",
";",
"if",
"(",
"$",
"Row",
")",
"{",
"$",
"Update",
"=",
"TRUE",
";",
"foreach",
"(",
"$",
"Set",
"as",
"$",
"Key",
"=>",
"$",
"Value",
")",
"{",
"unset",
"(",
"$",
"Set",
"[",
"$",
"Key",
"]",
")",
";",
"$",
"Key",
"=",
"trim",
"(",
"$",
"Key",
",",
"'`'",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"CaptureModifications",
"&&",
"!",
"array_key_exists",
"(",
"$",
"Key",
",",
"$",
"Row",
")",
")",
"continue",
";",
"if",
"(",
"in_array",
"(",
"$",
"Key",
",",
"array",
"(",
"'DateInserted'",
",",
"'InsertUserID'",
",",
"'DateUpdated'",
",",
"'UpdateUserID'",
")",
")",
")",
"continue",
";",
"// We are assuming here that if the existing record doesn't contain the column then it's just been added.",
"if",
"(",
"preg_match",
"(",
"'/^`(.+)`$/'",
",",
"$",
"Value",
",",
"$",
"Matches",
")",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"Key",
",",
"$",
"Row",
")",
"||",
"$",
"Row",
"[",
"$",
"Key",
"]",
"!=",
"$",
"Row",
"[",
"$",
"Matches",
"[",
"1",
"]",
"]",
")",
"$",
"this",
"->",
"Set",
"(",
"'`'",
".",
"$",
"Key",
".",
"'`'",
",",
"$",
"Value",
",",
"FALSE",
")",
";",
"}",
"elseif",
"(",
"!",
"array_key_exists",
"(",
"$",
"Key",
",",
"$",
"Row",
")",
"||",
"$",
"Row",
"[",
"$",
"Key",
"]",
"!=",
"$",
"Value",
")",
"{",
"$",
"this",
"->",
"Set",
"(",
"'`'",
".",
"$",
"Key",
".",
"'`'",
",",
"$",
"Value",
")",
";",
"}",
"}",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"_Sets",
")",
"==",
"0",
")",
"{",
"$",
"this",
"->",
"Reset",
"(",
")",
";",
"return",
";",
"}",
"}",
"}",
"else",
"{",
"$",
"Count",
"=",
"$",
"this",
"->",
"GetCount",
"(",
"$",
"Table",
",",
"$",
"Where",
")",
";",
"$",
"Update",
"=",
"$",
"Count",
">",
"0",
";",
"}",
"if",
"(",
"$",
"Update",
")",
"{",
"// Update the table.",
"$",
"this",
"->",
"Put",
"(",
"$",
"Table",
",",
"$",
"Set",
",",
"$",
"Where",
")",
";",
"}",
"else",
"{",
"// Insert the table.",
"$",
"Set",
"=",
"array_merge",
"(",
"$",
"Set",
",",
"$",
"Where",
")",
";",
"$",
"this",
"->",
"Insert",
"(",
"$",
"Table",
",",
"$",
"Set",
")",
";",
"}",
"}"
] | Inserts or updates values in the table depending on whether they are already there.
@param string $Table The name of the table to insert/update.
@param array $Set The columns to update.
@param array $Where The columns to find the row to update.
If a row is not found then one is inserted and the items in this array are merged with $Set. | [
"Inserts",
"or",
"updates",
"values",
"in",
"the",
"table",
"depending",
"on",
"whether",
"they",
"are",
"already",
"there",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/database/class.sqldriver.php#L1127-L1185 |
8,283 | bishopb/vanilla | library/database/class.sqldriver.php | Gdn_SQLDriver.MapAliases | public function MapAliases($TableString) {
// Make sure all tables have an alias.
if(strpos($TableString, ' ') === FALSE) {
$TableString .= " `$TableString`";
}
// Map the alias to the alias mapping array
$TableString = trim(preg_replace('/\s+as\s+/i', ' ', $TableString));
$Alias = strrchr($TableString, " ");
$TableName = substr($TableString, 0, strlen($TableString) - strlen($Alias));
// If no alias was specified then it will be set to the tablename.
$Alias = trim($Alias);
if(strlen($Alias) == 0) {
$Alias = $TableName;
$TableString .= " `$Alias`";
}
//$this->_AliasMap[$Alias] = $TableName;
// Return the string with the database table prefix prepended
return $this->Database->DatabasePrefix . $TableString;
} | php | public function MapAliases($TableString) {
// Make sure all tables have an alias.
if(strpos($TableString, ' ') === FALSE) {
$TableString .= " `$TableString`";
}
// Map the alias to the alias mapping array
$TableString = trim(preg_replace('/\s+as\s+/i', ' ', $TableString));
$Alias = strrchr($TableString, " ");
$TableName = substr($TableString, 0, strlen($TableString) - strlen($Alias));
// If no alias was specified then it will be set to the tablename.
$Alias = trim($Alias);
if(strlen($Alias) == 0) {
$Alias = $TableName;
$TableString .= " `$Alias`";
}
//$this->_AliasMap[$Alias] = $TableName;
// Return the string with the database table prefix prepended
return $this->Database->DatabasePrefix . $TableString;
} | [
"public",
"function",
"MapAliases",
"(",
"$",
"TableString",
")",
"{",
"// Make sure all tables have an alias.",
"if",
"(",
"strpos",
"(",
"$",
"TableString",
",",
"' '",
")",
"===",
"FALSE",
")",
"{",
"$",
"TableString",
".=",
"\" `$TableString`\"",
";",
"}",
"// Map the alias to the alias mapping array",
"$",
"TableString",
"=",
"trim",
"(",
"preg_replace",
"(",
"'/\\s+as\\s+/i'",
",",
"' '",
",",
"$",
"TableString",
")",
")",
";",
"$",
"Alias",
"=",
"strrchr",
"(",
"$",
"TableString",
",",
"\" \"",
")",
";",
"$",
"TableName",
"=",
"substr",
"(",
"$",
"TableString",
",",
"0",
",",
"strlen",
"(",
"$",
"TableString",
")",
"-",
"strlen",
"(",
"$",
"Alias",
")",
")",
";",
"// If no alias was specified then it will be set to the tablename.",
"$",
"Alias",
"=",
"trim",
"(",
"$",
"Alias",
")",
";",
"if",
"(",
"strlen",
"(",
"$",
"Alias",
")",
"==",
"0",
")",
"{",
"$",
"Alias",
"=",
"$",
"TableName",
";",
"$",
"TableString",
".=",
"\" `$Alias`\"",
";",
"}",
"//$this->_AliasMap[$Alias] = $TableName;",
"// Return the string with the database table prefix prepended",
"return",
"$",
"this",
"->",
"Database",
"->",
"DatabasePrefix",
".",
"$",
"TableString",
";",
"}"
] | Takes a provided table specification and parses out any table aliases
provided, placing them in an alias mapping array. Returns the table
specification with any table prefix prepended.
@param string $TableString The string specification of the table. ie.
"tbl_User as u" or "user u".
@return string | [
"Takes",
"a",
"provided",
"table",
"specification",
"and",
"parses",
"out",
"any",
"table",
"aliases",
"provided",
"placing",
"them",
"in",
"an",
"alias",
"mapping",
"array",
".",
"Returns",
"the",
"table",
"specification",
"with",
"any",
"table",
"prefix",
"prepended",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/database/class.sqldriver.php#L1294-L1316 |
8,284 | bishopb/vanilla | library/database/class.sqldriver.php | Gdn_SQLDriver.NamedParameter | public function NamedParameter($Name, $CreateNew = FALSE, $Value = NULL) {
// Format the parameter name so it is safe for sql
$NiceName = ':'.preg_replace('/([^\w\d_-])/', '', $Name); // Removes everything from the string except letters, numbers, dashes, and underscores
if($CreateNew) {
// Make sure that the new name doesn't already exist.
$NumberedName = $NiceName;
$i = 0;
while (array_key_exists($NumberedName, $this->_NamedParameters)) {
$NumberedName = $NiceName.$i;
++$i;
}
$NiceName = $NumberedName;
}
if(!is_null($Value)) {
$this->_NamedParameters[$NiceName] = $Value;
}
return $NiceName;
} | php | public function NamedParameter($Name, $CreateNew = FALSE, $Value = NULL) {
// Format the parameter name so it is safe for sql
$NiceName = ':'.preg_replace('/([^\w\d_-])/', '', $Name); // Removes everything from the string except letters, numbers, dashes, and underscores
if($CreateNew) {
// Make sure that the new name doesn't already exist.
$NumberedName = $NiceName;
$i = 0;
while (array_key_exists($NumberedName, $this->_NamedParameters)) {
$NumberedName = $NiceName.$i;
++$i;
}
$NiceName = $NumberedName;
}
if(!is_null($Value)) {
$this->_NamedParameters[$NiceName] = $Value;
}
return $NiceName;
} | [
"public",
"function",
"NamedParameter",
"(",
"$",
"Name",
",",
"$",
"CreateNew",
"=",
"FALSE",
",",
"$",
"Value",
"=",
"NULL",
")",
"{",
"// Format the parameter name so it is safe for sql",
"$",
"NiceName",
"=",
"':'",
".",
"preg_replace",
"(",
"'/([^\\w\\d_-])/'",
",",
"''",
",",
"$",
"Name",
")",
";",
"// Removes everything from the string except letters, numbers, dashes, and underscores",
"if",
"(",
"$",
"CreateNew",
")",
"{",
"// Make sure that the new name doesn't already exist.",
"$",
"NumberedName",
"=",
"$",
"NiceName",
";",
"$",
"i",
"=",
"0",
";",
"while",
"(",
"array_key_exists",
"(",
"$",
"NumberedName",
",",
"$",
"this",
"->",
"_NamedParameters",
")",
")",
"{",
"$",
"NumberedName",
"=",
"$",
"NiceName",
".",
"$",
"i",
";",
"++",
"$",
"i",
";",
"}",
"$",
"NiceName",
"=",
"$",
"NumberedName",
";",
"}",
"if",
"(",
"!",
"is_null",
"(",
"$",
"Value",
")",
")",
"{",
"$",
"this",
"->",
"_NamedParameters",
"[",
"$",
"NiceName",
"]",
"=",
"$",
"Value",
";",
"}",
"return",
"$",
"NiceName",
";",
"}"
] | Takes a parameter name and makes sure it is cleaned up to be used as a
named parameter in a pdo prepared statement.
@param string $Name The name of the parameter to cleanup
@param boolean $CreateNew Wether or not this is a new or existing parameter.
@return string The cleaned up named parameter name. | [
"Takes",
"a",
"parameter",
"name",
"and",
"makes",
"sure",
"it",
"is",
"cleaned",
"up",
"to",
"be",
"used",
"as",
"a",
"named",
"parameter",
"in",
"a",
"pdo",
"prepared",
"statement",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/database/class.sqldriver.php#L1333-L1353 |
8,285 | bishopb/vanilla | library/database/class.sqldriver.php | Gdn_SQLDriver._ParseExpr | protected function _ParseExpr($Expr, $Name = NULL, $EscapeExpr = FALSE) {
$Result = '';
$C = substr($Expr, 0, 1);
if($C === '=' && $EscapeExpr === FALSE) {
// This is a function call. Each parameter has to be parsed.
$FunctionArray = preg_split('/(\[[^\]]+\])/', substr($Expr, 1), -1, PREG_SPLIT_DELIM_CAPTURE);
for($i = 0; $i < count($FunctionArray); $i++) {
$Part = $FunctionArray[$i];
if(substr($Part, 1) == '[') {
// Translate the part of the function call.
$Part = $this->_FieldExpr(substr($Part, 1, strlen($Part) - 2), $Name);
$FunctionArray[$i] = $Part;
}
}
// Combine the array back to the original function call.
$Result = join($FunctionArray);
} elseif($C === '@' && $EscapeExpr === FALSE) {
// This is a literal. Don't do anything.
$Result = substr($Expr, 1);
} else {
// This is a column reference.
if(is_null($Name)) {
$Result = $this->EscapeIdentifier($Expr);
} else {
// This is a named parameter.
// Check to see if the named parameter is valid.
if(in_array(substr($Expr, 0, 1), array('=', '@'))) {
// The parameter has to be a default name.
$Result = $this->NamedParameter('Param', TRUE);
} else {
$Result = $this->NamedParameter($Name, TRUE);
}
$this->_NamedParameters[$Result] = $Expr;
}
}
return $Result;
} | php | protected function _ParseExpr($Expr, $Name = NULL, $EscapeExpr = FALSE) {
$Result = '';
$C = substr($Expr, 0, 1);
if($C === '=' && $EscapeExpr === FALSE) {
// This is a function call. Each parameter has to be parsed.
$FunctionArray = preg_split('/(\[[^\]]+\])/', substr($Expr, 1), -1, PREG_SPLIT_DELIM_CAPTURE);
for($i = 0; $i < count($FunctionArray); $i++) {
$Part = $FunctionArray[$i];
if(substr($Part, 1) == '[') {
// Translate the part of the function call.
$Part = $this->_FieldExpr(substr($Part, 1, strlen($Part) - 2), $Name);
$FunctionArray[$i] = $Part;
}
}
// Combine the array back to the original function call.
$Result = join($FunctionArray);
} elseif($C === '@' && $EscapeExpr === FALSE) {
// This is a literal. Don't do anything.
$Result = substr($Expr, 1);
} else {
// This is a column reference.
if(is_null($Name)) {
$Result = $this->EscapeIdentifier($Expr);
} else {
// This is a named parameter.
// Check to see if the named parameter is valid.
if(in_array(substr($Expr, 0, 1), array('=', '@'))) {
// The parameter has to be a default name.
$Result = $this->NamedParameter('Param', TRUE);
} else {
$Result = $this->NamedParameter($Name, TRUE);
}
$this->_NamedParameters[$Result] = $Expr;
}
}
return $Result;
} | [
"protected",
"function",
"_ParseExpr",
"(",
"$",
"Expr",
",",
"$",
"Name",
"=",
"NULL",
",",
"$",
"EscapeExpr",
"=",
"FALSE",
")",
"{",
"$",
"Result",
"=",
"''",
";",
"$",
"C",
"=",
"substr",
"(",
"$",
"Expr",
",",
"0",
",",
"1",
")",
";",
"if",
"(",
"$",
"C",
"===",
"'='",
"&&",
"$",
"EscapeExpr",
"===",
"FALSE",
")",
"{",
"// This is a function call. Each parameter has to be parsed.",
"$",
"FunctionArray",
"=",
"preg_split",
"(",
"'/(\\[[^\\]]+\\])/'",
",",
"substr",
"(",
"$",
"Expr",
",",
"1",
")",
",",
"-",
"1",
",",
"PREG_SPLIT_DELIM_CAPTURE",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"count",
"(",
"$",
"FunctionArray",
")",
";",
"$",
"i",
"++",
")",
"{",
"$",
"Part",
"=",
"$",
"FunctionArray",
"[",
"$",
"i",
"]",
";",
"if",
"(",
"substr",
"(",
"$",
"Part",
",",
"1",
")",
"==",
"'['",
")",
"{",
"// Translate the part of the function call.",
"$",
"Part",
"=",
"$",
"this",
"->",
"_FieldExpr",
"(",
"substr",
"(",
"$",
"Part",
",",
"1",
",",
"strlen",
"(",
"$",
"Part",
")",
"-",
"2",
")",
",",
"$",
"Name",
")",
";",
"$",
"FunctionArray",
"[",
"$",
"i",
"]",
"=",
"$",
"Part",
";",
"}",
"}",
"// Combine the array back to the original function call.",
"$",
"Result",
"=",
"join",
"(",
"$",
"FunctionArray",
")",
";",
"}",
"elseif",
"(",
"$",
"C",
"===",
"'@'",
"&&",
"$",
"EscapeExpr",
"===",
"FALSE",
")",
"{",
"// This is a literal. Don't do anything.",
"$",
"Result",
"=",
"substr",
"(",
"$",
"Expr",
",",
"1",
")",
";",
"}",
"else",
"{",
"// This is a column reference.",
"if",
"(",
"is_null",
"(",
"$",
"Name",
")",
")",
"{",
"$",
"Result",
"=",
"$",
"this",
"->",
"EscapeIdentifier",
"(",
"$",
"Expr",
")",
";",
"}",
"else",
"{",
"// This is a named parameter.",
"// Check to see if the named parameter is valid.",
"if",
"(",
"in_array",
"(",
"substr",
"(",
"$",
"Expr",
",",
"0",
",",
"1",
")",
",",
"array",
"(",
"'='",
",",
"'@'",
")",
")",
")",
"{",
"// The parameter has to be a default name.",
"$",
"Result",
"=",
"$",
"this",
"->",
"NamedParameter",
"(",
"'Param'",
",",
"TRUE",
")",
";",
"}",
"else",
"{",
"$",
"Result",
"=",
"$",
"this",
"->",
"NamedParameter",
"(",
"$",
"Name",
",",
"TRUE",
")",
";",
"}",
"$",
"this",
"->",
"_NamedParameters",
"[",
"$",
"Result",
"]",
"=",
"$",
"Expr",
";",
"}",
"}",
"return",
"$",
"Result",
";",
"}"
] | Parses an expression for use in where clauses.
@param string $Expr The expression to parse.
@param string $Name A name to give the parameter if $Expr becomes a named parameter.
@return string The parsed expression. | [
"Parses",
"an",
"expression",
"for",
"use",
"in",
"where",
"clauses",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/database/class.sqldriver.php#L1525-L1565 |
8,286 | bishopb/vanilla | library/database/class.sqldriver.php | Gdn_SQLDriver.PrefixTable | public function PrefixTable($Table) {
$Prefix = $this->Database->DatabasePrefix;
if ($Prefix != '' && substr($Table, 0, strlen($Prefix)) != $Prefix)
$Table = $Prefix.$Table;
return $Table;
} | php | public function PrefixTable($Table) {
$Prefix = $this->Database->DatabasePrefix;
if ($Prefix != '' && substr($Table, 0, strlen($Prefix)) != $Prefix)
$Table = $Prefix.$Table;
return $Table;
} | [
"public",
"function",
"PrefixTable",
"(",
"$",
"Table",
")",
"{",
"$",
"Prefix",
"=",
"$",
"this",
"->",
"Database",
"->",
"DatabasePrefix",
";",
"if",
"(",
"$",
"Prefix",
"!=",
"''",
"&&",
"substr",
"(",
"$",
"Table",
",",
"0",
",",
"strlen",
"(",
"$",
"Prefix",
")",
")",
"!=",
"$",
"Prefix",
")",
"$",
"Table",
"=",
"$",
"Prefix",
".",
"$",
"Table",
";",
"return",
"$",
"Table",
";",
"}"
] | Prefixes a table with the database prefix if it is not already there.
@param string $Table The table name to prefix. | [
"Prefixes",
"a",
"table",
"with",
"the",
"database",
"prefix",
"if",
"it",
"is",
"not",
"already",
"there",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/database/class.sqldriver.php#L1588-L1595 |
8,287 | bishopb/vanilla | library/database/class.sqldriver.php | Gdn_SQLDriver.Put | public function Put($Table = '', $Set = NULL, $Where = FALSE, $Limit = FALSE) {
$this->Update($Table, $Set, $Where, $Limit);
if (count($this->_Sets) == 0 || !isset($this->_Froms[0])) {
$this->Reset();
return FALSE;
}
$Sql = $this->GetUpdate($this->_Froms, $this->_Sets, $this->_Wheres, $this->_OrderBys, $this->_Limit);
$Result = $this->Query($Sql, 'update');
return $Result;
} | php | public function Put($Table = '', $Set = NULL, $Where = FALSE, $Limit = FALSE) {
$this->Update($Table, $Set, $Where, $Limit);
if (count($this->_Sets) == 0 || !isset($this->_Froms[0])) {
$this->Reset();
return FALSE;
}
$Sql = $this->GetUpdate($this->_Froms, $this->_Sets, $this->_Wheres, $this->_OrderBys, $this->_Limit);
$Result = $this->Query($Sql, 'update');
return $Result;
} | [
"public",
"function",
"Put",
"(",
"$",
"Table",
"=",
"''",
",",
"$",
"Set",
"=",
"NULL",
",",
"$",
"Where",
"=",
"FALSE",
",",
"$",
"Limit",
"=",
"FALSE",
")",
"{",
"$",
"this",
"->",
"Update",
"(",
"$",
"Table",
",",
"$",
"Set",
",",
"$",
"Where",
",",
"$",
"Limit",
")",
";",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"_Sets",
")",
"==",
"0",
"||",
"!",
"isset",
"(",
"$",
"this",
"->",
"_Froms",
"[",
"0",
"]",
")",
")",
"{",
"$",
"this",
"->",
"Reset",
"(",
")",
";",
"return",
"FALSE",
";",
"}",
"$",
"Sql",
"=",
"$",
"this",
"->",
"GetUpdate",
"(",
"$",
"this",
"->",
"_Froms",
",",
"$",
"this",
"->",
"_Sets",
",",
"$",
"this",
"->",
"_Wheres",
",",
"$",
"this",
"->",
"_OrderBys",
",",
"$",
"this",
"->",
"_Limit",
")",
";",
"$",
"Result",
"=",
"$",
"this",
"->",
"Query",
"(",
"$",
"Sql",
",",
"'update'",
")",
";",
"return",
"$",
"Result",
";",
"}"
] | Builds the update statement and runs the query, returning a result object.
@param string $Table The table to which data should be updated.
@param mixed $Set An array of $FieldName => $Value pairs, or an object of $DataSet->Field
properties containing one rowset.
@param string $Where Adds to the $this->_Wheres collection using $this->Where();
@param int $Limit Adds a limit to the query. | [
"Builds",
"the",
"update",
"statement",
"and",
"runs",
"the",
"query",
"returning",
"a",
"result",
"object",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/database/class.sqldriver.php#L1606-L1618 |
8,288 | bishopb/vanilla | library/database/class.sqldriver.php | Gdn_SQLDriver.SelectCase | public function SelectCase($Field, $Options, $Alias) {
$CaseOptions = '';
foreach ($Options as $Key => $Val) {
if ($Key == '')
$CaseOptions .= ' else ' . $Val;
else
$CaseOptions .= ' when ' . $Key . ' then ' . $Val;
}
$Expr = array('Field' => $Field, 'Function' => '', 'Alias' => $Alias, 'CaseOptions' => $CaseOptions);
if($Alias == '')
$this->_Selects[] = $Expr;
else
$this->_Selects[$Alias] = $Expr;
return $this;
} | php | public function SelectCase($Field, $Options, $Alias) {
$CaseOptions = '';
foreach ($Options as $Key => $Val) {
if ($Key == '')
$CaseOptions .= ' else ' . $Val;
else
$CaseOptions .= ' when ' . $Key . ' then ' . $Val;
}
$Expr = array('Field' => $Field, 'Function' => '', 'Alias' => $Alias, 'CaseOptions' => $CaseOptions);
if($Alias == '')
$this->_Selects[] = $Expr;
else
$this->_Selects[$Alias] = $Expr;
return $this;
} | [
"public",
"function",
"SelectCase",
"(",
"$",
"Field",
",",
"$",
"Options",
",",
"$",
"Alias",
")",
"{",
"$",
"CaseOptions",
"=",
"''",
";",
"foreach",
"(",
"$",
"Options",
"as",
"$",
"Key",
"=>",
"$",
"Val",
")",
"{",
"if",
"(",
"$",
"Key",
"==",
"''",
")",
"$",
"CaseOptions",
".=",
"' else '",
".",
"$",
"Val",
";",
"else",
"$",
"CaseOptions",
".=",
"' when '",
".",
"$",
"Key",
".",
"' then '",
".",
"$",
"Val",
";",
"}",
"$",
"Expr",
"=",
"array",
"(",
"'Field'",
"=>",
"$",
"Field",
",",
"'Function'",
"=>",
"''",
",",
"'Alias'",
"=>",
"$",
"Alias",
",",
"'CaseOptions'",
"=>",
"$",
"CaseOptions",
")",
";",
"if",
"(",
"$",
"Alias",
"==",
"''",
")",
"$",
"this",
"->",
"_Selects",
"[",
"]",
"=",
"$",
"Expr",
";",
"else",
"$",
"this",
"->",
"_Selects",
"[",
"$",
"Alias",
"]",
"=",
"$",
"Expr",
";",
"return",
"$",
"this",
";",
"}"
] | Allows the specification of a case statement in the select list.
@param string $Field The field being examined in the case statement.
@param array $Options The options and results in an associative array. A
blank key will be the final "else" option of the case statement. eg.
array('null' => 1, '' => 0) results in "when null then 1 else 0".
@param string $Alias The alias to give a column name. | [
"Allows",
"the",
"specification",
"of",
"a",
"case",
"statement",
"in",
"the",
"select",
"list",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/database/class.sqldriver.php#L1768-L1785 |
8,289 | synapsestudios/synapse-base | src/Synapse/Controller/ControllerServiceProvider.php | ControllerServiceProvider.register | public function register(Application $app)
{
$app['resolver'] = $app->share($app->extend('resolver', function ($resolver, $app) {
return new Resolver($resolver, $app);
}));
$app->initializer(
'Synapse\\Application\\UrlGeneratorAwareInterface',
function ($object, $app) {
$object->setUrlGenerator($app['url_generator']);
return $object;
}
);
$app->initializer(
'Synapse\\Debug\\DebugModeAwareInterface',
function ($object, $app) {
$object->setDebug($app['debug']);
return $object;
}
);
} | php | public function register(Application $app)
{
$app['resolver'] = $app->share($app->extend('resolver', function ($resolver, $app) {
return new Resolver($resolver, $app);
}));
$app->initializer(
'Synapse\\Application\\UrlGeneratorAwareInterface',
function ($object, $app) {
$object->setUrlGenerator($app['url_generator']);
return $object;
}
);
$app->initializer(
'Synapse\\Debug\\DebugModeAwareInterface',
function ($object, $app) {
$object->setDebug($app['debug']);
return $object;
}
);
} | [
"public",
"function",
"register",
"(",
"Application",
"$",
"app",
")",
"{",
"$",
"app",
"[",
"'resolver'",
"]",
"=",
"$",
"app",
"->",
"share",
"(",
"$",
"app",
"->",
"extend",
"(",
"'resolver'",
",",
"function",
"(",
"$",
"resolver",
",",
"$",
"app",
")",
"{",
"return",
"new",
"Resolver",
"(",
"$",
"resolver",
",",
"$",
"app",
")",
";",
"}",
")",
")",
";",
"$",
"app",
"->",
"initializer",
"(",
"'Synapse\\\\Application\\\\UrlGeneratorAwareInterface'",
",",
"function",
"(",
"$",
"object",
",",
"$",
"app",
")",
"{",
"$",
"object",
"->",
"setUrlGenerator",
"(",
"$",
"app",
"[",
"'url_generator'",
"]",
")",
";",
"return",
"$",
"object",
";",
"}",
")",
";",
"$",
"app",
"->",
"initializer",
"(",
"'Synapse\\\\Debug\\\\DebugModeAwareInterface'",
",",
"function",
"(",
"$",
"object",
",",
"$",
"app",
")",
"{",
"$",
"object",
"->",
"setDebug",
"(",
"$",
"app",
"[",
"'debug'",
"]",
")",
";",
"return",
"$",
"object",
";",
"}",
")",
";",
"}"
] | Register the controller resolver and initializers
@param Application $app | [
"Register",
"the",
"controller",
"resolver",
"and",
"initializers"
] | 60c830550491742a077ab063f924e2f0b63825da | https://github.com/synapsestudios/synapse-base/blob/60c830550491742a077ab063f924e2f0b63825da/src/Synapse/Controller/ControllerServiceProvider.php#L15-L36 |
8,290 | Innmind/RestBundle | Client/ServerFactory.php | ServerFactory.make | public function make($host)
{
$host = $this->resolver->resolve($host, '/');
$hash = md5($host);
if (isset($this->instances[$hash])) {
return $this->instances[$hash];
}
$validator = new Validator(
$this->validator,
new ResourceNormalizer
);
$instance = new Server(
$this->capabilities->make($host),
new Client(
$this->loader->make($host),
$this->serializer,
$this->resolver,
$validator,
$this->dispatcher,
$this->http
)
);
$this->instances[$hash] = $instance;
return $instance;
} | php | public function make($host)
{
$host = $this->resolver->resolve($host, '/');
$hash = md5($host);
if (isset($this->instances[$hash])) {
return $this->instances[$hash];
}
$validator = new Validator(
$this->validator,
new ResourceNormalizer
);
$instance = new Server(
$this->capabilities->make($host),
new Client(
$this->loader->make($host),
$this->serializer,
$this->resolver,
$validator,
$this->dispatcher,
$this->http
)
);
$this->instances[$hash] = $instance;
return $instance;
} | [
"public",
"function",
"make",
"(",
"$",
"host",
")",
"{",
"$",
"host",
"=",
"$",
"this",
"->",
"resolver",
"->",
"resolve",
"(",
"$",
"host",
",",
"'/'",
")",
";",
"$",
"hash",
"=",
"md5",
"(",
"$",
"host",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"instances",
"[",
"$",
"hash",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"instances",
"[",
"$",
"hash",
"]",
";",
"}",
"$",
"validator",
"=",
"new",
"Validator",
"(",
"$",
"this",
"->",
"validator",
",",
"new",
"ResourceNormalizer",
")",
";",
"$",
"instance",
"=",
"new",
"Server",
"(",
"$",
"this",
"->",
"capabilities",
"->",
"make",
"(",
"$",
"host",
")",
",",
"new",
"Client",
"(",
"$",
"this",
"->",
"loader",
"->",
"make",
"(",
"$",
"host",
")",
",",
"$",
"this",
"->",
"serializer",
",",
"$",
"this",
"->",
"resolver",
",",
"$",
"validator",
",",
"$",
"this",
"->",
"dispatcher",
",",
"$",
"this",
"->",
"http",
")",
")",
";",
"$",
"this",
"->",
"instances",
"[",
"$",
"hash",
"]",
"=",
"$",
"instance",
";",
"return",
"$",
"instance",
";",
"}"
] | Make a server object for the given host
@param string $host
@return Server | [
"Make",
"a",
"server",
"object",
"for",
"the",
"given",
"host"
] | 46de57d9b45dfbfcf98867be3c601fba57f2edc2 | https://github.com/Innmind/RestBundle/blob/46de57d9b45dfbfcf98867be3c601fba57f2edc2/Client/ServerFactory.php#L51-L78 |
8,291 | kambo-1st/KamboRouter | src/Dispatcher/ClosureAutoBind.php | ClosureAutoBind.setNotFoundHandler | public function setNotFoundHandler($handler) : ClosureAutoBind
{
if (!$this->isClosure($handler)) {
throw new InvalidArgumentException(
'Handler must be closure'
);
}
$this->notFoundHandler = $handler;
return $this;
} | php | public function setNotFoundHandler($handler) : ClosureAutoBind
{
if (!$this->isClosure($handler)) {
throw new InvalidArgumentException(
'Handler must be closure'
);
}
$this->notFoundHandler = $handler;
return $this;
} | [
"public",
"function",
"setNotFoundHandler",
"(",
"$",
"handler",
")",
":",
"ClosureAutoBind",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isClosure",
"(",
"$",
"handler",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Handler must be closure'",
")",
";",
"}",
"$",
"this",
"->",
"notFoundHandler",
"=",
"$",
"handler",
";",
"return",
"$",
"this",
";",
"}"
] | Sets not found handler
@param Closure $handler handler that will be excuted if nothing has been
found
@return self for fluent interface
@throws InvalidArgumentException if the provided value is not closure | [
"Sets",
"not",
"found",
"handler"
] | 32ad63ab1c5483714868d5acbbc67beb2f0b1cda | https://github.com/kambo-1st/KamboRouter/blob/32ad63ab1c5483714868d5acbbc67beb2f0b1cda/src/Dispatcher/ClosureAutoBind.php#L82-L93 |
8,292 | kambo-1st/KamboRouter | src/Dispatcher/ClosureAutoBind.php | ClosureAutoBind.getFunctionArguments | private function getFunctionArguments(array $paramMap, array $matches, array $parameters) : array
{
$output = [];
$matches = array_values($matches);
foreach ($parameters as $valueName) {
foreach ($paramMap as $possition => $value) {
if ($value == $valueName[1][0]) {
$output[] = $matches[$possition];
}
}
}
return $output;
} | php | private function getFunctionArguments(array $paramMap, array $matches, array $parameters) : array
{
$output = [];
$matches = array_values($matches);
foreach ($parameters as $valueName) {
foreach ($paramMap as $possition => $value) {
if ($value == $valueName[1][0]) {
$output[] = $matches[$possition];
}
}
}
return $output;
} | [
"private",
"function",
"getFunctionArguments",
"(",
"array",
"$",
"paramMap",
",",
"array",
"$",
"matches",
",",
"array",
"$",
"parameters",
")",
":",
"array",
"{",
"$",
"output",
"=",
"[",
"]",
";",
"$",
"matches",
"=",
"array_values",
"(",
"$",
"matches",
")",
";",
"foreach",
"(",
"$",
"parameters",
"as",
"$",
"valueName",
")",
"{",
"foreach",
"(",
"$",
"paramMap",
"as",
"$",
"possition",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"==",
"$",
"valueName",
"[",
"1",
"]",
"[",
"0",
"]",
")",
"{",
"$",
"output",
"[",
"]",
"=",
"$",
"matches",
"[",
"$",
"possition",
"]",
";",
"}",
"}",
"}",
"return",
"$",
"output",
";",
"}"
] | Get arguments for closure function in proper order
from provided parameters
@param array $paramMap parameter map for getting proper order
@param array $matches parameters from request
@param array $parameters expected parameters from route
@return array Parameters in right order, if there are not any
parametrs an empty array is returned. | [
"Get",
"arguments",
"for",
"closure",
"function",
"in",
"proper",
"order",
"from",
"provided",
"parameters"
] | 32ad63ab1c5483714868d5acbbc67beb2f0b1cda | https://github.com/kambo-1st/KamboRouter/blob/32ad63ab1c5483714868d5acbbc67beb2f0b1cda/src/Dispatcher/ClosureAutoBind.php#L120-L134 |
8,293 | kambo-1st/KamboRouter | src/Dispatcher/ClosureAutoBind.php | ClosureAutoBind.getFunctionArgumentsNames | private function getFunctionArgumentsNames($closure) : array
{
$result = [];
$closureReflection = new ReflectionFunction($closure);
foreach ($closureReflection->getParameters() as $param) {
$result[] = $param->name;
}
return $result;
} | php | private function getFunctionArgumentsNames($closure) : array
{
$result = [];
$closureReflection = new ReflectionFunction($closure);
foreach ($closureReflection->getParameters() as $param) {
$result[] = $param->name;
}
return $result;
} | [
"private",
"function",
"getFunctionArgumentsNames",
"(",
"$",
"closure",
")",
":",
"array",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"$",
"closureReflection",
"=",
"new",
"ReflectionFunction",
"(",
"$",
"closure",
")",
";",
"foreach",
"(",
"$",
"closureReflection",
"->",
"getParameters",
"(",
")",
"as",
"$",
"param",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"$",
"param",
"->",
"name",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Get name of parameters for provided closure
@param \Closure $closure
@return array | [
"Get",
"name",
"of",
"parameters",
"for",
"provided",
"closure"
] | 32ad63ab1c5483714868d5acbbc67beb2f0b1cda | https://github.com/kambo-1st/KamboRouter/blob/32ad63ab1c5483714868d5acbbc67beb2f0b1cda/src/Dispatcher/ClosureAutoBind.php#L143-L154 |
8,294 | koinephp/Mvc | lib/Koine/Mvc/View.php | View.renderWithLayout | public function renderWithLayout($template, array $localVariables = array())
{
$this->addData(array(
'localVariables' => $localVariables,
'view' => $template,
));
return $this->render($this->getLayout(), $localVariables);
} | php | public function renderWithLayout($template, array $localVariables = array())
{
$this->addData(array(
'localVariables' => $localVariables,
'view' => $template,
));
return $this->render($this->getLayout(), $localVariables);
} | [
"public",
"function",
"renderWithLayout",
"(",
"$",
"template",
",",
"array",
"$",
"localVariables",
"=",
"array",
"(",
")",
")",
"{",
"$",
"this",
"->",
"addData",
"(",
"array",
"(",
"'localVariables'",
"=>",
"$",
"localVariables",
",",
"'view'",
"=>",
"$",
"template",
",",
")",
")",
";",
"return",
"$",
"this",
"->",
"render",
"(",
"$",
"this",
"->",
"getLayout",
"(",
")",
",",
"$",
"localVariables",
")",
";",
"}"
] | Renders with layout
@param string $template
@param array $localVariables | [
"Renders",
"with",
"layout"
] | 2c018f2638ea08d82dec3002c0c81a863be2e194 | https://github.com/koinephp/Mvc/blob/2c018f2638ea08d82dec3002c0c81a863be2e194/lib/Koine/Mvc/View.php#L56-L64 |
8,295 | webriq/core | module/Customize/src/Grid/Customize/Model/CssParser.php | CssParser.parse | public function parse( $file )
{
if ( ! is_file( $file ) || ! is_readable( $file ) )
{
return null;
}
$sheet = new Sheet\Structure();
$this->buffer = @ file_get_contents( $file );
$this->acceptBom();
while ( ! empty( $this->buffer ) )
{
$this->acceptEntry( $sheet );
}
return $sheet;
} | php | public function parse( $file )
{
if ( ! is_file( $file ) || ! is_readable( $file ) )
{
return null;
}
$sheet = new Sheet\Structure();
$this->buffer = @ file_get_contents( $file );
$this->acceptBom();
while ( ! empty( $this->buffer ) )
{
$this->acceptEntry( $sheet );
}
return $sheet;
} | [
"public",
"function",
"parse",
"(",
"$",
"file",
")",
"{",
"if",
"(",
"!",
"is_file",
"(",
"$",
"file",
")",
"||",
"!",
"is_readable",
"(",
"$",
"file",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"sheet",
"=",
"new",
"Sheet",
"\\",
"Structure",
"(",
")",
";",
"$",
"this",
"->",
"buffer",
"=",
"@",
"file_get_contents",
"(",
"$",
"file",
")",
";",
"$",
"this",
"->",
"acceptBom",
"(",
")",
";",
"while",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"buffer",
")",
")",
"{",
"$",
"this",
"->",
"acceptEntry",
"(",
"$",
"sheet",
")",
";",
"}",
"return",
"$",
"sheet",
";",
"}"
] | Parse a css file
@param string $file
@return \Customize\Model\Sheet\Structure | [
"Parse",
"a",
"css",
"file"
] | cfeb6e8a4732561c2215ec94e736c07f9b8bc990 | https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Customize/src/Grid/Customize/Model/CssParser.php#L41-L58 |
8,296 | webriq/core | module/Customize/src/Grid/Customize/Model/CssParser.php | CssParser.acceptWhiteSpace | public function acceptWhiteSpace( $additional = '' )
{
$this->buffer = ltrim( $this->buffer, self::WHITE_SPACE . $additional );
while ( substr( $this->buffer, 0, 2 ) == '/*' )
{
$this->buffer = ltrim(
preg_replace( '#/\*.*?\*/s#', '', $this->buffer ),
self::WHITE_SPACE . $additional
);
}
} | php | public function acceptWhiteSpace( $additional = '' )
{
$this->buffer = ltrim( $this->buffer, self::WHITE_SPACE . $additional );
while ( substr( $this->buffer, 0, 2 ) == '/*' )
{
$this->buffer = ltrim(
preg_replace( '#/\*.*?\*/s#', '', $this->buffer ),
self::WHITE_SPACE . $additional
);
}
} | [
"public",
"function",
"acceptWhiteSpace",
"(",
"$",
"additional",
"=",
"''",
")",
"{",
"$",
"this",
"->",
"buffer",
"=",
"ltrim",
"(",
"$",
"this",
"->",
"buffer",
",",
"self",
"::",
"WHITE_SPACE",
".",
"$",
"additional",
")",
";",
"while",
"(",
"substr",
"(",
"$",
"this",
"->",
"buffer",
",",
"0",
",",
"2",
")",
"==",
"'/*'",
")",
"{",
"$",
"this",
"->",
"buffer",
"=",
"ltrim",
"(",
"preg_replace",
"(",
"'#/\\*.*?\\*/s#'",
",",
"''",
",",
"$",
"this",
"->",
"buffer",
")",
",",
"self",
"::",
"WHITE_SPACE",
".",
"$",
"additional",
")",
";",
"}",
"}"
] | Accept white-space & comments
@param string $additional
@return void | [
"Accept",
"white",
"-",
"space",
"&",
"comments"
] | cfeb6e8a4732561c2215ec94e736c07f9b8bc990 | https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Customize/src/Grid/Customize/Model/CssParser.php#L76-L87 |
8,297 | movicon/movicon-http | src/http/request/RequestCookie.php | RequestCookie.get | public static function get($name, $options = [])
{
$default = isset($options["default"]) ? $options["default"] : null;
return isset($_COOKIE[$name]) ? $_COOKIE[$name] : $default;
} | php | public static function get($name, $options = [])
{
$default = isset($options["default"]) ? $options["default"] : null;
return isset($_COOKIE[$name]) ? $_COOKIE[$name] : $default;
} | [
"public",
"static",
"function",
"get",
"(",
"$",
"name",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"default",
"=",
"isset",
"(",
"$",
"options",
"[",
"\"default\"",
"]",
")",
"?",
"$",
"options",
"[",
"\"default\"",
"]",
":",
"null",
";",
"return",
"isset",
"(",
"$",
"_COOKIE",
"[",
"$",
"name",
"]",
")",
"?",
"$",
"_COOKIE",
"[",
"$",
"name",
"]",
":",
"$",
"default",
";",
"}"
] | Gets a cookie.
Example:
// gets a cookie and returns '123' if the cookie does not exist
$token = RequestCookie::get("token", ["default" => "123"]);
@param string $name Cookie name
@param array $options Options (not required)
@return mixed|null | [
"Gets",
"a",
"cookie",
"."
] | ae9e4aa763c52f272c628fef0ec4496478312355 | https://github.com/movicon/movicon-http/blob/ae9e4aa763c52f272c628fef0ec4496478312355/src/http/request/RequestCookie.php#L19-L24 |
8,298 | robertasproniu/tic-tac-toe-agent | src/Board.php | Board.setBoard | public function setBoard(array $board)
{
if (empty($board)) {
return false;
}
// is not associative array and total size of array is not the same as board size then invalidate board
if (($boardSize = count($board, COUNT_RECURSIVE)) == count($board) && $boardSize != pow($this->size, 2)) {
return false;
}
// if not associative then set the boar as one
if (count($board, COUNT_RECURSIVE) == count($board)) {
$this->board = array_chunk($board, $this->size);
} else {
$this->board = $board;
}
// if distinct values is greater than 2 then invalidate board
$boardDistinctValues = array_unique(array_filter(array_reduce($this->board, 'array_merge', [])));
if (count($boardDistinctValues) > 2) {
return false;
}
return $this->board;
} | php | public function setBoard(array $board)
{
if (empty($board)) {
return false;
}
// is not associative array and total size of array is not the same as board size then invalidate board
if (($boardSize = count($board, COUNT_RECURSIVE)) == count($board) && $boardSize != pow($this->size, 2)) {
return false;
}
// if not associative then set the boar as one
if (count($board, COUNT_RECURSIVE) == count($board)) {
$this->board = array_chunk($board, $this->size);
} else {
$this->board = $board;
}
// if distinct values is greater than 2 then invalidate board
$boardDistinctValues = array_unique(array_filter(array_reduce($this->board, 'array_merge', [])));
if (count($boardDistinctValues) > 2) {
return false;
}
return $this->board;
} | [
"public",
"function",
"setBoard",
"(",
"array",
"$",
"board",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"board",
")",
")",
"{",
"return",
"false",
";",
"}",
"// is not associative array and total size of array is not the same as board size then invalidate board",
"if",
"(",
"(",
"$",
"boardSize",
"=",
"count",
"(",
"$",
"board",
",",
"COUNT_RECURSIVE",
")",
")",
"==",
"count",
"(",
"$",
"board",
")",
"&&",
"$",
"boardSize",
"!=",
"pow",
"(",
"$",
"this",
"->",
"size",
",",
"2",
")",
")",
"{",
"return",
"false",
";",
"}",
"// if not associative then set the boar as one",
"if",
"(",
"count",
"(",
"$",
"board",
",",
"COUNT_RECURSIVE",
")",
"==",
"count",
"(",
"$",
"board",
")",
")",
"{",
"$",
"this",
"->",
"board",
"=",
"array_chunk",
"(",
"$",
"board",
",",
"$",
"this",
"->",
"size",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"board",
"=",
"$",
"board",
";",
"}",
"// if distinct values is greater than 2 then invalidate board",
"$",
"boardDistinctValues",
"=",
"array_unique",
"(",
"array_filter",
"(",
"array_reduce",
"(",
"$",
"this",
"->",
"board",
",",
"'array_merge'",
",",
"[",
"]",
")",
")",
")",
";",
"if",
"(",
"count",
"(",
"$",
"boardDistinctValues",
")",
">",
"2",
")",
"{",
"return",
"false",
";",
"}",
"return",
"$",
"this",
"->",
"board",
";",
"}"
] | Set Board Values
@param array $board
@return array
@throws \Exception | [
"Set",
"Board",
"Values"
] | 00bc8e31e3c9770f2ee24d97d82e40dff20e3e98 | https://github.com/robertasproniu/tic-tac-toe-agent/blob/00bc8e31e3c9770f2ee24d97d82e40dff20e3e98/src/Board.php#L28-L53 |
8,299 | robertasproniu/tic-tac-toe-agent | src/Board.php | Board.setValue | public function setValue(array $position, $value)
{
if (!$this->validatePosition($position)) {
return false;
}
list ($xPos, $yPos) = $position;
if (!empty($this->board[$xPos][$yPos])) {
return false;
}
$this->board[$xPos][$yPos] = $value;
} | php | public function setValue(array $position, $value)
{
if (!$this->validatePosition($position)) {
return false;
}
list ($xPos, $yPos) = $position;
if (!empty($this->board[$xPos][$yPos])) {
return false;
}
$this->board[$xPos][$yPos] = $value;
} | [
"public",
"function",
"setValue",
"(",
"array",
"$",
"position",
",",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"validatePosition",
"(",
"$",
"position",
")",
")",
"{",
"return",
"false",
";",
"}",
"list",
"(",
"$",
"xPos",
",",
"$",
"yPos",
")",
"=",
"$",
"position",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"board",
"[",
"$",
"xPos",
"]",
"[",
"$",
"yPos",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"board",
"[",
"$",
"xPos",
"]",
"[",
"$",
"yPos",
"]",
"=",
"$",
"value",
";",
"}"
] | Set value to a particular position on board
@param array $position
@param $value
@ | [
"Set",
"value",
"to",
"a",
"particular",
"position",
"on",
"board"
] | 00bc8e31e3c9770f2ee24d97d82e40dff20e3e98 | https://github.com/robertasproniu/tic-tac-toe-agent/blob/00bc8e31e3c9770f2ee24d97d82e40dff20e3e98/src/Board.php#L86-L100 |
Subsets and Splits