id
int32 0
241k
| repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
list | docstring
stringlengths 3
47.2k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 91
247
|
---|---|---|---|---|---|---|---|---|---|---|---|
15,900 | JoffreyPoreeCoding/MongoDB-ODM | src/GridFS/Repository.php | Repository.deleteOne | public function deleteOne($document, $options = [])
{
$unhydratedObject = $this->hydrator->unhydrate($document);
$id = $unhydratedObject["_id"];
$this->bucket->delete($id);
$this->documentManager->removeObject($document);
} | php | public function deleteOne($document, $options = [])
{
$unhydratedObject = $this->hydrator->unhydrate($document);
$id = $unhydratedObject["_id"];
$this->bucket->delete($id);
$this->documentManager->removeObject($document);
} | [
"public",
"function",
"deleteOne",
"(",
"$",
"document",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"unhydratedObject",
"=",
"$",
"this",
"->",
"hydrator",
"->",
"unhydrate",
"(",
"$",
"document",
")",
";",
"$",
"id",
"=",
"$",
"unhydratedObject",
"[",
"\"_id\"",
"]",
";",
"$",
"this",
"->",
"bucket",
"->",
"delete",
"(",
"$",
"id",
")",
";",
"$",
"this",
"->",
"documentManager",
"->",
"removeObject",
"(",
"$",
"document",
")",
";",
"}"
]
| Delete a document form gr
@param object|array $document Document or query to delete
@param array $options Useless, just for Repository compatibility
@return void | [
"Delete",
"a",
"document",
"form",
"gr"
]
| 56fd7ab28c22f276573a89d56bb93c8d74ad7f74 | https://github.com/JoffreyPoreeCoding/MongoDB-ODM/blob/56fd7ab28c22f276573a89d56bb93c8d74ad7f74/src/GridFS/Repository.php#L321-L329 |
15,901 | JoffreyPoreeCoding/MongoDB-ODM | src/GridFS/Repository.php | Repository.getUpdateQuery | public function getUpdateQuery($document)
{
$updateQuery = [];
$old = $this->uncacheObject($document);
$new = $this->hydrator->unhydrate($document);
unset($new["stream"]);
return $this->updateQueryCreator->createUpdateQuery($old, $new);
} | php | public function getUpdateQuery($document)
{
$updateQuery = [];
$old = $this->uncacheObject($document);
$new = $this->hydrator->unhydrate($document);
unset($new["stream"]);
return $this->updateQueryCreator->createUpdateQuery($old, $new);
} | [
"public",
"function",
"getUpdateQuery",
"(",
"$",
"document",
")",
"{",
"$",
"updateQuery",
"=",
"[",
"]",
";",
"$",
"old",
"=",
"$",
"this",
"->",
"uncacheObject",
"(",
"$",
"document",
")",
";",
"$",
"new",
"=",
"$",
"this",
"->",
"hydrator",
"->",
"unhydrate",
"(",
"$",
"document",
")",
";",
"unset",
"(",
"$",
"new",
"[",
"\"stream\"",
"]",
")",
";",
"return",
"$",
"this",
"->",
"updateQueryCreator",
"->",
"createUpdateQuery",
"(",
"$",
"old",
",",
"$",
"new",
")",
";",
"}"
]
| Create the update query from object diff
@param object $document The document that the update query will match
@return array | [
"Create",
"the",
"update",
"query",
"from",
"object",
"diff"
]
| 56fd7ab28c22f276573a89d56bb93c8d74ad7f74 | https://github.com/JoffreyPoreeCoding/MongoDB-ODM/blob/56fd7ab28c22f276573a89d56bb93c8d74ad7f74/src/GridFS/Repository.php#L349-L357 |
15,902 | JoffreyPoreeCoding/MongoDB-ODM | src/GridFS/Repository.php | Repository.getStreamProjection | private function getStreamProjection($projections)
{
if (isset($projections['stream'])) {
return $projections['stream'];
} elseif (empty($projections)) {
return true;
} else {
if (isset($projections['_id'])) {
unset($projections['_id']);
}
return reset($projections) ? false : true;
}
} | php | private function getStreamProjection($projections)
{
if (isset($projections['stream'])) {
return $projections['stream'];
} elseif (empty($projections)) {
return true;
} else {
if (isset($projections['_id'])) {
unset($projections['_id']);
}
return reset($projections) ? false : true;
}
} | [
"private",
"function",
"getStreamProjection",
"(",
"$",
"projections",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"projections",
"[",
"'stream'",
"]",
")",
")",
"{",
"return",
"$",
"projections",
"[",
"'stream'",
"]",
";",
"}",
"elseif",
"(",
"empty",
"(",
"$",
"projections",
")",
")",
"{",
"return",
"true",
";",
"}",
"else",
"{",
"if",
"(",
"isset",
"(",
"$",
"projections",
"[",
"'_id'",
"]",
")",
")",
"{",
"unset",
"(",
"$",
"projections",
"[",
"'_id'",
"]",
")",
";",
"}",
"return",
"reset",
"(",
"$",
"projections",
")",
"?",
"false",
":",
"true",
";",
"}",
"}"
]
| Get the stream projection
@param array $projections Projection of query
@return boolean | [
"Get",
"the",
"stream",
"projection"
]
| 56fd7ab28c22f276573a89d56bb93c8d74ad7f74 | https://github.com/JoffreyPoreeCoding/MongoDB-ODM/blob/56fd7ab28c22f276573a89d56bb93c8d74ad7f74/src/GridFS/Repository.php#L365-L377 |
15,903 | FrenchFrogs/framework | src/Core/Panel.php | Panel.useDefaultPanel | public function useDefaultPanel($title = '')
{
/** @var $panel \FrenchFrogs\Panel\Panel\Panel */
$panel = configurator()->get('panel.class');
$panel = new $panel;
$panel->setTitle(strval($title));
return $this->setPanel($panel);
} | php | public function useDefaultPanel($title = '')
{
/** @var $panel \FrenchFrogs\Panel\Panel\Panel */
$panel = configurator()->get('panel.class');
$panel = new $panel;
$panel->setTitle(strval($title));
return $this->setPanel($panel);
} | [
"public",
"function",
"useDefaultPanel",
"(",
"$",
"title",
"=",
"''",
")",
"{",
"/** @var $panel \\FrenchFrogs\\Panel\\Panel\\Panel */",
"$",
"panel",
"=",
"configurator",
"(",
")",
"->",
"get",
"(",
"'panel.class'",
")",
";",
"$",
"panel",
"=",
"new",
"$",
"panel",
";",
"$",
"panel",
"->",
"setTitle",
"(",
"strval",
"(",
"$",
"title",
")",
")",
";",
"return",
"$",
"this",
"->",
"setPanel",
"(",
"$",
"panel",
")",
";",
"}"
]
| Set default panel
@param string $title
@return $this | [
"Set",
"default",
"panel"
]
| a4838c698a5600437e87dac6d35ba8ebe32c4395 | https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Core/Panel.php#L35-L44 |
15,904 | e0ipso/drupal-unit-autoload | src/Discovery/PathFinderCore.php | PathFinderCore.isDrupalRoot | protected function isDrupalRoot($directory) {
if (!empty($directory) && is_dir($directory) && file_exists($directory . DIRECTORY_SEPARATOR . '/index.php')) {
// Drupal 7 root.
// We check for the presence of 'modules/field/field.module' to differentiate this from a D6 site
return (file_exists($directory . DIRECTORY_SEPARATOR . 'includes/common.inc')
&& file_exists($directory . DIRECTORY_SEPARATOR . 'misc/drupal.js')
&& file_exists($directory . DIRECTORY_SEPARATOR . 'modules/field/field.module'));
}
return FALSE;
} | php | protected function isDrupalRoot($directory) {
if (!empty($directory) && is_dir($directory) && file_exists($directory . DIRECTORY_SEPARATOR . '/index.php')) {
// Drupal 7 root.
// We check for the presence of 'modules/field/field.module' to differentiate this from a D6 site
return (file_exists($directory . DIRECTORY_SEPARATOR . 'includes/common.inc')
&& file_exists($directory . DIRECTORY_SEPARATOR . 'misc/drupal.js')
&& file_exists($directory . DIRECTORY_SEPARATOR . 'modules/field/field.module'));
}
return FALSE;
} | [
"protected",
"function",
"isDrupalRoot",
"(",
"$",
"directory",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"directory",
")",
"&&",
"is_dir",
"(",
"$",
"directory",
")",
"&&",
"file_exists",
"(",
"$",
"directory",
".",
"DIRECTORY_SEPARATOR",
".",
"'/index.php'",
")",
")",
"{",
"// Drupal 7 root.",
"// We check for the presence of 'modules/field/field.module' to differentiate this from a D6 site",
"return",
"(",
"file_exists",
"(",
"$",
"directory",
".",
"DIRECTORY_SEPARATOR",
".",
"'includes/common.inc'",
")",
"&&",
"file_exists",
"(",
"$",
"directory",
".",
"DIRECTORY_SEPARATOR",
".",
"'misc/drupal.js'",
")",
"&&",
"file_exists",
"(",
"$",
"directory",
".",
"DIRECTORY_SEPARATOR",
".",
"'modules/field/field.module'",
")",
")",
";",
"}",
"return",
"FALSE",
";",
"}"
]
| Checks if the passed directory is the Drupal root.
@param string $directory
The directory path.
@return bool
TRUE if the passed directory is the Drupal root. | [
"Checks",
"if",
"the",
"passed",
"directory",
"is",
"the",
"Drupal",
"root",
"."
]
| 7ce147b269c7333eca31e2cd04b736d6274b9cbf | https://github.com/e0ipso/drupal-unit-autoload/blob/7ce147b269c7333eca31e2cd04b736d6274b9cbf/src/Discovery/PathFinderCore.php#L45-L54 |
15,905 | jasny/router | src/Router/Runner/PhpScript.php | PhpScript.run | public function run(ServerRequestInterface $request, ResponseInterface $response)
{
$route = $request->getAttribute('route');
$file = !empty($route->file) ? ltrim($route->file, '/') : '';
if ($file[0] === '~' || strpos($file, '..') !== false) {
trigger_error("Won't route to '$file': '~', '..' are not allowed in filename", E_USER_NOTICE);
return $this->notFound($request, $response);
}
if (!file_exists($file)) {
trigger_error("Failed to route using '$file': File doesn't exist", E_USER_NOTICE);
return $this->notFound($request, $response);
}
$result = $this->includeScript($file, $request, $response);
return $result === true || $result === 1 ? $response : $result;
} | php | public function run(ServerRequestInterface $request, ResponseInterface $response)
{
$route = $request->getAttribute('route');
$file = !empty($route->file) ? ltrim($route->file, '/') : '';
if ($file[0] === '~' || strpos($file, '..') !== false) {
trigger_error("Won't route to '$file': '~', '..' are not allowed in filename", E_USER_NOTICE);
return $this->notFound($request, $response);
}
if (!file_exists($file)) {
trigger_error("Failed to route using '$file': File doesn't exist", E_USER_NOTICE);
return $this->notFound($request, $response);
}
$result = $this->includeScript($file, $request, $response);
return $result === true || $result === 1 ? $response : $result;
} | [
"public",
"function",
"run",
"(",
"ServerRequestInterface",
"$",
"request",
",",
"ResponseInterface",
"$",
"response",
")",
"{",
"$",
"route",
"=",
"$",
"request",
"->",
"getAttribute",
"(",
"'route'",
")",
";",
"$",
"file",
"=",
"!",
"empty",
"(",
"$",
"route",
"->",
"file",
")",
"?",
"ltrim",
"(",
"$",
"route",
"->",
"file",
",",
"'/'",
")",
":",
"''",
";",
"if",
"(",
"$",
"file",
"[",
"0",
"]",
"===",
"'~'",
"||",
"strpos",
"(",
"$",
"file",
",",
"'..'",
")",
"!==",
"false",
")",
"{",
"trigger_error",
"(",
"\"Won't route to '$file': '~', '..' are not allowed in filename\"",
",",
"E_USER_NOTICE",
")",
";",
"return",
"$",
"this",
"->",
"notFound",
"(",
"$",
"request",
",",
"$",
"response",
")",
";",
"}",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"file",
")",
")",
"{",
"trigger_error",
"(",
"\"Failed to route using '$file': File doesn't exist\"",
",",
"E_USER_NOTICE",
")",
";",
"return",
"$",
"this",
"->",
"notFound",
"(",
"$",
"request",
",",
"$",
"response",
")",
";",
"}",
"$",
"result",
"=",
"$",
"this",
"->",
"includeScript",
"(",
"$",
"file",
",",
"$",
"request",
",",
"$",
"response",
")",
";",
"return",
"$",
"result",
"===",
"true",
"||",
"$",
"result",
"===",
"1",
"?",
"$",
"response",
":",
"$",
"result",
";",
"}"
]
| Route to a file
@param ServerRequestInterface $request
@param ResponseInterface $response
@return ResponseInterface|mixed | [
"Route",
"to",
"a",
"file"
]
| 4c776665ba343150b442c21893946e3d54190896 | https://github.com/jasny/router/blob/4c776665ba343150b442c21893946e3d54190896/src/Router/Runner/PhpScript.php#L35-L53 |
15,906 | FrenchFrogs/framework | src/Form/Element/Select.php | Select.setDependOn | public function setDependOn($selector, $url)
{
return $this->addAttribute('data-parent-url', $url)
->addAttribute('data-parent-selector', $selector)
->addAttribute('data-populate', function(Element $element){
return $element->getValue();
})
->addClass('select-remote');
} | php | public function setDependOn($selector, $url)
{
return $this->addAttribute('data-parent-url', $url)
->addAttribute('data-parent-selector', $selector)
->addAttribute('data-populate', function(Element $element){
return $element->getValue();
})
->addClass('select-remote');
} | [
"public",
"function",
"setDependOn",
"(",
"$",
"selector",
",",
"$",
"url",
")",
"{",
"return",
"$",
"this",
"->",
"addAttribute",
"(",
"'data-parent-url'",
",",
"$",
"url",
")",
"->",
"addAttribute",
"(",
"'data-parent-selector'",
",",
"$",
"selector",
")",
"->",
"addAttribute",
"(",
"'data-populate'",
",",
"function",
"(",
"Element",
"$",
"element",
")",
"{",
"return",
"$",
"element",
"->",
"getValue",
"(",
")",
";",
"}",
")",
"->",
"addClass",
"(",
"'select-remote'",
")",
";",
"}"
]
| Set Options from parent selection
@param $selector
@param $url
@return $this | [
"Set",
"Options",
"from",
"parent",
"selection"
]
| a4838c698a5600437e87dac6d35ba8ebe32c4395 | https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Form/Element/Select.php#L135-L143 |
15,907 | ericpoe/haystack | src/HArray.php | HArray.toHString | public function toHString($glue = '')
{
if (empty($this->arr)) {
return new HString();
}
$str = new ArrayToString($this->arr, $glue);
return new HString($str->toString());
} | php | public function toHString($glue = '')
{
if (empty($this->arr)) {
return new HString();
}
$str = new ArrayToString($this->arr, $glue);
return new HString($str->toString());
} | [
"public",
"function",
"toHString",
"(",
"$",
"glue",
"=",
"''",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"arr",
")",
")",
"{",
"return",
"new",
"HString",
"(",
")",
";",
"}",
"$",
"str",
"=",
"new",
"ArrayToString",
"(",
"$",
"this",
"->",
"arr",
",",
"$",
"glue",
")",
";",
"return",
"new",
"HString",
"(",
"$",
"str",
"->",
"toString",
"(",
")",
")",
";",
"}"
]
| Alias to PHP function `implode`
@param string $glue - defaults to an empty string
@return HString | [
"Alias",
"to",
"PHP",
"function",
"implode"
]
| 92c9ec4698fd013c1465efa6d49bc844a5869be0 | https://github.com/ericpoe/haystack/blob/92c9ec4698fd013c1465efa6d49bc844a5869be0/src/HArray.php#L61-L69 |
15,908 | FrenchFrogs/framework | src/Table/Table/Pagination.php | Pagination.paginate | public function paginate(array $params)
{
// page
if (isset($params[$this->getParamPage()])) {
$this->setPage($params[$this->getParamPage()]);
}
return $this;
} | php | public function paginate(array $params)
{
// page
if (isset($params[$this->getParamPage()])) {
$this->setPage($params[$this->getParamPage()]);
}
return $this;
} | [
"public",
"function",
"paginate",
"(",
"array",
"$",
"params",
")",
"{",
"// page",
"if",
"(",
"isset",
"(",
"$",
"params",
"[",
"$",
"this",
"->",
"getParamPage",
"(",
")",
"]",
")",
")",
"{",
"$",
"this",
"->",
"setPage",
"(",
"$",
"params",
"[",
"$",
"this",
"->",
"getParamPage",
"(",
")",
"]",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| Fast pagination setup
@param array $params
@return $this | [
"Fast",
"pagination",
"setup"
]
| a4838c698a5600437e87dac6d35ba8ebe32c4395 | https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Table/Table/Pagination.php#L213-L222 |
15,909 | stubbles/stubbles-webapp-core | src/main/php/WebApp.php | WebApp.run | public function run(): SendableResponse
{
$request = WebRequest::fromRawSource();
$response = new WebResponse($request);
if ($response->isFixed()) {
return $response; // http version of request not supported
}
try {
$requestUri = $request->uri();
} catch (MalformedUri $mue) {
$response->status()->badRequest();
return $response;
}
$this->configureRouting($this->routing);
$uriResource = $this->routing->findResource($requestUri, $request->method());
if ($this->switchToHttps($request, $uriResource)) {
$response->redirect($uriResource->httpsUri());
return $response;
}
try {
if (!$uriResource->negotiateMimeType($request, $response)) {
return $response;
}
$this->sessionHandshake($request, $response);
if ($uriResource->applyPreInterceptors($request, $response)) {
$response->write($uriResource->resolve($request, $response));
$uriResource->applyPostInterceptors($request, $response);
}
} catch (\Exception $e) {
$this->injector->getInstance(ExceptionLogger::class)->log($e);
$response->write($response->internalServerError($e->getMessage()));
}
return $response;
} | php | public function run(): SendableResponse
{
$request = WebRequest::fromRawSource();
$response = new WebResponse($request);
if ($response->isFixed()) {
return $response; // http version of request not supported
}
try {
$requestUri = $request->uri();
} catch (MalformedUri $mue) {
$response->status()->badRequest();
return $response;
}
$this->configureRouting($this->routing);
$uriResource = $this->routing->findResource($requestUri, $request->method());
if ($this->switchToHttps($request, $uriResource)) {
$response->redirect($uriResource->httpsUri());
return $response;
}
try {
if (!$uriResource->negotiateMimeType($request, $response)) {
return $response;
}
$this->sessionHandshake($request, $response);
if ($uriResource->applyPreInterceptors($request, $response)) {
$response->write($uriResource->resolve($request, $response));
$uriResource->applyPostInterceptors($request, $response);
}
} catch (\Exception $e) {
$this->injector->getInstance(ExceptionLogger::class)->log($e);
$response->write($response->internalServerError($e->getMessage()));
}
return $response;
} | [
"public",
"function",
"run",
"(",
")",
":",
"SendableResponse",
"{",
"$",
"request",
"=",
"WebRequest",
"::",
"fromRawSource",
"(",
")",
";",
"$",
"response",
"=",
"new",
"WebResponse",
"(",
"$",
"request",
")",
";",
"if",
"(",
"$",
"response",
"->",
"isFixed",
"(",
")",
")",
"{",
"return",
"$",
"response",
";",
"// http version of request not supported",
"}",
"try",
"{",
"$",
"requestUri",
"=",
"$",
"request",
"->",
"uri",
"(",
")",
";",
"}",
"catch",
"(",
"MalformedUri",
"$",
"mue",
")",
"{",
"$",
"response",
"->",
"status",
"(",
")",
"->",
"badRequest",
"(",
")",
";",
"return",
"$",
"response",
";",
"}",
"$",
"this",
"->",
"configureRouting",
"(",
"$",
"this",
"->",
"routing",
")",
";",
"$",
"uriResource",
"=",
"$",
"this",
"->",
"routing",
"->",
"findResource",
"(",
"$",
"requestUri",
",",
"$",
"request",
"->",
"method",
"(",
")",
")",
";",
"if",
"(",
"$",
"this",
"->",
"switchToHttps",
"(",
"$",
"request",
",",
"$",
"uriResource",
")",
")",
"{",
"$",
"response",
"->",
"redirect",
"(",
"$",
"uriResource",
"->",
"httpsUri",
"(",
")",
")",
";",
"return",
"$",
"response",
";",
"}",
"try",
"{",
"if",
"(",
"!",
"$",
"uriResource",
"->",
"negotiateMimeType",
"(",
"$",
"request",
",",
"$",
"response",
")",
")",
"{",
"return",
"$",
"response",
";",
"}",
"$",
"this",
"->",
"sessionHandshake",
"(",
"$",
"request",
",",
"$",
"response",
")",
";",
"if",
"(",
"$",
"uriResource",
"->",
"applyPreInterceptors",
"(",
"$",
"request",
",",
"$",
"response",
")",
")",
"{",
"$",
"response",
"->",
"write",
"(",
"$",
"uriResource",
"->",
"resolve",
"(",
"$",
"request",
",",
"$",
"response",
")",
")",
";",
"$",
"uriResource",
"->",
"applyPostInterceptors",
"(",
"$",
"request",
",",
"$",
"response",
")",
";",
"}",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"injector",
"->",
"getInstance",
"(",
"ExceptionLogger",
"::",
"class",
")",
"->",
"log",
"(",
"$",
"e",
")",
";",
"$",
"response",
"->",
"write",
"(",
"$",
"response",
"->",
"internalServerError",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
")",
";",
"}",
"return",
"$",
"response",
";",
"}"
]
| runs the application but does not send the response
@return \stubbles\webapp\response\SendableResponse | [
"runs",
"the",
"application",
"but",
"does",
"not",
"send",
"the",
"response"
]
| 7705f129011a81d5cc3c76b4b150fab3dadac6a3 | https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/WebApp.php#L58-L96 |
15,910 | stubbles/stubbles-webapp-core | src/main/php/WebApp.php | WebApp.sessionHandshake | private function sessionHandshake(Request $request, Response $response)
{
$session = $this->createSession($request, $response);
if (null !== $session) {
$this->injector->setSession(
$request->attachSession($session),
Session::class
);
}
} | php | private function sessionHandshake(Request $request, Response $response)
{
$session = $this->createSession($request, $response);
if (null !== $session) {
$this->injector->setSession(
$request->attachSession($session),
Session::class
);
}
} | [
"private",
"function",
"sessionHandshake",
"(",
"Request",
"$",
"request",
",",
"Response",
"$",
"response",
")",
"{",
"$",
"session",
"=",
"$",
"this",
"->",
"createSession",
"(",
"$",
"request",
",",
"$",
"response",
")",
";",
"if",
"(",
"null",
"!==",
"$",
"session",
")",
"{",
"$",
"this",
"->",
"injector",
"->",
"setSession",
"(",
"$",
"request",
"->",
"attachSession",
"(",
"$",
"session",
")",
",",
"Session",
"::",
"class",
")",
";",
"}",
"}"
]
| ensures session is present when created
@param \stubbles\webapp\Request $request
@param \stubbles\webapp\Response $response | [
"ensures",
"session",
"is",
"present",
"when",
"created"
]
| 7705f129011a81d5cc3c76b4b150fab3dadac6a3 | https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/WebApp.php#L104-L113 |
15,911 | stubbles/stubbles-webapp-core | src/main/php/WebApp.php | WebApp.switchToHttps | protected function switchToHttps(Request $request, UriResource $uriResource): bool
{
return !$request->isSsl() && $uriResource->requiresHttps();
} | php | protected function switchToHttps(Request $request, UriResource $uriResource): bool
{
return !$request->isSsl() && $uriResource->requiresHttps();
} | [
"protected",
"function",
"switchToHttps",
"(",
"Request",
"$",
"request",
",",
"UriResource",
"$",
"uriResource",
")",
":",
"bool",
"{",
"return",
"!",
"$",
"request",
"->",
"isSsl",
"(",
")",
"&&",
"$",
"uriResource",
"->",
"requiresHttps",
"(",
")",
";",
"}"
]
| checks whether a switch to https must be made
@param \stubbles\webapp\Request $request
@param \stubbles\webapp\routing\UriResource $uriResource
@return bool | [
"checks",
"whether",
"a",
"switch",
"to",
"https",
"must",
"be",
"made"
]
| 7705f129011a81d5cc3c76b4b150fab3dadac6a3 | https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/WebApp.php#L135-L138 |
15,912 | harp-orm/query | src/Compiler/Compiler.php | Compiler.humanize | public static function humanize($sql, array $parameters)
{
$parameters = array_map(__NAMESPACE__.'\Compiler::quoteValue', $parameters);
return preg_replace_callback('/\?/', function () use (& $parameters) {
return current(each($parameters));
}, $sql);
} | php | public static function humanize($sql, array $parameters)
{
$parameters = array_map(__NAMESPACE__.'\Compiler::quoteValue', $parameters);
return preg_replace_callback('/\?/', function () use (& $parameters) {
return current(each($parameters));
}, $sql);
} | [
"public",
"static",
"function",
"humanize",
"(",
"$",
"sql",
",",
"array",
"$",
"parameters",
")",
"{",
"$",
"parameters",
"=",
"array_map",
"(",
"__NAMESPACE__",
".",
"'\\Compiler::quoteValue'",
",",
"$",
"parameters",
")",
";",
"return",
"preg_replace_callback",
"(",
"'/\\?/'",
",",
"function",
"(",
")",
"use",
"(",
"&",
"$",
"parameters",
")",
"{",
"return",
"current",
"(",
"each",
"(",
"$",
"parameters",
")",
")",
";",
"}",
",",
"$",
"sql",
")",
";",
"}"
]
| Replace placeholders with parameters
@param string $sql
@param array $parameters
@return string | [
"Replace",
"placeholders",
"with",
"parameters"
]
| 98ce2468a0a31fe15ed3692bad32547bf6dbe41a | https://github.com/harp-orm/query/blob/98ce2468a0a31fe15ed3692bad32547bf6dbe41a/src/Compiler/Compiler.php#L127-L134 |
15,913 | harp-orm/query | src/Compiler/Compiler.php | Compiler.parameters | public static function parameters(array $items)
{
$parameters = array();
$items = array_filter(Arr::flatten($items));
foreach ($items as $item) {
$itemParams = $item->getParameters();
if ($itemParams !== null) {
$parameters []= $itemParams;
}
}
return Arr::flatten($parameters);
} | php | public static function parameters(array $items)
{
$parameters = array();
$items = array_filter(Arr::flatten($items));
foreach ($items as $item) {
$itemParams = $item->getParameters();
if ($itemParams !== null) {
$parameters []= $itemParams;
}
}
return Arr::flatten($parameters);
} | [
"public",
"static",
"function",
"parameters",
"(",
"array",
"$",
"items",
")",
"{",
"$",
"parameters",
"=",
"array",
"(",
")",
";",
"$",
"items",
"=",
"array_filter",
"(",
"Arr",
"::",
"flatten",
"(",
"$",
"items",
")",
")",
";",
"foreach",
"(",
"$",
"items",
"as",
"$",
"item",
")",
"{",
"$",
"itemParams",
"=",
"$",
"item",
"->",
"getParameters",
"(",
")",
";",
"if",
"(",
"$",
"itemParams",
"!==",
"null",
")",
"{",
"$",
"parameters",
"[",
"]",
"=",
"$",
"itemParams",
";",
"}",
"}",
"return",
"Arr",
"::",
"flatten",
"(",
"$",
"parameters",
")",
";",
"}"
]
| Get parameters from Parametrised objects
@param array $items
@return array | [
"Get",
"parameters",
"from",
"Parametrised",
"objects"
]
| 98ce2468a0a31fe15ed3692bad32547bf6dbe41a | https://github.com/harp-orm/query/blob/98ce2468a0a31fe15ed3692bad32547bf6dbe41a/src/Compiler/Compiler.php#L157-L171 |
15,914 | RinkAttendant6/JsonI18n | src/ResourceBuilder.php | ResourceBuilder.fromString | public static function fromString(string $input, string $locale): Resource
{
$data = json_decode($input, true);
if (json_last_error() !== \JSON_ERROR_NONE) {
if (function_exists('json_last_error_msg')) {
throw new \InvalidArgumentException(json_last_error_msg(), json_last_error());
}
throw new \InvalidArgumentException("Error parsing JSON.", json_last_error());
}
return static::fromArray($data, $locale);
} | php | public static function fromString(string $input, string $locale): Resource
{
$data = json_decode($input, true);
if (json_last_error() !== \JSON_ERROR_NONE) {
if (function_exists('json_last_error_msg')) {
throw new \InvalidArgumentException(json_last_error_msg(), json_last_error());
}
throw new \InvalidArgumentException("Error parsing JSON.", json_last_error());
}
return static::fromArray($data, $locale);
} | [
"public",
"static",
"function",
"fromString",
"(",
"string",
"$",
"input",
",",
"string",
"$",
"locale",
")",
":",
"Resource",
"{",
"$",
"data",
"=",
"json_decode",
"(",
"$",
"input",
",",
"true",
")",
";",
"if",
"(",
"json_last_error",
"(",
")",
"!==",
"\\",
"JSON_ERROR_NONE",
")",
"{",
"if",
"(",
"function_exists",
"(",
"'json_last_error_msg'",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"json_last_error_msg",
"(",
")",
",",
"json_last_error",
"(",
")",
")",
";",
"}",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"Error parsing JSON.\"",
",",
"json_last_error",
"(",
")",
")",
";",
"}",
"return",
"static",
"::",
"fromArray",
"(",
"$",
"data",
",",
"$",
"locale",
")",
";",
"}"
]
| Creates a Resource from a JSON string
@param string $input The JSON object
@param string $locale The locale
@return Resource | [
"Creates",
"a",
"Resource",
"from",
"a",
"JSON",
"string"
]
| 882cbd43d273f771a384eb09d205d327033aaae3 | https://github.com/RinkAttendant6/JsonI18n/blob/882cbd43d273f771a384eb09d205d327033aaae3/src/ResourceBuilder.php#L31-L42 |
15,915 | RinkAttendant6/JsonI18n | src/ResourceBuilder.php | ResourceBuilder.fromFile | public static function fromFile(string $file, string $locale): Resource
{
if (!is_file($file)) {
throw new \InvalidArgumentException("$file is not a file");
}
$contents = file_get_contents($file);
if ($contents === false) {
throw new \RuntimeException("Error reading file at $file.");
}
return static::fromString($contents, $locale);
} | php | public static function fromFile(string $file, string $locale): Resource
{
if (!is_file($file)) {
throw new \InvalidArgumentException("$file is not a file");
}
$contents = file_get_contents($file);
if ($contents === false) {
throw new \RuntimeException("Error reading file at $file.");
}
return static::fromString($contents, $locale);
} | [
"public",
"static",
"function",
"fromFile",
"(",
"string",
"$",
"file",
",",
"string",
"$",
"locale",
")",
":",
"Resource",
"{",
"if",
"(",
"!",
"is_file",
"(",
"$",
"file",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"$file is not a file\"",
")",
";",
"}",
"$",
"contents",
"=",
"file_get_contents",
"(",
"$",
"file",
")",
";",
"if",
"(",
"$",
"contents",
"===",
"false",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"\"Error reading file at $file.\"",
")",
";",
"}",
"return",
"static",
"::",
"fromString",
"(",
"$",
"contents",
",",
"$",
"locale",
")",
";",
"}"
]
| Creates a Resource from a file
@param string $file The path to the file
@param string $locale The locale
@return Resource | [
"Creates",
"a",
"Resource",
"from",
"a",
"file"
]
| 882cbd43d273f771a384eb09d205d327033aaae3 | https://github.com/RinkAttendant6/JsonI18n/blob/882cbd43d273f771a384eb09d205d327033aaae3/src/ResourceBuilder.php#L50-L63 |
15,916 | awesomite/chariot | src/Pattern/StdPatterns/DatePattern.php | DatePattern.toUrl | public function toUrl($rawData): string
{
$data = $this->processRawData($rawData);
if (\is_object($data) && $data instanceof \DateTimeInterface) {
return $data->format(static::DATE_FORMAT);
}
if (\is_int($data)) {
return (new \DateTime())->setTimestamp($data)->format(static::DATE_FORMAT);
}
if (\is_string($data) && $this->match($data)) {
$sData = (string) $data;
if ($this->checkDate($sData)) {
return $sData;
}
}
throw $this->newInvalidToUrl($data);
} | php | public function toUrl($rawData): string
{
$data = $this->processRawData($rawData);
if (\is_object($data) && $data instanceof \DateTimeInterface) {
return $data->format(static::DATE_FORMAT);
}
if (\is_int($data)) {
return (new \DateTime())->setTimestamp($data)->format(static::DATE_FORMAT);
}
if (\is_string($data) && $this->match($data)) {
$sData = (string) $data;
if ($this->checkDate($sData)) {
return $sData;
}
}
throw $this->newInvalidToUrl($data);
} | [
"public",
"function",
"toUrl",
"(",
"$",
"rawData",
")",
":",
"string",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"processRawData",
"(",
"$",
"rawData",
")",
";",
"if",
"(",
"\\",
"is_object",
"(",
"$",
"data",
")",
"&&",
"$",
"data",
"instanceof",
"\\",
"DateTimeInterface",
")",
"{",
"return",
"$",
"data",
"->",
"format",
"(",
"static",
"::",
"DATE_FORMAT",
")",
";",
"}",
"if",
"(",
"\\",
"is_int",
"(",
"$",
"data",
")",
")",
"{",
"return",
"(",
"new",
"\\",
"DateTime",
"(",
")",
")",
"->",
"setTimestamp",
"(",
"$",
"data",
")",
"->",
"format",
"(",
"static",
"::",
"DATE_FORMAT",
")",
";",
"}",
"if",
"(",
"\\",
"is_string",
"(",
"$",
"data",
")",
"&&",
"$",
"this",
"->",
"match",
"(",
"$",
"data",
")",
")",
"{",
"$",
"sData",
"=",
"(",
"string",
")",
"$",
"data",
";",
"if",
"(",
"$",
"this",
"->",
"checkDate",
"(",
"$",
"sData",
")",
")",
"{",
"return",
"$",
"sData",
";",
"}",
"}",
"throw",
"$",
"this",
"->",
"newInvalidToUrl",
"(",
"$",
"data",
")",
";",
"}"
]
| Convert passed argument to date in format YYYY-mm-dd
@param int|string|\DateTimeInterface $rawData
@return string
@throws PatternException | [
"Convert",
"passed",
"argument",
"to",
"date",
"in",
"format",
"YYYY",
"-",
"mm",
"-",
"dd"
]
| 3229e38537b857be1d352308ba340dc530b12afb | https://github.com/awesomite/chariot/blob/3229e38537b857be1d352308ba340dc530b12afb/src/Pattern/StdPatterns/DatePattern.php#L53-L73 |
15,917 | awesomite/chariot | src/Pattern/StdPatterns/DatePattern.php | DatePattern.fromUrl | public function fromUrl(string $param)
{
if ($this->checkDate($param)) {
return new \DateTimeImmutable($param, $this->timezone);
}
throw $this->newInvalidFromUrl($param);
} | php | public function fromUrl(string $param)
{
if ($this->checkDate($param)) {
return new \DateTimeImmutable($param, $this->timezone);
}
throw $this->newInvalidFromUrl($param);
} | [
"public",
"function",
"fromUrl",
"(",
"string",
"$",
"param",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"checkDate",
"(",
"$",
"param",
")",
")",
"{",
"return",
"new",
"\\",
"DateTimeImmutable",
"(",
"$",
"param",
",",
"$",
"this",
"->",
"timezone",
")",
";",
"}",
"throw",
"$",
"this",
"->",
"newInvalidFromUrl",
"(",
"$",
"param",
")",
";",
"}"
]
| Convert date in format YYYY-mm-dd to \DateTimeImmutable object
@param string $param
@return \DateTimeImmutable
@throws PatternException | [
"Convert",
"date",
"in",
"format",
"YYYY",
"-",
"mm",
"-",
"dd",
"to",
"\\",
"DateTimeImmutable",
"object"
]
| 3229e38537b857be1d352308ba340dc530b12afb | https://github.com/awesomite/chariot/blob/3229e38537b857be1d352308ba340dc530b12afb/src/Pattern/StdPatterns/DatePattern.php#L104-L111 |
15,918 | sulu/SuluSalesShippingBundle | src/Sulu/Bundle/Sales/CoreBundle/Entity/BaseOrderAddress.php | BaseOrderAddress.copyValuesFromInterface | public function copyValuesFromInterface(OrderAddressInterface $from, OrderAddressInterface $to)
{
// account
$to->setAccountName($from->getAccountName());
$to->setUid($from->getUid());
// contact
$to->setTitle($from->getTitle());
$to->setSalutation($from->getSalutation());
$to->setFirstName($from->getFirstName());
$to->setLastName($from->getLastName());
$to->setEmail($from->getEmail());
$to->setPhone($from->getPhone());
$to->setPhoneMobile($from->getPhoneMobile());
// address
$to->setStreet($from->getStreet());
$to->setNumber($from->getNumber());
$to->setAddition($from->getAddition());
$to->setZip($from->getZip());
$to->setCity($from->getCity());
$to->setState($from->getState());
$to->setCountry($from->getCountry());
$to->setContactAddress($from->getContactAddress());
$to->setNote($from->getNote());
// postbox
$to->setPostboxCity($from->getPostboxCity());
$to->setPostboxNumber($from->getPostboxNumber());
$to->setPostboxPostcode($from->getPostboxPostcode());
} | php | public function copyValuesFromInterface(OrderAddressInterface $from, OrderAddressInterface $to)
{
// account
$to->setAccountName($from->getAccountName());
$to->setUid($from->getUid());
// contact
$to->setTitle($from->getTitle());
$to->setSalutation($from->getSalutation());
$to->setFirstName($from->getFirstName());
$to->setLastName($from->getLastName());
$to->setEmail($from->getEmail());
$to->setPhone($from->getPhone());
$to->setPhoneMobile($from->getPhoneMobile());
// address
$to->setStreet($from->getStreet());
$to->setNumber($from->getNumber());
$to->setAddition($from->getAddition());
$to->setZip($from->getZip());
$to->setCity($from->getCity());
$to->setState($from->getState());
$to->setCountry($from->getCountry());
$to->setContactAddress($from->getContactAddress());
$to->setNote($from->getNote());
// postbox
$to->setPostboxCity($from->getPostboxCity());
$to->setPostboxNumber($from->getPostboxNumber());
$to->setPostboxPostcode($from->getPostboxPostcode());
} | [
"public",
"function",
"copyValuesFromInterface",
"(",
"OrderAddressInterface",
"$",
"from",
",",
"OrderAddressInterface",
"$",
"to",
")",
"{",
"// account",
"$",
"to",
"->",
"setAccountName",
"(",
"$",
"from",
"->",
"getAccountName",
"(",
")",
")",
";",
"$",
"to",
"->",
"setUid",
"(",
"$",
"from",
"->",
"getUid",
"(",
")",
")",
";",
"// contact",
"$",
"to",
"->",
"setTitle",
"(",
"$",
"from",
"->",
"getTitle",
"(",
")",
")",
";",
"$",
"to",
"->",
"setSalutation",
"(",
"$",
"from",
"->",
"getSalutation",
"(",
")",
")",
";",
"$",
"to",
"->",
"setFirstName",
"(",
"$",
"from",
"->",
"getFirstName",
"(",
")",
")",
";",
"$",
"to",
"->",
"setLastName",
"(",
"$",
"from",
"->",
"getLastName",
"(",
")",
")",
";",
"$",
"to",
"->",
"setEmail",
"(",
"$",
"from",
"->",
"getEmail",
"(",
")",
")",
";",
"$",
"to",
"->",
"setPhone",
"(",
"$",
"from",
"->",
"getPhone",
"(",
")",
")",
";",
"$",
"to",
"->",
"setPhoneMobile",
"(",
"$",
"from",
"->",
"getPhoneMobile",
"(",
")",
")",
";",
"// address",
"$",
"to",
"->",
"setStreet",
"(",
"$",
"from",
"->",
"getStreet",
"(",
")",
")",
";",
"$",
"to",
"->",
"setNumber",
"(",
"$",
"from",
"->",
"getNumber",
"(",
")",
")",
";",
"$",
"to",
"->",
"setAddition",
"(",
"$",
"from",
"->",
"getAddition",
"(",
")",
")",
";",
"$",
"to",
"->",
"setZip",
"(",
"$",
"from",
"->",
"getZip",
"(",
")",
")",
";",
"$",
"to",
"->",
"setCity",
"(",
"$",
"from",
"->",
"getCity",
"(",
")",
")",
";",
"$",
"to",
"->",
"setState",
"(",
"$",
"from",
"->",
"getState",
"(",
")",
")",
";",
"$",
"to",
"->",
"setCountry",
"(",
"$",
"from",
"->",
"getCountry",
"(",
")",
")",
";",
"$",
"to",
"->",
"setContactAddress",
"(",
"$",
"from",
"->",
"getContactAddress",
"(",
")",
")",
";",
"$",
"to",
"->",
"setNote",
"(",
"$",
"from",
"->",
"getNote",
"(",
")",
")",
";",
"// postbox",
"$",
"to",
"->",
"setPostboxCity",
"(",
"$",
"from",
"->",
"getPostboxCity",
"(",
")",
")",
";",
"$",
"to",
"->",
"setPostboxNumber",
"(",
"$",
"from",
"->",
"getPostboxNumber",
"(",
")",
")",
";",
"$",
"to",
"->",
"setPostboxPostcode",
"(",
"$",
"from",
"->",
"getPostboxPostcode",
"(",
")",
")",
";",
"}"
]
| Copies address data from one order-address-interface to another
@param OrderAddressInterface $from
@param OrderAddressInterface $to | [
"Copies",
"address",
"data",
"from",
"one",
"order",
"-",
"address",
"-",
"interface",
"to",
"another"
]
| 0d39de262d58579e5679db99a77dbf717d600b5e | https://github.com/sulu/SuluSalesShippingBundle/blob/0d39de262d58579e5679db99a77dbf717d600b5e/src/Sulu/Bundle/Sales/CoreBundle/Entity/BaseOrderAddress.php#L651-L678 |
15,919 | sulu/SuluSalesShippingBundle | src/Sulu/Bundle/Sales/CoreBundle/Entity/BaseOrderAddress.php | BaseOrderAddress.toArray | public function toArray()
{
return array(
// account
'accountName' => $this->getAccountName(),
'uid' => $this->getUid(),
// contact
'title' => $this->getTitle(),
'salutation' => $this->getSalutation(),
'firstName' => $this->getFirstName(),
'lastName' => $this->getLastName(),
'email' => $this->getEmail(),
'phone' => $this->getPhone(),
'phoneMobile' => $this->getPhoneMobile(),
// address
'street' => $this->getStreet(),
'number' => $this->getNumber(),
'addition' => $this->getAddition(),
'zip' => $this->getZip(),
'city' => $this->getCity(),
'state' => $this->getState(),
'country' => $this->getCountry(),
'note' => $this->getNote(),
'contactAddress' => $this->getContactAddress() ? array(
'id' => $this->getContactAddress()->getId()
) : null,
// postbox
'postboxCity' => $this->getPostboxCity(),
'postboxNumber' => $this->getPostboxNumber(),
'postboxPostcode' => $this->getPostboxPostcode(),
);
} | php | public function toArray()
{
return array(
// account
'accountName' => $this->getAccountName(),
'uid' => $this->getUid(),
// contact
'title' => $this->getTitle(),
'salutation' => $this->getSalutation(),
'firstName' => $this->getFirstName(),
'lastName' => $this->getLastName(),
'email' => $this->getEmail(),
'phone' => $this->getPhone(),
'phoneMobile' => $this->getPhoneMobile(),
// address
'street' => $this->getStreet(),
'number' => $this->getNumber(),
'addition' => $this->getAddition(),
'zip' => $this->getZip(),
'city' => $this->getCity(),
'state' => $this->getState(),
'country' => $this->getCountry(),
'note' => $this->getNote(),
'contactAddress' => $this->getContactAddress() ? array(
'id' => $this->getContactAddress()->getId()
) : null,
// postbox
'postboxCity' => $this->getPostboxCity(),
'postboxNumber' => $this->getPostboxNumber(),
'postboxPostcode' => $this->getPostboxPostcode(),
);
} | [
"public",
"function",
"toArray",
"(",
")",
"{",
"return",
"array",
"(",
"// account",
"'accountName'",
"=>",
"$",
"this",
"->",
"getAccountName",
"(",
")",
",",
"'uid'",
"=>",
"$",
"this",
"->",
"getUid",
"(",
")",
",",
"// contact",
"'title'",
"=>",
"$",
"this",
"->",
"getTitle",
"(",
")",
",",
"'salutation'",
"=>",
"$",
"this",
"->",
"getSalutation",
"(",
")",
",",
"'firstName'",
"=>",
"$",
"this",
"->",
"getFirstName",
"(",
")",
",",
"'lastName'",
"=>",
"$",
"this",
"->",
"getLastName",
"(",
")",
",",
"'email'",
"=>",
"$",
"this",
"->",
"getEmail",
"(",
")",
",",
"'phone'",
"=>",
"$",
"this",
"->",
"getPhone",
"(",
")",
",",
"'phoneMobile'",
"=>",
"$",
"this",
"->",
"getPhoneMobile",
"(",
")",
",",
"// address",
"'street'",
"=>",
"$",
"this",
"->",
"getStreet",
"(",
")",
",",
"'number'",
"=>",
"$",
"this",
"->",
"getNumber",
"(",
")",
",",
"'addition'",
"=>",
"$",
"this",
"->",
"getAddition",
"(",
")",
",",
"'zip'",
"=>",
"$",
"this",
"->",
"getZip",
"(",
")",
",",
"'city'",
"=>",
"$",
"this",
"->",
"getCity",
"(",
")",
",",
"'state'",
"=>",
"$",
"this",
"->",
"getState",
"(",
")",
",",
"'country'",
"=>",
"$",
"this",
"->",
"getCountry",
"(",
")",
",",
"'note'",
"=>",
"$",
"this",
"->",
"getNote",
"(",
")",
",",
"'contactAddress'",
"=>",
"$",
"this",
"->",
"getContactAddress",
"(",
")",
"?",
"array",
"(",
"'id'",
"=>",
"$",
"this",
"->",
"getContactAddress",
"(",
")",
"->",
"getId",
"(",
")",
")",
":",
"null",
",",
"// postbox",
"'postboxCity'",
"=>",
"$",
"this",
"->",
"getPostboxCity",
"(",
")",
",",
"'postboxNumber'",
"=>",
"$",
"this",
"->",
"getPostboxNumber",
"(",
")",
",",
"'postboxPostcode'",
"=>",
"$",
"this",
"->",
"getPostboxPostcode",
"(",
")",
",",
")",
";",
"}"
]
| Converts a BaseOrderAddress | [
"Converts",
"a",
"BaseOrderAddress"
]
| 0d39de262d58579e5679db99a77dbf717d600b5e | https://github.com/sulu/SuluSalesShippingBundle/blob/0d39de262d58579e5679db99a77dbf717d600b5e/src/Sulu/Bundle/Sales/CoreBundle/Entity/BaseOrderAddress.php#L683-L714 |
15,920 | gisostallenberg/file-permission-calculator | src/FilePermissionCalculator.php | FilePermissionCalculator.getStringRepresentation | public static function getStringRepresentation($mode)
{
$permissions = '';
if (($mode & 0xC000) == 0xC000) {
$permissions = 's'; // socket
} elseif (($mode & 0xA000) == 0xA000) {
$permissions = 'l'; // symbolic link
} elseif (($mode & 0x8000) == 0x8000) {
$permissions = '-'; // regular
} elseif (($mode & 0x6000) == 0x6000) {
$permissions = 'b'; // block special
} elseif (($mode & 0x4000) == 0x4000) {
$permissions = 'd'; // directory
} elseif (($mode & 0x2000) == 0x2000) {
$permissions = 'c'; // character special
} elseif (($mode & 0x1000) == 0x1000) {
$permissions = 'p'; // FIFO pipe
} else {
$permissions = 'u'; // unknown
}
// owner
$permissions .= (($mode & 0x0100) ? 'r' : '-');
$permissions .= (($mode & 0x0080) ? 'w' : '-');
$permissions .= (($mode & 0x0040) ?
(($mode & 0x0800) ? 's' : 'x') :
(($mode & 0x0800) ? 'S' : '-'));
// group
$permissions .= (($mode & 0x0020) ? 'r' : '-');
$permissions .= (($mode & 0x0010) ? 'w' : '-');
$permissions .= (($mode & 0x0008) ?
(($mode & 0x0400) ? 's' : 'x') :
(($mode & 0x0400) ? 'S' : '-'));
// world
$permissions .= (($mode & 0x0004) ? 'r' : '-');
$permissions .= (($mode & 0x0002) ? 'w' : '-');
$permissions .= (($mode & 0x0001) ?
(($mode & 0x0200) ? 't' : 'x') :
(($mode & 0x0200) ? 'T' : '-'));
return $permissions;
} | php | public static function getStringRepresentation($mode)
{
$permissions = '';
if (($mode & 0xC000) == 0xC000) {
$permissions = 's'; // socket
} elseif (($mode & 0xA000) == 0xA000) {
$permissions = 'l'; // symbolic link
} elseif (($mode & 0x8000) == 0x8000) {
$permissions = '-'; // regular
} elseif (($mode & 0x6000) == 0x6000) {
$permissions = 'b'; // block special
} elseif (($mode & 0x4000) == 0x4000) {
$permissions = 'd'; // directory
} elseif (($mode & 0x2000) == 0x2000) {
$permissions = 'c'; // character special
} elseif (($mode & 0x1000) == 0x1000) {
$permissions = 'p'; // FIFO pipe
} else {
$permissions = 'u'; // unknown
}
// owner
$permissions .= (($mode & 0x0100) ? 'r' : '-');
$permissions .= (($mode & 0x0080) ? 'w' : '-');
$permissions .= (($mode & 0x0040) ?
(($mode & 0x0800) ? 's' : 'x') :
(($mode & 0x0800) ? 'S' : '-'));
// group
$permissions .= (($mode & 0x0020) ? 'r' : '-');
$permissions .= (($mode & 0x0010) ? 'w' : '-');
$permissions .= (($mode & 0x0008) ?
(($mode & 0x0400) ? 's' : 'x') :
(($mode & 0x0400) ? 'S' : '-'));
// world
$permissions .= (($mode & 0x0004) ? 'r' : '-');
$permissions .= (($mode & 0x0002) ? 'w' : '-');
$permissions .= (($mode & 0x0001) ?
(($mode & 0x0200) ? 't' : 'x') :
(($mode & 0x0200) ? 'T' : '-'));
return $permissions;
} | [
"public",
"static",
"function",
"getStringRepresentation",
"(",
"$",
"mode",
")",
"{",
"$",
"permissions",
"=",
"''",
";",
"if",
"(",
"(",
"$",
"mode",
"&",
"0xC000",
")",
"==",
"0xC000",
")",
"{",
"$",
"permissions",
"=",
"'s'",
";",
"// socket",
"}",
"elseif",
"(",
"(",
"$",
"mode",
"&",
"0xA000",
")",
"==",
"0xA000",
")",
"{",
"$",
"permissions",
"=",
"'l'",
";",
"// symbolic link",
"}",
"elseif",
"(",
"(",
"$",
"mode",
"&",
"0x8000",
")",
"==",
"0x8000",
")",
"{",
"$",
"permissions",
"=",
"'-'",
";",
"// regular",
"}",
"elseif",
"(",
"(",
"$",
"mode",
"&",
"0x6000",
")",
"==",
"0x6000",
")",
"{",
"$",
"permissions",
"=",
"'b'",
";",
"// block special",
"}",
"elseif",
"(",
"(",
"$",
"mode",
"&",
"0x4000",
")",
"==",
"0x4000",
")",
"{",
"$",
"permissions",
"=",
"'d'",
";",
"// directory",
"}",
"elseif",
"(",
"(",
"$",
"mode",
"&",
"0x2000",
")",
"==",
"0x2000",
")",
"{",
"$",
"permissions",
"=",
"'c'",
";",
"// character special",
"}",
"elseif",
"(",
"(",
"$",
"mode",
"&",
"0x1000",
")",
"==",
"0x1000",
")",
"{",
"$",
"permissions",
"=",
"'p'",
";",
"// FIFO pipe",
"}",
"else",
"{",
"$",
"permissions",
"=",
"'u'",
";",
"// unknown",
"}",
"// owner",
"$",
"permissions",
".=",
"(",
"(",
"$",
"mode",
"&",
"0x0100",
")",
"?",
"'r'",
":",
"'-'",
")",
";",
"$",
"permissions",
".=",
"(",
"(",
"$",
"mode",
"&",
"0x0080",
")",
"?",
"'w'",
":",
"'-'",
")",
";",
"$",
"permissions",
".=",
"(",
"(",
"$",
"mode",
"&",
"0x0040",
")",
"?",
"(",
"(",
"$",
"mode",
"&",
"0x0800",
")",
"?",
"'s'",
":",
"'x'",
")",
":",
"(",
"(",
"$",
"mode",
"&",
"0x0800",
")",
"?",
"'S'",
":",
"'-'",
")",
")",
";",
"// group",
"$",
"permissions",
".=",
"(",
"(",
"$",
"mode",
"&",
"0x0020",
")",
"?",
"'r'",
":",
"'-'",
")",
";",
"$",
"permissions",
".=",
"(",
"(",
"$",
"mode",
"&",
"0x0010",
")",
"?",
"'w'",
":",
"'-'",
")",
";",
"$",
"permissions",
".=",
"(",
"(",
"$",
"mode",
"&",
"0x0008",
")",
"?",
"(",
"(",
"$",
"mode",
"&",
"0x0400",
")",
"?",
"'s'",
":",
"'x'",
")",
":",
"(",
"(",
"$",
"mode",
"&",
"0x0400",
")",
"?",
"'S'",
":",
"'-'",
")",
")",
";",
"// world",
"$",
"permissions",
".=",
"(",
"(",
"$",
"mode",
"&",
"0x0004",
")",
"?",
"'r'",
":",
"'-'",
")",
";",
"$",
"permissions",
".=",
"(",
"(",
"$",
"mode",
"&",
"0x0002",
")",
"?",
"'w'",
":",
"'-'",
")",
";",
"$",
"permissions",
".=",
"(",
"(",
"$",
"mode",
"&",
"0x0001",
")",
"?",
"(",
"(",
"$",
"mode",
"&",
"0x0200",
")",
"?",
"'t'",
":",
"'x'",
")",
":",
"(",
"(",
"$",
"mode",
"&",
"0x0200",
")",
"?",
"'T'",
":",
"'-'",
")",
")",
";",
"return",
"$",
"permissions",
";",
"}"
]
| Gives a string representation of the permissions.
See "Example #2 Display full permissions" on http://php.net/manual/en/function.fileperms.php
@param int $mode
@return FilePermissionCalculator | [
"Gives",
"a",
"string",
"representation",
"of",
"the",
"permissions",
"."
]
| ac7fa1fe3c0792890c3834d0e978964dbb1cdbd8 | https://github.com/gisostallenberg/file-permission-calculator/blob/ac7fa1fe3c0792890c3834d0e978964dbb1cdbd8/src/FilePermissionCalculator.php#L175-L219 |
15,921 | gisostallenberg/file-permission-calculator | src/FilePermissionCalculator.php | FilePermissionCalculator.getModeFromStringRepresentation | public static function getModeFromStringRepresentation($permissions)
{
if (strlen($permissions) !== 10) {
throw new InvalidArgumentException('Please provide a 10 character long string');
}
$mode = 0;
if ($permissions[0] == 's') {
$mode = 0140000;
} elseif ($permissions[0] == 'l') {
$mode = 0120000;
} elseif ($permissions[0] == '-') {
$mode = 0100000;
} elseif ($permissions[0] == 'b') {
$mode = 060000;
} elseif ($permissions[0] == 'd') {
$mode = 040000;
} elseif ($permissions[0] == 'c') {
$mode = 020000;
} elseif ($permissions[0] == 'p') {
$mode = 010000;
} elseif ($permissions[0] == 'u') {
$mode = 0;
}
if ($permissions[1] == 'r') {
$mode += 0400;
}
if ($permissions[2] == 'w') {
$mode += 0200;
}
if ($permissions[3] == 'x') {
$mode += 0100;
} elseif ($permissions[3] == 's') {
$mode += 04100;
} elseif ($permissions[3] == 'S') {
$mode += 04000;
}
if ($permissions[4] == 'r') {
$mode += 040;
}
if ($permissions[5] == 'w') {
$mode += 020;
}
if ($permissions[6] == 'x') {
$mode += 010;
} elseif ($permissions[6] == 's') {
$mode += 02010;
} elseif ($permissions[6] == 'S') {
$mode += 02000;
}
if ($permissions[7] == 'r') {
$mode += 04;
}
if ($permissions[8] == 'w') {
$mode += 02;
}
if ($permissions[9] == 'x') {
$mode += 01;
} elseif ($permissions[9] == 't') {
$mode += 01001;
} elseif ($permissions[9] == 'T') {
$mode += 01000;
}
return $mode;
} | php | public static function getModeFromStringRepresentation($permissions)
{
if (strlen($permissions) !== 10) {
throw new InvalidArgumentException('Please provide a 10 character long string');
}
$mode = 0;
if ($permissions[0] == 's') {
$mode = 0140000;
} elseif ($permissions[0] == 'l') {
$mode = 0120000;
} elseif ($permissions[0] == '-') {
$mode = 0100000;
} elseif ($permissions[0] == 'b') {
$mode = 060000;
} elseif ($permissions[0] == 'd') {
$mode = 040000;
} elseif ($permissions[0] == 'c') {
$mode = 020000;
} elseif ($permissions[0] == 'p') {
$mode = 010000;
} elseif ($permissions[0] == 'u') {
$mode = 0;
}
if ($permissions[1] == 'r') {
$mode += 0400;
}
if ($permissions[2] == 'w') {
$mode += 0200;
}
if ($permissions[3] == 'x') {
$mode += 0100;
} elseif ($permissions[3] == 's') {
$mode += 04100;
} elseif ($permissions[3] == 'S') {
$mode += 04000;
}
if ($permissions[4] == 'r') {
$mode += 040;
}
if ($permissions[5] == 'w') {
$mode += 020;
}
if ($permissions[6] == 'x') {
$mode += 010;
} elseif ($permissions[6] == 's') {
$mode += 02010;
} elseif ($permissions[6] == 'S') {
$mode += 02000;
}
if ($permissions[7] == 'r') {
$mode += 04;
}
if ($permissions[8] == 'w') {
$mode += 02;
}
if ($permissions[9] == 'x') {
$mode += 01;
} elseif ($permissions[9] == 't') {
$mode += 01001;
} elseif ($permissions[9] == 'T') {
$mode += 01000;
}
return $mode;
} | [
"public",
"static",
"function",
"getModeFromStringRepresentation",
"(",
"$",
"permissions",
")",
"{",
"if",
"(",
"strlen",
"(",
"$",
"permissions",
")",
"!==",
"10",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Please provide a 10 character long string'",
")",
";",
"}",
"$",
"mode",
"=",
"0",
";",
"if",
"(",
"$",
"permissions",
"[",
"0",
"]",
"==",
"'s'",
")",
"{",
"$",
"mode",
"=",
"0140000",
";",
"}",
"elseif",
"(",
"$",
"permissions",
"[",
"0",
"]",
"==",
"'l'",
")",
"{",
"$",
"mode",
"=",
"0120000",
";",
"}",
"elseif",
"(",
"$",
"permissions",
"[",
"0",
"]",
"==",
"'-'",
")",
"{",
"$",
"mode",
"=",
"0100000",
";",
"}",
"elseif",
"(",
"$",
"permissions",
"[",
"0",
"]",
"==",
"'b'",
")",
"{",
"$",
"mode",
"=",
"060000",
";",
"}",
"elseif",
"(",
"$",
"permissions",
"[",
"0",
"]",
"==",
"'d'",
")",
"{",
"$",
"mode",
"=",
"040000",
";",
"}",
"elseif",
"(",
"$",
"permissions",
"[",
"0",
"]",
"==",
"'c'",
")",
"{",
"$",
"mode",
"=",
"020000",
";",
"}",
"elseif",
"(",
"$",
"permissions",
"[",
"0",
"]",
"==",
"'p'",
")",
"{",
"$",
"mode",
"=",
"010000",
";",
"}",
"elseif",
"(",
"$",
"permissions",
"[",
"0",
"]",
"==",
"'u'",
")",
"{",
"$",
"mode",
"=",
"0",
";",
"}",
"if",
"(",
"$",
"permissions",
"[",
"1",
"]",
"==",
"'r'",
")",
"{",
"$",
"mode",
"+=",
"0400",
";",
"}",
"if",
"(",
"$",
"permissions",
"[",
"2",
"]",
"==",
"'w'",
")",
"{",
"$",
"mode",
"+=",
"0200",
";",
"}",
"if",
"(",
"$",
"permissions",
"[",
"3",
"]",
"==",
"'x'",
")",
"{",
"$",
"mode",
"+=",
"0100",
";",
"}",
"elseif",
"(",
"$",
"permissions",
"[",
"3",
"]",
"==",
"'s'",
")",
"{",
"$",
"mode",
"+=",
"04100",
";",
"}",
"elseif",
"(",
"$",
"permissions",
"[",
"3",
"]",
"==",
"'S'",
")",
"{",
"$",
"mode",
"+=",
"04000",
";",
"}",
"if",
"(",
"$",
"permissions",
"[",
"4",
"]",
"==",
"'r'",
")",
"{",
"$",
"mode",
"+=",
"040",
";",
"}",
"if",
"(",
"$",
"permissions",
"[",
"5",
"]",
"==",
"'w'",
")",
"{",
"$",
"mode",
"+=",
"020",
";",
"}",
"if",
"(",
"$",
"permissions",
"[",
"6",
"]",
"==",
"'x'",
")",
"{",
"$",
"mode",
"+=",
"010",
";",
"}",
"elseif",
"(",
"$",
"permissions",
"[",
"6",
"]",
"==",
"'s'",
")",
"{",
"$",
"mode",
"+=",
"02010",
";",
"}",
"elseif",
"(",
"$",
"permissions",
"[",
"6",
"]",
"==",
"'S'",
")",
"{",
"$",
"mode",
"+=",
"02000",
";",
"}",
"if",
"(",
"$",
"permissions",
"[",
"7",
"]",
"==",
"'r'",
")",
"{",
"$",
"mode",
"+=",
"04",
";",
"}",
"if",
"(",
"$",
"permissions",
"[",
"8",
"]",
"==",
"'w'",
")",
"{",
"$",
"mode",
"+=",
"02",
";",
"}",
"if",
"(",
"$",
"permissions",
"[",
"9",
"]",
"==",
"'x'",
")",
"{",
"$",
"mode",
"+=",
"01",
";",
"}",
"elseif",
"(",
"$",
"permissions",
"[",
"9",
"]",
"==",
"'t'",
")",
"{",
"$",
"mode",
"+=",
"01001",
";",
"}",
"elseif",
"(",
"$",
"permissions",
"[",
"9",
"]",
"==",
"'T'",
")",
"{",
"$",
"mode",
"+=",
"01000",
";",
"}",
"return",
"$",
"mode",
";",
"}"
]
| Converts the string representation to a mode.
See comment of 'paul maybe at squirrel mail org' on http://php.net/manual/en/function.chmod.php
@param string $permissions
@return int | [
"Converts",
"the",
"string",
"representation",
"to",
"a",
"mode",
"."
]
| ac7fa1fe3c0792890c3834d0e978964dbb1cdbd8 | https://github.com/gisostallenberg/file-permission-calculator/blob/ac7fa1fe3c0792890c3834d0e978964dbb1cdbd8/src/FilePermissionCalculator.php#L230-L298 |
15,922 | Atlantic18/CoralCoreBundle | Service/Request/CurlRequestHandle.php | CurlRequestHandle.setHeader | public function setHeader($key, $value)
{
$this->headers[$key] = $value;
//Headers can't be passed as key: value associative array
$tmpHeaders = array();
foreach($this->headers as $tmpKey => $tmpValue)
{
$tmpHeaders[] = "$tmpKey: $tmpValue";
}
curl_setopt($this->handle, CURLOPT_HTTPHEADER, $tmpHeaders);
} | php | public function setHeader($key, $value)
{
$this->headers[$key] = $value;
//Headers can't be passed as key: value associative array
$tmpHeaders = array();
foreach($this->headers as $tmpKey => $tmpValue)
{
$tmpHeaders[] = "$tmpKey: $tmpValue";
}
curl_setopt($this->handle, CURLOPT_HTTPHEADER, $tmpHeaders);
} | [
"public",
"function",
"setHeader",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"headers",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"//Headers can't be passed as key: value associative array",
"$",
"tmpHeaders",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"headers",
"as",
"$",
"tmpKey",
"=>",
"$",
"tmpValue",
")",
"{",
"$",
"tmpHeaders",
"[",
"]",
"=",
"\"$tmpKey: $tmpValue\"",
";",
"}",
"curl_setopt",
"(",
"$",
"this",
"->",
"handle",
",",
"CURLOPT_HTTPHEADER",
",",
"$",
"tmpHeaders",
")",
";",
"}"
]
| Set request header
@param string $key Request header key
@param string $value Request header value | [
"Set",
"request",
"header"
]
| 7d74ffaf51046ad13cbfc2b0b69d656a499f38ab | https://github.com/Atlantic18/CoralCoreBundle/blob/7d74ffaf51046ad13cbfc2b0b69d656a499f38ab/Service/Request/CurlRequestHandle.php#L62-L74 |
15,923 | FrenchFrogs/framework | src/Container/Head.php | Head.identity | public function identity($title, $description)
{
$this->title($title);
$this->meta('description', $description);
return $this;
} | php | public function identity($title, $description)
{
$this->title($title);
$this->meta('description', $description);
return $this;
} | [
"public",
"function",
"identity",
"(",
"$",
"title",
",",
"$",
"description",
")",
"{",
"$",
"this",
"->",
"title",
"(",
"$",
"title",
")",
";",
"$",
"this",
"->",
"meta",
"(",
"'description'",
",",
"$",
"description",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Fast identity set
@param $title
@param $description
@return $this | [
"Fast",
"identity",
"set"
]
| a4838c698a5600437e87dac6d35ba8ebe32c4395 | https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Container/Head.php#L43-L48 |
15,924 | FrenchFrogs/framework | src/Container/Head.php | Head.fb | public function fb($title = null, $site = null, $url = null, $description = null, $type = null, $app = null)
{
if (!is_null($title)) {
$this->property('og:title', $title);
}
if (!is_null($site)) {
$this->property('og:site_name', $site);
}
if (!is_null($url)) {
$this->property('og:url', $url);
}
if (!is_null($description)) {
$this->property('og:description', $description);
}
if (!is_null($url)) {
$this->property('og:type', $type);
}
if (!is_null($app)) {
$this->property('fb:app_id', $app);
}
} | php | public function fb($title = null, $site = null, $url = null, $description = null, $type = null, $app = null)
{
if (!is_null($title)) {
$this->property('og:title', $title);
}
if (!is_null($site)) {
$this->property('og:site_name', $site);
}
if (!is_null($url)) {
$this->property('og:url', $url);
}
if (!is_null($description)) {
$this->property('og:description', $description);
}
if (!is_null($url)) {
$this->property('og:type', $type);
}
if (!is_null($app)) {
$this->property('fb:app_id', $app);
}
} | [
"public",
"function",
"fb",
"(",
"$",
"title",
"=",
"null",
",",
"$",
"site",
"=",
"null",
",",
"$",
"url",
"=",
"null",
",",
"$",
"description",
"=",
"null",
",",
"$",
"type",
"=",
"null",
",",
"$",
"app",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"title",
")",
")",
"{",
"$",
"this",
"->",
"property",
"(",
"'og:title'",
",",
"$",
"title",
")",
";",
"}",
"if",
"(",
"!",
"is_null",
"(",
"$",
"site",
")",
")",
"{",
"$",
"this",
"->",
"property",
"(",
"'og:site_name'",
",",
"$",
"site",
")",
";",
"}",
"if",
"(",
"!",
"is_null",
"(",
"$",
"url",
")",
")",
"{",
"$",
"this",
"->",
"property",
"(",
"'og:url'",
",",
"$",
"url",
")",
";",
"}",
"if",
"(",
"!",
"is_null",
"(",
"$",
"description",
")",
")",
"{",
"$",
"this",
"->",
"property",
"(",
"'og:description'",
",",
"$",
"description",
")",
";",
"}",
"if",
"(",
"!",
"is_null",
"(",
"$",
"url",
")",
")",
"{",
"$",
"this",
"->",
"property",
"(",
"'og:type'",
",",
"$",
"type",
")",
";",
"}",
"if",
"(",
"!",
"is_null",
"(",
"$",
"app",
")",
")",
"{",
"$",
"this",
"->",
"property",
"(",
"'fb:app_id'",
",",
"$",
"app",
")",
";",
"}",
"}"
]
| Usefool facebook open graph
@param null $title
@param null $site
@param null $url
@param null $description
@param null $type
@param null $app | [
"Usefool",
"facebook",
"open",
"graph"
]
| a4838c698a5600437e87dac6d35ba8ebe32c4395 | https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Container/Head.php#L95-L120 |
15,925 | FrenchFrogs/framework | src/Container/Head.php | Head.twitter | public function twitter($title, $site, $description, $image = null, $card = 'summary')
{
$this->meta('twitter:card', $card);
$this->meta('twitter:site', $site);
$this->meta('twitter:title', $title);
$this->meta('twitter:description', $description);
$this->meta('twitter:card', $title);
if (!is_null($image)) {
$this->meta('twitter:image', $image);
}
} | php | public function twitter($title, $site, $description, $image = null, $card = 'summary')
{
$this->meta('twitter:card', $card);
$this->meta('twitter:site', $site);
$this->meta('twitter:title', $title);
$this->meta('twitter:description', $description);
$this->meta('twitter:card', $title);
if (!is_null($image)) {
$this->meta('twitter:image', $image);
}
} | [
"public",
"function",
"twitter",
"(",
"$",
"title",
",",
"$",
"site",
",",
"$",
"description",
",",
"$",
"image",
"=",
"null",
",",
"$",
"card",
"=",
"'summary'",
")",
"{",
"$",
"this",
"->",
"meta",
"(",
"'twitter:card'",
",",
"$",
"card",
")",
";",
"$",
"this",
"->",
"meta",
"(",
"'twitter:site'",
",",
"$",
"site",
")",
";",
"$",
"this",
"->",
"meta",
"(",
"'twitter:title'",
",",
"$",
"title",
")",
";",
"$",
"this",
"->",
"meta",
"(",
"'twitter:description'",
",",
"$",
"description",
")",
";",
"$",
"this",
"->",
"meta",
"(",
"'twitter:card'",
",",
"$",
"title",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"image",
")",
")",
"{",
"$",
"this",
"->",
"meta",
"(",
"'twitter:image'",
",",
"$",
"image",
")",
";",
"}",
"}"
]
| Set twitter meta
@param string $card
@param $site
@param $title
@param $description
@param null $image | [
"Set",
"twitter",
"meta"
]
| a4838c698a5600437e87dac6d35ba8ebe32c4395 | https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Container/Head.php#L131-L142 |
15,926 | blast-project/CoreBundle | src/CodeGenerator/CodeGeneratorRegistry.php | CodeGeneratorRegistry.register | public static function register(CodeGeneratorInterface $codeGenerator)
{
$class = get_class($codeGenerator);
if (!defined("$class::ENTITY_CLASS")) {
throw new \Exception($class . ' must define a ENTITY_CLASS constant.');
}
if (!defined("$class::ENTITY_FIELD")) {
throw new \Exception($class . ' must define a ENTITY_FIELD constant.');
}
self::$generators[$codeGenerator::ENTITY_CLASS][$codeGenerator::ENTITY_FIELD] = $codeGenerator;
} | php | public static function register(CodeGeneratorInterface $codeGenerator)
{
$class = get_class($codeGenerator);
if (!defined("$class::ENTITY_CLASS")) {
throw new \Exception($class . ' must define a ENTITY_CLASS constant.');
}
if (!defined("$class::ENTITY_FIELD")) {
throw new \Exception($class . ' must define a ENTITY_FIELD constant.');
}
self::$generators[$codeGenerator::ENTITY_CLASS][$codeGenerator::ENTITY_FIELD] = $codeGenerator;
} | [
"public",
"static",
"function",
"register",
"(",
"CodeGeneratorInterface",
"$",
"codeGenerator",
")",
"{",
"$",
"class",
"=",
"get_class",
"(",
"$",
"codeGenerator",
")",
";",
"if",
"(",
"!",
"defined",
"(",
"\"$class::ENTITY_CLASS\"",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"$",
"class",
".",
"' must define a ENTITY_CLASS constant.'",
")",
";",
"}",
"if",
"(",
"!",
"defined",
"(",
"\"$class::ENTITY_FIELD\"",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"$",
"class",
".",
"' must define a ENTITY_FIELD constant.'",
")",
";",
"}",
"self",
"::",
"$",
"generators",
"[",
"$",
"codeGenerator",
"::",
"ENTITY_CLASS",
"]",
"[",
"$",
"codeGenerator",
"::",
"ENTITY_FIELD",
"]",
"=",
"$",
"codeGenerator",
";",
"}"
]
| Registers an entity code generator service.
@param CodeGeneratorInterface $codeGenerator the entity code generator service
@throws \Exception | [
"Registers",
"an",
"entity",
"code",
"generator",
"service",
"."
]
| 7a0832758ca14e5bc5d65515532c1220df3930ae | https://github.com/blast-project/CoreBundle/blob/7a0832758ca14e5bc5d65515532c1220df3930ae/src/CodeGenerator/CodeGeneratorRegistry.php#L26-L36 |
15,927 | blast-project/CoreBundle | src/CodeGenerator/CodeGeneratorRegistry.php | CodeGeneratorRegistry.getCodeGenerator | public static function getCodeGenerator($entityClass, $entityField = 'code')
{
if (!isset(self::$generators[$entityClass][$entityField])) {
throw new \Exception("There is no registered entity code generator for class $entityClass and field $entityField");
}
return self::$generators[$entityClass][$entityField];
} | php | public static function getCodeGenerator($entityClass, $entityField = 'code')
{
if (!isset(self::$generators[$entityClass][$entityField])) {
throw new \Exception("There is no registered entity code generator for class $entityClass and field $entityField");
}
return self::$generators[$entityClass][$entityField];
} | [
"public",
"static",
"function",
"getCodeGenerator",
"(",
"$",
"entityClass",
",",
"$",
"entityField",
"=",
"'code'",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"generators",
"[",
"$",
"entityClass",
"]",
"[",
"$",
"entityField",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"There is no registered entity code generator for class $entityClass and field $entityField\"",
")",
";",
"}",
"return",
"self",
"::",
"$",
"generators",
"[",
"$",
"entityClass",
"]",
"[",
"$",
"entityField",
"]",
";",
"}"
]
| Returns the last registered entity code generator service id for a given entity class and field.
@param string $entityClass
@param string $entityField
@return CodeGeneratorInterface
@throws \Exception | [
"Returns",
"the",
"last",
"registered",
"entity",
"code",
"generator",
"service",
"id",
"for",
"a",
"given",
"entity",
"class",
"and",
"field",
"."
]
| 7a0832758ca14e5bc5d65515532c1220df3930ae | https://github.com/blast-project/CoreBundle/blob/7a0832758ca14e5bc5d65515532c1220df3930ae/src/CodeGenerator/CodeGeneratorRegistry.php#L48-L55 |
15,928 | blast-project/CoreBundle | src/CodeGenerator/CodeGeneratorRegistry.php | CodeGeneratorRegistry.getCodeGenerators | public static function getCodeGenerators($entityClass = null)
{
if ($entityClass) {
if (!isset(self::$generators[$entityClass])) {
throw new \Exception("There is no registered entity code generator for class $entityClass");
}
return self::$generators[$entityClass];
} else {
return self::$generators;
}
} | php | public static function getCodeGenerators($entityClass = null)
{
if ($entityClass) {
if (!isset(self::$generators[$entityClass])) {
throw new \Exception("There is no registered entity code generator for class $entityClass");
}
return self::$generators[$entityClass];
} else {
return self::$generators;
}
} | [
"public",
"static",
"function",
"getCodeGenerators",
"(",
"$",
"entityClass",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"entityClass",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"generators",
"[",
"$",
"entityClass",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"There is no registered entity code generator for class $entityClass\"",
")",
";",
"}",
"return",
"self",
"::",
"$",
"generators",
"[",
"$",
"entityClass",
"]",
";",
"}",
"else",
"{",
"return",
"self",
"::",
"$",
"generators",
";",
"}",
"}"
]
| Returns registred code generators for specifyed entity class.
@param string $entityClass
@return array | [
"Returns",
"registred",
"code",
"generators",
"for",
"specifyed",
"entity",
"class",
"."
]
| 7a0832758ca14e5bc5d65515532c1220df3930ae | https://github.com/blast-project/CoreBundle/blob/7a0832758ca14e5bc5d65515532c1220df3930ae/src/CodeGenerator/CodeGeneratorRegistry.php#L64-L75 |
15,929 | BugBuster1701/banner | classes/ModuleBannerTag.php | ModuleBannerTag.getModuleData | protected function getModuleData($moduleId)
{
$this->module_id = $moduleId; //for RandomBlocker Session
//DEBUG log_message('getModuleData Banner Modul ID:'.$moduleId,'Banner.log');
$objBannerModule = \Database::getInstance()->prepare("SELECT
banner_hideempty,
banner_firstview,
banner_categories,
banner_template,
banner_redirect,
banner_useragent,
cssID,
space,
headline
FROM
tl_module
WHERE
id=?
AND
type=?")
->execute($moduleId, 'banner');
if ($objBannerModule->numRows == 0)
{
return false;
}
$this->banner_hideempty = $objBannerModule->banner_hideempty;
$this->banner_firstview = $objBannerModule->banner_firstview;
$this->banner_categories = $objBannerModule->banner_categories;
$this->banner_template = $objBannerModule->banner_template;
$this->banner_redirect = $objBannerModule->banner_redirect;
$this->banner_useragent = $objBannerModule->banner_useragent;
$this->cssID = $objBannerModule->cssID;
$this->space = $objBannerModule->space;
$this->headline = $objBannerModule->headline;
return true;
} | php | protected function getModuleData($moduleId)
{
$this->module_id = $moduleId; //for RandomBlocker Session
//DEBUG log_message('getModuleData Banner Modul ID:'.$moduleId,'Banner.log');
$objBannerModule = \Database::getInstance()->prepare("SELECT
banner_hideempty,
banner_firstview,
banner_categories,
banner_template,
banner_redirect,
banner_useragent,
cssID,
space,
headline
FROM
tl_module
WHERE
id=?
AND
type=?")
->execute($moduleId, 'banner');
if ($objBannerModule->numRows == 0)
{
return false;
}
$this->banner_hideempty = $objBannerModule->banner_hideempty;
$this->banner_firstview = $objBannerModule->banner_firstview;
$this->banner_categories = $objBannerModule->banner_categories;
$this->banner_template = $objBannerModule->banner_template;
$this->banner_redirect = $objBannerModule->banner_redirect;
$this->banner_useragent = $objBannerModule->banner_useragent;
$this->cssID = $objBannerModule->cssID;
$this->space = $objBannerModule->space;
$this->headline = $objBannerModule->headline;
return true;
} | [
"protected",
"function",
"getModuleData",
"(",
"$",
"moduleId",
")",
"{",
"$",
"this",
"->",
"module_id",
"=",
"$",
"moduleId",
";",
"//for RandomBlocker Session",
"//DEBUG log_message('getModuleData Banner Modul ID:'.$moduleId,'Banner.log');",
"$",
"objBannerModule",
"=",
"\\",
"Database",
"::",
"getInstance",
"(",
")",
"->",
"prepare",
"(",
"\"SELECT \n banner_hideempty,\n \t banner_firstview,\n \t banner_categories,\n \t banner_template,\n \t banner_redirect,\n \t banner_useragent,\n cssID,\n space,\n headline \n FROM \n tl_module \n WHERE \n id=?\n AND\n type=?\"",
")",
"->",
"execute",
"(",
"$",
"moduleId",
",",
"'banner'",
")",
";",
"if",
"(",
"$",
"objBannerModule",
"->",
"numRows",
"==",
"0",
")",
"{",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"banner_hideempty",
"=",
"$",
"objBannerModule",
"->",
"banner_hideempty",
";",
"$",
"this",
"->",
"banner_firstview",
"=",
"$",
"objBannerModule",
"->",
"banner_firstview",
";",
"$",
"this",
"->",
"banner_categories",
"=",
"$",
"objBannerModule",
"->",
"banner_categories",
";",
"$",
"this",
"->",
"banner_template",
"=",
"$",
"objBannerModule",
"->",
"banner_template",
";",
"$",
"this",
"->",
"banner_redirect",
"=",
"$",
"objBannerModule",
"->",
"banner_redirect",
";",
"$",
"this",
"->",
"banner_useragent",
"=",
"$",
"objBannerModule",
"->",
"banner_useragent",
";",
"$",
"this",
"->",
"cssID",
"=",
"$",
"objBannerModule",
"->",
"cssID",
";",
"$",
"this",
"->",
"space",
"=",
"$",
"objBannerModule",
"->",
"space",
";",
"$",
"this",
"->",
"headline",
"=",
"$",
"objBannerModule",
"->",
"headline",
";",
"return",
"true",
";",
"}"
]
| Wrapper for backward compatibility
@param integer $moduleId
@return boolean | [
"Wrapper",
"for",
"backward",
"compatibility"
]
| 3ffac36837923194ab0ebaf308c0b23a3684b005 | https://github.com/BugBuster1701/banner/blob/3ffac36837923194ab0ebaf308c0b23a3684b005/classes/ModuleBannerTag.php#L115-L150 |
15,930 | datasift/datasift-php | lib/DataSift/Definition.php | DataSift_Definition.set | public function set($csdl)
{
if ($csdl === false) {
$this->_csdl = false;
} else {
if (! is_string($csdl)) {
throw new DataSift_Exception_InvalidData('Definitions must be strings.');
}
// Trim the incoming string
$csdl = trim($csdl);
// If the string has changed, reset the hash
if ($this->_csdl != $csdl) {
$this->clearHash();
}
$this->_csdl = $csdl;
}
} | php | public function set($csdl)
{
if ($csdl === false) {
$this->_csdl = false;
} else {
if (! is_string($csdl)) {
throw new DataSift_Exception_InvalidData('Definitions must be strings.');
}
// Trim the incoming string
$csdl = trim($csdl);
// If the string has changed, reset the hash
if ($this->_csdl != $csdl) {
$this->clearHash();
}
$this->_csdl = $csdl;
}
} | [
"public",
"function",
"set",
"(",
"$",
"csdl",
")",
"{",
"if",
"(",
"$",
"csdl",
"===",
"false",
")",
"{",
"$",
"this",
"->",
"_csdl",
"=",
"false",
";",
"}",
"else",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"csdl",
")",
")",
"{",
"throw",
"new",
"DataSift_Exception_InvalidData",
"(",
"'Definitions must be strings.'",
")",
";",
"}",
"// Trim the incoming string",
"$",
"csdl",
"=",
"trim",
"(",
"$",
"csdl",
")",
";",
"// If the string has changed, reset the hash",
"if",
"(",
"$",
"this",
"->",
"_csdl",
"!=",
"$",
"csdl",
")",
"{",
"$",
"this",
"->",
"clearHash",
"(",
")",
";",
"}",
"$",
"this",
"->",
"_csdl",
"=",
"$",
"csdl",
";",
"}",
"}"
]
| Sets the definition string.
@param string $csdl The new definition string.
@return void
@throws DataSift_Exception_InvalidData | [
"Sets",
"the",
"definition",
"string",
"."
]
| 35282461ad3e54880e5940bb5afce26c75dc4bb9 | https://github.com/datasift/datasift-php/blob/35282461ad3e54880e5940bb5afce26c75dc4bb9/lib/DataSift/Definition.php#L101-L120 |
15,931 | datasift/datasift-php | lib/DataSift/Definition.php | DataSift_Definition.clearHash | protected function clearHash()
{
if ($this->_csdl === false) {
throw new DataSift_Exception_InvalidData('Cannot clear the hash of a hash-only definition object');
}
$this->_hash = false;
$this->_created_at = false;
$this->_total_dpu = false;
} | php | protected function clearHash()
{
if ($this->_csdl === false) {
throw new DataSift_Exception_InvalidData('Cannot clear the hash of a hash-only definition object');
}
$this->_hash = false;
$this->_created_at = false;
$this->_total_dpu = false;
} | [
"protected",
"function",
"clearHash",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_csdl",
"===",
"false",
")",
"{",
"throw",
"new",
"DataSift_Exception_InvalidData",
"(",
"'Cannot clear the hash of a hash-only definition object'",
")",
";",
"}",
"$",
"this",
"->",
"_hash",
"=",
"false",
";",
"$",
"this",
"->",
"_created_at",
"=",
"false",
";",
"$",
"this",
"->",
"_total_dpu",
"=",
"false",
";",
"}"
]
| Reset the hash to false. The effect of this is to mark the definition
as requiring compilation. Also resets other variables that depend on
the CSDL.
@return void | [
"Reset",
"the",
"hash",
"to",
"false",
".",
"The",
"effect",
"of",
"this",
"is",
"to",
"mark",
"the",
"definition",
"as",
"requiring",
"compilation",
".",
"Also",
"resets",
"other",
"variables",
"that",
"depend",
"on",
"the",
"CSDL",
"."
]
| 35282461ad3e54880e5940bb5afce26c75dc4bb9 | https://github.com/datasift/datasift-php/blob/35282461ad3e54880e5940bb5afce26c75dc4bb9/lib/DataSift/Definition.php#L146-L154 |
15,932 | datasift/datasift-php | lib/DataSift/Definition.php | DataSift_Definition.getCreatedAt | public function getCreatedAt()
{
if ($this->_csdl === false) {
throw new DataSift_Exception_InvalidData('Created at date not available');
}
if ($this->_created_at === false) {
// Catch any compilation errors so they don't pass up to the caller
try {
$this->validate();
} catch (DataSift_Exception_CompileFailed $e) {
}
}
return $this->_created_at;
} | php | public function getCreatedAt()
{
if ($this->_csdl === false) {
throw new DataSift_Exception_InvalidData('Created at date not available');
}
if ($this->_created_at === false) {
// Catch any compilation errors so they don't pass up to the caller
try {
$this->validate();
} catch (DataSift_Exception_CompileFailed $e) {
}
}
return $this->_created_at;
} | [
"public",
"function",
"getCreatedAt",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_csdl",
"===",
"false",
")",
"{",
"throw",
"new",
"DataSift_Exception_InvalidData",
"(",
"'Created at date not available'",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"_created_at",
"===",
"false",
")",
"{",
"// Catch any compilation errors so they don't pass up to the caller",
"try",
"{",
"$",
"this",
"->",
"validate",
"(",
")",
";",
"}",
"catch",
"(",
"DataSift_Exception_CompileFailed",
"$",
"e",
")",
"{",
"}",
"}",
"return",
"$",
"this",
"->",
"_created_at",
";",
"}"
]
| Returns the date when the stream was first created. If the created at
date has not yet been obtained it validates the definition first.
@return int The date as a unix timestamp.
@throws DataSift_Exception_APIError
@throws DataSift_Exception_RateLimitExceeded
@throws DataSift_Exception_InvalidData | [
"Returns",
"the",
"date",
"when",
"the",
"stream",
"was",
"first",
"created",
".",
"If",
"the",
"created",
"at",
"date",
"has",
"not",
"yet",
"been",
"obtained",
"it",
"validates",
"the",
"definition",
"first",
"."
]
| 35282461ad3e54880e5940bb5afce26c75dc4bb9 | https://github.com/datasift/datasift-php/blob/35282461ad3e54880e5940bb5afce26c75dc4bb9/lib/DataSift/Definition.php#L165-L178 |
15,933 | datasift/datasift-php | lib/DataSift/Definition.php | DataSift_Definition.getTotalDPU | public function getTotalDPU()
{
if ($this->_csdl === false) {
throw new DataSift_Exception_InvalidData('Total DPU not available');
}
if ($this->_total_dpu === false) {
// Catch any compilation errors so they don't pass up to the caller
try {
$this->validate();
} catch (DataSift_Exception_CompileFailed $e) {
}
}
return $this->_total_dpu;
} | php | public function getTotalDPU()
{
if ($this->_csdl === false) {
throw new DataSift_Exception_InvalidData('Total DPU not available');
}
if ($this->_total_dpu === false) {
// Catch any compilation errors so they don't pass up to the caller
try {
$this->validate();
} catch (DataSift_Exception_CompileFailed $e) {
}
}
return $this->_total_dpu;
} | [
"public",
"function",
"getTotalDPU",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_csdl",
"===",
"false",
")",
"{",
"throw",
"new",
"DataSift_Exception_InvalidData",
"(",
"'Total DPU not available'",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"_total_dpu",
"===",
"false",
")",
"{",
"// Catch any compilation errors so they don't pass up to the caller",
"try",
"{",
"$",
"this",
"->",
"validate",
"(",
")",
";",
"}",
"catch",
"(",
"DataSift_Exception_CompileFailed",
"$",
"e",
")",
"{",
"}",
"}",
"return",
"$",
"this",
"->",
"_total_dpu",
";",
"}"
]
| Returns the total DPU of the stream. If the DPU has not yet been
obtained it validates the definition first.
@return int The total DPU.
@throws DataSift_Exception_APIError
@throws DataSift_Exception_RateLimitExceeded
@throws DataSift_Exception_InvalidData | [
"Returns",
"the",
"total",
"DPU",
"of",
"the",
"stream",
".",
"If",
"the",
"DPU",
"has",
"not",
"yet",
"been",
"obtained",
"it",
"validates",
"the",
"definition",
"first",
"."
]
| 35282461ad3e54880e5940bb5afce26c75dc4bb9 | https://github.com/datasift/datasift-php/blob/35282461ad3e54880e5940bb5afce26c75dc4bb9/lib/DataSift/Definition.php#L189-L202 |
15,934 | datasift/datasift-php | lib/DataSift/Definition.php | DataSift_Definition.compile | public function compile()
{
if (strlen($this->_csdl) == 0) {
throw new DataSift_Exception_InvalidData('Cannot compile an empty definition.');
}
try {
$res = $this->_user->post('compile', array('csdl' => $this->_csdl));
if (isset($res['hash'])) {
$this->_hash = $res['hash'];
} else {
throw new DataSift_Exception_CompileFailed('Compiled successfully but no hash in the response');
}
if (isset($res['created_at'])) {
$this->_created_at = strtotime($res['created_at']);
} else {
throw new DataSift_Exception_CompileFailed('Compiled successfully but no created_at in the response');
}
if (isset($res['dpu'])) {
$this->_total_dpu = $res['dpu'];
} else {
throw new DataSift_Exception_CompileFailed('Compiled successfully but no DPU in the response');
}
} catch (DataSift_Exception_APIError $e) {
// Reset the hash
$this->clearHash();
switch ($e->getCode()) {
case 400:
// Compilation failed, we should have an error message
throw new DataSift_Exception_CompileFailed($e->getMessage());
break;
default:
throw new DataSift_Exception_CompileFailed(
'Unexpected APIError code: ' . $e->getCode() . ' [' . $e->getMessage() . ']'
);
}
}
} | php | public function compile()
{
if (strlen($this->_csdl) == 0) {
throw new DataSift_Exception_InvalidData('Cannot compile an empty definition.');
}
try {
$res = $this->_user->post('compile', array('csdl' => $this->_csdl));
if (isset($res['hash'])) {
$this->_hash = $res['hash'];
} else {
throw new DataSift_Exception_CompileFailed('Compiled successfully but no hash in the response');
}
if (isset($res['created_at'])) {
$this->_created_at = strtotime($res['created_at']);
} else {
throw new DataSift_Exception_CompileFailed('Compiled successfully but no created_at in the response');
}
if (isset($res['dpu'])) {
$this->_total_dpu = $res['dpu'];
} else {
throw new DataSift_Exception_CompileFailed('Compiled successfully but no DPU in the response');
}
} catch (DataSift_Exception_APIError $e) {
// Reset the hash
$this->clearHash();
switch ($e->getCode()) {
case 400:
// Compilation failed, we should have an error message
throw new DataSift_Exception_CompileFailed($e->getMessage());
break;
default:
throw new DataSift_Exception_CompileFailed(
'Unexpected APIError code: ' . $e->getCode() . ' [' . $e->getMessage() . ']'
);
}
}
} | [
"public",
"function",
"compile",
"(",
")",
"{",
"if",
"(",
"strlen",
"(",
"$",
"this",
"->",
"_csdl",
")",
"==",
"0",
")",
"{",
"throw",
"new",
"DataSift_Exception_InvalidData",
"(",
"'Cannot compile an empty definition.'",
")",
";",
"}",
"try",
"{",
"$",
"res",
"=",
"$",
"this",
"->",
"_user",
"->",
"post",
"(",
"'compile'",
",",
"array",
"(",
"'csdl'",
"=>",
"$",
"this",
"->",
"_csdl",
")",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"res",
"[",
"'hash'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"_hash",
"=",
"$",
"res",
"[",
"'hash'",
"]",
";",
"}",
"else",
"{",
"throw",
"new",
"DataSift_Exception_CompileFailed",
"(",
"'Compiled successfully but no hash in the response'",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"res",
"[",
"'created_at'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"_created_at",
"=",
"strtotime",
"(",
"$",
"res",
"[",
"'created_at'",
"]",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"DataSift_Exception_CompileFailed",
"(",
"'Compiled successfully but no created_at in the response'",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"res",
"[",
"'dpu'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"_total_dpu",
"=",
"$",
"res",
"[",
"'dpu'",
"]",
";",
"}",
"else",
"{",
"throw",
"new",
"DataSift_Exception_CompileFailed",
"(",
"'Compiled successfully but no DPU in the response'",
")",
";",
"}",
"}",
"catch",
"(",
"DataSift_Exception_APIError",
"$",
"e",
")",
"{",
"// Reset the hash",
"$",
"this",
"->",
"clearHash",
"(",
")",
";",
"switch",
"(",
"$",
"e",
"->",
"getCode",
"(",
")",
")",
"{",
"case",
"400",
":",
"// Compilation failed, we should have an error message",
"throw",
"new",
"DataSift_Exception_CompileFailed",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"break",
";",
"default",
":",
"throw",
"new",
"DataSift_Exception_CompileFailed",
"(",
"'Unexpected APIError code: '",
".",
"$",
"e",
"->",
"getCode",
"(",
")",
".",
"' ['",
".",
"$",
"e",
"->",
"getMessage",
"(",
")",
".",
"']'",
")",
";",
"}",
"}",
"}"
]
| Call the DataSift API to compile this defintion. On success it will
store the returned hash.
@return void
@throws DataSift_Exception_APIError
@throws DataSift_Exception_RateLimitExceeded
@throws DataSift_Exception_InvalidData
@throws DataSift_Exception_CompileFailed | [
"Call",
"the",
"DataSift",
"API",
"to",
"compile",
"this",
"defintion",
".",
"On",
"success",
"it",
"will",
"store",
"the",
"returned",
"hash",
"."
]
| 35282461ad3e54880e5940bb5afce26c75dc4bb9 | https://github.com/datasift/datasift-php/blob/35282461ad3e54880e5940bb5afce26c75dc4bb9/lib/DataSift/Definition.php#L214-L254 |
15,935 | datasift/datasift-php | lib/DataSift/Definition.php | DataSift_Definition.getDPUBreakdown | public function getDPUBreakdown()
{
$retval = false;
if (strlen(trim($this->_csdl)) == 0) {
throw new DataSift_Exception_InvalidData('Cannot get the DPU for an empty definition.');
}
$retval = $this->_user->post('dpu', array('hash' => $this->getHash()));
$this->_total_dpu = $retval['dpu'];
return $retval;
} | php | public function getDPUBreakdown()
{
$retval = false;
if (strlen(trim($this->_csdl)) == 0) {
throw new DataSift_Exception_InvalidData('Cannot get the DPU for an empty definition.');
}
$retval = $this->_user->post('dpu', array('hash' => $this->getHash()));
$this->_total_dpu = $retval['dpu'];
return $retval;
} | [
"public",
"function",
"getDPUBreakdown",
"(",
")",
"{",
"$",
"retval",
"=",
"false",
";",
"if",
"(",
"strlen",
"(",
"trim",
"(",
"$",
"this",
"->",
"_csdl",
")",
")",
"==",
"0",
")",
"{",
"throw",
"new",
"DataSift_Exception_InvalidData",
"(",
"'Cannot get the DPU for an empty definition.'",
")",
";",
"}",
"$",
"retval",
"=",
"$",
"this",
"->",
"_user",
"->",
"post",
"(",
"'dpu'",
",",
"array",
"(",
"'hash'",
"=>",
"$",
"this",
"->",
"getHash",
"(",
")",
")",
")",
";",
"$",
"this",
"->",
"_total_dpu",
"=",
"$",
"retval",
"[",
"'dpu'",
"]",
";",
"return",
"$",
"retval",
";",
"}"
]
| Call the DataSift API to get the DPU for this definition. Returns an
array containing...
dpu => The breakdown of running the rule
total => The total dpu of the rule
@return array
@throws DataSift_Exception_InvalidData
@throws DataSift_Exception_APIError
@throws DataSift_Exception_CompileError | [
"Call",
"the",
"DataSift",
"API",
"to",
"get",
"the",
"DPU",
"for",
"this",
"definition",
".",
"Returns",
"an",
"array",
"containing",
"...",
"dpu",
"=",
">",
"The",
"breakdown",
"of",
"running",
"the",
"rule",
"total",
"=",
">",
"The",
"total",
"dpu",
"of",
"the",
"rule"
]
| 35282461ad3e54880e5940bb5afce26c75dc4bb9 | https://github.com/datasift/datasift-php/blob/35282461ad3e54880e5940bb5afce26c75dc4bb9/lib/DataSift/Definition.php#L319-L330 |
15,936 | datasift/datasift-php | lib/DataSift/Definition.php | DataSift_Definition.getBuffered | public function getBuffered($count = false, $from_id = false)
{
$retval = false;
if (strlen(trim($this->_csdl)) == 0) {
throw new DataSift_Exception_InvalidData('Cannot get buffered interactions for an empty definition.');
}
$params = array('hash' => $this->getHash());
if ($count !== false) {
$params['count'] = $count;
}
if ($from_id !== false) {
$params['interaction_id'] = $from_id;
}
$retval = $this->_user->post('stream', $params);
if (isset($retval['stream'])) {
$retval = $retval['stream'];
} else {
throw new DataSift_Exception_APIError('No data in the response');
}
return $retval;
} | php | public function getBuffered($count = false, $from_id = false)
{
$retval = false;
if (strlen(trim($this->_csdl)) == 0) {
throw new DataSift_Exception_InvalidData('Cannot get buffered interactions for an empty definition.');
}
$params = array('hash' => $this->getHash());
if ($count !== false) {
$params['count'] = $count;
}
if ($from_id !== false) {
$params['interaction_id'] = $from_id;
}
$retval = $this->_user->post('stream', $params);
if (isset($retval['stream'])) {
$retval = $retval['stream'];
} else {
throw new DataSift_Exception_APIError('No data in the response');
}
return $retval;
} | [
"public",
"function",
"getBuffered",
"(",
"$",
"count",
"=",
"false",
",",
"$",
"from_id",
"=",
"false",
")",
"{",
"$",
"retval",
"=",
"false",
";",
"if",
"(",
"strlen",
"(",
"trim",
"(",
"$",
"this",
"->",
"_csdl",
")",
")",
"==",
"0",
")",
"{",
"throw",
"new",
"DataSift_Exception_InvalidData",
"(",
"'Cannot get buffered interactions for an empty definition.'",
")",
";",
"}",
"$",
"params",
"=",
"array",
"(",
"'hash'",
"=>",
"$",
"this",
"->",
"getHash",
"(",
")",
")",
";",
"if",
"(",
"$",
"count",
"!==",
"false",
")",
"{",
"$",
"params",
"[",
"'count'",
"]",
"=",
"$",
"count",
";",
"}",
"if",
"(",
"$",
"from_id",
"!==",
"false",
")",
"{",
"$",
"params",
"[",
"'interaction_id'",
"]",
"=",
"$",
"from_id",
";",
"}",
"$",
"retval",
"=",
"$",
"this",
"->",
"_user",
"->",
"post",
"(",
"'stream'",
",",
"$",
"params",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"retval",
"[",
"'stream'",
"]",
")",
")",
"{",
"$",
"retval",
"=",
"$",
"retval",
"[",
"'stream'",
"]",
";",
"}",
"else",
"{",
"throw",
"new",
"DataSift_Exception_APIError",
"(",
"'No data in the response'",
")",
";",
"}",
"return",
"$",
"retval",
";",
"}"
]
| Call the DataSift API to get buffered interactions.
@param int $count Optional number of interactions to return (max 200).
@param int $from_id Optional start ID.
@return array
@throws DataSift_Exception_InvalidData
@throws DataSift_Exception_APIError
@throws DataSift_Exception_CompileError | [
"Call",
"the",
"DataSift",
"API",
"to",
"get",
"buffered",
"interactions",
"."
]
| 35282461ad3e54880e5940bb5afce26c75dc4bb9 | https://github.com/datasift/datasift-php/blob/35282461ad3e54880e5940bb5afce26c75dc4bb9/lib/DataSift/Definition.php#L343-L368 |
15,937 | datasift/datasift-php | lib/DataSift/Definition.php | DataSift_Definition.createHistoric | public function createHistoric($start, $end, $sources, $name, $sample = DataSift_Historic::DEFAULT_SAMPLE)
{
return new DataSift_Historic($this->_user, $this->getHash(), $start, $end, $sources, $name, $sample);
} | php | public function createHistoric($start, $end, $sources, $name, $sample = DataSift_Historic::DEFAULT_SAMPLE)
{
return new DataSift_Historic($this->_user, $this->getHash(), $start, $end, $sources, $name, $sample);
} | [
"public",
"function",
"createHistoric",
"(",
"$",
"start",
",",
"$",
"end",
",",
"$",
"sources",
",",
"$",
"name",
",",
"$",
"sample",
"=",
"DataSift_Historic",
"::",
"DEFAULT_SAMPLE",
")",
"{",
"return",
"new",
"DataSift_Historic",
"(",
"$",
"this",
"->",
"_user",
",",
"$",
"this",
"->",
"getHash",
"(",
")",
",",
"$",
"start",
",",
"$",
"end",
",",
"$",
"sources",
",",
"$",
"name",
",",
"$",
"sample",
")",
";",
"}"
]
| Create a historic based on this CSDL.
@param int $start The timestamp from which to start the query.
@param int $end The timestamp at which to end the query.
@param array $sources An array of sources required.
@param string $name An optional name for this historic.
@param float $sample Sample size (10 or 100)
@return DataSift_Historic
@throws DataSift_Exception_InvalidData
@throws DataSift_Exception_APIError
@throws DataSift_Exception_CompileError | [
"Create",
"a",
"historic",
"based",
"on",
"this",
"CSDL",
"."
]
| 35282461ad3e54880e5940bb5afce26c75dc4bb9 | https://github.com/datasift/datasift-php/blob/35282461ad3e54880e5940bb5afce26c75dc4bb9/lib/DataSift/Definition.php#L384-L387 |
15,938 | datasift/datasift-php | lib/DataSift/Definition.php | DataSift_Definition.getConsumer | public function getConsumer($type, $eventHandler)
{
return DataSift_StreamConsumer::factory($this->_user, $type, $this, $eventHandler);
} | php | public function getConsumer($type, $eventHandler)
{
return DataSift_StreamConsumer::factory($this->_user, $type, $this, $eventHandler);
} | [
"public",
"function",
"getConsumer",
"(",
"$",
"type",
",",
"$",
"eventHandler",
")",
"{",
"return",
"DataSift_StreamConsumer",
"::",
"factory",
"(",
"$",
"this",
"->",
"_user",
",",
"$",
"type",
",",
"$",
"this",
",",
"$",
"eventHandler",
")",
";",
"}"
]
| Returns a DataSift_StreamConsumer-derived object for this definition,
for the given type.
@param string $type The consumer type for which to construct a consumer.
@param DataSift_IStreamConsumerEventHandler $eventHandler An instance of DataSift_IStreamConsumerEventHandler
@return DataSift_StreamConsumer The consumer object.
@throws DataSift_Exception_InvalidData
@see DataSift_StreamConsumer | [
"Returns",
"a",
"DataSift_StreamConsumer",
"-",
"derived",
"object",
"for",
"this",
"definition",
"for",
"the",
"given",
"type",
"."
]
| 35282461ad3e54880e5940bb5afce26c75dc4bb9 | https://github.com/datasift/datasift-php/blob/35282461ad3e54880e5940bb5afce26c75dc4bb9/lib/DataSift/Definition.php#L400-L403 |
15,939 | activecollab/databasestructure | src/Builder/TypeTableBuilder.php | TypeTableBuilder.prepareCreateTableStatement | public function prepareCreateTableStatement(TypeInterface $type)
{
$result = [];
$result[] = 'CREATE TABLE IF NOT EXISTS ' . $this->getConnection()->escapeTableName($type->getName()) . ' (';
$generaterd_field_indexes = [];
foreach ($type->getAllFields() as $field) {
if ($field instanceof ScalarField) {
$result[] = ' ' . $this->prepareFieldStatement($field) . ',';
}
if ($field instanceof JsonFieldInterface) {
foreach ($field->getValueExtractors() as $value_extractor) {
$result[] = ' ' . $this->prepareGeneratedFieldStatement($field, $value_extractor) . ',';
if ($value_extractor->getAddIndex()) {
$generaterd_field_indexes[] = new Index($value_extractor->getFieldName());
}
}
}
}
$indexes = $type->getAllIndexes();
if (!empty($generaterd_field_indexes)) {
$indexes = array_merge($indexes, $generaterd_field_indexes);
}
foreach ($indexes as $index) {
$result[] = ' ' . $this->prepareIndexStatement($index) . ',';
}
$last_line = count($result) - 1;
$result[$last_line] = rtrim($result[$last_line], ',');
$result[] = ') ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;';
return implode("\n", $result);
} | php | public function prepareCreateTableStatement(TypeInterface $type)
{
$result = [];
$result[] = 'CREATE TABLE IF NOT EXISTS ' . $this->getConnection()->escapeTableName($type->getName()) . ' (';
$generaterd_field_indexes = [];
foreach ($type->getAllFields() as $field) {
if ($field instanceof ScalarField) {
$result[] = ' ' . $this->prepareFieldStatement($field) . ',';
}
if ($field instanceof JsonFieldInterface) {
foreach ($field->getValueExtractors() as $value_extractor) {
$result[] = ' ' . $this->prepareGeneratedFieldStatement($field, $value_extractor) . ',';
if ($value_extractor->getAddIndex()) {
$generaterd_field_indexes[] = new Index($value_extractor->getFieldName());
}
}
}
}
$indexes = $type->getAllIndexes();
if (!empty($generaterd_field_indexes)) {
$indexes = array_merge($indexes, $generaterd_field_indexes);
}
foreach ($indexes as $index) {
$result[] = ' ' . $this->prepareIndexStatement($index) . ',';
}
$last_line = count($result) - 1;
$result[$last_line] = rtrim($result[$last_line], ',');
$result[] = ') ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;';
return implode("\n", $result);
} | [
"public",
"function",
"prepareCreateTableStatement",
"(",
"TypeInterface",
"$",
"type",
")",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"$",
"result",
"[",
"]",
"=",
"'CREATE TABLE IF NOT EXISTS '",
".",
"$",
"this",
"->",
"getConnection",
"(",
")",
"->",
"escapeTableName",
"(",
"$",
"type",
"->",
"getName",
"(",
")",
")",
".",
"' ('",
";",
"$",
"generaterd_field_indexes",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"type",
"->",
"getAllFields",
"(",
")",
"as",
"$",
"field",
")",
"{",
"if",
"(",
"$",
"field",
"instanceof",
"ScalarField",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"' '",
".",
"$",
"this",
"->",
"prepareFieldStatement",
"(",
"$",
"field",
")",
".",
"','",
";",
"}",
"if",
"(",
"$",
"field",
"instanceof",
"JsonFieldInterface",
")",
"{",
"foreach",
"(",
"$",
"field",
"->",
"getValueExtractors",
"(",
")",
"as",
"$",
"value_extractor",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"' '",
".",
"$",
"this",
"->",
"prepareGeneratedFieldStatement",
"(",
"$",
"field",
",",
"$",
"value_extractor",
")",
".",
"','",
";",
"if",
"(",
"$",
"value_extractor",
"->",
"getAddIndex",
"(",
")",
")",
"{",
"$",
"generaterd_field_indexes",
"[",
"]",
"=",
"new",
"Index",
"(",
"$",
"value_extractor",
"->",
"getFieldName",
"(",
")",
")",
";",
"}",
"}",
"}",
"}",
"$",
"indexes",
"=",
"$",
"type",
"->",
"getAllIndexes",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"generaterd_field_indexes",
")",
")",
"{",
"$",
"indexes",
"=",
"array_merge",
"(",
"$",
"indexes",
",",
"$",
"generaterd_field_indexes",
")",
";",
"}",
"foreach",
"(",
"$",
"indexes",
"as",
"$",
"index",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"' '",
".",
"$",
"this",
"->",
"prepareIndexStatement",
"(",
"$",
"index",
")",
".",
"','",
";",
"}",
"$",
"last_line",
"=",
"count",
"(",
"$",
"result",
")",
"-",
"1",
";",
"$",
"result",
"[",
"$",
"last_line",
"]",
"=",
"rtrim",
"(",
"$",
"result",
"[",
"$",
"last_line",
"]",
",",
"','",
")",
";",
"$",
"result",
"[",
"]",
"=",
"') ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;'",
";",
"return",
"implode",
"(",
"\"\\n\"",
",",
"$",
"result",
")",
";",
"}"
]
| Prepare CREATE TABLE statement for the given type.
@param TypeInterface $type
@return string | [
"Prepare",
"CREATE",
"TABLE",
"statement",
"for",
"the",
"given",
"type",
"."
]
| 4b2353c4422186bcfce63b3212da3e70e63eb5df | https://github.com/activecollab/databasestructure/blob/4b2353c4422186bcfce63b3212da3e70e63eb5df/src/Builder/TypeTableBuilder.php#L124-L164 |
15,940 | activecollab/databasestructure | src/Builder/TypeTableBuilder.php | TypeTableBuilder.prepareFieldStatement | private function prepareFieldStatement(ScalarField $field)
{
$result = $this->getConnection()->escapeFieldName($field->getName()) . ' ' . $this->prepareTypeDefinition($field);
if ($field->getDefaultValue() !== null) {
$result .= ' NOT NULL';
}
if (!($field instanceof IntegerField && $field->getName() == 'id')) {
$result .= ' DEFAULT ' . $this->prepareDefaultValue($field);
}
return $result;
} | php | private function prepareFieldStatement(ScalarField $field)
{
$result = $this->getConnection()->escapeFieldName($field->getName()) . ' ' . $this->prepareTypeDefinition($field);
if ($field->getDefaultValue() !== null) {
$result .= ' NOT NULL';
}
if (!($field instanceof IntegerField && $field->getName() == 'id')) {
$result .= ' DEFAULT ' . $this->prepareDefaultValue($field);
}
return $result;
} | [
"private",
"function",
"prepareFieldStatement",
"(",
"ScalarField",
"$",
"field",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"getConnection",
"(",
")",
"->",
"escapeFieldName",
"(",
"$",
"field",
"->",
"getName",
"(",
")",
")",
".",
"' '",
".",
"$",
"this",
"->",
"prepareTypeDefinition",
"(",
"$",
"field",
")",
";",
"if",
"(",
"$",
"field",
"->",
"getDefaultValue",
"(",
")",
"!==",
"null",
")",
"{",
"$",
"result",
".=",
"' NOT NULL'",
";",
"}",
"if",
"(",
"!",
"(",
"$",
"field",
"instanceof",
"IntegerField",
"&&",
"$",
"field",
"->",
"getName",
"(",
")",
"==",
"'id'",
")",
")",
"{",
"$",
"result",
".=",
"' DEFAULT '",
".",
"$",
"this",
"->",
"prepareDefaultValue",
"(",
"$",
"field",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
]
| Prepare field statement based on the field settings.
@param ScalarField $field
@return string | [
"Prepare",
"field",
"statement",
"based",
"on",
"the",
"field",
"settings",
"."
]
| 4b2353c4422186bcfce63b3212da3e70e63eb5df | https://github.com/activecollab/databasestructure/blob/4b2353c4422186bcfce63b3212da3e70e63eb5df/src/Builder/TypeTableBuilder.php#L172-L185 |
15,941 | activecollab/databasestructure | src/Builder/TypeTableBuilder.php | TypeTableBuilder.prepareTypeDefinition | private function prepareTypeDefinition(ScalarField $field)
{
if ($field instanceof IntegerField) {
switch ($field->getSize()) {
case FieldInterface::SIZE_TINY:
$result = 'TINYINT';
break;
case ScalarField::SIZE_SMALL:
$result = 'SMALLINT';
break;
case FieldInterface::SIZE_MEDIUM:
$result = 'MEDIUMINT';
break;
case FieldInterface::SIZE_BIG:
$result = 'BIGINT';
break;
default:
$result = 'INT';
}
if ($field->isUnsigned()) {
$result .= ' UNSIGNED';
}
if ($field->getName() == 'id') {
$result .= ' AUTO_INCREMENT';
}
return $result;
} elseif ($field instanceof BooleanField) {
return 'TINYINT(1) UNSIGNED';
} elseif ($field instanceof DateField) {
return 'DATE';
} elseif ($field instanceof DateTimeField) {
return 'DATETIME';
} elseif ($field instanceof DecimalField) {
$result = 'DECIMAL(' . $field->getLength() . ', ' . $field->getScale() . ')';
if ($field->isUnsigned()) {
$result .= ' UNSIGNED';
}
return $result;
} elseif ($field instanceof EnumField) {
return 'ENUM(' . implode(',', array_map(function ($possibility) {
return $this->getConnection()->escapeValue($possibility);
}, $field->getPossibilities())) . ')';
} elseif ($field instanceof FloatField) {
$result = 'FLOAT(' . $field->getLength() . ', ' . $field->getScale() . ')';
if ($field->isUnsigned()) {
$result .= ' UNSIGNED';
}
return $result;
} elseif ($field instanceof JsonField) {
return 'JSON';
} elseif ($field instanceof StringField) {
return 'VARCHAR(' . $field->getLength() . ')';
} elseif ($field instanceof TextField) {
switch ($field->getSize()) {
case FieldInterface::SIZE_TINY:
return 'TINYTEXT';
case ScalarField::SIZE_SMALL:
return 'TEXT';
case FieldInterface::SIZE_MEDIUM:
return 'MEDIUMTEXT';
default:
return 'LONGTEXT';
}
} elseif ($field instanceof TimeField) {
return 'TIME';
} else {
throw new InvalidArgumentException('Field ' . get_class($field) . ' is not a support scalar field');
}
} | php | private function prepareTypeDefinition(ScalarField $field)
{
if ($field instanceof IntegerField) {
switch ($field->getSize()) {
case FieldInterface::SIZE_TINY:
$result = 'TINYINT';
break;
case ScalarField::SIZE_SMALL:
$result = 'SMALLINT';
break;
case FieldInterface::SIZE_MEDIUM:
$result = 'MEDIUMINT';
break;
case FieldInterface::SIZE_BIG:
$result = 'BIGINT';
break;
default:
$result = 'INT';
}
if ($field->isUnsigned()) {
$result .= ' UNSIGNED';
}
if ($field->getName() == 'id') {
$result .= ' AUTO_INCREMENT';
}
return $result;
} elseif ($field instanceof BooleanField) {
return 'TINYINT(1) UNSIGNED';
} elseif ($field instanceof DateField) {
return 'DATE';
} elseif ($field instanceof DateTimeField) {
return 'DATETIME';
} elseif ($field instanceof DecimalField) {
$result = 'DECIMAL(' . $field->getLength() . ', ' . $field->getScale() . ')';
if ($field->isUnsigned()) {
$result .= ' UNSIGNED';
}
return $result;
} elseif ($field instanceof EnumField) {
return 'ENUM(' . implode(',', array_map(function ($possibility) {
return $this->getConnection()->escapeValue($possibility);
}, $field->getPossibilities())) . ')';
} elseif ($field instanceof FloatField) {
$result = 'FLOAT(' . $field->getLength() . ', ' . $field->getScale() . ')';
if ($field->isUnsigned()) {
$result .= ' UNSIGNED';
}
return $result;
} elseif ($field instanceof JsonField) {
return 'JSON';
} elseif ($field instanceof StringField) {
return 'VARCHAR(' . $field->getLength() . ')';
} elseif ($field instanceof TextField) {
switch ($field->getSize()) {
case FieldInterface::SIZE_TINY:
return 'TINYTEXT';
case ScalarField::SIZE_SMALL:
return 'TEXT';
case FieldInterface::SIZE_MEDIUM:
return 'MEDIUMTEXT';
default:
return 'LONGTEXT';
}
} elseif ($field instanceof TimeField) {
return 'TIME';
} else {
throw new InvalidArgumentException('Field ' . get_class($field) . ' is not a support scalar field');
}
} | [
"private",
"function",
"prepareTypeDefinition",
"(",
"ScalarField",
"$",
"field",
")",
"{",
"if",
"(",
"$",
"field",
"instanceof",
"IntegerField",
")",
"{",
"switch",
"(",
"$",
"field",
"->",
"getSize",
"(",
")",
")",
"{",
"case",
"FieldInterface",
"::",
"SIZE_TINY",
":",
"$",
"result",
"=",
"'TINYINT'",
";",
"break",
";",
"case",
"ScalarField",
"::",
"SIZE_SMALL",
":",
"$",
"result",
"=",
"'SMALLINT'",
";",
"break",
";",
"case",
"FieldInterface",
"::",
"SIZE_MEDIUM",
":",
"$",
"result",
"=",
"'MEDIUMINT'",
";",
"break",
";",
"case",
"FieldInterface",
"::",
"SIZE_BIG",
":",
"$",
"result",
"=",
"'BIGINT'",
";",
"break",
";",
"default",
":",
"$",
"result",
"=",
"'INT'",
";",
"}",
"if",
"(",
"$",
"field",
"->",
"isUnsigned",
"(",
")",
")",
"{",
"$",
"result",
".=",
"' UNSIGNED'",
";",
"}",
"if",
"(",
"$",
"field",
"->",
"getName",
"(",
")",
"==",
"'id'",
")",
"{",
"$",
"result",
".=",
"' AUTO_INCREMENT'",
";",
"}",
"return",
"$",
"result",
";",
"}",
"elseif",
"(",
"$",
"field",
"instanceof",
"BooleanField",
")",
"{",
"return",
"'TINYINT(1) UNSIGNED'",
";",
"}",
"elseif",
"(",
"$",
"field",
"instanceof",
"DateField",
")",
"{",
"return",
"'DATE'",
";",
"}",
"elseif",
"(",
"$",
"field",
"instanceof",
"DateTimeField",
")",
"{",
"return",
"'DATETIME'",
";",
"}",
"elseif",
"(",
"$",
"field",
"instanceof",
"DecimalField",
")",
"{",
"$",
"result",
"=",
"'DECIMAL('",
".",
"$",
"field",
"->",
"getLength",
"(",
")",
".",
"', '",
".",
"$",
"field",
"->",
"getScale",
"(",
")",
".",
"')'",
";",
"if",
"(",
"$",
"field",
"->",
"isUnsigned",
"(",
")",
")",
"{",
"$",
"result",
".=",
"' UNSIGNED'",
";",
"}",
"return",
"$",
"result",
";",
"}",
"elseif",
"(",
"$",
"field",
"instanceof",
"EnumField",
")",
"{",
"return",
"'ENUM('",
".",
"implode",
"(",
"','",
",",
"array_map",
"(",
"function",
"(",
"$",
"possibility",
")",
"{",
"return",
"$",
"this",
"->",
"getConnection",
"(",
")",
"->",
"escapeValue",
"(",
"$",
"possibility",
")",
";",
"}",
",",
"$",
"field",
"->",
"getPossibilities",
"(",
")",
")",
")",
".",
"')'",
";",
"}",
"elseif",
"(",
"$",
"field",
"instanceof",
"FloatField",
")",
"{",
"$",
"result",
"=",
"'FLOAT('",
".",
"$",
"field",
"->",
"getLength",
"(",
")",
".",
"', '",
".",
"$",
"field",
"->",
"getScale",
"(",
")",
".",
"')'",
";",
"if",
"(",
"$",
"field",
"->",
"isUnsigned",
"(",
")",
")",
"{",
"$",
"result",
".=",
"' UNSIGNED'",
";",
"}",
"return",
"$",
"result",
";",
"}",
"elseif",
"(",
"$",
"field",
"instanceof",
"JsonField",
")",
"{",
"return",
"'JSON'",
";",
"}",
"elseif",
"(",
"$",
"field",
"instanceof",
"StringField",
")",
"{",
"return",
"'VARCHAR('",
".",
"$",
"field",
"->",
"getLength",
"(",
")",
".",
"')'",
";",
"}",
"elseif",
"(",
"$",
"field",
"instanceof",
"TextField",
")",
"{",
"switch",
"(",
"$",
"field",
"->",
"getSize",
"(",
")",
")",
"{",
"case",
"FieldInterface",
"::",
"SIZE_TINY",
":",
"return",
"'TINYTEXT'",
";",
"case",
"ScalarField",
"::",
"SIZE_SMALL",
":",
"return",
"'TEXT'",
";",
"case",
"FieldInterface",
"::",
"SIZE_MEDIUM",
":",
"return",
"'MEDIUMTEXT'",
";",
"default",
":",
"return",
"'LONGTEXT'",
";",
"}",
"}",
"elseif",
"(",
"$",
"field",
"instanceof",
"TimeField",
")",
"{",
"return",
"'TIME'",
";",
"}",
"else",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Field '",
".",
"get_class",
"(",
"$",
"field",
")",
".",
"' is not a support scalar field'",
")",
";",
"}",
"}"
]
| Prepare type definition for the given field.
@param ScalarField $field
@return string | [
"Prepare",
"type",
"definition",
"for",
"the",
"given",
"field",
"."
]
| 4b2353c4422186bcfce63b3212da3e70e63eb5df | https://github.com/activecollab/databasestructure/blob/4b2353c4422186bcfce63b3212da3e70e63eb5df/src/Builder/TypeTableBuilder.php#L193-L268 |
15,942 | activecollab/databasestructure | src/Builder/TypeTableBuilder.php | TypeTableBuilder.prepareDefaultValue | public function prepareDefaultValue(ScalarField $field)
{
$default_value = $field->getDefaultValue();
if ($default_value === null) {
return 'NULL';
}
if ($field instanceof DateField || $field instanceof DateTimeField) {
$timestamp = is_int($default_value) ? $default_value : strtotime($default_value);
if ($field instanceof DateTimeField) {
return $this->getConnection()->escapeValue(date('Y-m-d H:i:s', $timestamp));
} else {
return $this->getConnection()->escapeValue(date('Y-m-d', $timestamp));
}
}
return $this->getConnection()->escapeValue($default_value);
} | php | public function prepareDefaultValue(ScalarField $field)
{
$default_value = $field->getDefaultValue();
if ($default_value === null) {
return 'NULL';
}
if ($field instanceof DateField || $field instanceof DateTimeField) {
$timestamp = is_int($default_value) ? $default_value : strtotime($default_value);
if ($field instanceof DateTimeField) {
return $this->getConnection()->escapeValue(date('Y-m-d H:i:s', $timestamp));
} else {
return $this->getConnection()->escapeValue(date('Y-m-d', $timestamp));
}
}
return $this->getConnection()->escapeValue($default_value);
} | [
"public",
"function",
"prepareDefaultValue",
"(",
"ScalarField",
"$",
"field",
")",
"{",
"$",
"default_value",
"=",
"$",
"field",
"->",
"getDefaultValue",
"(",
")",
";",
"if",
"(",
"$",
"default_value",
"===",
"null",
")",
"{",
"return",
"'NULL'",
";",
"}",
"if",
"(",
"$",
"field",
"instanceof",
"DateField",
"||",
"$",
"field",
"instanceof",
"DateTimeField",
")",
"{",
"$",
"timestamp",
"=",
"is_int",
"(",
"$",
"default_value",
")",
"?",
"$",
"default_value",
":",
"strtotime",
"(",
"$",
"default_value",
")",
";",
"if",
"(",
"$",
"field",
"instanceof",
"DateTimeField",
")",
"{",
"return",
"$",
"this",
"->",
"getConnection",
"(",
")",
"->",
"escapeValue",
"(",
"date",
"(",
"'Y-m-d H:i:s'",
",",
"$",
"timestamp",
")",
")",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"getConnection",
"(",
")",
"->",
"escapeValue",
"(",
"date",
"(",
"'Y-m-d'",
",",
"$",
"timestamp",
")",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"getConnection",
"(",
")",
"->",
"escapeValue",
"(",
"$",
"default_value",
")",
";",
"}"
]
| Prepare default value.
@param ScalarField $field
@return string | [
"Prepare",
"default",
"value",
"."
]
| 4b2353c4422186bcfce63b3212da3e70e63eb5df | https://github.com/activecollab/databasestructure/blob/4b2353c4422186bcfce63b3212da3e70e63eb5df/src/Builder/TypeTableBuilder.php#L276-L295 |
15,943 | activecollab/databasestructure | src/Builder/TypeTableBuilder.php | TypeTableBuilder.prepareGeneratedFieldStatement | public function prepareGeneratedFieldStatement(FieldInterface $source_field, ValueExtractorInterface $extractor)
{
$generated_field_name = $this->getConnection()->escapeFieldName($extractor->getFieldName());
switch ($extractor->getValueCaster()) {
case ValueCasterInterface::CAST_INT:
$field_type = 'INT';
break;
case ValueCasterInterface::CAST_FLOAT:
$field_type = 'DECIMAL(12, 2)';
break;
case ValueCasterInterface::CAST_BOOL:
$field_type = 'TINYINT(1) UNSIGNED';
break;
case ValueCasterInterface::CAST_DATE:
$field_type = 'DATE';
break;
case ValueCasterInterface::CAST_DATETIME:
$field_type = 'DATETIME';
break;
case ValueCasterInterface::CAST_JSON:
$field_type = 'JSON';
break;
default:
$field_type = 'VARCHAR(191)';
}
$expression = $this->prepareGeneratedFieldExpression(
$this->getConnection()->escapeFieldName($source_field->getName()),
var_export($extractor->getExpression(), true),
$extractor->getValueCaster(),
$this->getConnection()->escapeValue($extractor->getDefaultValue())
);
$storage = $extractor->getStoreValue() ? 'STORED' : 'VIRTUAL';
return trim("$generated_field_name $field_type AS ($expression) $storage");
} | php | public function prepareGeneratedFieldStatement(FieldInterface $source_field, ValueExtractorInterface $extractor)
{
$generated_field_name = $this->getConnection()->escapeFieldName($extractor->getFieldName());
switch ($extractor->getValueCaster()) {
case ValueCasterInterface::CAST_INT:
$field_type = 'INT';
break;
case ValueCasterInterface::CAST_FLOAT:
$field_type = 'DECIMAL(12, 2)';
break;
case ValueCasterInterface::CAST_BOOL:
$field_type = 'TINYINT(1) UNSIGNED';
break;
case ValueCasterInterface::CAST_DATE:
$field_type = 'DATE';
break;
case ValueCasterInterface::CAST_DATETIME:
$field_type = 'DATETIME';
break;
case ValueCasterInterface::CAST_JSON:
$field_type = 'JSON';
break;
default:
$field_type = 'VARCHAR(191)';
}
$expression = $this->prepareGeneratedFieldExpression(
$this->getConnection()->escapeFieldName($source_field->getName()),
var_export($extractor->getExpression(), true),
$extractor->getValueCaster(),
$this->getConnection()->escapeValue($extractor->getDefaultValue())
);
$storage = $extractor->getStoreValue() ? 'STORED' : 'VIRTUAL';
return trim("$generated_field_name $field_type AS ($expression) $storage");
} | [
"public",
"function",
"prepareGeneratedFieldStatement",
"(",
"FieldInterface",
"$",
"source_field",
",",
"ValueExtractorInterface",
"$",
"extractor",
")",
"{",
"$",
"generated_field_name",
"=",
"$",
"this",
"->",
"getConnection",
"(",
")",
"->",
"escapeFieldName",
"(",
"$",
"extractor",
"->",
"getFieldName",
"(",
")",
")",
";",
"switch",
"(",
"$",
"extractor",
"->",
"getValueCaster",
"(",
")",
")",
"{",
"case",
"ValueCasterInterface",
"::",
"CAST_INT",
":",
"$",
"field_type",
"=",
"'INT'",
";",
"break",
";",
"case",
"ValueCasterInterface",
"::",
"CAST_FLOAT",
":",
"$",
"field_type",
"=",
"'DECIMAL(12, 2)'",
";",
"break",
";",
"case",
"ValueCasterInterface",
"::",
"CAST_BOOL",
":",
"$",
"field_type",
"=",
"'TINYINT(1) UNSIGNED'",
";",
"break",
";",
"case",
"ValueCasterInterface",
"::",
"CAST_DATE",
":",
"$",
"field_type",
"=",
"'DATE'",
";",
"break",
";",
"case",
"ValueCasterInterface",
"::",
"CAST_DATETIME",
":",
"$",
"field_type",
"=",
"'DATETIME'",
";",
"break",
";",
"case",
"ValueCasterInterface",
"::",
"CAST_JSON",
":",
"$",
"field_type",
"=",
"'JSON'",
";",
"break",
";",
"default",
":",
"$",
"field_type",
"=",
"'VARCHAR(191)'",
";",
"}",
"$",
"expression",
"=",
"$",
"this",
"->",
"prepareGeneratedFieldExpression",
"(",
"$",
"this",
"->",
"getConnection",
"(",
")",
"->",
"escapeFieldName",
"(",
"$",
"source_field",
"->",
"getName",
"(",
")",
")",
",",
"var_export",
"(",
"$",
"extractor",
"->",
"getExpression",
"(",
")",
",",
"true",
")",
",",
"$",
"extractor",
"->",
"getValueCaster",
"(",
")",
",",
"$",
"this",
"->",
"getConnection",
"(",
")",
"->",
"escapeValue",
"(",
"$",
"extractor",
"->",
"getDefaultValue",
"(",
")",
")",
")",
";",
"$",
"storage",
"=",
"$",
"extractor",
"->",
"getStoreValue",
"(",
")",
"?",
"'STORED'",
":",
"'VIRTUAL'",
";",
"return",
"trim",
"(",
"\"$generated_field_name $field_type AS ($expression) $storage\"",
")",
";",
"}"
]
| Prpeare generated field statement.
@param FieldInterface $source_field
@param ValueExtractorInterface $extractor
@return string | [
"Prpeare",
"generated",
"field",
"statement",
"."
]
| 4b2353c4422186bcfce63b3212da3e70e63eb5df | https://github.com/activecollab/databasestructure/blob/4b2353c4422186bcfce63b3212da3e70e63eb5df/src/Builder/TypeTableBuilder.php#L304-L340 |
15,944 | activecollab/databasestructure | src/Builder/TypeTableBuilder.php | TypeTableBuilder.prepareGeneratedFieldExpression | private function prepareGeneratedFieldExpression($escaped_field_name, $escaped_expression, $caster, $escaped_default_value)
{
$value_extractor_expression = "{$escaped_field_name}->>{$escaped_expression}";
switch ($caster) {
case ValueCasterInterface::CAST_BOOL:
return "IF({$value_extractor_expression} IS NULL, $escaped_default_value, IF({$value_extractor_expression} = 'true' OR ({$value_extractor_expression} REGEXP '^-?[0-9]+$' AND CAST({$value_extractor_expression} AS SIGNED) != 0), 1, 0))";
case ValueCasterInterface::CAST_DATE:
return "IF({$value_extractor_expression} IS NULL, $escaped_default_value, CAST({$value_extractor_expression} AS DATE))";
case ValueCasterInterface::CAST_DATETIME:
return "IF({$value_extractor_expression} IS NULL, $escaped_default_value, CAST({$value_extractor_expression} AS DATETIME))";
case ValueCasterInterface::CAST_INT:
return "IF({$value_extractor_expression} IS NULL, $escaped_default_value, CAST({$value_extractor_expression} AS SIGNED INTEGER))";
case ValueCasterInterface::CAST_FLOAT:
return "IF({$value_extractor_expression} IS NULL, $escaped_default_value, CAST({$value_extractor_expression} AS DECIMAL(12, 2)))";
default:
return "IF({$value_extractor_expression} IS NULL, $escaped_default_value, {$value_extractor_expression})";
}
} | php | private function prepareGeneratedFieldExpression($escaped_field_name, $escaped_expression, $caster, $escaped_default_value)
{
$value_extractor_expression = "{$escaped_field_name}->>{$escaped_expression}";
switch ($caster) {
case ValueCasterInterface::CAST_BOOL:
return "IF({$value_extractor_expression} IS NULL, $escaped_default_value, IF({$value_extractor_expression} = 'true' OR ({$value_extractor_expression} REGEXP '^-?[0-9]+$' AND CAST({$value_extractor_expression} AS SIGNED) != 0), 1, 0))";
case ValueCasterInterface::CAST_DATE:
return "IF({$value_extractor_expression} IS NULL, $escaped_default_value, CAST({$value_extractor_expression} AS DATE))";
case ValueCasterInterface::CAST_DATETIME:
return "IF({$value_extractor_expression} IS NULL, $escaped_default_value, CAST({$value_extractor_expression} AS DATETIME))";
case ValueCasterInterface::CAST_INT:
return "IF({$value_extractor_expression} IS NULL, $escaped_default_value, CAST({$value_extractor_expression} AS SIGNED INTEGER))";
case ValueCasterInterface::CAST_FLOAT:
return "IF({$value_extractor_expression} IS NULL, $escaped_default_value, CAST({$value_extractor_expression} AS DECIMAL(12, 2)))";
default:
return "IF({$value_extractor_expression} IS NULL, $escaped_default_value, {$value_extractor_expression})";
}
} | [
"private",
"function",
"prepareGeneratedFieldExpression",
"(",
"$",
"escaped_field_name",
",",
"$",
"escaped_expression",
",",
"$",
"caster",
",",
"$",
"escaped_default_value",
")",
"{",
"$",
"value_extractor_expression",
"=",
"\"{$escaped_field_name}->>{$escaped_expression}\"",
";",
"switch",
"(",
"$",
"caster",
")",
"{",
"case",
"ValueCasterInterface",
"::",
"CAST_BOOL",
":",
"return",
"\"IF({$value_extractor_expression} IS NULL, $escaped_default_value, IF({$value_extractor_expression} = 'true' OR ({$value_extractor_expression} REGEXP '^-?[0-9]+$' AND CAST({$value_extractor_expression} AS SIGNED) != 0), 1, 0))\"",
";",
"case",
"ValueCasterInterface",
"::",
"CAST_DATE",
":",
"return",
"\"IF({$value_extractor_expression} IS NULL, $escaped_default_value, CAST({$value_extractor_expression} AS DATE))\"",
";",
"case",
"ValueCasterInterface",
"::",
"CAST_DATETIME",
":",
"return",
"\"IF({$value_extractor_expression} IS NULL, $escaped_default_value, CAST({$value_extractor_expression} AS DATETIME))\"",
";",
"case",
"ValueCasterInterface",
"::",
"CAST_INT",
":",
"return",
"\"IF({$value_extractor_expression} IS NULL, $escaped_default_value, CAST({$value_extractor_expression} AS SIGNED INTEGER))\"",
";",
"case",
"ValueCasterInterface",
"::",
"CAST_FLOAT",
":",
"return",
"\"IF({$value_extractor_expression} IS NULL, $escaped_default_value, CAST({$value_extractor_expression} AS DECIMAL(12, 2)))\"",
";",
"default",
":",
"return",
"\"IF({$value_extractor_expression} IS NULL, $escaped_default_value, {$value_extractor_expression})\"",
";",
"}",
"}"
]
| Prepare extraction statement based on expression.
@param string $escaped_field_name
@param string $escaped_expression
@param string $caster
@param mixed $escaped_default_value
@return string | [
"Prepare",
"extraction",
"statement",
"based",
"on",
"expression",
"."
]
| 4b2353c4422186bcfce63b3212da3e70e63eb5df | https://github.com/activecollab/databasestructure/blob/4b2353c4422186bcfce63b3212da3e70e63eb5df/src/Builder/TypeTableBuilder.php#L351-L369 |
15,945 | activecollab/databasestructure | src/Builder/TypeTableBuilder.php | TypeTableBuilder.prepareIndexStatement | public function prepareIndexStatement(IndexInterface $index)
{
switch ($index->getIndexType()) {
case IndexInterface::PRIMARY:
$result = 'PRIMARY KEY';
break;
case IndexInterface::UNIQUE:
$result = 'UNIQUE ' . $this->getConnection()->escapeFieldName($index->getName());
break;
case IndexInterface::FULLTEXT:
$result = 'FULLTEXT ' . $this->getConnection()->escapeFieldName($index->getName());
break;
default:
$result = 'INDEX ' . $this->getConnection()->escapeFieldName($index->getName());
break;
}
return $result . ' (' . implode(', ', array_map(function ($field_name) {
return $this->getConnection()->escapeFieldName($field_name);
}, $index->getFields())) . ')';
} | php | public function prepareIndexStatement(IndexInterface $index)
{
switch ($index->getIndexType()) {
case IndexInterface::PRIMARY:
$result = 'PRIMARY KEY';
break;
case IndexInterface::UNIQUE:
$result = 'UNIQUE ' . $this->getConnection()->escapeFieldName($index->getName());
break;
case IndexInterface::FULLTEXT:
$result = 'FULLTEXT ' . $this->getConnection()->escapeFieldName($index->getName());
break;
default:
$result = 'INDEX ' . $this->getConnection()->escapeFieldName($index->getName());
break;
}
return $result . ' (' . implode(', ', array_map(function ($field_name) {
return $this->getConnection()->escapeFieldName($field_name);
}, $index->getFields())) . ')';
} | [
"public",
"function",
"prepareIndexStatement",
"(",
"IndexInterface",
"$",
"index",
")",
"{",
"switch",
"(",
"$",
"index",
"->",
"getIndexType",
"(",
")",
")",
"{",
"case",
"IndexInterface",
"::",
"PRIMARY",
":",
"$",
"result",
"=",
"'PRIMARY KEY'",
";",
"break",
";",
"case",
"IndexInterface",
"::",
"UNIQUE",
":",
"$",
"result",
"=",
"'UNIQUE '",
".",
"$",
"this",
"->",
"getConnection",
"(",
")",
"->",
"escapeFieldName",
"(",
"$",
"index",
"->",
"getName",
"(",
")",
")",
";",
"break",
";",
"case",
"IndexInterface",
"::",
"FULLTEXT",
":",
"$",
"result",
"=",
"'FULLTEXT '",
".",
"$",
"this",
"->",
"getConnection",
"(",
")",
"->",
"escapeFieldName",
"(",
"$",
"index",
"->",
"getName",
"(",
")",
")",
";",
"break",
";",
"default",
":",
"$",
"result",
"=",
"'INDEX '",
".",
"$",
"this",
"->",
"getConnection",
"(",
")",
"->",
"escapeFieldName",
"(",
"$",
"index",
"->",
"getName",
"(",
")",
")",
";",
"break",
";",
"}",
"return",
"$",
"result",
".",
"' ('",
".",
"implode",
"(",
"', '",
",",
"array_map",
"(",
"function",
"(",
"$",
"field_name",
")",
"{",
"return",
"$",
"this",
"->",
"getConnection",
"(",
")",
"->",
"escapeFieldName",
"(",
"$",
"field_name",
")",
";",
"}",
",",
"$",
"index",
"->",
"getFields",
"(",
")",
")",
")",
".",
"')'",
";",
"}"
]
| Prepare index statement.
@param IndexInterface $index
@return string | [
"Prepare",
"index",
"statement",
"."
]
| 4b2353c4422186bcfce63b3212da3e70e63eb5df | https://github.com/activecollab/databasestructure/blob/4b2353c4422186bcfce63b3212da3e70e63eb5df/src/Builder/TypeTableBuilder.php#L377-L397 |
15,946 | activecollab/databasestructure | src/Builder/TypeTableBuilder.php | TypeTableBuilder.prepareConnectionCreateTableStatement | public function prepareConnectionCreateTableStatement(TypeInterface $source, TypeInterface $target, HasAndBelongsToManyAssociation $association)
{
$result = [];
$result[] = 'CREATE TABLE IF NOT EXISTS ' . $this->getConnection()->escapeTableName($association->getConnectionTableName()) . ' (';
$left_field_name = $association->getLeftFieldName();
$right_field_name = $association->getRightFieldName();
$left_field = (new IntegerField($left_field_name, 0))->unsigned(true)->size($source->getIdField()->getSize());
$right_field = (new IntegerField($right_field_name, 0))->unsigned(true)->size($target->getIdField()->getSize());
$result[] = ' ' . $this->prepareFieldStatement($left_field) . ',';
$result[] = ' ' . $this->prepareFieldStatement($right_field) . ',';
$result[] = ' ' . $this->prepareIndexStatement(new Index('PRIMARY', [$left_field->getName(), $right_field->getName()], IndexInterface::PRIMARY)) . ',';
$result[] = ' ' . $this->prepareIndexStatement(new Index($right_field->getName()));
$result[] = ') ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;';
return implode("\n", $result);
} | php | public function prepareConnectionCreateTableStatement(TypeInterface $source, TypeInterface $target, HasAndBelongsToManyAssociation $association)
{
$result = [];
$result[] = 'CREATE TABLE IF NOT EXISTS ' . $this->getConnection()->escapeTableName($association->getConnectionTableName()) . ' (';
$left_field_name = $association->getLeftFieldName();
$right_field_name = $association->getRightFieldName();
$left_field = (new IntegerField($left_field_name, 0))->unsigned(true)->size($source->getIdField()->getSize());
$right_field = (new IntegerField($right_field_name, 0))->unsigned(true)->size($target->getIdField()->getSize());
$result[] = ' ' . $this->prepareFieldStatement($left_field) . ',';
$result[] = ' ' . $this->prepareFieldStatement($right_field) . ',';
$result[] = ' ' . $this->prepareIndexStatement(new Index('PRIMARY', [$left_field->getName(), $right_field->getName()], IndexInterface::PRIMARY)) . ',';
$result[] = ' ' . $this->prepareIndexStatement(new Index($right_field->getName()));
$result[] = ') ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;';
return implode("\n", $result);
} | [
"public",
"function",
"prepareConnectionCreateTableStatement",
"(",
"TypeInterface",
"$",
"source",
",",
"TypeInterface",
"$",
"target",
",",
"HasAndBelongsToManyAssociation",
"$",
"association",
")",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"$",
"result",
"[",
"]",
"=",
"'CREATE TABLE IF NOT EXISTS '",
".",
"$",
"this",
"->",
"getConnection",
"(",
")",
"->",
"escapeTableName",
"(",
"$",
"association",
"->",
"getConnectionTableName",
"(",
")",
")",
".",
"' ('",
";",
"$",
"left_field_name",
"=",
"$",
"association",
"->",
"getLeftFieldName",
"(",
")",
";",
"$",
"right_field_name",
"=",
"$",
"association",
"->",
"getRightFieldName",
"(",
")",
";",
"$",
"left_field",
"=",
"(",
"new",
"IntegerField",
"(",
"$",
"left_field_name",
",",
"0",
")",
")",
"->",
"unsigned",
"(",
"true",
")",
"->",
"size",
"(",
"$",
"source",
"->",
"getIdField",
"(",
")",
"->",
"getSize",
"(",
")",
")",
";",
"$",
"right_field",
"=",
"(",
"new",
"IntegerField",
"(",
"$",
"right_field_name",
",",
"0",
")",
")",
"->",
"unsigned",
"(",
"true",
")",
"->",
"size",
"(",
"$",
"target",
"->",
"getIdField",
"(",
")",
"->",
"getSize",
"(",
")",
")",
";",
"$",
"result",
"[",
"]",
"=",
"' '",
".",
"$",
"this",
"->",
"prepareFieldStatement",
"(",
"$",
"left_field",
")",
".",
"','",
";",
"$",
"result",
"[",
"]",
"=",
"' '",
".",
"$",
"this",
"->",
"prepareFieldStatement",
"(",
"$",
"right_field",
")",
".",
"','",
";",
"$",
"result",
"[",
"]",
"=",
"' '",
".",
"$",
"this",
"->",
"prepareIndexStatement",
"(",
"new",
"Index",
"(",
"'PRIMARY'",
",",
"[",
"$",
"left_field",
"->",
"getName",
"(",
")",
",",
"$",
"right_field",
"->",
"getName",
"(",
")",
"]",
",",
"IndexInterface",
"::",
"PRIMARY",
")",
")",
".",
"','",
";",
"$",
"result",
"[",
"]",
"=",
"' '",
".",
"$",
"this",
"->",
"prepareIndexStatement",
"(",
"new",
"Index",
"(",
"$",
"right_field",
"->",
"getName",
"(",
")",
")",
")",
";",
"$",
"result",
"[",
"]",
"=",
"') ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;'",
";",
"return",
"implode",
"(",
"\"\\n\"",
",",
"$",
"result",
")",
";",
"}"
]
| Prepare create connection table statement.
@param TypeInterface $source
@param TypeInterface $target
@param HasAndBelongsToManyAssociation $association
@return string | [
"Prepare",
"create",
"connection",
"table",
"statement",
"."
]
| 4b2353c4422186bcfce63b3212da3e70e63eb5df | https://github.com/activecollab/databasestructure/blob/4b2353c4422186bcfce63b3212da3e70e63eb5df/src/Builder/TypeTableBuilder.php#L419-L439 |
15,947 | crossjoin/Css | src/Crossjoin/Css/Format/Rule/TraitComments.php | TraitComments.setComments | public function setComments($comments)
{
$this->comments = [];
if (!is_array($comments)) {
$comments = [$comments];
}
foreach ($comments as $comment) {
$this->addComment($comment);
}
return $this;
} | php | public function setComments($comments)
{
$this->comments = [];
if (!is_array($comments)) {
$comments = [$comments];
}
foreach ($comments as $comment) {
$this->addComment($comment);
}
return $this;
} | [
"public",
"function",
"setComments",
"(",
"$",
"comments",
")",
"{",
"$",
"this",
"->",
"comments",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"comments",
")",
")",
"{",
"$",
"comments",
"=",
"[",
"$",
"comments",
"]",
";",
"}",
"foreach",
"(",
"$",
"comments",
"as",
"$",
"comment",
")",
"{",
"$",
"this",
"->",
"addComment",
"(",
"$",
"comment",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| Sets comments.
@param string[]|string $comments
@return $this | [
"Sets",
"comments",
"."
]
| 7b50ca94c4bdad60d01cfa327f00b7a600d6f9f3 | https://github.com/crossjoin/Css/blob/7b50ca94c4bdad60d01cfa327f00b7a600d6f9f3/src/Crossjoin/Css/Format/Rule/TraitComments.php#L19-L30 |
15,948 | readdle/fqdb | src/Readdle/Database/FQDBExecutor.php | FQDBExecutor.execute | public function execute($sqlQuery, $params = [], $prefix = '')
{
if ($prefix !== '')
$this->_testQueryStarts($sqlQuery, $prefix);
$statement = $this->_executeQuery($sqlQuery, $params);
return $statement->rowCount();
} | php | public function execute($sqlQuery, $params = [], $prefix = '')
{
if ($prefix !== '')
$this->_testQueryStarts($sqlQuery, $prefix);
$statement = $this->_executeQuery($sqlQuery, $params);
return $statement->rowCount();
} | [
"public",
"function",
"execute",
"(",
"$",
"sqlQuery",
",",
"$",
"params",
"=",
"[",
"]",
",",
"$",
"prefix",
"=",
"''",
")",
"{",
"if",
"(",
"$",
"prefix",
"!==",
"''",
")",
"$",
"this",
"->",
"_testQueryStarts",
"(",
"$",
"sqlQuery",
",",
"$",
"prefix",
")",
";",
"$",
"statement",
"=",
"$",
"this",
"->",
"_executeQuery",
"(",
"$",
"sqlQuery",
",",
"$",
"params",
")",
";",
"return",
"$",
"statement",
"->",
"rowCount",
"(",
")",
";",
"}"
]
| Execute given SQL query. Please DON'T use instead of other functions
example - use this if you need something like "TRUNCATE TABLE `users`"
use it VERY CAREFULLY!
@param string $sqlQuery
@param array $params
@param string $prefix prefix to check SQL query against
@return int affected rows count | [
"Execute",
"given",
"SQL",
"query",
".",
"Please",
"DON",
"T",
"use",
"instead",
"of",
"other",
"functions"
]
| 4ef2e8f3343a7c8fbb309c243be502a160c42083 | https://github.com/readdle/fqdb/blob/4ef2e8f3343a7c8fbb309c243be502a160c42083/src/Readdle/Database/FQDBExecutor.php#L96-L103 |
15,949 | readdle/fqdb | src/Readdle/Database/FQDBExecutor.php | FQDBExecutor.checkConnection | private function checkConnection()
{
if ($this->_databaseServer !== self::DB_MYSQL) {
return;
}
$interval = (time() - (int)$this->_lastCheckTime);
if ($interval >= self::MYSQL_CONNECTION_TIMEOUT) {
$this->connect();
}
} | php | private function checkConnection()
{
if ($this->_databaseServer !== self::DB_MYSQL) {
return;
}
$interval = (time() - (int)$this->_lastCheckTime);
if ($interval >= self::MYSQL_CONNECTION_TIMEOUT) {
$this->connect();
}
} | [
"private",
"function",
"checkConnection",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_databaseServer",
"!==",
"self",
"::",
"DB_MYSQL",
")",
"{",
"return",
";",
"}",
"$",
"interval",
"=",
"(",
"time",
"(",
")",
"-",
"(",
"int",
")",
"$",
"this",
"->",
"_lastCheckTime",
")",
";",
"if",
"(",
"$",
"interval",
">=",
"self",
"::",
"MYSQL_CONNECTION_TIMEOUT",
")",
"{",
"$",
"this",
"->",
"connect",
"(",
")",
";",
"}",
"}"
]
| if last query was too long time ago - reconnect | [
"if",
"last",
"query",
"was",
"too",
"long",
"time",
"ago",
"-",
"reconnect"
]
| 4ef2e8f3343a7c8fbb309c243be502a160c42083 | https://github.com/readdle/fqdb/blob/4ef2e8f3343a7c8fbb309c243be502a160c42083/src/Readdle/Database/FQDBExecutor.php#L201-L212 |
15,950 | readdle/fqdb | src/Readdle/Database/FQDBExecutor.php | FQDBExecutor._getWarnings | private function _getWarnings($sqlQueryString, $options = [])
{
if ($this->_databaseServer === self::DB_MYSQL) {
$stm = $this->_pdo->query('SHOW WARNINGS');
$sqlWarnings = $stm->fetchAll(\PDO::FETCH_ASSOC);
} else {
$sqlWarnings = [['Message' => 'WarningReporting not impl. for ' . $this->_pdo->getAttribute(\PDO::ATTR_DRIVER_NAME)]];
}
if (count($sqlWarnings) > 0) {
$warnings = "Query:\n{$sqlQueryString}\n";
if (!empty($options)) {
$warnings .= "Params: (";
foreach ($options as $key => $value) {
$warnings .= $key . '=' . json_encode($value) . ', ';
}
$warnings = substr($warnings, 0, -2) . ")\n";
}
$warnings .= "Produced Warnings:";
foreach ($sqlWarnings as $warn) {
$warnings .= "\n* " . $warn['Message'];
}
return $warnings;
}
return '';
} | php | private function _getWarnings($sqlQueryString, $options = [])
{
if ($this->_databaseServer === self::DB_MYSQL) {
$stm = $this->_pdo->query('SHOW WARNINGS');
$sqlWarnings = $stm->fetchAll(\PDO::FETCH_ASSOC);
} else {
$sqlWarnings = [['Message' => 'WarningReporting not impl. for ' . $this->_pdo->getAttribute(\PDO::ATTR_DRIVER_NAME)]];
}
if (count($sqlWarnings) > 0) {
$warnings = "Query:\n{$sqlQueryString}\n";
if (!empty($options)) {
$warnings .= "Params: (";
foreach ($options as $key => $value) {
$warnings .= $key . '=' . json_encode($value) . ', ';
}
$warnings = substr($warnings, 0, -2) . ")\n";
}
$warnings .= "Produced Warnings:";
foreach ($sqlWarnings as $warn) {
$warnings .= "\n* " . $warn['Message'];
}
return $warnings;
}
return '';
} | [
"private",
"function",
"_getWarnings",
"(",
"$",
"sqlQueryString",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_databaseServer",
"===",
"self",
"::",
"DB_MYSQL",
")",
"{",
"$",
"stm",
"=",
"$",
"this",
"->",
"_pdo",
"->",
"query",
"(",
"'SHOW WARNINGS'",
")",
";",
"$",
"sqlWarnings",
"=",
"$",
"stm",
"->",
"fetchAll",
"(",
"\\",
"PDO",
"::",
"FETCH_ASSOC",
")",
";",
"}",
"else",
"{",
"$",
"sqlWarnings",
"=",
"[",
"[",
"'Message'",
"=>",
"'WarningReporting not impl. for '",
".",
"$",
"this",
"->",
"_pdo",
"->",
"getAttribute",
"(",
"\\",
"PDO",
"::",
"ATTR_DRIVER_NAME",
")",
"]",
"]",
";",
"}",
"if",
"(",
"count",
"(",
"$",
"sqlWarnings",
")",
">",
"0",
")",
"{",
"$",
"warnings",
"=",
"\"Query:\\n{$sqlQueryString}\\n\"",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"options",
")",
")",
"{",
"$",
"warnings",
".=",
"\"Params: (\"",
";",
"foreach",
"(",
"$",
"options",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"warnings",
".=",
"$",
"key",
".",
"'='",
".",
"json_encode",
"(",
"$",
"value",
")",
".",
"', '",
";",
"}",
"$",
"warnings",
"=",
"substr",
"(",
"$",
"warnings",
",",
"0",
",",
"-",
"2",
")",
".",
"\")\\n\"",
";",
"}",
"$",
"warnings",
".=",
"\"Produced Warnings:\"",
";",
"foreach",
"(",
"$",
"sqlWarnings",
"as",
"$",
"warn",
")",
"{",
"$",
"warnings",
".=",
"\"\\n* \"",
".",
"$",
"warn",
"[",
"'Message'",
"]",
";",
"}",
"return",
"$",
"warnings",
";",
"}",
"return",
"''",
";",
"}"
]
| gathers Warning info from \PDO
@param string $sqlQueryString SQL query string with placeholders
@param array $options options passed to query
@return string | [
"gathers",
"Warning",
"info",
"from",
"\\",
"PDO"
]
| 4ef2e8f3343a7c8fbb309c243be502a160c42083 | https://github.com/readdle/fqdb/blob/4ef2e8f3343a7c8fbb309c243be502a160c42083/src/Readdle/Database/FQDBExecutor.php#L220-L254 |
15,951 | bestit/commercetools-order-export-bundle | src/Event/PrepareOrderExportEvent.php | PrepareOrderExportEvent.addExportData | public function addExportData($key, $data = null): PrepareOrderExportEvent
{
if (is_array($key)) {
$this->exportData = array_merge($this->exportData, $key);
} else {
$this->exportData[$key] = $data;
}
return $this;
} | php | public function addExportData($key, $data = null): PrepareOrderExportEvent
{
if (is_array($key)) {
$this->exportData = array_merge($this->exportData, $key);
} else {
$this->exportData[$key] = $data;
}
return $this;
} | [
"public",
"function",
"addExportData",
"(",
"$",
"key",
",",
"$",
"data",
"=",
"null",
")",
":",
"PrepareOrderExportEvent",
"{",
"if",
"(",
"is_array",
"(",
"$",
"key",
")",
")",
"{",
"$",
"this",
"->",
"exportData",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"exportData",
",",
"$",
"key",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"exportData",
"[",
"$",
"key",
"]",
"=",
"$",
"data",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| Adds an exportable data.
@param string|array $key
@param null $data
@return PrepareOrderExportEvent | [
"Adds",
"an",
"exportable",
"data",
"."
]
| 44bd0dedff6edab5ecf5803dcf6d24ffe0dbf845 | https://github.com/bestit/commercetools-order-export-bundle/blob/44bd0dedff6edab5ecf5803dcf6d24ffe0dbf845/src/Event/PrepareOrderExportEvent.php#L26-L35 |
15,952 | EFTEC/SecurityOne | lib/SecurityOne.php | SecurityOne.factoryUser | public function factoryUser($user,$password,$name,$group,$role,$status,$email=null,$iduser=null,$extra=[]) {
$this->user=$user;
$this->password=$password;
$this->fullName=$name;
$this->group=$group;
$this->role=$role;
$this->status=$status;
$this->email=$email;
$this->iduser=$iduser;
$this->extraFields=$extra;
} | php | public function factoryUser($user,$password,$name,$group,$role,$status,$email=null,$iduser=null,$extra=[]) {
$this->user=$user;
$this->password=$password;
$this->fullName=$name;
$this->group=$group;
$this->role=$role;
$this->status=$status;
$this->email=$email;
$this->iduser=$iduser;
$this->extraFields=$extra;
} | [
"public",
"function",
"factoryUser",
"(",
"$",
"user",
",",
"$",
"password",
",",
"$",
"name",
",",
"$",
"group",
",",
"$",
"role",
",",
"$",
"status",
",",
"$",
"email",
"=",
"null",
",",
"$",
"iduser",
"=",
"null",
",",
"$",
"extra",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"user",
"=",
"$",
"user",
";",
"$",
"this",
"->",
"password",
"=",
"$",
"password",
";",
"$",
"this",
"->",
"fullName",
"=",
"$",
"name",
";",
"$",
"this",
"->",
"group",
"=",
"$",
"group",
";",
"$",
"this",
"->",
"role",
"=",
"$",
"role",
";",
"$",
"this",
"->",
"status",
"=",
"$",
"status",
";",
"$",
"this",
"->",
"email",
"=",
"$",
"email",
";",
"$",
"this",
"->",
"iduser",
"=",
"$",
"iduser",
";",
"$",
"this",
"->",
"extraFields",
"=",
"$",
"extra",
";",
"}"
]
| It sets the current user.
@param string $user
@param string $password
@param string $name
@param string[] $group
@param string $role
@param int $status 0=disabled,1=enabled
@param string $email
@param string $iduser
@param array $extra | [
"It",
"sets",
"the",
"current",
"user",
"."
]
| 509412cd8d71dcadce763efa4655c6dfe2dffe13 | https://github.com/EFTEC/SecurityOne/blob/509412cd8d71dcadce763efa4655c6dfe2dffe13/lib/SecurityOne.php#L112-L122 |
15,953 | EFTEC/SecurityOne | lib/SecurityOne.php | SecurityOne.serialize | public function serialize() {
$r=['user'=>$this->user
,'name'=>$this->fullName
,'uid'=>$this->uid
,'group'=>$this->group
,'role'=>$this->role];
/* optional fields */
if ($this->email!==null) $r['email']=$this->email;
if ($this->iduser!==null) $r['iduser']=$this->iduser;
$r['extrafields']=$this->extraFields;
return $r;
} | php | public function serialize() {
$r=['user'=>$this->user
,'name'=>$this->fullName
,'uid'=>$this->uid
,'group'=>$this->group
,'role'=>$this->role];
/* optional fields */
if ($this->email!==null) $r['email']=$this->email;
if ($this->iduser!==null) $r['iduser']=$this->iduser;
$r['extrafields']=$this->extraFields;
return $r;
} | [
"public",
"function",
"serialize",
"(",
")",
"{",
"$",
"r",
"=",
"[",
"'user'",
"=>",
"$",
"this",
"->",
"user",
",",
"'name'",
"=>",
"$",
"this",
"->",
"fullName",
",",
"'uid'",
"=>",
"$",
"this",
"->",
"uid",
",",
"'group'",
"=>",
"$",
"this",
"->",
"group",
",",
"'role'",
"=>",
"$",
"this",
"->",
"role",
"]",
";",
"/* optional fields */",
"if",
"(",
"$",
"this",
"->",
"email",
"!==",
"null",
")",
"$",
"r",
"[",
"'email'",
"]",
"=",
"$",
"this",
"->",
"email",
";",
"if",
"(",
"$",
"this",
"->",
"iduser",
"!==",
"null",
")",
"$",
"r",
"[",
"'iduser'",
"]",
"=",
"$",
"this",
"->",
"iduser",
";",
"$",
"r",
"[",
"'extrafields'",
"]",
"=",
"$",
"this",
"->",
"extraFields",
";",
"return",
"$",
"r",
";",
"}"
]
| Returns an associative array with the current user
@return array=['user'='','name'=>'','uid'=>'','group'=>[],'role'=>''
,'email'=>'','iduser'=>'','extrafields'=>[]] | [
"Returns",
"an",
"associative",
"array",
"with",
"the",
"current",
"user"
]
| 509412cd8d71dcadce763efa4655c6dfe2dffe13 | https://github.com/EFTEC/SecurityOne/blob/509412cd8d71dcadce763efa4655c6dfe2dffe13/lib/SecurityOne.php#L142-L155 |
15,954 | EFTEC/SecurityOne | lib/SecurityOne.php | SecurityOne.deserialize | public function deserialize($array) {
$this->user=@$array['user'];
$this->fullName=@$array['name'];
$this->uid=@$array['uid'];
$this->group=@$array['group'];
$this->role=@$array['role'];
$this->status=@$array['status'];
/* optional fields */
$this->email=@$array['email'];
$this->iduser=@$array['iduser'];
$this->extraFields=@$array['extrafields'];
} | php | public function deserialize($array) {
$this->user=@$array['user'];
$this->fullName=@$array['name'];
$this->uid=@$array['uid'];
$this->group=@$array['group'];
$this->role=@$array['role'];
$this->status=@$array['status'];
/* optional fields */
$this->email=@$array['email'];
$this->iduser=@$array['iduser'];
$this->extraFields=@$array['extrafields'];
} | [
"public",
"function",
"deserialize",
"(",
"$",
"array",
")",
"{",
"$",
"this",
"->",
"user",
"=",
"@",
"$",
"array",
"[",
"'user'",
"]",
";",
"$",
"this",
"->",
"fullName",
"=",
"@",
"$",
"array",
"[",
"'name'",
"]",
";",
"$",
"this",
"->",
"uid",
"=",
"@",
"$",
"array",
"[",
"'uid'",
"]",
";",
"$",
"this",
"->",
"group",
"=",
"@",
"$",
"array",
"[",
"'group'",
"]",
";",
"$",
"this",
"->",
"role",
"=",
"@",
"$",
"array",
"[",
"'role'",
"]",
";",
"$",
"this",
"->",
"status",
"=",
"@",
"$",
"array",
"[",
"'status'",
"]",
";",
"/* optional fields */",
"$",
"this",
"->",
"email",
"=",
"@",
"$",
"array",
"[",
"'email'",
"]",
";",
"$",
"this",
"->",
"iduser",
"=",
"@",
"$",
"array",
"[",
"'iduser'",
"]",
";",
"$",
"this",
"->",
"extraFields",
"=",
"@",
"$",
"array",
"[",
"'extrafields'",
"]",
";",
"}"
]
| Set the current user by using an associative array
@param $array=['user'=>'','name'=>'','uid'=>'','group'=>[],role=>''
,'status'=>0,'email'=>'','iduser'=>0,'extrafields'=>[]] | [
"Set",
"the",
"current",
"user",
"by",
"using",
"an",
"associative",
"array"
]
| 509412cd8d71dcadce763efa4655c6dfe2dffe13 | https://github.com/EFTEC/SecurityOne/blob/509412cd8d71dcadce763efa4655c6dfe2dffe13/lib/SecurityOne.php#L177-L188 |
15,955 | EFTEC/SecurityOne | lib/SecurityOne.php | SecurityOne.login | public function login($user,$password,$storeCookie=false) {
$this->user=$user;
$this->password=$this->encrypt($password);
$this->uid=$this->genUID();
//$this->other=$other;
if (call_user_func($this->loginFn,$this)) {
$this->fixSession($storeCookie && $this->useCookie);
return true;
} else {
@session_destroy();
@session_write_close();
$this->isLogged=false;
return false;
}
} | php | public function login($user,$password,$storeCookie=false) {
$this->user=$user;
$this->password=$this->encrypt($password);
$this->uid=$this->genUID();
//$this->other=$other;
if (call_user_func($this->loginFn,$this)) {
$this->fixSession($storeCookie && $this->useCookie);
return true;
} else {
@session_destroy();
@session_write_close();
$this->isLogged=false;
return false;
}
} | [
"public",
"function",
"login",
"(",
"$",
"user",
",",
"$",
"password",
",",
"$",
"storeCookie",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"user",
"=",
"$",
"user",
";",
"$",
"this",
"->",
"password",
"=",
"$",
"this",
"->",
"encrypt",
"(",
"$",
"password",
")",
";",
"$",
"this",
"->",
"uid",
"=",
"$",
"this",
"->",
"genUID",
"(",
")",
";",
"//$this->other=$other;",
"if",
"(",
"call_user_func",
"(",
"$",
"this",
"->",
"loginFn",
",",
"$",
"this",
")",
")",
"{",
"$",
"this",
"->",
"fixSession",
"(",
"$",
"storeCookie",
"&&",
"$",
"this",
"->",
"useCookie",
")",
";",
"return",
"true",
";",
"}",
"else",
"{",
"@",
"session_destroy",
"(",
")",
";",
"@",
"session_write_close",
"(",
")",
";",
"$",
"this",
"->",
"isLogged",
"=",
"false",
";",
"return",
"false",
";",
"}",
"}"
]
| It's used when the user log with an user and password. So it must be used only in the login screen.
After that, the user is stored in the session.
@param string $user
@param string $password Not encrypted password
@param bool $storeCookie
@return bool | [
"It",
"s",
"used",
"when",
"the",
"user",
"log",
"with",
"an",
"user",
"and",
"password",
".",
"So",
"it",
"must",
"be",
"used",
"only",
"in",
"the",
"login",
"screen",
".",
"After",
"that",
"the",
"user",
"is",
"stored",
"in",
"the",
"session",
"."
]
| 509412cd8d71dcadce763efa4655c6dfe2dffe13 | https://github.com/EFTEC/SecurityOne/blob/509412cd8d71dcadce763efa4655c6dfe2dffe13/lib/SecurityOne.php#L262-L276 |
15,956 | EFTEC/SecurityOne | lib/SecurityOne.php | SecurityOne.logout | public function logout() {
$this->user="";
$this->password="";
$this->isLogged=false;
if ($this->useCookie) {
unset($_COOKIE['phpcookiesess']);
setcookie('phpcookiesess', null, -1, '/');
}
@session_destroy();
@session_write_close();
} | php | public function logout() {
$this->user="";
$this->password="";
$this->isLogged=false;
if ($this->useCookie) {
unset($_COOKIE['phpcookiesess']);
setcookie('phpcookiesess', null, -1, '/');
}
@session_destroy();
@session_write_close();
} | [
"public",
"function",
"logout",
"(",
")",
"{",
"$",
"this",
"->",
"user",
"=",
"\"\"",
";",
"$",
"this",
"->",
"password",
"=",
"\"\"",
";",
"$",
"this",
"->",
"isLogged",
"=",
"false",
";",
"if",
"(",
"$",
"this",
"->",
"useCookie",
")",
"{",
"unset",
"(",
"$",
"_COOKIE",
"[",
"'phpcookiesess'",
"]",
")",
";",
"setcookie",
"(",
"'phpcookiesess'",
",",
"null",
",",
"-",
"1",
",",
"'/'",
")",
";",
"}",
"@",
"session_destroy",
"(",
")",
";",
"@",
"session_write_close",
"(",
")",
";",
"}"
]
| Logout and the session is destroyed. It doesn't redirect to the home page. | [
"Logout",
"and",
"the",
"session",
"is",
"destroyed",
".",
"It",
"doesn",
"t",
"redirect",
"to",
"the",
"home",
"page",
"."
]
| 509412cd8d71dcadce763efa4655c6dfe2dffe13 | https://github.com/EFTEC/SecurityOne/blob/509412cd8d71dcadce763efa4655c6dfe2dffe13/lib/SecurityOne.php#L289-L299 |
15,957 | EFTEC/SecurityOne | lib/SecurityOne.php | SecurityOne.isLogged | public function isLogged() {
if (!$this->isLogged) return false;
if ($this->genUID()!=$this->uid) return false; // uid doesn't correspond.
return true;
} | php | public function isLogged() {
if (!$this->isLogged) return false;
if ($this->genUID()!=$this->uid) return false; // uid doesn't correspond.
return true;
} | [
"public",
"function",
"isLogged",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isLogged",
")",
"return",
"false",
";",
"if",
"(",
"$",
"this",
"->",
"genUID",
"(",
")",
"!=",
"$",
"this",
"->",
"uid",
")",
"return",
"false",
";",
"// uid doesn't correspond.",
"return",
"true",
";",
"}"
]
| Returns true if the user is logged. False if not. It also returns false if the UID doesn't correspond.
@return bool | [
"Returns",
"true",
"if",
"the",
"user",
"is",
"logged",
".",
"False",
"if",
"not",
".",
"It",
"also",
"returns",
"false",
"if",
"the",
"UID",
"doesn",
"t",
"correspond",
"."
]
| 509412cd8d71dcadce763efa4655c6dfe2dffe13 | https://github.com/EFTEC/SecurityOne/blob/509412cd8d71dcadce763efa4655c6dfe2dffe13/lib/SecurityOne.php#L305-L309 |
15,958 | EFTEC/SecurityOne | lib/SecurityOne.php | SecurityOne.getCurrent | public function getCurrent($closeSession=false) {
if (session_status() === PHP_SESSION_ACTIVE ? TRUE : FALSE) {
$b=@session_start();
if (!$b) return false; // session is not open and I am unable to open it
}
$obj=@$_SESSION['_user'];
if ($obj!==null) $this->deserialize($obj);
if ($closeSession) @session_write_close();
return $obj;
} | php | public function getCurrent($closeSession=false) {
if (session_status() === PHP_SESSION_ACTIVE ? TRUE : FALSE) {
$b=@session_start();
if (!$b) return false; // session is not open and I am unable to open it
}
$obj=@$_SESSION['_user'];
if ($obj!==null) $this->deserialize($obj);
if ($closeSession) @session_write_close();
return $obj;
} | [
"public",
"function",
"getCurrent",
"(",
"$",
"closeSession",
"=",
"false",
")",
"{",
"if",
"(",
"session_status",
"(",
")",
"===",
"PHP_SESSION_ACTIVE",
"?",
"TRUE",
":",
"FALSE",
")",
"{",
"$",
"b",
"=",
"@",
"session_start",
"(",
")",
";",
"if",
"(",
"!",
"$",
"b",
")",
"return",
"false",
";",
"// session is not open and I am unable to open it",
"}",
"$",
"obj",
"=",
"@",
"$",
"_SESSION",
"[",
"'_user'",
"]",
";",
"if",
"(",
"$",
"obj",
"!==",
"null",
")",
"$",
"this",
"->",
"deserialize",
"(",
"$",
"obj",
")",
";",
"if",
"(",
"$",
"closeSession",
")",
"@",
"session_write_close",
"(",
")",
";",
"return",
"$",
"obj",
";",
"}"
]
| Load current user. It returns an array
@param bool $closeSession
@return bool | [
"Load",
"current",
"user",
".",
"It",
"returns",
"an",
"array"
]
| 509412cd8d71dcadce763efa4655c6dfe2dffe13 | https://github.com/EFTEC/SecurityOne/blob/509412cd8d71dcadce763efa4655c6dfe2dffe13/lib/SecurityOne.php#L343-L354 |
15,959 | drpdigital/json-api-parser | src/ResolvedCollection.php | ResolvedCollection.getByClass | public function getByClass($className)
{
$types = array_unique(Arr::wrap(Arr::get($this->classMapping, $className, [])));
$resolved = array_map([$this, 'get'], $types);
return $this->firstOrAll(Arr::collapse($resolved));
} | php | public function getByClass($className)
{
$types = array_unique(Arr::wrap(Arr::get($this->classMapping, $className, [])));
$resolved = array_map([$this, 'get'], $types);
return $this->firstOrAll(Arr::collapse($resolved));
} | [
"public",
"function",
"getByClass",
"(",
"$",
"className",
")",
"{",
"$",
"types",
"=",
"array_unique",
"(",
"Arr",
"::",
"wrap",
"(",
"Arr",
"::",
"get",
"(",
"$",
"this",
"->",
"classMapping",
",",
"$",
"className",
",",
"[",
"]",
")",
")",
")",
";",
"$",
"resolved",
"=",
"array_map",
"(",
"[",
"$",
"this",
",",
"'get'",
"]",
",",
"$",
"types",
")",
";",
"return",
"$",
"this",
"->",
"firstOrAll",
"(",
"Arr",
"::",
"collapse",
"(",
"$",
"resolved",
")",
")",
";",
"}"
]
| Get the resolved resource by type.
This will return an array of that resource if multiple resources of that type were
resolved. If only 1 item in the array then that 1 item will be returned instead.
@param string $className
@return mixed|array | [
"Get",
"the",
"resolved",
"resource",
"by",
"type",
"."
]
| b1ceefc0c19ec326129126253114c121e97ca943 | https://github.com/drpdigital/json-api-parser/blob/b1ceefc0c19ec326129126253114c121e97ca943/src/ResolvedCollection.php#L23-L29 |
15,960 | drpdigital/json-api-parser | src/ResolvedCollection.php | ResolvedCollection.add | public function add($key, $value)
{
parent::add($key, $value);
if (is_object($value) === false) {
return;
}
$this->classMapping[get_class($value)][] = $key;
} | php | public function add($key, $value)
{
parent::add($key, $value);
if (is_object($value) === false) {
return;
}
$this->classMapping[get_class($value)][] = $key;
} | [
"public",
"function",
"add",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"parent",
"::",
"add",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"if",
"(",
"is_object",
"(",
"$",
"value",
")",
"===",
"false",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"classMapping",
"[",
"get_class",
"(",
"$",
"value",
")",
"]",
"[",
"]",
"=",
"$",
"key",
";",
"}"
]
| Add resolved resource to the collection.
@param string $key
@param mixed $value | [
"Add",
"resolved",
"resource",
"to",
"the",
"collection",
"."
]
| b1ceefc0c19ec326129126253114c121e97ca943 | https://github.com/drpdigital/json-api-parser/blob/b1ceefc0c19ec326129126253114c121e97ca943/src/ResolvedCollection.php#L37-L46 |
15,961 | opis/storages | session/Database.php | Database.read | public function read($id)
{
try {
$result = $this->db->from($this->table)
->where($this->columns['id'])->eq($id)
->column($this->columns['data']);
return $result === false ? '' : $result;
} catch (PDOException $e) {
return '';
}
} | php | public function read($id)
{
try {
$result = $this->db->from($this->table)
->where($this->columns['id'])->eq($id)
->column($this->columns['data']);
return $result === false ? '' : $result;
} catch (PDOException $e) {
return '';
}
} | [
"public",
"function",
"read",
"(",
"$",
"id",
")",
"{",
"try",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"db",
"->",
"from",
"(",
"$",
"this",
"->",
"table",
")",
"->",
"where",
"(",
"$",
"this",
"->",
"columns",
"[",
"'id'",
"]",
")",
"->",
"eq",
"(",
"$",
"id",
")",
"->",
"column",
"(",
"$",
"this",
"->",
"columns",
"[",
"'data'",
"]",
")",
";",
"return",
"$",
"result",
"===",
"false",
"?",
"''",
":",
"$",
"result",
";",
"}",
"catch",
"(",
"PDOException",
"$",
"e",
")",
"{",
"return",
"''",
";",
"}",
"}"
]
| Returns session data.
@param string $id Session id
@return string | [
"Returns",
"session",
"data",
"."
]
| 548dd631239c7cd75c04d17878b677e646540fde | https://github.com/opis/storages/blob/548dd631239c7cd75c04d17878b677e646540fde/session/Database.php#L111-L122 |
15,962 | opis/storages | session/Database.php | Database.gc | public function gc($maxLifetime)
{
try {
return (bool) $this->db->from($this->table)
->where($this->columns['expires'])->lt(time())
->delete();
} catch (PDOException $e) {
return false;
}
} | php | public function gc($maxLifetime)
{
try {
return (bool) $this->db->from($this->table)
->where($this->columns['expires'])->lt(time())
->delete();
} catch (PDOException $e) {
return false;
}
} | [
"public",
"function",
"gc",
"(",
"$",
"maxLifetime",
")",
"{",
"try",
"{",
"return",
"(",
"bool",
")",
"$",
"this",
"->",
"db",
"->",
"from",
"(",
"$",
"this",
"->",
"table",
")",
"->",
"where",
"(",
"$",
"this",
"->",
"columns",
"[",
"'expires'",
"]",
")",
"->",
"lt",
"(",
"time",
"(",
")",
")",
"->",
"delete",
"(",
")",
";",
"}",
"catch",
"(",
"PDOException",
"$",
"e",
")",
"{",
"return",
"false",
";",
"}",
"}"
]
| Garbage collector.
@param int $maxLifetime Lifetime in secods
@return boolean | [
"Garbage",
"collector",
"."
]
| 548dd631239c7cd75c04d17878b677e646540fde | https://github.com/opis/storages/blob/548dd631239c7cd75c04d17878b677e646540fde/session/Database.php#L183-L192 |
15,963 | nicoSWD/put.io-api-v2 | src/PutIO/Engines/PutIO/TransfersEngine.php | TransfersEngine.add | public function add($url, $parentID = 0, $extract = \false, $callbackUrl = '')
{
$data = [
'url' => $url,
'save_parent_id' => $parentID,
'extract' => ($extract ? 'True' : 'False'),
'callback_url' => $callbackUrl
];
return $this->post('transfers/add', $data, \false);
} | php | public function add($url, $parentID = 0, $extract = \false, $callbackUrl = '')
{
$data = [
'url' => $url,
'save_parent_id' => $parentID,
'extract' => ($extract ? 'True' : 'False'),
'callback_url' => $callbackUrl
];
return $this->post('transfers/add', $data, \false);
} | [
"public",
"function",
"add",
"(",
"$",
"url",
",",
"$",
"parentID",
"=",
"0",
",",
"$",
"extract",
"=",
"\\",
"false",
",",
"$",
"callbackUrl",
"=",
"''",
")",
"{",
"$",
"data",
"=",
"[",
"'url'",
"=>",
"$",
"url",
",",
"'save_parent_id'",
"=>",
"$",
"parentID",
",",
"'extract'",
"=>",
"(",
"$",
"extract",
"?",
"'True'",
":",
"'False'",
")",
",",
"'callback_url'",
"=>",
"$",
"callbackUrl",
"]",
";",
"return",
"$",
"this",
"->",
"post",
"(",
"'transfers/add'",
",",
"$",
"data",
",",
"\\",
"false",
")",
";",
"}"
]
| Adds a new transfer to the queue.
@param string $url URL of the file/torrent
@param int $parentID ID of the target folder. 0 = root
@param bool $extract Extract file when download complete
@param string $callbackUrl put.io will POST the metadata of the file to
the given URL when file is ready.
@return array | [
"Adds",
"a",
"new",
"transfer",
"to",
"the",
"queue",
"."
]
| d91bedd91ea75793512a921bfd9aa83e86a6f0a7 | https://github.com/nicoSWD/put.io-api-v2/blob/d91bedd91ea75793512a921bfd9aa83e86a6f0a7/src/PutIO/Engines/PutIO/TransfersEngine.php#L44-L54 |
15,964 | nicoSWD/put.io-api-v2 | src/PutIO/Engines/PutIO/TransfersEngine.php | TransfersEngine.cancel | public function cancel($transferIDs)
{
if (is_array($transferIDs)) {
$transferIDs = implode(',', $transferIDs);
}
$data = [
'transfer_ids' => $transferIDs
];
return $this->post('transfers/cancel', $data, \true);
} | php | public function cancel($transferIDs)
{
if (is_array($transferIDs)) {
$transferIDs = implode(',', $transferIDs);
}
$data = [
'transfer_ids' => $transferIDs
];
return $this->post('transfers/cancel', $data, \true);
} | [
"public",
"function",
"cancel",
"(",
"$",
"transferIDs",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"transferIDs",
")",
")",
"{",
"$",
"transferIDs",
"=",
"implode",
"(",
"','",
",",
"$",
"transferIDs",
")",
";",
"}",
"$",
"data",
"=",
"[",
"'transfer_ids'",
"=>",
"$",
"transferIDs",
"]",
";",
"return",
"$",
"this",
"->",
"post",
"(",
"'transfers/cancel'",
",",
"$",
"data",
",",
"\\",
"true",
")",
";",
"}"
]
| Cancels given transfers.
@param int|array $transferIDs Transfer IDs you want to cancel.
@return boolean | [
"Cancels",
"given",
"transfers",
"."
]
| d91bedd91ea75793512a921bfd9aa83e86a6f0a7 | https://github.com/nicoSWD/put.io-api-v2/blob/d91bedd91ea75793512a921bfd9aa83e86a6f0a7/src/PutIO/Engines/PutIO/TransfersEngine.php#L88-L99 |
15,965 | VDMi/Guzzle-oAuth | src/GuzzleOauth/Consumer/Facebook.php | Facebook.normalizeAccessToken | protected function normalizeAccessToken($access_token) {
if (!isset($access_token['expires_in']) && isset($access_token['expires'])) {
$access_token['expires_in'] = $access_token['expires'];
unset($access_token['expires']);
}
return parent::normalizeAccessToken($access_token);
} | php | protected function normalizeAccessToken($access_token) {
if (!isset($access_token['expires_in']) && isset($access_token['expires'])) {
$access_token['expires_in'] = $access_token['expires'];
unset($access_token['expires']);
}
return parent::normalizeAccessToken($access_token);
} | [
"protected",
"function",
"normalizeAccessToken",
"(",
"$",
"access_token",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"access_token",
"[",
"'expires_in'",
"]",
")",
"&&",
"isset",
"(",
"$",
"access_token",
"[",
"'expires'",
"]",
")",
")",
"{",
"$",
"access_token",
"[",
"'expires_in'",
"]",
"=",
"$",
"access_token",
"[",
"'expires'",
"]",
";",
"unset",
"(",
"$",
"access_token",
"[",
"'expires'",
"]",
")",
";",
"}",
"return",
"parent",
"::",
"normalizeAccessToken",
"(",
"$",
"access_token",
")",
";",
"}"
]
| Facebook does it differently... again! | [
"Facebook",
"does",
"it",
"differently",
"...",
"again!"
]
| e2b2561e4e402e13ba605082bf768b29942f90cb | https://github.com/VDMi/Guzzle-oAuth/blob/e2b2561e4e402e13ba605082bf768b29942f90cb/src/GuzzleOauth/Consumer/Facebook.php#L33-L39 |
15,966 | opis/utils | lib/ArrayHandler.php | ArrayHandler.get | public function get($path, $default = null)
{
$path = explode($this->separator, $path);
$item = &$this->item;
foreach ($path as $key) {
if (!is_array($item)) {
return $default;
}
if (!array_key_exists($key, $item)) {
return $default;
}
$item = &$item[$key];
}
return $item;
} | php | public function get($path, $default = null)
{
$path = explode($this->separator, $path);
$item = &$this->item;
foreach ($path as $key) {
if (!is_array($item)) {
return $default;
}
if (!array_key_exists($key, $item)) {
return $default;
}
$item = &$item[$key];
}
return $item;
} | [
"public",
"function",
"get",
"(",
"$",
"path",
",",
"$",
"default",
"=",
"null",
")",
"{",
"$",
"path",
"=",
"explode",
"(",
"$",
"this",
"->",
"separator",
",",
"$",
"path",
")",
";",
"$",
"item",
"=",
"&",
"$",
"this",
"->",
"item",
";",
"foreach",
"(",
"$",
"path",
"as",
"$",
"key",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"item",
")",
")",
"{",
"return",
"$",
"default",
";",
"}",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"item",
")",
")",
"{",
"return",
"$",
"default",
";",
"}",
"$",
"item",
"=",
"&",
"$",
"item",
"[",
"$",
"key",
"]",
";",
"}",
"return",
"$",
"item",
";",
"}"
]
| Get the value stored under the specified path
@access public
@param string $path Value's path
@param mixed $default Default value that will be returned
@return mixed | [
"Get",
"the",
"value",
"stored",
"under",
"the",
"specified",
"path"
]
| 239cd3dc3760eb746838011e712592700fe5d58c | https://github.com/opis/utils/blob/239cd3dc3760eb746838011e712592700fe5d58c/lib/ArrayHandler.php#L69-L88 |
15,967 | opis/utils | lib/ArrayHandler.php | ArrayHandler.remove | public function remove($path)
{
$path = explode($this->separator, $path);
$last = array_pop($path);
$item = &$this->item;
foreach ($path as $key) {
if (array_key_exists($key, $item) && is_array($item[$key])) {
$item = &$item[$key];
continue;
}
return false;
}
if (array_key_exists($last, $item)) {
unset($item[$last]);
return true;
}
return false;
} | php | public function remove($path)
{
$path = explode($this->separator, $path);
$last = array_pop($path);
$item = &$this->item;
foreach ($path as $key) {
if (array_key_exists($key, $item) && is_array($item[$key])) {
$item = &$item[$key];
continue;
}
return false;
}
if (array_key_exists($last, $item)) {
unset($item[$last]);
return true;
}
return false;
} | [
"public",
"function",
"remove",
"(",
"$",
"path",
")",
"{",
"$",
"path",
"=",
"explode",
"(",
"$",
"this",
"->",
"separator",
",",
"$",
"path",
")",
";",
"$",
"last",
"=",
"array_pop",
"(",
"$",
"path",
")",
";",
"$",
"item",
"=",
"&",
"$",
"this",
"->",
"item",
";",
"foreach",
"(",
"$",
"path",
"as",
"$",
"key",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"item",
")",
"&&",
"is_array",
"(",
"$",
"item",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"item",
"=",
"&",
"$",
"item",
"[",
"$",
"key",
"]",
";",
"continue",
";",
"}",
"return",
"false",
";",
"}",
"if",
"(",
"array_key_exists",
"(",
"$",
"last",
",",
"$",
"item",
")",
")",
"{",
"unset",
"(",
"$",
"item",
"[",
"$",
"last",
"]",
")",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
]
| Remove a path
@access public
@param string $path Path to be removed
@return boolean | [
"Remove",
"a",
"path"
]
| 239cd3dc3760eb746838011e712592700fe5d58c | https://github.com/opis/utils/blob/239cd3dc3760eb746838011e712592700fe5d58c/lib/ArrayHandler.php#L152-L173 |
15,968 | opis/utils | lib/ArrayHandler.php | ArrayHandler.unserialize | public function unserialize($data)
{
$data = unserialize($data);
$this->item = $data['item'];
$this->separator = $data['separator'];
$this->constraint = $data['constraint'];
} | php | public function unserialize($data)
{
$data = unserialize($data);
$this->item = $data['item'];
$this->separator = $data['separator'];
$this->constraint = $data['constraint'];
} | [
"public",
"function",
"unserialize",
"(",
"$",
"data",
")",
"{",
"$",
"data",
"=",
"unserialize",
"(",
"$",
"data",
")",
";",
"$",
"this",
"->",
"item",
"=",
"$",
"data",
"[",
"'item'",
"]",
";",
"$",
"this",
"->",
"separator",
"=",
"$",
"data",
"[",
"'separator'",
"]",
";",
"$",
"this",
"->",
"constraint",
"=",
"$",
"data",
"[",
"'constraint'",
"]",
";",
"}"
]
| Method inherited from Serializable
@access public
@param string $data | [
"Method",
"inherited",
"from",
"Serializable"
]
| 239cd3dc3760eb746838011e712592700fe5d58c | https://github.com/opis/utils/blob/239cd3dc3760eb746838011e712592700fe5d58c/lib/ArrayHandler.php#L243-L250 |
15,969 | opis/utils | lib/ArrayHandler.php | ArrayHandler.isArray | public function isArray($path)
{
$value = $this->get($path, $this);
if ($value === $this || !is_array($value)) {
return false;
}
return array_keys($value) === range(0, count($value) - 1);
} | php | public function isArray($path)
{
$value = $this->get($path, $this);
if ($value === $this || !is_array($value)) {
return false;
}
return array_keys($value) === range(0, count($value) - 1);
} | [
"public",
"function",
"isArray",
"(",
"$",
"path",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"get",
"(",
"$",
"path",
",",
"$",
"this",
")",
";",
"if",
"(",
"$",
"value",
"===",
"$",
"this",
"||",
"!",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"array_keys",
"(",
"$",
"value",
")",
"===",
"range",
"(",
"0",
",",
"count",
"(",
"$",
"value",
")",
"-",
"1",
")",
";",
"}"
]
| Check if the value stored under the specified path is a JSON array
@access public
@param string $path The path to check
@return boolean | [
"Check",
"if",
"the",
"value",
"stored",
"under",
"the",
"specified",
"path",
"is",
"a",
"JSON",
"array"
]
| 239cd3dc3760eb746838011e712592700fe5d58c | https://github.com/opis/utils/blob/239cd3dc3760eb746838011e712592700fe5d58c/lib/ArrayHandler.php#L261-L270 |
15,970 | opis/utils | lib/ArrayHandler.php | ArrayHandler.isString | public function isString($path)
{
$value = $this->get($path, $this);
return $value === $this ? false : is_string($value);
} | php | public function isString($path)
{
$value = $this->get($path, $this);
return $value === $this ? false : is_string($value);
} | [
"public",
"function",
"isString",
"(",
"$",
"path",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"get",
"(",
"$",
"path",
",",
"$",
"this",
")",
";",
"return",
"$",
"value",
"===",
"$",
"this",
"?",
"false",
":",
"is_string",
"(",
"$",
"value",
")",
";",
"}"
]
| Check if the value stored under the specified path is a string
@access public
@param string $path The path to check
@return boolean | [
"Check",
"if",
"the",
"value",
"stored",
"under",
"the",
"specified",
"path",
"is",
"a",
"string"
]
| 239cd3dc3760eb746838011e712592700fe5d58c | https://github.com/opis/utils/blob/239cd3dc3760eb746838011e712592700fe5d58c/lib/ArrayHandler.php#L301-L306 |
15,971 | opis/utils | lib/ArrayHandler.php | ArrayHandler.isNumber | public function isNumber($path)
{
$value = $this->get($path, $this);
return $value === $this ? false : is_numeric($value);
} | php | public function isNumber($path)
{
$value = $this->get($path, $this);
return $value === $this ? false : is_numeric($value);
} | [
"public",
"function",
"isNumber",
"(",
"$",
"path",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"get",
"(",
"$",
"path",
",",
"$",
"this",
")",
";",
"return",
"$",
"value",
"===",
"$",
"this",
"?",
"false",
":",
"is_numeric",
"(",
"$",
"value",
")",
";",
"}"
]
| Check if the value stored under the specified path is a number
@access public
@param string $path The path to check
@return boolean | [
"Check",
"if",
"the",
"value",
"stored",
"under",
"the",
"specified",
"path",
"is",
"a",
"number"
]
| 239cd3dc3760eb746838011e712592700fe5d58c | https://github.com/opis/utils/blob/239cd3dc3760eb746838011e712592700fe5d58c/lib/ArrayHandler.php#L317-L322 |
15,972 | opis/utils | lib/ArrayHandler.php | ArrayHandler.isNull | public function isNull($path)
{
$value = $this->get($path, $this);
return $value === $this ? false : is_null($value);
} | php | public function isNull($path)
{
$value = $this->get($path, $this);
return $value === $this ? false : is_null($value);
} | [
"public",
"function",
"isNull",
"(",
"$",
"path",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"get",
"(",
"$",
"path",
",",
"$",
"this",
")",
";",
"return",
"$",
"value",
"===",
"$",
"this",
"?",
"false",
":",
"is_null",
"(",
"$",
"value",
")",
";",
"}"
]
| Check if the value stored under the specified path is a `null` value
@access public
@param string $path The path to check
@return boolean | [
"Check",
"if",
"the",
"value",
"stored",
"under",
"the",
"specified",
"path",
"is",
"a",
"null",
"value"
]
| 239cd3dc3760eb746838011e712592700fe5d58c | https://github.com/opis/utils/blob/239cd3dc3760eb746838011e712592700fe5d58c/lib/ArrayHandler.php#L333-L338 |
15,973 | opis/utils | lib/ArrayHandler.php | ArrayHandler.isBoolean | public function isBoolean($path)
{
$value = $this->get($path, $this);
return $value === $this ? false : is_bool($value);
} | php | public function isBoolean($path)
{
$value = $this->get($path, $this);
return $value === $this ? false : is_bool($value);
} | [
"public",
"function",
"isBoolean",
"(",
"$",
"path",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"get",
"(",
"$",
"path",
",",
"$",
"this",
")",
";",
"return",
"$",
"value",
"===",
"$",
"this",
"?",
"false",
":",
"is_bool",
"(",
"$",
"value",
")",
";",
"}"
]
| Check if the value stored under the specified path is a boolean value
@access public
@param string $path The path to check
@return boolean | [
"Check",
"if",
"the",
"value",
"stored",
"under",
"the",
"specified",
"path",
"is",
"a",
"boolean",
"value"
]
| 239cd3dc3760eb746838011e712592700fe5d58c | https://github.com/opis/utils/blob/239cd3dc3760eb746838011e712592700fe5d58c/lib/ArrayHandler.php#L349-L354 |
15,974 | drmvc/framework | src/Framework/App.php | App.initRequest | private function initRequest(): App
{
try {
$request = ServerRequestFactory::fromGlobals();
$this->containers()->set('request', $request);
} catch (\InvalidArgumentException $e) {
new Exception($e);
}
return $this;
} | php | private function initRequest(): App
{
try {
$request = ServerRequestFactory::fromGlobals();
$this->containers()->set('request', $request);
} catch (\InvalidArgumentException $e) {
new Exception($e);
}
return $this;
} | [
"private",
"function",
"initRequest",
"(",
")",
":",
"App",
"{",
"try",
"{",
"$",
"request",
"=",
"ServerRequestFactory",
"::",
"fromGlobals",
"(",
")",
";",
"$",
"this",
"->",
"containers",
"(",
")",
"->",
"set",
"(",
"'request'",
",",
"$",
"request",
")",
";",
"}",
"catch",
"(",
"\\",
"InvalidArgumentException",
"$",
"e",
")",
"{",
"new",
"Exception",
"(",
"$",
"e",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| Initiate PSR-7 request object
@return App | [
"Initiate",
"PSR",
"-",
"7",
"request",
"object"
]
| 6a49aa4e0314b37343a95d7c8ac5d10f72b45d71 | https://github.com/drmvc/framework/blob/6a49aa4e0314b37343a95d7c8ac5d10f72b45d71/src/Framework/App.php#L94-L103 |
15,975 | drmvc/framework | src/Framework/App.php | App.initResponse | private function initResponse(): App
{
try {
$response = new Response();
$this->containers()->set('response', $response);
} catch (\InvalidArgumentException $e) {
new Exception($e);
}
return $this;
} | php | private function initResponse(): App
{
try {
$response = new Response();
$this->containers()->set('response', $response);
} catch (\InvalidArgumentException $e) {
new Exception($e);
}
return $this;
} | [
"private",
"function",
"initResponse",
"(",
")",
":",
"App",
"{",
"try",
"{",
"$",
"response",
"=",
"new",
"Response",
"(",
")",
";",
"$",
"this",
"->",
"containers",
"(",
")",
"->",
"set",
"(",
"'response'",
",",
"$",
"response",
")",
";",
"}",
"catch",
"(",
"\\",
"InvalidArgumentException",
"$",
"e",
")",
"{",
"new",
"Exception",
"(",
"$",
"e",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| Initiate PSR-7 response object
@return App | [
"Initiate",
"PSR",
"-",
"7",
"response",
"object"
]
| 6a49aa4e0314b37343a95d7c8ac5d10f72b45d71 | https://github.com/drmvc/framework/blob/6a49aa4e0314b37343a95d7c8ac5d10f72b45d71/src/Framework/App.php#L110-L119 |
15,976 | drmvc/framework | src/Framework/App.php | App.initRouter | private function initRouter(): App
{
$request = $this->container('request');
$response = $this->container('response');
$router = new Router($request, $response);
$router->error(Error::class);
$this->containers()->set('router', $router);
return $this;
} | php | private function initRouter(): App
{
$request = $this->container('request');
$response = $this->container('response');
$router = new Router($request, $response);
$router->error(Error::class);
$this->containers()->set('router', $router);
return $this;
} | [
"private",
"function",
"initRouter",
"(",
")",
":",
"App",
"{",
"$",
"request",
"=",
"$",
"this",
"->",
"container",
"(",
"'request'",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"container",
"(",
"'response'",
")",
";",
"$",
"router",
"=",
"new",
"Router",
"(",
"$",
"request",
",",
"$",
"response",
")",
";",
"$",
"router",
"->",
"error",
"(",
"Error",
"::",
"class",
")",
";",
"$",
"this",
"->",
"containers",
"(",
")",
"->",
"set",
"(",
"'router'",
",",
"$",
"router",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Put route into the container of classes
@return App | [
"Put",
"route",
"into",
"the",
"container",
"of",
"classes"
]
| 6a49aa4e0314b37343a95d7c8ac5d10f72b45d71 | https://github.com/drmvc/framework/blob/6a49aa4e0314b37343a95d7c8ac5d10f72b45d71/src/Framework/App.php#L126-L135 |
15,977 | drmvc/framework | src/Framework/App.php | App.map | public function map(array $methods, string $pattern, $callable): MethodsInterface
{
$this->container('router')->map($methods, $pattern, $callable);
return $this;
} | php | public function map(array $methods, string $pattern, $callable): MethodsInterface
{
$this->container('router')->map($methods, $pattern, $callable);
return $this;
} | [
"public",
"function",
"map",
"(",
"array",
"$",
"methods",
",",
"string",
"$",
"pattern",
",",
"$",
"callable",
")",
":",
"MethodsInterface",
"{",
"$",
"this",
"->",
"container",
"(",
"'router'",
")",
"->",
"map",
"(",
"$",
"methods",
",",
"$",
"pattern",
",",
"$",
"callable",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Few methods provided
@param array $methods
@param string $pattern
@param callable|string $callable
@return MethodsInterface | [
"Few",
"methods",
"provided"
]
| 6a49aa4e0314b37343a95d7c8ac5d10f72b45d71 | https://github.com/drmvc/framework/blob/6a49aa4e0314b37343a95d7c8ac5d10f72b45d71/src/Framework/App.php#L206-L210 |
15,978 | drmvc/framework | src/Framework/App.php | App.detectAction | private function detectAction(string $className, array $variables = []): string
{
$action =
// 1. Action name in line with class name eg. MyApp\Index:test - alias for `action_test`
$this->extractActionFromClass($className)
?? (
// 2. If action name in variables (we need first item)
$variables['action'][0]
// 3. Default action is index
?? self::DEFAULT_ACTION
);
return 'action_' . $action;
} | php | private function detectAction(string $className, array $variables = []): string
{
$action =
// 1. Action name in line with class name eg. MyApp\Index:test - alias for `action_test`
$this->extractActionFromClass($className)
?? (
// 2. If action name in variables (we need first item)
$variables['action'][0]
// 3. Default action is index
?? self::DEFAULT_ACTION
);
return 'action_' . $action;
} | [
"private",
"function",
"detectAction",
"(",
"string",
"$",
"className",
",",
"array",
"$",
"variables",
"=",
"[",
"]",
")",
":",
"string",
"{",
"$",
"action",
"=",
"// 1. Action name in line with class name eg. MyApp\\Index:test - alias for `action_test`",
"$",
"this",
"->",
"extractActionFromClass",
"(",
"$",
"className",
")",
"??",
"(",
"// 2. If action name in variables (we need first item)",
"$",
"variables",
"[",
"'action'",
"]",
"[",
"0",
"]",
"// 3. Default action is index",
"??",
"self",
"::",
"DEFAULT_ACTION",
")",
";",
"return",
"'action_'",
".",
"$",
"action",
";",
"}"
]
| Detect action by string name, variable or use default
@param string $className - eg. MyApp\Index:test
@param array $variables
@return string | [
"Detect",
"action",
"by",
"string",
"name",
"variable",
"or",
"use",
"default"
]
| 6a49aa4e0314b37343a95d7c8ac5d10f72b45d71 | https://github.com/drmvc/framework/blob/6a49aa4e0314b37343a95d7c8ac5d10f72b45d71/src/Framework/App.php#L253-L266 |
15,979 | drmvc/framework | src/Framework/App.php | App.methodCheck | private function methodCheck($class, string $action): bool
{
try {
// If method not found in required class
if (!\method_exists($class, $action)) {
$className = \get_class($class);
throw new Exception("Method \"$action\" is not found in \"$className\"");
}
} catch (Exception $e) {
return false;
}
return true;
} | php | private function methodCheck($class, string $action): bool
{
try {
// If method not found in required class
if (!\method_exists($class, $action)) {
$className = \get_class($class);
throw new Exception("Method \"$action\" is not found in \"$className\"");
}
} catch (Exception $e) {
return false;
}
return true;
} | [
"private",
"function",
"methodCheck",
"(",
"$",
"class",
",",
"string",
"$",
"action",
")",
":",
"bool",
"{",
"try",
"{",
"// If method not found in required class",
"if",
"(",
"!",
"\\",
"method_exists",
"(",
"$",
"class",
",",
"$",
"action",
")",
")",
"{",
"$",
"className",
"=",
"\\",
"get_class",
"(",
"$",
"class",
")",
";",
"throw",
"new",
"Exception",
"(",
"\"Method \\\"$action\\\" is not found in \\\"$className\\\"\"",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
]
| Check if method exist in required class
@param object $class
@param string $action
@return bool | [
"Check",
"if",
"method",
"exist",
"in",
"required",
"class"
]
| 6a49aa4e0314b37343a95d7c8ac5d10f72b45d71 | https://github.com/drmvc/framework/blob/6a49aa4e0314b37343a95d7c8ac5d10f72b45d71/src/Framework/App.php#L275-L287 |
15,980 | drmvc/framework | src/Framework/App.php | App.exec | private function exec(
RouteInterface $route,
RequestInterface $request,
ResponseInterface $response,
bool $error = false
) {
$variables = $route->getVariables();
$callback = $route->getCallback();
// If extracted call back is string
if (\is_string($callback)) {
$className = $this->extractClass($callback);
// Then class provided
$class = new $className();
$action = $this->detectAction($callback, $variables);
// If method is not found in class and error is not triggered, then trigger error
if (true !== $error && false === $this->methodCheck($class, $action)) {
$router = $this->container('router');
$routeError = $router->getError();
return $this->exec($routeError, $request, $response, true);
}
// Call required action, with request/response
$class->$action($request, $response, $variables);
} else {
// Else simple callback
$callback($request, $response, $variables);
}
return $response->getBody();
} | php | private function exec(
RouteInterface $route,
RequestInterface $request,
ResponseInterface $response,
bool $error = false
) {
$variables = $route->getVariables();
$callback = $route->getCallback();
// If extracted call back is string
if (\is_string($callback)) {
$className = $this->extractClass($callback);
// Then class provided
$class = new $className();
$action = $this->detectAction($callback, $variables);
// If method is not found in class and error is not triggered, then trigger error
if (true !== $error && false === $this->methodCheck($class, $action)) {
$router = $this->container('router');
$routeError = $router->getError();
return $this->exec($routeError, $request, $response, true);
}
// Call required action, with request/response
$class->$action($request, $response, $variables);
} else {
// Else simple callback
$callback($request, $response, $variables);
}
return $response->getBody();
} | [
"private",
"function",
"exec",
"(",
"RouteInterface",
"$",
"route",
",",
"RequestInterface",
"$",
"request",
",",
"ResponseInterface",
"$",
"response",
",",
"bool",
"$",
"error",
"=",
"false",
")",
"{",
"$",
"variables",
"=",
"$",
"route",
"->",
"getVariables",
"(",
")",
";",
"$",
"callback",
"=",
"$",
"route",
"->",
"getCallback",
"(",
")",
";",
"// If extracted call back is string",
"if",
"(",
"\\",
"is_string",
"(",
"$",
"callback",
")",
")",
"{",
"$",
"className",
"=",
"$",
"this",
"->",
"extractClass",
"(",
"$",
"callback",
")",
";",
"// Then class provided",
"$",
"class",
"=",
"new",
"$",
"className",
"(",
")",
";",
"$",
"action",
"=",
"$",
"this",
"->",
"detectAction",
"(",
"$",
"callback",
",",
"$",
"variables",
")",
";",
"// If method is not found in class and error is not triggered, then trigger error",
"if",
"(",
"true",
"!==",
"$",
"error",
"&&",
"false",
"===",
"$",
"this",
"->",
"methodCheck",
"(",
"$",
"class",
",",
"$",
"action",
")",
")",
"{",
"$",
"router",
"=",
"$",
"this",
"->",
"container",
"(",
"'router'",
")",
";",
"$",
"routeError",
"=",
"$",
"router",
"->",
"getError",
"(",
")",
";",
"return",
"$",
"this",
"->",
"exec",
"(",
"$",
"routeError",
",",
"$",
"request",
",",
"$",
"response",
",",
"true",
")",
";",
"}",
"// Call required action, with request/response",
"$",
"class",
"->",
"$",
"action",
"(",
"$",
"request",
",",
"$",
"response",
",",
"$",
"variables",
")",
";",
"}",
"else",
"{",
"// Else simple callback",
"$",
"callback",
"(",
"$",
"request",
",",
"$",
"response",
",",
"$",
"variables",
")",
";",
"}",
"return",
"$",
"response",
"->",
"getBody",
"(",
")",
";",
"}"
]
| Here we need to solve how to display the page, and if method is
not available need to show error
@param RouteInterface $route
@param RequestInterface $request
@param ResponseInterface $response
@param bool $error
@return StreamInterface | [
"Here",
"we",
"need",
"to",
"solve",
"how",
"to",
"display",
"the",
"page",
"and",
"if",
"method",
"is",
"not",
"available",
"need",
"to",
"show",
"error"
]
| 6a49aa4e0314b37343a95d7c8ac5d10f72b45d71 | https://github.com/drmvc/framework/blob/6a49aa4e0314b37343a95d7c8ac5d10f72b45d71/src/Framework/App.php#L299-L331 |
15,981 | drmvc/framework | src/Framework/App.php | App.run | public function run(): StreamInterface
{
// Extract some important objects
$router = $this->container('router');
$request = $this->container('request');
$response = $this->container('response');
// Get current matched route with and extract variables with callback
$route = $router->getRoute();
return $this->exec($route, $request, $response);
} | php | public function run(): StreamInterface
{
// Extract some important objects
$router = $this->container('router');
$request = $this->container('request');
$response = $this->container('response');
// Get current matched route with and extract variables with callback
$route = $router->getRoute();
return $this->exec($route, $request, $response);
} | [
"public",
"function",
"run",
"(",
")",
":",
"StreamInterface",
"{",
"// Extract some important objects",
"$",
"router",
"=",
"$",
"this",
"->",
"container",
"(",
"'router'",
")",
";",
"$",
"request",
"=",
"$",
"this",
"->",
"container",
"(",
"'request'",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"container",
"(",
"'response'",
")",
";",
"// Get current matched route with and extract variables with callback",
"$",
"route",
"=",
"$",
"router",
"->",
"getRoute",
"(",
")",
";",
"return",
"$",
"this",
"->",
"exec",
"(",
"$",
"route",
",",
"$",
"request",
",",
"$",
"response",
")",
";",
"}"
]
| Simple runner should parse query and make work on user's class
@return StreamInterface | [
"Simple",
"runner",
"should",
"parse",
"query",
"and",
"make",
"work",
"on",
"user",
"s",
"class"
]
| 6a49aa4e0314b37343a95d7c8ac5d10f72b45d71 | https://github.com/drmvc/framework/blob/6a49aa4e0314b37343a95d7c8ac5d10f72b45d71/src/Framework/App.php#L338-L349 |
15,982 | stubbles/stubbles-webapp-core | src/main/php/routing/ResolvingResource.php | ResolvingResource.resolve | public function resolve(Request $request, Response $response)
{
$uriPath = $this->calledUri->path($this->route->configuredPath());
$target = $this->route->target();
if (is_callable($target)) {
return $target($request, $response, $uriPath);
}
if ($target instanceof Target) {
return $target->resolve($request, $response, $uriPath);
}
$targetInstance = $this->injector->getInstance($target);
if (!($targetInstance instanceof Target)) {
return $response->internalServerError(
'Configured target class ' . $target . ' for route ' . $uriPath
. ' is not an instance of ' . Target::class
);
}
return $targetInstance->resolve($request, $response, $uriPath);
} | php | public function resolve(Request $request, Response $response)
{
$uriPath = $this->calledUri->path($this->route->configuredPath());
$target = $this->route->target();
if (is_callable($target)) {
return $target($request, $response, $uriPath);
}
if ($target instanceof Target) {
return $target->resolve($request, $response, $uriPath);
}
$targetInstance = $this->injector->getInstance($target);
if (!($targetInstance instanceof Target)) {
return $response->internalServerError(
'Configured target class ' . $target . ' for route ' . $uriPath
. ' is not an instance of ' . Target::class
);
}
return $targetInstance->resolve($request, $response, $uriPath);
} | [
"public",
"function",
"resolve",
"(",
"Request",
"$",
"request",
",",
"Response",
"$",
"response",
")",
"{",
"$",
"uriPath",
"=",
"$",
"this",
"->",
"calledUri",
"->",
"path",
"(",
"$",
"this",
"->",
"route",
"->",
"configuredPath",
"(",
")",
")",
";",
"$",
"target",
"=",
"$",
"this",
"->",
"route",
"->",
"target",
"(",
")",
";",
"if",
"(",
"is_callable",
"(",
"$",
"target",
")",
")",
"{",
"return",
"$",
"target",
"(",
"$",
"request",
",",
"$",
"response",
",",
"$",
"uriPath",
")",
";",
"}",
"if",
"(",
"$",
"target",
"instanceof",
"Target",
")",
"{",
"return",
"$",
"target",
"->",
"resolve",
"(",
"$",
"request",
",",
"$",
"response",
",",
"$",
"uriPath",
")",
";",
"}",
"$",
"targetInstance",
"=",
"$",
"this",
"->",
"injector",
"->",
"getInstance",
"(",
"$",
"target",
")",
";",
"if",
"(",
"!",
"(",
"$",
"targetInstance",
"instanceof",
"Target",
")",
")",
"{",
"return",
"$",
"response",
"->",
"internalServerError",
"(",
"'Configured target class '",
".",
"$",
"target",
".",
"' for route '",
".",
"$",
"uriPath",
".",
"' is not an instance of '",
".",
"Target",
"::",
"class",
")",
";",
"}",
"return",
"$",
"targetInstance",
"->",
"resolve",
"(",
"$",
"request",
",",
"$",
"response",
",",
"$",
"uriPath",
")",
";",
"}"
]
| triggers actual logic on this resource
The logic might be capsuled in a closure, a callback, or a processor
class. The return value from this logic will be used to evaluate whether
post processors are called by the web app. A return value of false means
no post processor will be called, whereas any other or no return value
will result in post processors being called by the webapp.
@param \stubbles\webapp\Request $request current request
@param \stubbles\webapp\Response $response response to send
@return mixed | [
"triggers",
"actual",
"logic",
"on",
"this",
"resource"
]
| 7705f129011a81d5cc3c76b4b150fab3dadac6a3 | https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/ResolvingResource.php#L73-L94 |
15,983 | FrenchFrogs/framework | src/Table/Renderer/Bootstrap.php | Bootstrap.container | public function container(Column\Container $column, array $row) {
$html = '';
foreach($column->getColumns() as $c) {
/** @var Column\Column $c */
$html .= $c->render($row) . PHP_EOL;
}
return $this->post($html, $column, $row);
} | php | public function container(Column\Container $column, array $row) {
$html = '';
foreach($column->getColumns() as $c) {
/** @var Column\Column $c */
$html .= $c->render($row) . PHP_EOL;
}
return $this->post($html, $column, $row);
} | [
"public",
"function",
"container",
"(",
"Column",
"\\",
"Container",
"$",
"column",
",",
"array",
"$",
"row",
")",
"{",
"$",
"html",
"=",
"''",
";",
"foreach",
"(",
"$",
"column",
"->",
"getColumns",
"(",
")",
"as",
"$",
"c",
")",
"{",
"/** @var Column\\Column $c */",
"$",
"html",
".=",
"$",
"c",
"->",
"render",
"(",
"$",
"row",
")",
".",
"PHP_EOL",
";",
"}",
"return",
"$",
"this",
"->",
"post",
"(",
"$",
"html",
",",
"$",
"column",
",",
"$",
"row",
")",
";",
"}"
]
| Render a container
@param \FrenchFrogs\Table\Column\Container $column
@param array $row
@return string | [
"Render",
"a",
"container"
]
| a4838c698a5600437e87dac6d35ba8ebe32c4395 | https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Table/Renderer/Bootstrap.php#L186-L195 |
15,984 | FrenchFrogs/framework | src/Table/Renderer/Bootstrap.php | Bootstrap.boolean | public function boolean(Column\Boolean $column, array $row)
{
$html = '';
if($column->getValue($row)) {
$html .= '<i class="fa fa-check"></i>';
}
return $this->post($html, $column, $row);
} | php | public function boolean(Column\Boolean $column, array $row)
{
$html = '';
if($column->getValue($row)) {
$html .= '<i class="fa fa-check"></i>';
}
return $this->post($html, $column, $row);
} | [
"public",
"function",
"boolean",
"(",
"Column",
"\\",
"Boolean",
"$",
"column",
",",
"array",
"$",
"row",
")",
"{",
"$",
"html",
"=",
"''",
";",
"if",
"(",
"$",
"column",
"->",
"getValue",
"(",
"$",
"row",
")",
")",
"{",
"$",
"html",
".=",
"'<i class=\"fa fa-check\"></i>'",
";",
"}",
"return",
"$",
"this",
"->",
"post",
"(",
"$",
"html",
",",
"$",
"column",
",",
"$",
"row",
")",
";",
"}"
]
| render boolean icon
@param \FrenchFrogs\Table\Column\Boolean $column
@param array $row
@return string | [
"render",
"boolean",
"icon"
]
| a4838c698a5600437e87dac6d35ba8ebe32c4395 | https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Table/Renderer/Bootstrap.php#L204-L213 |
15,985 | FrenchFrogs/framework | src/Table/Renderer/Bootstrap.php | Bootstrap.remote_boolean | public function remote_boolean(Column\RemoteBoolean $column, array $row)
{
$table = $column->getTable();
// Attributes
$attributes = [
'class' => 'ff-remote-boolean make-switch',
'type' => 'checkbox',
'data-size' => 'small',
'value' => true,
'data-id' => $row[$column->getTable()->getIdField()],
'data-column' => $column->getName(),
];
if(isset($row[$column->getName()]) && !empty($row[$column->getName()])) {
$attributes['checked'] = 'checked';
}
$html = html('input', $attributes);
return $this->post($html, $column, $row);
} | php | public function remote_boolean(Column\RemoteBoolean $column, array $row)
{
$table = $column->getTable();
// Attributes
$attributes = [
'class' => 'ff-remote-boolean make-switch',
'type' => 'checkbox',
'data-size' => 'small',
'value' => true,
'data-id' => $row[$column->getTable()->getIdField()],
'data-column' => $column->getName(),
];
if(isset($row[$column->getName()]) && !empty($row[$column->getName()])) {
$attributes['checked'] = 'checked';
}
$html = html('input', $attributes);
return $this->post($html, $column, $row);
} | [
"public",
"function",
"remote_boolean",
"(",
"Column",
"\\",
"RemoteBoolean",
"$",
"column",
",",
"array",
"$",
"row",
")",
"{",
"$",
"table",
"=",
"$",
"column",
"->",
"getTable",
"(",
")",
";",
"// Attributes",
"$",
"attributes",
"=",
"[",
"'class'",
"=>",
"'ff-remote-boolean make-switch'",
",",
"'type'",
"=>",
"'checkbox'",
",",
"'data-size'",
"=>",
"'small'",
",",
"'value'",
"=>",
"true",
",",
"'data-id'",
"=>",
"$",
"row",
"[",
"$",
"column",
"->",
"getTable",
"(",
")",
"->",
"getIdField",
"(",
")",
"]",
",",
"'data-column'",
"=>",
"$",
"column",
"->",
"getName",
"(",
")",
",",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"row",
"[",
"$",
"column",
"->",
"getName",
"(",
")",
"]",
")",
"&&",
"!",
"empty",
"(",
"$",
"row",
"[",
"$",
"column",
"->",
"getName",
"(",
")",
"]",
")",
")",
"{",
"$",
"attributes",
"[",
"'checked'",
"]",
"=",
"'checked'",
";",
"}",
"$",
"html",
"=",
"html",
"(",
"'input'",
",",
"$",
"attributes",
")",
";",
"return",
"$",
"this",
"->",
"post",
"(",
"$",
"html",
",",
"$",
"column",
",",
"$",
"row",
")",
";",
"}"
]
| render boolean switch
@param \FrenchFrogs\Table\Column\BooleanSwitch $column
@param array $row
@return string | [
"render",
"boolean",
"switch"
]
| a4838c698a5600437e87dac6d35ba8ebe32c4395 | https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Table/Renderer/Bootstrap.php#L222-L245 |
15,986 | FrenchFrogs/framework | src/Table/Renderer/Bootstrap.php | Bootstrap.icon | public function icon(Column\Icon $column, array $row)
{
$html = '';
$html .= '<i class="fa '. $column->getValue($row).'"></i>';
return $this->post($html, $column, $row);
} | php | public function icon(Column\Icon $column, array $row)
{
$html = '';
$html .= '<i class="fa '. $column->getValue($row).'"></i>';
return $this->post($html, $column, $row);
} | [
"public",
"function",
"icon",
"(",
"Column",
"\\",
"Icon",
"$",
"column",
",",
"array",
"$",
"row",
")",
"{",
"$",
"html",
"=",
"''",
";",
"$",
"html",
".=",
"'<i class=\"fa '",
".",
"$",
"column",
"->",
"getValue",
"(",
"$",
"row",
")",
".",
"'\"></i>'",
";",
"return",
"$",
"this",
"->",
"post",
"(",
"$",
"html",
",",
"$",
"column",
",",
"$",
"row",
")",
";",
"}"
]
| Render Icon column
@param \FrenchFrogs\Table\Column\Icon $column
@param array $row
@return string | [
"Render",
"Icon",
"column"
]
| a4838c698a5600437e87dac6d35ba8ebe32c4395 | https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Table/Renderer/Bootstrap.php#L255-L262 |
15,987 | FrenchFrogs/framework | src/Table/Renderer/Bootstrap.php | Bootstrap.custom | public function custom(Column\Custom $column, array $row)
{
$html = call_user_func($column->getCustom(), $row);
return $this->post($html, $column, $row);
} | php | public function custom(Column\Custom $column, array $row)
{
$html = call_user_func($column->getCustom(), $row);
return $this->post($html, $column, $row);
} | [
"public",
"function",
"custom",
"(",
"Column",
"\\",
"Custom",
"$",
"column",
",",
"array",
"$",
"row",
")",
"{",
"$",
"html",
"=",
"call_user_func",
"(",
"$",
"column",
"->",
"getCustom",
"(",
")",
",",
"$",
"row",
")",
";",
"return",
"$",
"this",
"->",
"post",
"(",
"$",
"html",
",",
"$",
"column",
",",
"$",
"row",
")",
";",
"}"
]
| Render custom callable column
@param \FrenchFrogs\Table\Column\Custom $column
@param array $row
@return mixed | [
"Render",
"custom",
"callable",
"column"
]
| a4838c698a5600437e87dac6d35ba8ebe32c4395 | https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Table/Renderer/Bootstrap.php#L271-L275 |
15,988 | FrenchFrogs/framework | src/Table/Renderer/Bootstrap.php | Bootstrap.text | public function text(Column\Text $column, array $row)
{
$attributes = $column->getAttributes();
if($column->hasTooltip()){
$attributes += [
'data-placement' => $column->getTooltipPosition(),
'data-original-title' => $column->getValue($row),
'data-toggle' => 'tooltip'
];
$html = html('div', $attributes, str_limit($column->getValue($row), 70));
} else {
$html = html('span',$attributes, $column->getValue($row));
}
return $this->post($html, $column, $row);
} | php | public function text(Column\Text $column, array $row)
{
$attributes = $column->getAttributes();
if($column->hasTooltip()){
$attributes += [
'data-placement' => $column->getTooltipPosition(),
'data-original-title' => $column->getValue($row),
'data-toggle' => 'tooltip'
];
$html = html('div', $attributes, str_limit($column->getValue($row), 70));
} else {
$html = html('span',$attributes, $column->getValue($row));
}
return $this->post($html, $column, $row);
} | [
"public",
"function",
"text",
"(",
"Column",
"\\",
"Text",
"$",
"column",
",",
"array",
"$",
"row",
")",
"{",
"$",
"attributes",
"=",
"$",
"column",
"->",
"getAttributes",
"(",
")",
";",
"if",
"(",
"$",
"column",
"->",
"hasTooltip",
"(",
")",
")",
"{",
"$",
"attributes",
"+=",
"[",
"'data-placement'",
"=>",
"$",
"column",
"->",
"getTooltipPosition",
"(",
")",
",",
"'data-original-title'",
"=>",
"$",
"column",
"->",
"getValue",
"(",
"$",
"row",
")",
",",
"'data-toggle'",
"=>",
"'tooltip'",
"]",
";",
"$",
"html",
"=",
"html",
"(",
"'div'",
",",
"$",
"attributes",
",",
"str_limit",
"(",
"$",
"column",
"->",
"getValue",
"(",
"$",
"row",
")",
",",
"70",
")",
")",
";",
"}",
"else",
"{",
"$",
"html",
"=",
"html",
"(",
"'span'",
",",
"$",
"attributes",
",",
"$",
"column",
"->",
"getValue",
"(",
"$",
"row",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"post",
"(",
"$",
"html",
",",
"$",
"column",
",",
"$",
"row",
")",
";",
"}"
]
| Render text column
@param \FrenchFrogs\Table\Column\Text $column
@param array $row
@return mixed|string | [
"Render",
"text",
"column"
]
| a4838c698a5600437e87dac6d35ba8ebe32c4395 | https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Table/Renderer/Bootstrap.php#L285-L303 |
15,989 | FrenchFrogs/framework | src/Table/Renderer/Bootstrap.php | Bootstrap.remote_text | public function remote_text(Column\RemoteText $column, array $row)
{
$html = $this->text($column, $row);
$html .= html('input', [
'type' => 'text',
'data-id' => $row[$column->getTable()->getIdField()],
'data-column' => $column->getName()
]);
$html = html('div', ['class' => 'ff-remote-text'], $html);
return $html;
} | php | public function remote_text(Column\RemoteText $column, array $row)
{
$html = $this->text($column, $row);
$html .= html('input', [
'type' => 'text',
'data-id' => $row[$column->getTable()->getIdField()],
'data-column' => $column->getName()
]);
$html = html('div', ['class' => 'ff-remote-text'], $html);
return $html;
} | [
"public",
"function",
"remote_text",
"(",
"Column",
"\\",
"RemoteText",
"$",
"column",
",",
"array",
"$",
"row",
")",
"{",
"$",
"html",
"=",
"$",
"this",
"->",
"text",
"(",
"$",
"column",
",",
"$",
"row",
")",
";",
"$",
"html",
".=",
"html",
"(",
"'input'",
",",
"[",
"'type'",
"=>",
"'text'",
",",
"'data-id'",
"=>",
"$",
"row",
"[",
"$",
"column",
"->",
"getTable",
"(",
")",
"->",
"getIdField",
"(",
")",
"]",
",",
"'data-column'",
"=>",
"$",
"column",
"->",
"getName",
"(",
")",
"]",
")",
";",
"$",
"html",
"=",
"html",
"(",
"'div'",
",",
"[",
"'class'",
"=>",
"'ff-remote-text'",
"]",
",",
"$",
"html",
")",
";",
"return",
"$",
"html",
";",
"}"
]
| Render a text remote
@param \FrenchFrogs\Table\Column\RemoteText $column
@param array $row
@return mixed|string | [
"Render",
"a",
"text",
"remote"
]
| a4838c698a5600437e87dac6d35ba8ebe32c4395 | https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Table/Renderer/Bootstrap.php#L342-L353 |
15,990 | FrenchFrogs/framework | src/Table/Renderer/Bootstrap.php | Bootstrap.remote_select | public function remote_select(Column\RemoteSelect $column, array $row)
{
// OPTIONS
$options = html('option', [], '--');
$elementValue = $row[$column->getIndex()];
foreach($column->getOptions() as $value => $key){
$attr = ['value' => $value];
if ($value == $elementValue){
$attr['selected'] = 'selected';
}
$options .= html('option', $attr, $key);
}
$html = html('select', [
'class' => 'ff-remote-select',
'data-id' => $row[$column->getTable()->getIdField()],
'data-column' => $column->getName()
], $options);
return $html;
} | php | public function remote_select(Column\RemoteSelect $column, array $row)
{
// OPTIONS
$options = html('option', [], '--');
$elementValue = $row[$column->getIndex()];
foreach($column->getOptions() as $value => $key){
$attr = ['value' => $value];
if ($value == $elementValue){
$attr['selected'] = 'selected';
}
$options .= html('option', $attr, $key);
}
$html = html('select', [
'class' => 'ff-remote-select',
'data-id' => $row[$column->getTable()->getIdField()],
'data-column' => $column->getName()
], $options);
return $html;
} | [
"public",
"function",
"remote_select",
"(",
"Column",
"\\",
"RemoteSelect",
"$",
"column",
",",
"array",
"$",
"row",
")",
"{",
"// OPTIONS",
"$",
"options",
"=",
"html",
"(",
"'option'",
",",
"[",
"]",
",",
"'--'",
")",
";",
"$",
"elementValue",
"=",
"$",
"row",
"[",
"$",
"column",
"->",
"getIndex",
"(",
")",
"]",
";",
"foreach",
"(",
"$",
"column",
"->",
"getOptions",
"(",
")",
"as",
"$",
"value",
"=>",
"$",
"key",
")",
"{",
"$",
"attr",
"=",
"[",
"'value'",
"=>",
"$",
"value",
"]",
";",
"if",
"(",
"$",
"value",
"==",
"$",
"elementValue",
")",
"{",
"$",
"attr",
"[",
"'selected'",
"]",
"=",
"'selected'",
";",
"}",
"$",
"options",
".=",
"html",
"(",
"'option'",
",",
"$",
"attr",
",",
"$",
"key",
")",
";",
"}",
"$",
"html",
"=",
"html",
"(",
"'select'",
",",
"[",
"'class'",
"=>",
"'ff-remote-select'",
",",
"'data-id'",
"=>",
"$",
"row",
"[",
"$",
"column",
"->",
"getTable",
"(",
")",
"->",
"getIdField",
"(",
")",
"]",
",",
"'data-column'",
"=>",
"$",
"column",
"->",
"getName",
"(",
")",
"]",
",",
"$",
"options",
")",
";",
"return",
"$",
"html",
";",
"}"
]
| Render remote Select
@param \FrenchFrogs\Table\Column\RemoteSelect $column
@param array $row
@return string | [
"Render",
"remote",
"Select"
]
| a4838c698a5600437e87dac6d35ba8ebe32c4395 | https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Table/Renderer/Bootstrap.php#L362-L382 |
15,991 | FrenchFrogs/framework | src/Table/Renderer/Bootstrap.php | Bootstrap.link | public function link(Column\Link $column, array $row)
{
if ($column->isRemote()) {
$column->addAttribute('data-target', '#' . $column->getRemoteId())
->addAttribute('data-toggle', 'modal');
} elseif($column->isCallback()) {
$column->addClass('callback-remote');
}
$html = html('a', ['href' => $column->getBindedLink($row)], $column->getValue($row));
return $this->post($html, $column, $row);
} | php | public function link(Column\Link $column, array $row)
{
if ($column->isRemote()) {
$column->addAttribute('data-target', '#' . $column->getRemoteId())
->addAttribute('data-toggle', 'modal');
} elseif($column->isCallback()) {
$column->addClass('callback-remote');
}
$html = html('a', ['href' => $column->getBindedLink($row)], $column->getValue($row));
return $this->post($html, $column, $row);
} | [
"public",
"function",
"link",
"(",
"Column",
"\\",
"Link",
"$",
"column",
",",
"array",
"$",
"row",
")",
"{",
"if",
"(",
"$",
"column",
"->",
"isRemote",
"(",
")",
")",
"{",
"$",
"column",
"->",
"addAttribute",
"(",
"'data-target'",
",",
"'#'",
".",
"$",
"column",
"->",
"getRemoteId",
"(",
")",
")",
"->",
"addAttribute",
"(",
"'data-toggle'",
",",
"'modal'",
")",
";",
"}",
"elseif",
"(",
"$",
"column",
"->",
"isCallback",
"(",
")",
")",
"{",
"$",
"column",
"->",
"addClass",
"(",
"'callback-remote'",
")",
";",
"}",
"$",
"html",
"=",
"html",
"(",
"'a'",
",",
"[",
"'href'",
"=>",
"$",
"column",
"->",
"getBindedLink",
"(",
"$",
"row",
")",
"]",
",",
"$",
"column",
"->",
"getValue",
"(",
"$",
"row",
")",
")",
";",
"return",
"$",
"this",
"->",
"post",
"(",
"$",
"html",
",",
"$",
"column",
",",
"$",
"row",
")",
";",
"}"
]
| Render link column
@param \FrenchFrogs\Table\Column\Link $column
@param array $row
@return string | [
"Render",
"link",
"column"
]
| a4838c698a5600437e87dac6d35ba8ebe32c4395 | https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Table/Renderer/Bootstrap.php#L392-L404 |
15,992 | FrenchFrogs/framework | src/Table/Renderer/Bootstrap.php | Bootstrap.button | public function button(Column\Button $column, array $row)
{
if ($column->hasOption()) {
$column->addClass(constant( Style::class . '::' . $column->getOption()));
}
if ($column->hasSize()) {
$column->addClass(constant( Style::class . '::' . $column->getSize()));
}
$column->addClass(Style::BUTTON_CLASS);
$column->addAttribute('href',$column->getBindedLink($row));
$label = '';
if ($column->hasIcon()) {
$label .= html('i', ['class' => $column->getIcon()]);
$label .= PHP_EOL;
}
$name = $column->getBindedLabel($row);
if ($column->isIconOnly()) {
$column->addClass('ff-tooltip-left');
} else {
$label .= $name;
}
if ($column->isRemote()) {
$column->addAttribute('data-target', '#' . $column->getRemoteId())
->addClass('modal-remote');
} elseif($column->isCallback()) {
$column->addClass('callback-remote');
}
$column->addAttribute('title', $name);
$html = html('a', $column->getAttributes(), $label );
$column->clearClasses()->center();
return $html;
} | php | public function button(Column\Button $column, array $row)
{
if ($column->hasOption()) {
$column->addClass(constant( Style::class . '::' . $column->getOption()));
}
if ($column->hasSize()) {
$column->addClass(constant( Style::class . '::' . $column->getSize()));
}
$column->addClass(Style::BUTTON_CLASS);
$column->addAttribute('href',$column->getBindedLink($row));
$label = '';
if ($column->hasIcon()) {
$label .= html('i', ['class' => $column->getIcon()]);
$label .= PHP_EOL;
}
$name = $column->getBindedLabel($row);
if ($column->isIconOnly()) {
$column->addClass('ff-tooltip-left');
} else {
$label .= $name;
}
if ($column->isRemote()) {
$column->addAttribute('data-target', '#' . $column->getRemoteId())
->addClass('modal-remote');
} elseif($column->isCallback()) {
$column->addClass('callback-remote');
}
$column->addAttribute('title', $name);
$html = html('a', $column->getAttributes(), $label );
$column->clearClasses()->center();
return $html;
} | [
"public",
"function",
"button",
"(",
"Column",
"\\",
"Button",
"$",
"column",
",",
"array",
"$",
"row",
")",
"{",
"if",
"(",
"$",
"column",
"->",
"hasOption",
"(",
")",
")",
"{",
"$",
"column",
"->",
"addClass",
"(",
"constant",
"(",
"Style",
"::",
"class",
".",
"'::'",
".",
"$",
"column",
"->",
"getOption",
"(",
")",
")",
")",
";",
"}",
"if",
"(",
"$",
"column",
"->",
"hasSize",
"(",
")",
")",
"{",
"$",
"column",
"->",
"addClass",
"(",
"constant",
"(",
"Style",
"::",
"class",
".",
"'::'",
".",
"$",
"column",
"->",
"getSize",
"(",
")",
")",
")",
";",
"}",
"$",
"column",
"->",
"addClass",
"(",
"Style",
"::",
"BUTTON_CLASS",
")",
";",
"$",
"column",
"->",
"addAttribute",
"(",
"'href'",
",",
"$",
"column",
"->",
"getBindedLink",
"(",
"$",
"row",
")",
")",
";",
"$",
"label",
"=",
"''",
";",
"if",
"(",
"$",
"column",
"->",
"hasIcon",
"(",
")",
")",
"{",
"$",
"label",
".=",
"html",
"(",
"'i'",
",",
"[",
"'class'",
"=>",
"$",
"column",
"->",
"getIcon",
"(",
")",
"]",
")",
";",
"$",
"label",
".=",
"PHP_EOL",
";",
"}",
"$",
"name",
"=",
"$",
"column",
"->",
"getBindedLabel",
"(",
"$",
"row",
")",
";",
"if",
"(",
"$",
"column",
"->",
"isIconOnly",
"(",
")",
")",
"{",
"$",
"column",
"->",
"addClass",
"(",
"'ff-tooltip-left'",
")",
";",
"}",
"else",
"{",
"$",
"label",
".=",
"$",
"name",
";",
"}",
"if",
"(",
"$",
"column",
"->",
"isRemote",
"(",
")",
")",
"{",
"$",
"column",
"->",
"addAttribute",
"(",
"'data-target'",
",",
"'#'",
".",
"$",
"column",
"->",
"getRemoteId",
"(",
")",
")",
"->",
"addClass",
"(",
"'modal-remote'",
")",
";",
"}",
"elseif",
"(",
"$",
"column",
"->",
"isCallback",
"(",
")",
")",
"{",
"$",
"column",
"->",
"addClass",
"(",
"'callback-remote'",
")",
";",
"}",
"$",
"column",
"->",
"addAttribute",
"(",
"'title'",
",",
"$",
"name",
")",
";",
"$",
"html",
"=",
"html",
"(",
"'a'",
",",
"$",
"column",
"->",
"getAttributes",
"(",
")",
",",
"$",
"label",
")",
";",
"$",
"column",
"->",
"clearClasses",
"(",
")",
"->",
"center",
"(",
")",
";",
"return",
"$",
"html",
";",
"}"
]
| Render a button
@param \FrenchFrogs\Table\Column\Button $column
@param array $row
@return mixed | [
"Render",
"a",
"button"
]
| a4838c698a5600437e87dac6d35ba8ebe32c4395 | https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Table/Renderer/Bootstrap.php#L452-L493 |
15,993 | FrenchFrogs/framework | src/Table/Renderer/Bootstrap.php | Bootstrap.code | public function code(Column\Code $column, array $row)
{
$html = html('code', [],$column->getValue($row));
return $this->post($html, $column, $row);
} | php | public function code(Column\Code $column, array $row)
{
$html = html('code', [],$column->getValue($row));
return $this->post($html, $column, $row);
} | [
"public",
"function",
"code",
"(",
"Column",
"\\",
"Code",
"$",
"column",
",",
"array",
"$",
"row",
")",
"{",
"$",
"html",
"=",
"html",
"(",
"'code'",
",",
"[",
"]",
",",
"$",
"column",
"->",
"getValue",
"(",
"$",
"row",
")",
")",
";",
"return",
"$",
"this",
"->",
"post",
"(",
"$",
"html",
",",
"$",
"column",
",",
"$",
"row",
")",
";",
"}"
]
| Rendor a code element
@param \FrenchFrogs\Table\Column\Code $column
@param array $row
@return string | [
"Rendor",
"a",
"code",
"element"
]
| a4838c698a5600437e87dac6d35ba8ebe32c4395 | https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Table/Renderer/Bootstrap.php#L503-L507 |
15,994 | FrenchFrogs/framework | src/Table/Renderer/Bootstrap.php | Bootstrap.pre | public function pre(Column\Pre $column, array $row)
{
$html = html('pre', [],$column->getValue($row));
return $this->post($html, $column, $row);
} | php | public function pre(Column\Pre $column, array $row)
{
$html = html('pre', [],$column->getValue($row));
return $this->post($html, $column, $row);
} | [
"public",
"function",
"pre",
"(",
"Column",
"\\",
"Pre",
"$",
"column",
",",
"array",
"$",
"row",
")",
"{",
"$",
"html",
"=",
"html",
"(",
"'pre'",
",",
"[",
"]",
",",
"$",
"column",
"->",
"getValue",
"(",
"$",
"row",
")",
")",
";",
"return",
"$",
"this",
"->",
"post",
"(",
"$",
"html",
",",
"$",
"column",
",",
"$",
"row",
")",
";",
"}"
]
| Render a pre element
@param \FrenchFrogs\Table\Column\Code $column
@param array $row
@return string | [
"Render",
"a",
"pre",
"element"
]
| a4838c698a5600437e87dac6d35ba8ebe32c4395 | https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Table/Renderer/Bootstrap.php#L516-L520 |
15,995 | FrenchFrogs/framework | src/Table/Renderer/Bootstrap.php | Bootstrap.strainerSelect | public function strainerSelect(Column\Strainer\Select $strainer)
{
$element = $strainer->getElement();
$element->addStyle('width', '100%');
$element->addClass(Style::FORM_ELEMENT_CONTROL);
$options = '';
if ($element->hasPlaceholder()){
$options .= html('option', ['value' => null], $element->getPlaceholder());
}
foreach($element->getOptions() as $value => $label){
$attr = ['value' => $value];
if ($element->hasValue() && in_array($value, $element->getValue())){
$attr['selected'] = 'selected';
}
$options .= html('option', $attr, $label);
}
return html('select', $element->getAttributes(), $options);
} | php | public function strainerSelect(Column\Strainer\Select $strainer)
{
$element = $strainer->getElement();
$element->addStyle('width', '100%');
$element->addClass(Style::FORM_ELEMENT_CONTROL);
$options = '';
if ($element->hasPlaceholder()){
$options .= html('option', ['value' => null], $element->getPlaceholder());
}
foreach($element->getOptions() as $value => $label){
$attr = ['value' => $value];
if ($element->hasValue() && in_array($value, $element->getValue())){
$attr['selected'] = 'selected';
}
$options .= html('option', $attr, $label);
}
return html('select', $element->getAttributes(), $options);
} | [
"public",
"function",
"strainerSelect",
"(",
"Column",
"\\",
"Strainer",
"\\",
"Select",
"$",
"strainer",
")",
"{",
"$",
"element",
"=",
"$",
"strainer",
"->",
"getElement",
"(",
")",
";",
"$",
"element",
"->",
"addStyle",
"(",
"'width'",
",",
"'100%'",
")",
";",
"$",
"element",
"->",
"addClass",
"(",
"Style",
"::",
"FORM_ELEMENT_CONTROL",
")",
";",
"$",
"options",
"=",
"''",
";",
"if",
"(",
"$",
"element",
"->",
"hasPlaceholder",
"(",
")",
")",
"{",
"$",
"options",
".=",
"html",
"(",
"'option'",
",",
"[",
"'value'",
"=>",
"null",
"]",
",",
"$",
"element",
"->",
"getPlaceholder",
"(",
")",
")",
";",
"}",
"foreach",
"(",
"$",
"element",
"->",
"getOptions",
"(",
")",
"as",
"$",
"value",
"=>",
"$",
"label",
")",
"{",
"$",
"attr",
"=",
"[",
"'value'",
"=>",
"$",
"value",
"]",
";",
"if",
"(",
"$",
"element",
"->",
"hasValue",
"(",
")",
"&&",
"in_array",
"(",
"$",
"value",
",",
"$",
"element",
"->",
"getValue",
"(",
")",
")",
")",
"{",
"$",
"attr",
"[",
"'selected'",
"]",
"=",
"'selected'",
";",
"}",
"$",
"options",
".=",
"html",
"(",
"'option'",
",",
"$",
"attr",
",",
"$",
"label",
")",
";",
"}",
"return",
"html",
"(",
"'select'",
",",
"$",
"element",
"->",
"getAttributes",
"(",
")",
",",
"$",
"options",
")",
";",
"}"
]
| Render strainer for a select element
@param \FrenchFrogs\Table\Column\Strainer\Select $strainer
@return string | [
"Render",
"strainer",
"for",
"a",
"select",
"element"
]
| a4838c698a5600437e87dac6d35ba8ebe32c4395 | https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Table/Renderer/Bootstrap.php#L647-L668 |
15,996 | bestit/commercetools-order-export-bundle | src/OrderNameGenerator.php | OrderNameGenerator.getOrderName | public function getOrderName(Order $order): string
{
if (preg_match_all('/{{(.*)}}/U', $scheme = $this->getNameScheme(), $matches)) {
foreach ($matches[1] as $index => $foundSnippet) {
$foundSnippetName = trim($foundSnippet);
$usedSnippet = $order->hasField($foundSnippetName)
? $order->get($foundSnippetName)
: date($foundSnippetName);
$scheme = str_replace($matches[0][$index], $usedSnippet, $scheme);
}
}
return $scheme;
} | php | public function getOrderName(Order $order): string
{
if (preg_match_all('/{{(.*)}}/U', $scheme = $this->getNameScheme(), $matches)) {
foreach ($matches[1] as $index => $foundSnippet) {
$foundSnippetName = trim($foundSnippet);
$usedSnippet = $order->hasField($foundSnippetName)
? $order->get($foundSnippetName)
: date($foundSnippetName);
$scheme = str_replace($matches[0][$index], $usedSnippet, $scheme);
}
}
return $scheme;
} | [
"public",
"function",
"getOrderName",
"(",
"Order",
"$",
"order",
")",
":",
"string",
"{",
"if",
"(",
"preg_match_all",
"(",
"'/{{(.*)}}/U'",
",",
"$",
"scheme",
"=",
"$",
"this",
"->",
"getNameScheme",
"(",
")",
",",
"$",
"matches",
")",
")",
"{",
"foreach",
"(",
"$",
"matches",
"[",
"1",
"]",
"as",
"$",
"index",
"=>",
"$",
"foundSnippet",
")",
"{",
"$",
"foundSnippetName",
"=",
"trim",
"(",
"$",
"foundSnippet",
")",
";",
"$",
"usedSnippet",
"=",
"$",
"order",
"->",
"hasField",
"(",
"$",
"foundSnippetName",
")",
"?",
"$",
"order",
"->",
"get",
"(",
"$",
"foundSnippetName",
")",
":",
"date",
"(",
"$",
"foundSnippetName",
")",
";",
"$",
"scheme",
"=",
"str_replace",
"(",
"$",
"matches",
"[",
"0",
"]",
"[",
"$",
"index",
"]",
",",
"$",
"usedSnippet",
",",
"$",
"scheme",
")",
";",
"}",
"}",
"return",
"$",
"scheme",
";",
"}"
]
| Returns the name for the order.
@param Order $order
@return string | [
"Returns",
"the",
"name",
"for",
"the",
"order",
"."
]
| 44bd0dedff6edab5ecf5803dcf6d24ffe0dbf845 | https://github.com/bestit/commercetools-order-export-bundle/blob/44bd0dedff6edab5ecf5803dcf6d24ffe0dbf845/src/OrderNameGenerator.php#L44-L58 |
15,997 | nicoSWD/put.io-api-v2 | src/PutIO/Helpers/HTTP/HTTPHelper.php | HTTPHelper.getMIMEType | protected function getMIMEType($file)
{
$mime = 'application/octet-stream';
if (function_exists('finfo_open') && $info = @finfo_open(FILEINFO_MIME)) {
if (($mime = @finfo_file($info, $file)) !== \false) {
$mime = explode(';', $mime);
$mime = trim($mime[0]);
}
}
return $mime;
} | php | protected function getMIMEType($file)
{
$mime = 'application/octet-stream';
if (function_exists('finfo_open') && $info = @finfo_open(FILEINFO_MIME)) {
if (($mime = @finfo_file($info, $file)) !== \false) {
$mime = explode(';', $mime);
$mime = trim($mime[0]);
}
}
return $mime;
} | [
"protected",
"function",
"getMIMEType",
"(",
"$",
"file",
")",
"{",
"$",
"mime",
"=",
"'application/octet-stream'",
";",
"if",
"(",
"function_exists",
"(",
"'finfo_open'",
")",
"&&",
"$",
"info",
"=",
"@",
"finfo_open",
"(",
"FILEINFO_MIME",
")",
")",
"{",
"if",
"(",
"(",
"$",
"mime",
"=",
"@",
"finfo_file",
"(",
"$",
"info",
",",
"$",
"file",
")",
")",
"!==",
"\\",
"false",
")",
"{",
"$",
"mime",
"=",
"explode",
"(",
"';'",
",",
"$",
"mime",
")",
";",
"$",
"mime",
"=",
"trim",
"(",
"$",
"mime",
"[",
"0",
"]",
")",
";",
"}",
"}",
"return",
"$",
"mime",
";",
"}"
]
| Attempts to get the MIME type of a given file. Required for native file
uploads.
Relies on the file info extension, which is shipped with PHP 5.3
and enabled by default. So,... nothing should go wrong, RIGHT?
@param string $file Path of the file you want to get the MIME type of.
@return string | [
"Attempts",
"to",
"get",
"the",
"MIME",
"type",
"of",
"a",
"given",
"file",
".",
"Required",
"for",
"native",
"file",
"uploads",
"."
]
| d91bedd91ea75793512a921bfd9aa83e86a6f0a7 | https://github.com/nicoSWD/put.io-api-v2/blob/d91bedd91ea75793512a921bfd9aa83e86a6f0a7/src/PutIO/Helpers/HTTP/HTTPHelper.php#L85-L97 |
15,998 | nicoSWD/put.io-api-v2 | src/PutIO/Helpers/HTTP/HTTPHelper.php | HTTPHelper.getResponse | protected function getResponse($response, $returnBool, $arrayKey = '')
{
$response = $this->jsonDecode($response);
if ($response === \null) {
return \false;
}
if ($returnBool) {
return $this->getStatus($response);
}
if ($arrayKey) {
if (isset($response[$arrayKey])) {
return $response[$arrayKey];
}
return \false;
}
return $response;
} | php | protected function getResponse($response, $returnBool, $arrayKey = '')
{
$response = $this->jsonDecode($response);
if ($response === \null) {
return \false;
}
if ($returnBool) {
return $this->getStatus($response);
}
if ($arrayKey) {
if (isset($response[$arrayKey])) {
return $response[$arrayKey];
}
return \false;
}
return $response;
} | [
"protected",
"function",
"getResponse",
"(",
"$",
"response",
",",
"$",
"returnBool",
",",
"$",
"arrayKey",
"=",
"''",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"jsonDecode",
"(",
"$",
"response",
")",
";",
"if",
"(",
"$",
"response",
"===",
"\\",
"null",
")",
"{",
"return",
"\\",
"false",
";",
"}",
"if",
"(",
"$",
"returnBool",
")",
"{",
"return",
"$",
"this",
"->",
"getStatus",
"(",
"$",
"response",
")",
";",
"}",
"if",
"(",
"$",
"arrayKey",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"response",
"[",
"$",
"arrayKey",
"]",
")",
")",
"{",
"return",
"$",
"response",
"[",
"$",
"arrayKey",
"]",
";",
"}",
"return",
"\\",
"false",
";",
"}",
"return",
"$",
"response",
";",
"}"
]
| Decodes the response and returns the appropriate value
@param string $response Response data from server.
@param bool $returnBool Whether or not to return boolean
@param string $arrayKey Will return all data on a specific array key
of the response.
@return array|bool | [
"Decodes",
"the",
"response",
"and",
"returns",
"the",
"appropriate",
"value"
]
| d91bedd91ea75793512a921bfd9aa83e86a6f0a7 | https://github.com/nicoSWD/put.io-api-v2/blob/d91bedd91ea75793512a921bfd9aa83e86a6f0a7/src/PutIO/Helpers/HTTP/HTTPHelper.php#L108-L129 |
15,999 | nicoSWD/put.io-api-v2 | src/PutIO/Helpers/HTTP/HTTPHelper.php | HTTPHelper.nativeJsonDecode | protected function nativeJsonDecode($string)
{
$result = @json_decode($string, \true);
if (!$result || JSON_ERROR_NONE !== json_last_error()) {
$result = \null;
}
return $result;
} | php | protected function nativeJsonDecode($string)
{
$result = @json_decode($string, \true);
if (!$result || JSON_ERROR_NONE !== json_last_error()) {
$result = \null;
}
return $result;
} | [
"protected",
"function",
"nativeJsonDecode",
"(",
"$",
"string",
")",
"{",
"$",
"result",
"=",
"@",
"json_decode",
"(",
"$",
"string",
",",
"\\",
"true",
")",
";",
"if",
"(",
"!",
"$",
"result",
"||",
"JSON_ERROR_NONE",
"!==",
"json_last_error",
"(",
")",
")",
"{",
"$",
"result",
"=",
"\\",
"null",
";",
"}",
"return",
"$",
"result",
";",
"}"
]
| Decodes a JSON encoded string natively.
@param string $string
@return array|null | [
"Decodes",
"a",
"JSON",
"encoded",
"string",
"natively",
"."
]
| d91bedd91ea75793512a921bfd9aa83e86a6f0a7 | https://github.com/nicoSWD/put.io-api-v2/blob/d91bedd91ea75793512a921bfd9aa83e86a6f0a7/src/PutIO/Helpers/HTTP/HTTPHelper.php#L160-L169 |
Subsets and Splits