repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1 value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 | partition stringclasses 1 value |
|---|---|---|---|---|---|---|---|---|---|---|---|
webeweb/jquery-datatables-bundle | Helper/DataTablesMappingHelper.php | DataTablesMappingHelper.getComparator | public static function getComparator(DataTablesMappingInterface $mapping) {
if (null === $mapping->getParent()) {
return "LIKE";
}
switch ($mapping->getParent()->getType()) {
case DataTablesColumnInterface::DATATABLES_TYPE_DATE:
case DataTablesColumnInterface::DATATABLES_TYPE_HTML_NUM:
case DataTablesColumnInterface::DATATABLES_TYPE_NUM:
case DataTablesColumnInterface::DATATABLES_TYPE_NUM_FMT:
return "=";
}
return "LIKE";
} | php | public static function getComparator(DataTablesMappingInterface $mapping) {
if (null === $mapping->getParent()) {
return "LIKE";
}
switch ($mapping->getParent()->getType()) {
case DataTablesColumnInterface::DATATABLES_TYPE_DATE:
case DataTablesColumnInterface::DATATABLES_TYPE_HTML_NUM:
case DataTablesColumnInterface::DATATABLES_TYPE_NUM:
case DataTablesColumnInterface::DATATABLES_TYPE_NUM_FMT:
return "=";
}
return "LIKE";
} | [
"public",
"static",
"function",
"getComparator",
"(",
"DataTablesMappingInterface",
"$",
"mapping",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"mapping",
"->",
"getParent",
"(",
")",
")",
"{",
"return",
"\"LIKE\"",
";",
"}",
"switch",
"(",
"$",
"mapping",
"-... | Get a comparator.
@param DataTablesMappingInterface $mapping The mapping.
@return string Returns the comparator. | [
"Get",
"a",
"comparator",
"."
] | b53df9585a523fa1617128e6b467a5e574262a94 | https://github.com/webeweb/jquery-datatables-bundle/blob/b53df9585a523fa1617128e6b467a5e574262a94/Helper/DataTablesMappingHelper.php#L50-L66 | train |
webeweb/jquery-datatables-bundle | Helper/DataTablesMappingHelper.php | DataTablesMappingHelper.getWhere | public static function getWhere(DataTablesMappingInterface $mapping) {
$where = [
static::getAlias($mapping),
static::getComparator($mapping),
static::getParam($mapping),
];
return implode(" ", $where);
} | php | public static function getWhere(DataTablesMappingInterface $mapping) {
$where = [
static::getAlias($mapping),
static::getComparator($mapping),
static::getParam($mapping),
];
return implode(" ", $where);
} | [
"public",
"static",
"function",
"getWhere",
"(",
"DataTablesMappingInterface",
"$",
"mapping",
")",
"{",
"$",
"where",
"=",
"[",
"static",
"::",
"getAlias",
"(",
"$",
"mapping",
")",
",",
"static",
"::",
"getComparator",
"(",
"$",
"mapping",
")",
",",
"sta... | Get a where.
@param DataTablesMappingInterface $mapping The mapping.
@return string Returns the where. | [
"Get",
"a",
"where",
"."
] | b53df9585a523fa1617128e6b467a5e574262a94 | https://github.com/webeweb/jquery-datatables-bundle/blob/b53df9585a523fa1617128e6b467a5e574262a94/Helper/DataTablesMappingHelper.php#L91-L100 | train |
webeweb/jquery-datatables-bundle | Controller/DataTablesController.php | DataTablesController.deleteAction | public function deleteAction(Request $request, $name, $id) {
$dtProvider = $this->getDataTablesProvider($name);
try {
$entity = $this->getDataTablesEntityById($dtProvider, $id);
$this->dispatchDataTablesEvent(DataTablesEvents::DATATABLES_PRE_DELETE, [$entity]);
$em = $this->getDoctrine()->getManager();
$em->remove($entity);
$em->flush();
$this->dispatchDataTablesEvent(DataTablesEvents::DATATABLES_POST_DELETE, [$entity]);
$output = $this->prepareActionResponse(200, "DataTablesController.deleteAction.success");
} catch (Exception $ex) {
$output = $this->handleDataTablesException($ex, "DataTablesController.deleteAction");
}
return $this->buildDataTablesResponse($request, $name, $output);
} | php | public function deleteAction(Request $request, $name, $id) {
$dtProvider = $this->getDataTablesProvider($name);
try {
$entity = $this->getDataTablesEntityById($dtProvider, $id);
$this->dispatchDataTablesEvent(DataTablesEvents::DATATABLES_PRE_DELETE, [$entity]);
$em = $this->getDoctrine()->getManager();
$em->remove($entity);
$em->flush();
$this->dispatchDataTablesEvent(DataTablesEvents::DATATABLES_POST_DELETE, [$entity]);
$output = $this->prepareActionResponse(200, "DataTablesController.deleteAction.success");
} catch (Exception $ex) {
$output = $this->handleDataTablesException($ex, "DataTablesController.deleteAction");
}
return $this->buildDataTablesResponse($request, $name, $output);
} | [
"public",
"function",
"deleteAction",
"(",
"Request",
"$",
"request",
",",
"$",
"name",
",",
"$",
"id",
")",
"{",
"$",
"dtProvider",
"=",
"$",
"this",
"->",
"getDataTablesProvider",
"(",
"$",
"name",
")",
";",
"try",
"{",
"$",
"entity",
"=",
"$",
"th... | Delete an existing entity.
@param Request $request The request.
@param string $name The provider name.
@param string $id The entity id.
@return Response Returns the response.
@throws UnregisteredDataTablesProviderException Throws an unregistered provider exception. | [
"Delete",
"an",
"existing",
"entity",
"."
] | b53df9585a523fa1617128e6b467a5e574262a94 | https://github.com/webeweb/jquery-datatables-bundle/blob/b53df9585a523fa1617128e6b467a5e574262a94/Controller/DataTablesController.php#L50-L73 | train |
webeweb/jquery-datatables-bundle | Controller/DataTablesController.php | DataTablesController.editAction | public function editAction(Request $request, $name, $id, $data, $value) {
$dtProvider = $this->getDataTablesProvider($name);
$dtEditor = $this->getDataTablesEditor($dtProvider);
$dtColumn = $this->getDataTablesColumn($dtProvider, $data);
try {
$entity = $this->getDataTablesEntityById($dtProvider, $id);
if (true === $request->isMethod(HTTPInterface::HTTP_METHOD_POST)) {
$value = $request->request->get("value");
}
$this->dispatchDataTablesEvent(DataTablesEvents::DATATABLES_PRE_EDIT, [$entity]);
$dtEditor->editColumn($dtColumn, $entity, $value);
$em = $this->getDoctrine()->getManager();
$em->persist($entity);
$em->flush();
$this->dispatchDataTablesEvent(DataTablesEvents::DATATABLES_POST_EDIT, [$entity]);
$output = $this->prepareActionResponse(200, "DataTablesController.editAction.success");
} catch (Exception $ex) {
$output = $this->handleDataTablesException($ex, "DataTablesController.editAction");
}
return new JsonResponse($output);
} | php | public function editAction(Request $request, $name, $id, $data, $value) {
$dtProvider = $this->getDataTablesProvider($name);
$dtEditor = $this->getDataTablesEditor($dtProvider);
$dtColumn = $this->getDataTablesColumn($dtProvider, $data);
try {
$entity = $this->getDataTablesEntityById($dtProvider, $id);
if (true === $request->isMethod(HTTPInterface::HTTP_METHOD_POST)) {
$value = $request->request->get("value");
}
$this->dispatchDataTablesEvent(DataTablesEvents::DATATABLES_PRE_EDIT, [$entity]);
$dtEditor->editColumn($dtColumn, $entity, $value);
$em = $this->getDoctrine()->getManager();
$em->persist($entity);
$em->flush();
$this->dispatchDataTablesEvent(DataTablesEvents::DATATABLES_POST_EDIT, [$entity]);
$output = $this->prepareActionResponse(200, "DataTablesController.editAction.success");
} catch (Exception $ex) {
$output = $this->handleDataTablesException($ex, "DataTablesController.editAction");
}
return new JsonResponse($output);
} | [
"public",
"function",
"editAction",
"(",
"Request",
"$",
"request",
",",
"$",
"name",
",",
"$",
"id",
",",
"$",
"data",
",",
"$",
"value",
")",
"{",
"$",
"dtProvider",
"=",
"$",
"this",
"->",
"getDataTablesProvider",
"(",
"$",
"name",
")",
";",
"$",
... | Edit an existing entity.
@param Request $request The request.
@param string $name The provider name
@param string $id The entity id.
@param string $data The data.
@param mixed $value The value
@return Response Returns the response.
@throws UnregisteredDataTablesProviderException Throws an unregistered provider exception.
@throws BadDataTablesEditorException Throws a bad editor exception.
@throws BadDataTablesColumnException Throws a bad column exception. | [
"Edit",
"an",
"existing",
"entity",
"."
] | b53df9585a523fa1617128e6b467a5e574262a94 | https://github.com/webeweb/jquery-datatables-bundle/blob/b53df9585a523fa1617128e6b467a5e574262a94/Controller/DataTablesController.php#L88-L121 | train |
webeweb/jquery-datatables-bundle | Controller/DataTablesController.php | DataTablesController.exportAction | public function exportAction(Request $request, $name) {
$windows = DataTablesExportHelper::isWindows($request);
$dtProvider = $this->getDataTablesProvider($name);
$dtExporter = $this->getDataTablesCSVExporter($dtProvider);
$repository = $this->getDataTablesRepository($dtProvider);
$filename = (new DateTime())->format("Y.m.d-H.i.s") . "-" . $dtProvider->getName() . ".csv";
$charset = true === $windows ? "iso-8859-1" : "utf-8";
$response = new StreamedResponse();
$response->headers->set("Content-Disposition", "attachment; filename=\"" . $filename . "\"");
$response->headers->set("Content-Type", "text/csv; charset=" . $charset);
$response->setCallback(function() use ($dtProvider, $repository, $dtExporter, $windows) {
$this->exportDataTablesCallback($dtProvider, $repository, $dtExporter, $windows);
});
$response->setStatusCode(200);
return $response;
} | php | public function exportAction(Request $request, $name) {
$windows = DataTablesExportHelper::isWindows($request);
$dtProvider = $this->getDataTablesProvider($name);
$dtExporter = $this->getDataTablesCSVExporter($dtProvider);
$repository = $this->getDataTablesRepository($dtProvider);
$filename = (new DateTime())->format("Y.m.d-H.i.s") . "-" . $dtProvider->getName() . ".csv";
$charset = true === $windows ? "iso-8859-1" : "utf-8";
$response = new StreamedResponse();
$response->headers->set("Content-Disposition", "attachment; filename=\"" . $filename . "\"");
$response->headers->set("Content-Type", "text/csv; charset=" . $charset);
$response->setCallback(function() use ($dtProvider, $repository, $dtExporter, $windows) {
$this->exportDataTablesCallback($dtProvider, $repository, $dtExporter, $windows);
});
$response->setStatusCode(200);
return $response;
} | [
"public",
"function",
"exportAction",
"(",
"Request",
"$",
"request",
",",
"$",
"name",
")",
"{",
"$",
"windows",
"=",
"DataTablesExportHelper",
"::",
"isWindows",
"(",
"$",
"request",
")",
";",
"$",
"dtProvider",
"=",
"$",
"this",
"->",
"getDataTablesProvid... | Export all entities.
@param string $name The provider name.
@return Response Returns the response.
@throws UnregisteredDataTablesProviderException Throws an unregistered provider exception.
@throws BadDataTablesCSVExporterException Throws a bad CSV exporter exception.
@throws BadDataTablesRepositoryException Throws a bad repository exception. | [
"Export",
"all",
"entities",
"."
] | b53df9585a523fa1617128e6b467a5e574262a94 | https://github.com/webeweb/jquery-datatables-bundle/blob/b53df9585a523fa1617128e6b467a5e574262a94/Controller/DataTablesController.php#L132-L155 | train |
webeweb/jquery-datatables-bundle | Controller/DataTablesController.php | DataTablesController.optionsAction | public function optionsAction($name) {
$dtProvider = $this->getDataTablesProvider($name);
$dtWrapper = $this->getDataTablesWrapper($dtProvider);
$dtOptions = DataTablesWrapperHelper::getOptions($dtWrapper);
return new JsonResponse($dtOptions);
} | php | public function optionsAction($name) {
$dtProvider = $this->getDataTablesProvider($name);
$dtWrapper = $this->getDataTablesWrapper($dtProvider);
$dtOptions = DataTablesWrapperHelper::getOptions($dtWrapper);
return new JsonResponse($dtOptions);
} | [
"public",
"function",
"optionsAction",
"(",
"$",
"name",
")",
"{",
"$",
"dtProvider",
"=",
"$",
"this",
"->",
"getDataTablesProvider",
"(",
"$",
"name",
")",
";",
"$",
"dtWrapper",
"=",
"$",
"this",
"->",
"getDataTablesWrapper",
"(",
"$",
"dtProvider",
")"... | Options of a DataTables.
@param string $name The provider name.
@return Response Returns a response.
@throws UnregisteredDataTablesProviderException Throws an unregistered provider exception. | [
"Options",
"of",
"a",
"DataTables",
"."
] | b53df9585a523fa1617128e6b467a5e574262a94 | https://github.com/webeweb/jquery-datatables-bundle/blob/b53df9585a523fa1617128e6b467a5e574262a94/Controller/DataTablesController.php#L215-L224 | train |
webeweb/jquery-datatables-bundle | Controller/DataTablesController.php | DataTablesController.showAction | public function showAction($name, $id) {
$dtProvider = $this->getDataTablesProvider($name);
try {
$entity = $this->getDataTablesEntityById($dtProvider, $id);
$this->dispatchDataTablesEvent(DataTablesEvents::DATATABLES_PRE_SHOW, [$entity]);
} catch (EntityNotFoundException $ex) {
$this->getLogger()->debug($ex->getMessage());
$entity = [];
}
$serializer = $this->getDataTablesSerializer();
return new Response($serializer->serialize($entity, "json"), 200, ["Content-type" => "application/json"]);
} | php | public function showAction($name, $id) {
$dtProvider = $this->getDataTablesProvider($name);
try {
$entity = $this->getDataTablesEntityById($dtProvider, $id);
$this->dispatchDataTablesEvent(DataTablesEvents::DATATABLES_PRE_SHOW, [$entity]);
} catch (EntityNotFoundException $ex) {
$this->getLogger()->debug($ex->getMessage());
$entity = [];
}
$serializer = $this->getDataTablesSerializer();
return new Response($serializer->serialize($entity, "json"), 200, ["Content-type" => "application/json"]);
} | [
"public",
"function",
"showAction",
"(",
"$",
"name",
",",
"$",
"id",
")",
"{",
"$",
"dtProvider",
"=",
"$",
"this",
"->",
"getDataTablesProvider",
"(",
"$",
"name",
")",
";",
"try",
"{",
"$",
"entity",
"=",
"$",
"this",
"->",
"getDataTablesEntityById",
... | Show an existing entity.
@param string $name The provider name.
@param string $id The entity id.
@return Response Returns the response.
@throws BadDataTablesRepositoryException Throws a bad repository exception.
@throws UnregisteredDataTablesProviderException Throws an unregistered provider exception. | [
"Show",
"an",
"existing",
"entity",
"."
] | b53df9585a523fa1617128e6b467a5e574262a94 | https://github.com/webeweb/jquery-datatables-bundle/blob/b53df9585a523fa1617128e6b467a5e574262a94/Controller/DataTablesController.php#L258-L277 | train |
wp-jungle/baobab | src/Baobab/Configuration/Initializer/Autoload.php | Autoload.loadPsr4 | public function loadPsr4()
{
$data = $this->getData();
// Always load these
if (isset($data['always']))
{
$this->loadPsr4Group($data['always']);
}
// These only in admin
if (is_admin() && isset($data['admin']))
{
$this->loadPsr4Group($data['admin']);
}
// These only in frontend
if ( !is_admin() && isset($data['frontend']))
{
$this->loadPsr4Group($data['frontend']);
}
} | php | public function loadPsr4()
{
$data = $this->getData();
// Always load these
if (isset($data['always']))
{
$this->loadPsr4Group($data['always']);
}
// These only in admin
if (is_admin() && isset($data['admin']))
{
$this->loadPsr4Group($data['admin']);
}
// These only in frontend
if ( !is_admin() && isset($data['frontend']))
{
$this->loadPsr4Group($data['frontend']);
}
} | [
"public",
"function",
"loadPsr4",
"(",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"getData",
"(",
")",
";",
"// Always load these",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"'always'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"loadPsr4Group",
"("... | Autoload all the classes inside the PSR4 sections for our groups | [
"Autoload",
"all",
"the",
"classes",
"inside",
"the",
"PSR4",
"sections",
"for",
"our",
"groups"
] | ed2a9f2bbc3d194aa4df454b50aec43796fc68da | https://github.com/wp-jungle/baobab/blob/ed2a9f2bbc3d194aa4df454b50aec43796fc68da/src/Baobab/Configuration/Initializer/Autoload.php#L44-L65 | train |
wp-jungle/baobab | src/Baobab/Configuration/Initializer/Autoload.php | Autoload.instantiateClasses | public function instantiateClasses()
{
$data = $this->getData();
// Always load these
if (isset($data['always']))
{
$this->instantiateGroup($data['always']);
}
// These only in admin
if (is_admin() && isset($data['admin']))
{
$this->instantiateGroup($data['admin']);
}
// These only in frontend
if ( !is_admin() && isset($data['frontend']))
{
$this->instantiateGroup($data['frontend']);
}
} | php | public function instantiateClasses()
{
$data = $this->getData();
// Always load these
if (isset($data['always']))
{
$this->instantiateGroup($data['always']);
}
// These only in admin
if (is_admin() && isset($data['admin']))
{
$this->instantiateGroup($data['admin']);
}
// These only in frontend
if ( !is_admin() && isset($data['frontend']))
{
$this->instantiateGroup($data['frontend']);
}
} | [
"public",
"function",
"instantiateClasses",
"(",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"getData",
"(",
")",
";",
"// Always load these",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"'always'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"instantiate... | Automatically instanciate all the classes inside the instanciate sections for our groups | [
"Automatically",
"instanciate",
"all",
"the",
"classes",
"inside",
"the",
"instanciate",
"sections",
"for",
"our",
"groups"
] | ed2a9f2bbc3d194aa4df454b50aec43796fc68da | https://github.com/wp-jungle/baobab/blob/ed2a9f2bbc3d194aa4df454b50aec43796fc68da/src/Baobab/Configuration/Initializer/Autoload.php#L70-L91 | train |
wp-jungle/baobab | src/Baobab/Configuration/Initializer/Autoload.php | Autoload.loadPsr4Group | private function loadPsr4Group($group)
{
if ( !isset($group['psr4']))
{
return;
}
foreach ($group['psr4'] as $prefix => $paths)
{
$this->objectRegistry->addPsr4($prefix, $paths);
}
} | php | private function loadPsr4Group($group)
{
if ( !isset($group['psr4']))
{
return;
}
foreach ($group['psr4'] as $prefix => $paths)
{
$this->objectRegistry->addPsr4($prefix, $paths);
}
} | [
"private",
"function",
"loadPsr4Group",
"(",
"$",
"group",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"group",
"[",
"'psr4'",
"]",
")",
")",
"{",
"return",
";",
"}",
"foreach",
"(",
"$",
"group",
"[",
"'psr4'",
"]",
"as",
"$",
"prefix",
"=>",
"... | Autoload the classes for a group
@param array $group The group | [
"Autoload",
"the",
"classes",
"for",
"a",
"group"
] | ed2a9f2bbc3d194aa4df454b50aec43796fc68da | https://github.com/wp-jungle/baobab/blob/ed2a9f2bbc3d194aa4df454b50aec43796fc68da/src/Baobab/Configuration/Initializer/Autoload.php#L98-L109 | train |
wp-jungle/baobab | src/Baobab/Configuration/Initializer/Autoload.php | Autoload.instantiateGroup | private function instantiateGroup($group)
{
if ( !isset($group['instantiate']))
{
return;
}
foreach ($group['instantiate'] as $nickname => $className)
{
$this->objectRegistry->register($nickname, new $className());
}
} | php | private function instantiateGroup($group)
{
if ( !isset($group['instantiate']))
{
return;
}
foreach ($group['instantiate'] as $nickname => $className)
{
$this->objectRegistry->register($nickname, new $className());
}
} | [
"private",
"function",
"instantiateGroup",
"(",
"$",
"group",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"group",
"[",
"'instantiate'",
"]",
")",
")",
"{",
"return",
";",
"}",
"foreach",
"(",
"$",
"group",
"[",
"'instantiate'",
"]",
"as",
"$",
"nic... | Instantiate the classes for a group
@param array $group The group | [
"Instantiate",
"the",
"classes",
"for",
"a",
"group"
] | ed2a9f2bbc3d194aa4df454b50aec43796fc68da | https://github.com/wp-jungle/baobab/blob/ed2a9f2bbc3d194aa4df454b50aec43796fc68da/src/Baobab/Configuration/Initializer/Autoload.php#L116-L127 | train |
codezero-be/twitter | src/Entities/User.php | User.createUser | private function createUser(array $user)
{
$this->fields = [
'id' => $this->getValue('id', $user),
'name' => $this->getValue('name', $user),
'username' => $this->getValue('username', $user),
'description' => $this->getValue('description', $user),
'location' => $this->getValue('location', $user),
'url' => $this->getValue('url', $user),
'followers_count' => $this->getValue('followers_count', $user),
'friends_count' => $this->getValue('friends_count', $user),
'favourites_count' => $this->getValue('favourites_count', $user),
'listed_count' => $this->getValue('listed_count', $user),
'created_at' => $this->getValue('created_at', $user)
];
} | php | private function createUser(array $user)
{
$this->fields = [
'id' => $this->getValue('id', $user),
'name' => $this->getValue('name', $user),
'username' => $this->getValue('username', $user),
'description' => $this->getValue('description', $user),
'location' => $this->getValue('location', $user),
'url' => $this->getValue('url', $user),
'followers_count' => $this->getValue('followers_count', $user),
'friends_count' => $this->getValue('friends_count', $user),
'favourites_count' => $this->getValue('favourites_count', $user),
'listed_count' => $this->getValue('listed_count', $user),
'created_at' => $this->getValue('created_at', $user)
];
} | [
"private",
"function",
"createUser",
"(",
"array",
"$",
"user",
")",
"{",
"$",
"this",
"->",
"fields",
"=",
"[",
"'id'",
"=>",
"$",
"this",
"->",
"getValue",
"(",
"'id'",
",",
"$",
"user",
")",
",",
"'name'",
"=>",
"$",
"this",
"->",
"getValue",
"(... | Set most used user properties
@link https://dev.twitter.com/docs/platform-objects/users
@param array $user
@return void | [
"Set",
"most",
"used",
"user",
"properties"
] | 272ef08e0f8d1ecd4b9534a3a0634b811aef6034 | https://github.com/codezero-be/twitter/blob/272ef08e0f8d1ecd4b9534a3a0634b811aef6034/src/Entities/User.php#L151-L166 | train |
wp-jungle/baobab | src/Baobab/Configuration/Initializer/Customizer.php | Customizer.configureKirki | public function configureKirki()
{
// These cannot be setup above directly, do it now
self::$OPTIONS_DEFAULTS['logo_image'] = Urls::assets('images/admin/customizer.png');
self::$OPTIONS_DEFAULTS['url_path'] = Urls::baobabFramework('vendor/aristath/kirki/');
// Todo pull description from somewhere where it is already defined
self::$OPTIONS_DEFAULTS['description'] = Strings::translate('This is the theme description');
$data = $this->getData();
return array_merge(self::$OPTIONS_DEFAULTS, $data['options']);
} | php | public function configureKirki()
{
// These cannot be setup above directly, do it now
self::$OPTIONS_DEFAULTS['logo_image'] = Urls::assets('images/admin/customizer.png');
self::$OPTIONS_DEFAULTS['url_path'] = Urls::baobabFramework('vendor/aristath/kirki/');
// Todo pull description from somewhere where it is already defined
self::$OPTIONS_DEFAULTS['description'] = Strings::translate('This is the theme description');
$data = $this->getData();
return array_merge(self::$OPTIONS_DEFAULTS, $data['options']);
} | [
"public",
"function",
"configureKirki",
"(",
")",
"{",
"// These cannot be setup above directly, do it now",
"self",
"::",
"$",
"OPTIONS_DEFAULTS",
"[",
"'logo_image'",
"]",
"=",
"Urls",
"::",
"assets",
"(",
"'images/admin/customizer.png'",
")",
";",
"self",
"::",
"$"... | Configure the Kirki library | [
"Configure",
"the",
"Kirki",
"library"
] | ed2a9f2bbc3d194aa4df454b50aec43796fc68da | https://github.com/wp-jungle/baobab/blob/ed2a9f2bbc3d194aa4df454b50aec43796fc68da/src/Baobab/Configuration/Initializer/Customizer.php#L53-L64 | train |
wp-jungle/baobab | src/Baobab/Configuration/Initializer/Customizer.php | Customizer.registerControls | public function registerControls($controls)
{
$data = $this->getData();
$customControls = $data['controls'];
foreach ($customControls as &$c) {
$c['label'] = $this->translateValueIfKeyExists($c, 'label');
$c['description'] = $this->translateValueIfKeyExists($c, 'description');
$c['default'] = $this->translateValueIfKeyExists($c, 'default');
$c['help'] = $this->translateValueIfKeyExists($c, 'help');
if (isset($c['choices'])) {
foreach ($c['choices'] as $id => $label) {
if (isset($label)) {
$c['choices'][$id] = Strings::translate($label);
}
}
}
}
return array_merge($controls, $customControls);
} | php | public function registerControls($controls)
{
$data = $this->getData();
$customControls = $data['controls'];
foreach ($customControls as &$c) {
$c['label'] = $this->translateValueIfKeyExists($c, 'label');
$c['description'] = $this->translateValueIfKeyExists($c, 'description');
$c['default'] = $this->translateValueIfKeyExists($c, 'default');
$c['help'] = $this->translateValueIfKeyExists($c, 'help');
if (isset($c['choices'])) {
foreach ($c['choices'] as $id => $label) {
if (isset($label)) {
$c['choices'][$id] = Strings::translate($label);
}
}
}
}
return array_merge($controls, $customControls);
} | [
"public",
"function",
"registerControls",
"(",
"$",
"controls",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"getData",
"(",
")",
";",
"$",
"customControls",
"=",
"$",
"data",
"[",
"'controls'",
"]",
";",
"foreach",
"(",
"$",
"customControls",
"as",
... | Register the controls in the various panels and sections
@param array $controls The controls to register
@return array The augmented controls array | [
"Register",
"the",
"controls",
"in",
"the",
"various",
"panels",
"and",
"sections"
] | ed2a9f2bbc3d194aa4df454b50aec43796fc68da | https://github.com/wp-jungle/baobab/blob/ed2a9f2bbc3d194aa4df454b50aec43796fc68da/src/Baobab/Configuration/Initializer/Customizer.php#L71-L90 | train |
wp-jungle/baobab | src/Baobab/Configuration/Initializer/Customizer.php | Customizer.createPanels | public function createPanels($wp_customize)
{
$data = $this->getData();
// Move all default sections to the default panel
$defaultPanel = $data['options']['default_panel'];
$wp_customize->add_panel($defaultPanel['id'], array(
'priority' => 10,
'title' => Strings::translate($defaultPanel['title']),
'description' => ''
));
$existingSections = $wp_customize->sections();
/** @var \WP_Customize_Section $section */
foreach ($existingSections as $sectionId => $section) {
if (empty($section->panel)) {
$section->panel = $defaultPanel['id'];
}
}
// Define additional panels and sections
$panels = $data['panels'];
$panelPriority = 1000;
foreach ($panels as $panelProps) {
if (isset($panelProps['title'])) {
$panelId = 'panel-' . $panelPriority;
$wp_customize->add_panel($panelId, array(
'priority' => $panelPriority,
'title' => Strings::translate($panelProps['title']),
'description' => Strings::translate($panelProps['description'])
));
} else {
$panelId = $defaultPanel['id'];
}
$sectionPriority = 10;
foreach ($panelProps['sections'] as $sectionId => $sectionProps) {
$wp_customize->add_section($sectionId, array(
'panel' => $panelId,
'priority' => $sectionPriority,
'title' => Strings::translate($sectionProps['title']),
'description' => Strings::translate($sectionProps['description'])
));
$sectionPriority += 10;
}
$panelPriority += 10;
}
return $wp_customize;
} | php | public function createPanels($wp_customize)
{
$data = $this->getData();
// Move all default sections to the default panel
$defaultPanel = $data['options']['default_panel'];
$wp_customize->add_panel($defaultPanel['id'], array(
'priority' => 10,
'title' => Strings::translate($defaultPanel['title']),
'description' => ''
));
$existingSections = $wp_customize->sections();
/** @var \WP_Customize_Section $section */
foreach ($existingSections as $sectionId => $section) {
if (empty($section->panel)) {
$section->panel = $defaultPanel['id'];
}
}
// Define additional panels and sections
$panels = $data['panels'];
$panelPriority = 1000;
foreach ($panels as $panelProps) {
if (isset($panelProps['title'])) {
$panelId = 'panel-' . $panelPriority;
$wp_customize->add_panel($panelId, array(
'priority' => $panelPriority,
'title' => Strings::translate($panelProps['title']),
'description' => Strings::translate($panelProps['description'])
));
} else {
$panelId = $defaultPanel['id'];
}
$sectionPriority = 10;
foreach ($panelProps['sections'] as $sectionId => $sectionProps) {
$wp_customize->add_section($sectionId, array(
'panel' => $panelId,
'priority' => $sectionPriority,
'title' => Strings::translate($sectionProps['title']),
'description' => Strings::translate($sectionProps['description'])
));
$sectionPriority += 10;
}
$panelPriority += 10;
}
return $wp_customize;
} | [
"public",
"function",
"createPanels",
"(",
"$",
"wp_customize",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"getData",
"(",
")",
";",
"// Move all default sections to the default panel",
"$",
"defaultPanel",
"=",
"$",
"data",
"[",
"'options'",
"]",
"[",
"'d... | Create all panels and sections
@param \WP_Customize_Manager $wp_customize the WP customizer
@return \WP_Customize_Manager | [
"Create",
"all",
"panels",
"and",
"sections"
] | ed2a9f2bbc3d194aa4df454b50aec43796fc68da | https://github.com/wp-jungle/baobab/blob/ed2a9f2bbc3d194aa4df454b50aec43796fc68da/src/Baobab/Configuration/Initializer/Customizer.php#L98-L150 | train |
codezero-be/twitter | src/Twitter.php | Twitter.getTweetsFromUser | public function getTweetsFromUser($username, $count = 10, $cacheMinutes = 30, $returnEntities = true)
{
$count = $this->getVerifiedCount($count, 1, 200);
$endpoint = '/statuses/user_timeline.json';
$url = $this->urlHelper->joinSlugs([$this->baseUrl, $this->apiVersion, $endpoint]);
$data = [
'screen_name' => $username,
'count' => $count
];
$headers = [
'Authorization' => 'Bearer ' . $this->requestAppAccessToken()
];
$response = $this->courier->get($url, $data, $headers, $cacheMinutes);
if ($returnEntities)
{
$tweets = $response->toArray();
$response = $this->createTweetEntities($tweets);
}
return $response;
} | php | public function getTweetsFromUser($username, $count = 10, $cacheMinutes = 30, $returnEntities = true)
{
$count = $this->getVerifiedCount($count, 1, 200);
$endpoint = '/statuses/user_timeline.json';
$url = $this->urlHelper->joinSlugs([$this->baseUrl, $this->apiVersion, $endpoint]);
$data = [
'screen_name' => $username,
'count' => $count
];
$headers = [
'Authorization' => 'Bearer ' . $this->requestAppAccessToken()
];
$response = $this->courier->get($url, $data, $headers, $cacheMinutes);
if ($returnEntities)
{
$tweets = $response->toArray();
$response = $this->createTweetEntities($tweets);
}
return $response;
} | [
"public",
"function",
"getTweetsFromUser",
"(",
"$",
"username",
",",
"$",
"count",
"=",
"10",
",",
"$",
"cacheMinutes",
"=",
"30",
",",
"$",
"returnEntities",
"=",
"true",
")",
"{",
"$",
"count",
"=",
"$",
"this",
"->",
"getVerifiedCount",
"(",
"$",
"... | Get tweets from a specific user
@link https://dev.twitter.com/docs/api/1.1/get/statuses/user_timeline
@param string $username
@param int $count
@param int $cacheMinutes
@param bool $returnEntities
@throws TwitterException
@return Response | [
"Get",
"tweets",
"from",
"a",
"specific",
"user"
] | 272ef08e0f8d1ecd4b9534a3a0634b811aef6034 | https://github.com/codezero-be/twitter/blob/272ef08e0f8d1ecd4b9534a3a0634b811aef6034/src/Twitter.php#L20-L46 | train |
rdohms/DMS | src/DMS/Bundle/LauncherBundle/Controller/PreUserController.php | PreUserController.indexAction | public function indexAction()
{
$em = $this->getDoctrine()->getEntityManager();
$entities = $em->getRepository('DMSLauncherBundle:PreUser')->findAll();
return array('entities' => $entities);
} | php | public function indexAction()
{
$em = $this->getDoctrine()->getEntityManager();
$entities = $em->getRepository('DMSLauncherBundle:PreUser')->findAll();
return array('entities' => $entities);
} | [
"public",
"function",
"indexAction",
"(",
")",
"{",
"$",
"em",
"=",
"$",
"this",
"->",
"getDoctrine",
"(",
")",
"->",
"getEntityManager",
"(",
")",
";",
"$",
"entities",
"=",
"$",
"em",
"->",
"getRepository",
"(",
"'DMSLauncherBundle:PreUser'",
")",
"->",
... | Lists all PreUser entities.
@Route("/", name="admin_preuser")
@Template() | [
"Lists",
"all",
"PreUser",
"entities",
"."
] | 3fab902ac2db2a31876101280cdfe7611146a243 | https://github.com/rdohms/DMS/blob/3fab902ac2db2a31876101280cdfe7611146a243/src/DMS/Bundle/LauncherBundle/Controller/PreUserController.php#L24-L31 | train |
rdohms/DMS | src/DMS/Bundle/LauncherBundle/Controller/PreUserController.php | PreUserController.showAction | public function showAction($id)
{
$em = $this->getDoctrine()->getEntityManager();
$entity = $em->getRepository('DMSLauncherBundle:PreUser')->find($id);
if (!$entity) {
throw $this->createNotFoundException('Unable to find PreUser entity.');
}
return array(
'entity' => $entity,
'referralCount' => $em->getRepository('DMSLauncherBundle:PreUser')->getReferralsCount($entity->getToken()),
);
} | php | public function showAction($id)
{
$em = $this->getDoctrine()->getEntityManager();
$entity = $em->getRepository('DMSLauncherBundle:PreUser')->find($id);
if (!$entity) {
throw $this->createNotFoundException('Unable to find PreUser entity.');
}
return array(
'entity' => $entity,
'referralCount' => $em->getRepository('DMSLauncherBundle:PreUser')->getReferralsCount($entity->getToken()),
);
} | [
"public",
"function",
"showAction",
"(",
"$",
"id",
")",
"{",
"$",
"em",
"=",
"$",
"this",
"->",
"getDoctrine",
"(",
")",
"->",
"getEntityManager",
"(",
")",
";",
"$",
"entity",
"=",
"$",
"em",
"->",
"getRepository",
"(",
"'DMSLauncherBundle:PreUser'",
"... | Finds and displays a PreUser entity.
@Route("/{id}/show", name="admin_preuser_show")
@Template() | [
"Finds",
"and",
"displays",
"a",
"PreUser",
"entity",
"."
] | 3fab902ac2db2a31876101280cdfe7611146a243 | https://github.com/rdohms/DMS/blob/3fab902ac2db2a31876101280cdfe7611146a243/src/DMS/Bundle/LauncherBundle/Controller/PreUserController.php#L39-L53 | train |
ArgentCrusade/selectel-cloud-storage | src/CloudStorage.php | CloudStorage.containers | public function containers($limit = 10000, $marker = '')
{
$response = $this->api->request('GET', '/', [
'query' => [
'limit' => intval($limit),
'marker' => $marker,
],
]);
if ($response->getStatusCode() !== 200) {
throw new ApiRequestFailedException('Unable to list containers.', $response->getStatusCode());
}
$containers = json_decode($response->getBody(), true);
return new Collection($this->transformContainers($containers));
} | php | public function containers($limit = 10000, $marker = '')
{
$response = $this->api->request('GET', '/', [
'query' => [
'limit' => intval($limit),
'marker' => $marker,
],
]);
if ($response->getStatusCode() !== 200) {
throw new ApiRequestFailedException('Unable to list containers.', $response->getStatusCode());
}
$containers = json_decode($response->getBody(), true);
return new Collection($this->transformContainers($containers));
} | [
"public",
"function",
"containers",
"(",
"$",
"limit",
"=",
"10000",
",",
"$",
"marker",
"=",
"''",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"api",
"->",
"request",
"(",
"'GET'",
",",
"'/'",
",",
"[",
"'query'",
"=>",
"[",
"'limit'",
"=>"... | Available containers.
@param int $limit = 10000
@param string $marker = ''
@throws \ArgentCrusade\Selectel\CloudStorage\Exceptions\ApiRequestFailedException
@return \ArgentCrusade\Selectel\CloudStorage\Contracts\Collections\CollectionContract | [
"Available",
"containers",
"."
] | f085af14b496463dc30d4804eac8c5f574d121a4 | https://github.com/ArgentCrusade/selectel-cloud-storage/blob/f085af14b496463dc30d4804eac8c5f574d121a4/src/CloudStorage.php#L48-L64 | train |
ArgentCrusade/selectel-cloud-storage | src/CloudStorage.php | CloudStorage.createContainer | public function createContainer($name, $type = 'public')
{
if (!in_array($type, ['public', 'private', 'gallery'])) {
throw new InvalidArgumentException('Unknown type "'.$type.'" provided.');
}
$response = $this->api->request('PUT', '/'.trim($name, '/'), [
'headers' => [
'X-Container-Meta-Type' => $type,
],
]);
switch ($response->getStatusCode()) {
case 201:
return $this->getContainer(trim($name, '/'));
case 202:
throw new ApiRequestFailedException('Container "'.$name.'" already exists.');
default:
throw new ApiRequestFailedException('Unable to create container "'.$name.'".', $response->getStatusCode());
}
} | php | public function createContainer($name, $type = 'public')
{
if (!in_array($type, ['public', 'private', 'gallery'])) {
throw new InvalidArgumentException('Unknown type "'.$type.'" provided.');
}
$response = $this->api->request('PUT', '/'.trim($name, '/'), [
'headers' => [
'X-Container-Meta-Type' => $type,
],
]);
switch ($response->getStatusCode()) {
case 201:
return $this->getContainer(trim($name, '/'));
case 202:
throw new ApiRequestFailedException('Container "'.$name.'" already exists.');
default:
throw new ApiRequestFailedException('Unable to create container "'.$name.'".', $response->getStatusCode());
}
} | [
"public",
"function",
"createContainer",
"(",
"$",
"name",
",",
"$",
"type",
"=",
"'public'",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"type",
",",
"[",
"'public'",
",",
"'private'",
",",
"'gallery'",
"]",
")",
")",
"{",
"throw",
"new",
"Inval... | Creates new container.
@param string $name
@param string $type
@throws \InvalidArgumentException
@throws \ArgentCrusade\Selectel\CloudStorage\Exceptions\ApiRequestFailedException
@return \ArgentCrusade\Selectel\CloudStorage\Contracts\ContainerContract | [
"Creates",
"new",
"container",
"."
] | f085af14b496463dc30d4804eac8c5f574d121a4 | https://github.com/ArgentCrusade/selectel-cloud-storage/blob/f085af14b496463dc30d4804eac8c5f574d121a4/src/CloudStorage.php#L89-L109 | train |
ArgentCrusade/selectel-cloud-storage | src/CloudStorage.php | CloudStorage.transformContainers | protected function transformContainers(array $items)
{
if (!count($items)) {
return [];
}
$containers = [];
foreach ($items as $item) {
$container = new Container($this->api, $this->uploader, $item['name'], $item);
$containers[$container->name()] = $container;
}
return $containers;
} | php | protected function transformContainers(array $items)
{
if (!count($items)) {
return [];
}
$containers = [];
foreach ($items as $item) {
$container = new Container($this->api, $this->uploader, $item['name'], $item);
$containers[$container->name()] = $container;
}
return $containers;
} | [
"protected",
"function",
"transformContainers",
"(",
"array",
"$",
"items",
")",
"{",
"if",
"(",
"!",
"count",
"(",
"$",
"items",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
"$",
"containers",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"items",
"as"... | Transforms containers response to Container objects.
@param array $items
@return array | [
"Transforms",
"containers",
"response",
"to",
"Container",
"objects",
"."
] | f085af14b496463dc30d4804eac8c5f574d121a4 | https://github.com/ArgentCrusade/selectel-cloud-storage/blob/f085af14b496463dc30d4804eac8c5f574d121a4/src/CloudStorage.php#L118-L132 | train |
lasallecms/lasallecms-l5-knowledgebase-pkg | src/KnowledgebaseServiceProvider.php | KnowledgebaseServiceProvider.setupMigrations | protected function setupMigrations()
{
$migrations = realpath(__DIR__.'/../database/migrations');
$this->publishes([
$migrations => $this->app->databasePath() . '/migrations',
]);
} | php | protected function setupMigrations()
{
$migrations = realpath(__DIR__.'/../database/migrations');
$this->publishes([
$migrations => $this->app->databasePath() . '/migrations',
]);
} | [
"protected",
"function",
"setupMigrations",
"(",
")",
"{",
"$",
"migrations",
"=",
"realpath",
"(",
"__DIR__",
".",
"'/../database/migrations'",
")",
";",
"$",
"this",
"->",
"publishes",
"(",
"[",
"$",
"migrations",
"=>",
"$",
"this",
"->",
"app",
"->",
"d... | Setup the Migrations.
@return void | [
"Setup",
"the",
"Migrations",
"."
] | f4f3072325015d40c4223aad96d045689b52b0b6 | https://github.com/lasallecms/lasallecms-l5-knowledgebase-pkg/blob/f4f3072325015d40c4223aad96d045689b52b0b6/src/KnowledgebaseServiceProvider.php#L97-L104 | train |
lasallecms/lasallecms-l5-knowledgebase-pkg | src/KnowledgebaseServiceProvider.php | KnowledgebaseServiceProvider.setupSeeds | protected function setupSeeds()
{
$seeds = realpath(__DIR__.'/../database/seeds');
$this->publishes([
$seeds => $this->app->databasePath() . '/seeds',
]);
} | php | protected function setupSeeds()
{
$seeds = realpath(__DIR__.'/../database/seeds');
$this->publishes([
$seeds => $this->app->databasePath() . '/seeds',
]);
} | [
"protected",
"function",
"setupSeeds",
"(",
")",
"{",
"$",
"seeds",
"=",
"realpath",
"(",
"__DIR__",
".",
"'/../database/seeds'",
")",
";",
"$",
"this",
"->",
"publishes",
"(",
"[",
"$",
"seeds",
"=>",
"$",
"this",
"->",
"app",
"->",
"databasePath",
"(",... | Setup the Seeds.
@return void | [
"Setup",
"the",
"Seeds",
"."
] | f4f3072325015d40c4223aad96d045689b52b0b6 | https://github.com/lasallecms/lasallecms-l5-knowledgebase-pkg/blob/f4f3072325015d40c4223aad96d045689b52b0b6/src/KnowledgebaseServiceProvider.php#L112-L119 | train |
oliverklee/ext-oelib | Classes/MailerFactory.php | Tx_Oelib_MailerFactory.getMailer | public function getMailer()
{
if ($this->isTestMode) {
$className = \Tx_Oelib_EmailCollector::class;
} else {
$className = \Tx_Oelib_RealMailer::class;
}
if (!is_object($this->mailer) || (get_class($this->mailer) !== $className)) {
$this->mailer = GeneralUtility::makeInstance($className);
}
return $this->mailer;
} | php | public function getMailer()
{
if ($this->isTestMode) {
$className = \Tx_Oelib_EmailCollector::class;
} else {
$className = \Tx_Oelib_RealMailer::class;
}
if (!is_object($this->mailer) || (get_class($this->mailer) !== $className)) {
$this->mailer = GeneralUtility::makeInstance($className);
}
return $this->mailer;
} | [
"public",
"function",
"getMailer",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isTestMode",
")",
"{",
"$",
"className",
"=",
"\\",
"Tx_Oelib_EmailCollector",
"::",
"class",
";",
"}",
"else",
"{",
"$",
"className",
"=",
"\\",
"Tx_Oelib_RealMailer",
"::",
... | Retrieves the singleton mailer instance. Depending on the mode, this
instance is either an e-mail collector or a real mailer.
@return \Tx_Oelib_AbstractMailer|\Tx_Oelib_RealMailer|\Tx_Oelib_EmailCollector the singleton mailer object | [
"Retrieves",
"the",
"singleton",
"mailer",
"instance",
".",
"Depending",
"on",
"the",
"mode",
"this",
"instance",
"is",
"either",
"an",
"e",
"-",
"mail",
"collector",
"or",
"a",
"real",
"mailer",
"."
] | f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1 | https://github.com/oliverklee/ext-oelib/blob/f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1/Classes/MailerFactory.php#L43-L56 | train |
codezero-be/twitter | src/TwitterBase.php | TwitterBase.requestAppAccessToken | protected function requestAppAccessToken()
{
$credentials = $this->authHelper->generateAppCredentials($this->apiKey, $this->apiSecret);
$endpoint = '/oauth2/token';
$url = $this->urlHelper->joinSlugs([$this->baseUrl, $endpoint]);
$data = ['grant_type' => 'client_credentials'];
$headers = [
'Authorization' => 'Basic ' . $credentials,
'Content-Type' => 'application/x-www-form-urlencoded;charset=UTF-8'
];
$response = $this->courier->post($url, $data, $headers)->toArray();
return $response['access_token'];
} | php | protected function requestAppAccessToken()
{
$credentials = $this->authHelper->generateAppCredentials($this->apiKey, $this->apiSecret);
$endpoint = '/oauth2/token';
$url = $this->urlHelper->joinSlugs([$this->baseUrl, $endpoint]);
$data = ['grant_type' => 'client_credentials'];
$headers = [
'Authorization' => 'Basic ' . $credentials,
'Content-Type' => 'application/x-www-form-urlencoded;charset=UTF-8'
];
$response = $this->courier->post($url, $data, $headers)->toArray();
return $response['access_token'];
} | [
"protected",
"function",
"requestAppAccessToken",
"(",
")",
"{",
"$",
"credentials",
"=",
"$",
"this",
"->",
"authHelper",
"->",
"generateAppCredentials",
"(",
"$",
"this",
"->",
"apiKey",
",",
"$",
"this",
"->",
"apiSecret",
")",
";",
"$",
"endpoint",
"=",
... | Request an app access token
@link https://dev.twitter.com/docs/api/1.1/post/oauth2/token
@throws TwitterException
@return string | [
"Request",
"an",
"app",
"access",
"token"
] | 272ef08e0f8d1ecd4b9534a3a0634b811aef6034 | https://github.com/codezero-be/twitter/blob/272ef08e0f8d1ecd4b9534a3a0634b811aef6034/src/TwitterBase.php#L101-L119 | train |
codezero-be/twitter | src/TwitterBase.php | TwitterBase.getVerifiedCount | protected function getVerifiedCount($count, $min = 1, $max = 100)
{
settype($count, "integer");
settype($min, "integer");
settype($max, "integer");
// If $min is greater than $max,
// use the smallest of the two ($max)
if ($min > $max) $min = $max;
if ($count < $min)
{
$count = $min;
}
elseif ($count > $max)
{
$count = $max;
}
return $count;
} | php | protected function getVerifiedCount($count, $min = 1, $max = 100)
{
settype($count, "integer");
settype($min, "integer");
settype($max, "integer");
// If $min is greater than $max,
// use the smallest of the two ($max)
if ($min > $max) $min = $max;
if ($count < $min)
{
$count = $min;
}
elseif ($count > $max)
{
$count = $max;
}
return $count;
} | [
"protected",
"function",
"getVerifiedCount",
"(",
"$",
"count",
",",
"$",
"min",
"=",
"1",
",",
"$",
"max",
"=",
"100",
")",
"{",
"settype",
"(",
"$",
"count",
",",
"\"integer\"",
")",
";",
"settype",
"(",
"$",
"min",
",",
"\"integer\"",
")",
";",
... | Verify that the count parameter is in range
@param int $count
@param int $min
@param int $max
@return int | [
"Verify",
"that",
"the",
"count",
"parameter",
"is",
"in",
"range"
] | 272ef08e0f8d1ecd4b9534a3a0634b811aef6034 | https://github.com/codezero-be/twitter/blob/272ef08e0f8d1ecd4b9534a3a0634b811aef6034/src/TwitterBase.php#L130-L150 | train |
codezero-be/twitter | src/TwitterBase.php | TwitterBase.createTweetEntities | protected function createTweetEntities($tweets)
{
$entities = [];
foreach ($tweets as $tweet)
{
$user = $this->twitterFactory->createUser($tweet['user']);
$entities[] = $this->twitterFactory->createTweet($tweet, $user);
}
return $entities;
} | php | protected function createTweetEntities($tweets)
{
$entities = [];
foreach ($tweets as $tweet)
{
$user = $this->twitterFactory->createUser($tweet['user']);
$entities[] = $this->twitterFactory->createTweet($tweet, $user);
}
return $entities;
} | [
"protected",
"function",
"createTweetEntities",
"(",
"$",
"tweets",
")",
"{",
"$",
"entities",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"tweets",
"as",
"$",
"tweet",
")",
"{",
"$",
"user",
"=",
"$",
"this",
"->",
"twitterFactory",
"->",
"createUser",
"... | Create Tweet Entities
@param $tweets
@return array | [
"Create",
"Tweet",
"Entities"
] | 272ef08e0f8d1ecd4b9534a3a0634b811aef6034 | https://github.com/codezero-be/twitter/blob/272ef08e0f8d1ecd4b9534a3a0634b811aef6034/src/TwitterBase.php#L159-L170 | train |
codezero-be/twitter | src/ServiceProviders/Laravel4.php | Laravel4.registerConfigurator | private function registerConfigurator()
{
$this->app->bind('CodeZero\Twitter\Twitter', function($app)
{
$config = $app['config']->has("twitter")
? $app['config']->get("twitter")
: $app['config']->get("twitter::config");
$configurator = new \CodeZero\Configurator\DefaultConfigurator();
$courier = $app->make('CodeZero\Twitter\TwitterCourier');
$authHelper = new \CodeZero\Twitter\AuthHelper();
$urlHelper = new \CodeZero\Utilities\UrlHelper();
$twitterFactory = new \CodeZero\Twitter\TwitterFactory();
return new \CodeZero\Twitter\Twitter($config, $configurator, $courier, $authHelper, $urlHelper, $twitterFactory);
});
} | php | private function registerConfigurator()
{
$this->app->bind('CodeZero\Twitter\Twitter', function($app)
{
$config = $app['config']->has("twitter")
? $app['config']->get("twitter")
: $app['config']->get("twitter::config");
$configurator = new \CodeZero\Configurator\DefaultConfigurator();
$courier = $app->make('CodeZero\Twitter\TwitterCourier');
$authHelper = new \CodeZero\Twitter\AuthHelper();
$urlHelper = new \CodeZero\Utilities\UrlHelper();
$twitterFactory = new \CodeZero\Twitter\TwitterFactory();
return new \CodeZero\Twitter\Twitter($config, $configurator, $courier, $authHelper, $urlHelper, $twitterFactory);
});
} | [
"private",
"function",
"registerConfigurator",
"(",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"bind",
"(",
"'CodeZero\\Twitter\\Twitter'",
",",
"function",
"(",
"$",
"app",
")",
"{",
"$",
"config",
"=",
"$",
"app",
"[",
"'config'",
"]",
"->",
"has",
"(",... | Register the configurator binding | [
"Register",
"the",
"configurator",
"binding"
] | 272ef08e0f8d1ecd4b9534a3a0634b811aef6034 | https://github.com/codezero-be/twitter/blob/272ef08e0f8d1ecd4b9534a3a0634b811aef6034/src/ServiceProviders/Laravel4.php#L42-L58 | train |
rdohms/DMS | src/DMS/Bundle/LauncherBundle/Controller/DefaultController.php | DefaultController.registerAction | public function registerAction()
{
$entity = new PreUser();
$request = $this->getRequest();
$form = $this->createForm(new RegistrationForm(), $entity);
$form->bindRequest($request);
if ($form->isValid()) {
$entity->setRegisteredOn(new \DateTime('now'));
$em = $this->getDoctrine()->getEntityManager();
$em->persist($entity);
$em->flush();
//Generate Token based on ID assigned
$entity->setToken(base_convert($entity->getId() + 100000000, 10, 32));
$em->persist($entity);
$em->flush();
return $this->redirect($this->generateUrl('launcher_done', array('token' => $entity->getToken())));
}
return array(
'entity' => $entity,
'form' => $form->createView()
);
} | php | public function registerAction()
{
$entity = new PreUser();
$request = $this->getRequest();
$form = $this->createForm(new RegistrationForm(), $entity);
$form->bindRequest($request);
if ($form->isValid()) {
$entity->setRegisteredOn(new \DateTime('now'));
$em = $this->getDoctrine()->getEntityManager();
$em->persist($entity);
$em->flush();
//Generate Token based on ID assigned
$entity->setToken(base_convert($entity->getId() + 100000000, 10, 32));
$em->persist($entity);
$em->flush();
return $this->redirect($this->generateUrl('launcher_done', array('token' => $entity->getToken())));
}
return array(
'entity' => $entity,
'form' => $form->createView()
);
} | [
"public",
"function",
"registerAction",
"(",
")",
"{",
"$",
"entity",
"=",
"new",
"PreUser",
"(",
")",
";",
"$",
"request",
"=",
"$",
"this",
"->",
"getRequest",
"(",
")",
";",
"$",
"form",
"=",
"$",
"this",
"->",
"createForm",
"(",
"new",
"Registrat... | Creates a new PreUser entity.
@Route("/launcher/register", name="launcher_register")
@Method("post")
@Template("DMSLauncherBundle:Default:index.html.twig") | [
"Creates",
"a",
"new",
"PreUser",
"entity",
"."
] | 3fab902ac2db2a31876101280cdfe7611146a243 | https://github.com/rdohms/DMS/blob/3fab902ac2db2a31876101280cdfe7611146a243/src/DMS/Bundle/LauncherBundle/Controller/DefaultController.php#L42-L69 | train |
Krinkle/intuition | language/mw-classes/LanguageKsh.php | LanguageKsh.commafy | public function commafy( $_ ) {
if ( !preg_match( '/^\d{1,4}$/', $_ ) ) {
return strrev( (string)preg_replace( '/(\d{3})(?=\d)(?!\d*\.)/', '$1,', strrev( $_ ) ) );
} else {
return $_;
}
} | php | public function commafy( $_ ) {
if ( !preg_match( '/^\d{1,4}$/', $_ ) ) {
return strrev( (string)preg_replace( '/(\d{3})(?=\d)(?!\d*\.)/', '$1,', strrev( $_ ) ) );
} else {
return $_;
}
} | [
"public",
"function",
"commafy",
"(",
"$",
"_",
")",
"{",
"if",
"(",
"!",
"preg_match",
"(",
"'/^\\d{1,4}$/'",
",",
"$",
"_",
")",
")",
"{",
"return",
"strrev",
"(",
"(",
"string",
")",
"preg_replace",
"(",
"'/(\\d{3})(?=\\d)(?!\\d*\\.)/'",
",",
"'$1,'",
... | Avoid grouping whole numbers between 0 to 9999
@param $_ string
@return string | [
"Avoid",
"grouping",
"whole",
"numbers",
"between",
"0",
"to",
"9999"
] | 36f48ffe925905ae5d60c7f04d76077e150d3a2c | https://github.com/Krinkle/intuition/blob/36f48ffe925905ae5d60c7f04d76077e150d3a2c/language/mw-classes/LanguageKsh.php#L154-L160 | train |
girosolution/girocheckout_sdk | src/girocheckout-sdk/GiroCheckout_SDK_Request.php | GiroCheckout_SDK_Request.addParam | public function addParam($param, $value) {
if (!$this->requestMethod->hasParam($param)) {
throw new GiroCheckout_SDK_Exception_helper('Failure: param "' . $param . '" not valid or misspelled. Please check API Params List.');
}
if ($value instanceof GiroCheckout_SDK_Request_Cart) {
$this->params[$param] = $value->getAllItems();
}
else {
$this->params[$param] = $value;
}
return $this;
} | php | public function addParam($param, $value) {
if (!$this->requestMethod->hasParam($param)) {
throw new GiroCheckout_SDK_Exception_helper('Failure: param "' . $param . '" not valid or misspelled. Please check API Params List.');
}
if ($value instanceof GiroCheckout_SDK_Request_Cart) {
$this->params[$param] = $value->getAllItems();
}
else {
$this->params[$param] = $value;
}
return $this;
} | [
"public",
"function",
"addParam",
"(",
"$",
"param",
",",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"requestMethod",
"->",
"hasParam",
"(",
"$",
"param",
")",
")",
"{",
"throw",
"new",
"GiroCheckout_SDK_Exception_helper",
"(",
"'Failure: p... | Adds a key value pair to the params variable. Used to fill the request with data.
@param String $param key
@param String $value value
@return GiroCheckout_SDK_Request $this own instance
@throws GiroCheckout_SDK_Exception_helper | [
"Adds",
"a",
"key",
"value",
"pair",
"to",
"the",
"params",
"variable",
".",
"Used",
"to",
"fill",
"the",
"request",
"with",
"data",
"."
] | 4360f8894452a9c8f41b07f021746105e27a8575 | https://github.com/girosolution/girocheckout_sdk/blob/4360f8894452a9c8f41b07f021746105e27a8575/src/girocheckout-sdk/GiroCheckout_SDK_Request.php#L91-L105 | train |
girosolution/girocheckout_sdk | src/girocheckout-sdk/GiroCheckout_SDK_Request.php | GiroCheckout_SDK_Request.getResponseParam | public function getResponseParam($param) {
if (isset($this->response[$param])) {
return $this->response[$param];
}
return null;
} | php | public function getResponseParam($param) {
if (isset($this->response[$param])) {
return $this->response[$param];
}
return null;
} | [
"public",
"function",
"getResponseParam",
"(",
"$",
"param",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"response",
"[",
"$",
"param",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"response",
"[",
"$",
"param",
"]",
";",
"}",
"return... | Returns the value from the response of the request.
@param String $param key
@return null/String $value value assigned to the given key | [
"Returns",
"the",
"value",
"from",
"the",
"response",
"of",
"the",
"request",
"."
] | 4360f8894452a9c8f41b07f021746105e27a8575 | https://github.com/girosolution/girocheckout_sdk/blob/4360f8894452a9c8f41b07f021746105e27a8575/src/girocheckout-sdk/GiroCheckout_SDK_Request.php#L137-L142 | train |
girosolution/girocheckout_sdk | src/girocheckout-sdk/GiroCheckout_SDK_Request.php | GiroCheckout_SDK_Request.redirectCustomerToPaymentProvider | public function redirectCustomerToPaymentProvider() {
if (isset($this->response['redirect'])) {
header('location:' . $this->response['redirect']);
exit;
}
elseif (isset($this->response['url'])) {
header('location:' . $this->response['url']);
exit;
}
} | php | public function redirectCustomerToPaymentProvider() {
if (isset($this->response['redirect'])) {
header('location:' . $this->response['redirect']);
exit;
}
elseif (isset($this->response['url'])) {
header('location:' . $this->response['url']);
exit;
}
} | [
"public",
"function",
"redirectCustomerToPaymentProvider",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"response",
"[",
"'redirect'",
"]",
")",
")",
"{",
"header",
"(",
"'location:'",
".",
"$",
"this",
"->",
"response",
"[",
"'redirect'",
"]... | modifies header to sent redirect location by GiroCheckout | [
"modifies",
"header",
"to",
"sent",
"redirect",
"location",
"by",
"GiroCheckout"
] | 4360f8894452a9c8f41b07f021746105e27a8575 | https://github.com/girosolution/girocheckout_sdk/blob/4360f8894452a9c8f41b07f021746105e27a8575/src/girocheckout-sdk/GiroCheckout_SDK_Request.php#L278-L287 | train |
bes89/mobiledetect-twig-extension | src/Bes/Twig/Extension/MobileDetectExtension.php | MobileDetectExtension.getAvailableDevices | public function getAvailableDevices()
{
$availableDevices = array();
$rules = array_change_key_case($this->detector->getRules());
foreach ($rules as $device => $rule) {
$availableDevices[$device] = static::fromCamelCase($device);
}
return $availableDevices;
} | php | public function getAvailableDevices()
{
$availableDevices = array();
$rules = array_change_key_case($this->detector->getRules());
foreach ($rules as $device => $rule) {
$availableDevices[$device] = static::fromCamelCase($device);
}
return $availableDevices;
} | [
"public",
"function",
"getAvailableDevices",
"(",
")",
"{",
"$",
"availableDevices",
"=",
"array",
"(",
")",
";",
"$",
"rules",
"=",
"array_change_key_case",
"(",
"$",
"this",
"->",
"detector",
"->",
"getRules",
"(",
")",
")",
";",
"foreach",
"(",
"$",
"... | Returns an array of all available devices
@return array | [
"Returns",
"an",
"array",
"of",
"all",
"available",
"devices"
] | e0de87a84eb19d7a46048069184d99318497816f | https://github.com/bes89/mobiledetect-twig-extension/blob/e0de87a84eb19d7a46048069184d99318497816f/src/Bes/Twig/Extension/MobileDetectExtension.php#L45-L55 | train |
rdohms/DMS | src/DMS/Filter/Mapping/ClassMetadataFactory.php | ClassMetadataFactory.loadInterfaceMetadata | protected function loadInterfaceMetadata($metadata)
{
foreach( $metadata->getReflectionClass()->getInterfaces() as $interface ) {
$metadata->mergeRules($this->getClassMetadata($interface->getName()));
}
} | php | protected function loadInterfaceMetadata($metadata)
{
foreach( $metadata->getReflectionClass()->getInterfaces() as $interface ) {
$metadata->mergeRules($this->getClassMetadata($interface->getName()));
}
} | [
"protected",
"function",
"loadInterfaceMetadata",
"(",
"$",
"metadata",
")",
"{",
"foreach",
"(",
"$",
"metadata",
"->",
"getReflectionClass",
"(",
")",
"->",
"getInterfaces",
"(",
")",
"as",
"$",
"interface",
")",
"{",
"$",
"metadata",
"->",
"mergeRules",
"... | Checks if the object has interfaces and cascades parsing of annotatiosn
to all the interfaces
@param ClassMetadata $metadata | [
"Checks",
"if",
"the",
"object",
"has",
"interfaces",
"and",
"cascades",
"parsing",
"of",
"annotatiosn",
"to",
"all",
"the",
"interfaces"
] | 3fab902ac2db2a31876101280cdfe7611146a243 | https://github.com/rdohms/DMS/blob/3fab902ac2db2a31876101280cdfe7611146a243/src/DMS/Filter/Mapping/ClassMetadataFactory.php#L151-L158 | train |
girosolution/girocheckout_sdk | src/girocheckout-sdk/api/GiroCheckout_SDK_AbstractApi.php | GiroCheckout_SDK_AbstractApi.hasParam | public function hasParam($paramName) {
if (isset($this->paramFields[$paramName])) {
return true;
}
elseif ('sourceId' === $paramName) {
return true;
} //default field due to support issues
elseif ('userAgent' === $paramName) {
return true;
} //default field due to support issues
elseif ('orderId' === $paramName) {
return true;
} //default field due to support issues
elseif ('customerId' === $paramName) {
return true;
} //default field due to support issues
return false;
} | php | public function hasParam($paramName) {
if (isset($this->paramFields[$paramName])) {
return true;
}
elseif ('sourceId' === $paramName) {
return true;
} //default field due to support issues
elseif ('userAgent' === $paramName) {
return true;
} //default field due to support issues
elseif ('orderId' === $paramName) {
return true;
} //default field due to support issues
elseif ('customerId' === $paramName) {
return true;
} //default field due to support issues
return false;
} | [
"public",
"function",
"hasParam",
"(",
"$",
"paramName",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"paramFields",
"[",
"$",
"paramName",
"]",
")",
")",
"{",
"return",
"true",
";",
"}",
"elseif",
"(",
"'sourceId'",
"===",
"$",
"paramName",
... | Checks if the param exists. Check is case sensitive.
@param String $param
@return boolean true if param exists | [
"Checks",
"if",
"the",
"param",
"exists",
".",
"Check",
"is",
"case",
"sensitive",
"."
] | 4360f8894452a9c8f41b07f021746105e27a8575 | https://github.com/girosolution/girocheckout_sdk/blob/4360f8894452a9c8f41b07f021746105e27a8575/src/girocheckout-sdk/api/GiroCheckout_SDK_AbstractApi.php#L52-L69 | train |
girosolution/girocheckout_sdk | src/girocheckout-sdk/api/GiroCheckout_SDK_AbstractApi.php | GiroCheckout_SDK_AbstractApi.getSubmitParams | public function getSubmitParams($params) {
$submitParams = array();
foreach ($this->paramFields as $k => $mandatory) {
if (isset($params[$k]) && strlen($params[$k]) > 0) {
$submitParams[$k] = $params[$k];
}
elseif ((!isset($params[$k]) || strlen($params[$k]) == 0) && $mandatory) {
throw new \Exception('mandatory field ' . $k . ' is unset or empty');
}
}
return $submitParams;
} | php | public function getSubmitParams($params) {
$submitParams = array();
foreach ($this->paramFields as $k => $mandatory) {
if (isset($params[$k]) && strlen($params[$k]) > 0) {
$submitParams[$k] = $params[$k];
}
elseif ((!isset($params[$k]) || strlen($params[$k]) == 0) && $mandatory) {
throw new \Exception('mandatory field ' . $k . ' is unset or empty');
}
}
return $submitParams;
} | [
"public",
"function",
"getSubmitParams",
"(",
"$",
"params",
")",
"{",
"$",
"submitParams",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"paramFields",
"as",
"$",
"k",
"=>",
"$",
"mandatory",
")",
"{",
"if",
"(",
"isset",
"(",
"$",... | Returns all API call param fields in the correct order.
Complains if a mandatory field is not present or empty.
@param mixed[] $params
@return mixed[] $submitParams
@throws \Exception if one of the mandatory fields is not set | [
"Returns",
"all",
"API",
"call",
"param",
"fields",
"in",
"the",
"correct",
"order",
".",
"Complains",
"if",
"a",
"mandatory",
"field",
"is",
"not",
"present",
"or",
"empty",
"."
] | 4360f8894452a9c8f41b07f021746105e27a8575 | https://github.com/girosolution/girocheckout_sdk/blob/4360f8894452a9c8f41b07f021746105e27a8575/src/girocheckout-sdk/api/GiroCheckout_SDK_AbstractApi.php#L79-L92 | train |
girosolution/girocheckout_sdk | src/girocheckout-sdk/api/GiroCheckout_SDK_AbstractApi.php | GiroCheckout_SDK_AbstractApi.checkResponse | public function checkResponse($response) {
if (!is_array($response)) {
return FALSE;
}
$responseParams = array();
foreach ($this->responseFields as $k => $mandatory) {
if (isset($response[$k])) {
$responseParams[$k] = $response[$k];
}
elseif (!isset($response[$k]) && $mandatory) {
throw new \Exception('expected response field ' . $k . ' is missing');
}
}
return $responseParams;
} | php | public function checkResponse($response) {
if (!is_array($response)) {
return FALSE;
}
$responseParams = array();
foreach ($this->responseFields as $k => $mandatory) {
if (isset($response[$k])) {
$responseParams[$k] = $response[$k];
}
elseif (!isset($response[$k]) && $mandatory) {
throw new \Exception('expected response field ' . $k . ' is missing');
}
}
return $responseParams;
} | [
"public",
"function",
"checkResponse",
"(",
"$",
"response",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"response",
")",
")",
"{",
"return",
"FALSE",
";",
"}",
"$",
"responseParams",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->"... | Returns all response param fields in the correct order.
@param mixed $response
@return mixed|boolean $responseParams
@throws \Exception if one of the mandatory fields is not set | [
"Returns",
"all",
"response",
"param",
"fields",
"in",
"the",
"correct",
"order",
"."
] | 4360f8894452a9c8f41b07f021746105e27a8575 | https://github.com/girosolution/girocheckout_sdk/blob/4360f8894452a9c8f41b07f021746105e27a8575/src/girocheckout-sdk/api/GiroCheckout_SDK_AbstractApi.php#L101-L117 | train |
girosolution/girocheckout_sdk | src/girocheckout-sdk/api/GiroCheckout_SDK_AbstractApi.php | GiroCheckout_SDK_AbstractApi.checkNotification | public function checkNotification($notify) {
if (!is_array($notify)) {
return FALSE;
}
$notifyParams = array();
foreach ($this->notifyFields as $k => $mandatory) {
if (isset($notify[$k])) {
$notifyParams[$k] = $notify[$k];
}
elseif (!isset($notify[$k]) && $mandatory) {
throw new \Exception('expected notification field ' . $k . ' is missing');
}
}
return $notifyParams;
} | php | public function checkNotification($notify) {
if (!is_array($notify)) {
return FALSE;
}
$notifyParams = array();
foreach ($this->notifyFields as $k => $mandatory) {
if (isset($notify[$k])) {
$notifyParams[$k] = $notify[$k];
}
elseif (!isset($notify[$k]) && $mandatory) {
throw new \Exception('expected notification field ' . $k . ' is missing');
}
}
return $notifyParams;
} | [
"public",
"function",
"checkNotification",
"(",
"$",
"notify",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"notify",
")",
")",
"{",
"return",
"FALSE",
";",
"}",
"$",
"notifyParams",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
... | Returns all notify param fields in the correct order.
@param mixed $notify
@return mixed|boolean $notifyParams
@throws \Exception if one of the mandatory fields is not set | [
"Returns",
"all",
"notify",
"param",
"fields",
"in",
"the",
"correct",
"order",
"."
] | 4360f8894452a9c8f41b07f021746105e27a8575 | https://github.com/girosolution/girocheckout_sdk/blob/4360f8894452a9c8f41b07f021746105e27a8575/src/girocheckout-sdk/api/GiroCheckout_SDK_AbstractApi.php#L126-L142 | train |
wp-jungle/baobab | src/Baobab/Configuration/Initializer/Assets.php | Assets.registerAssets | public function registerAssets()
{
$data = $this->getData();
// Read the assets manifest file if it exists
$manifest = $this->loadManifest();
if (isset($data['styles']))
{
foreach ($data['styles'] as $handle => $props)
{
$this->handleStyleAction('register', $handle, $props, $manifest);
}
}
if (isset($data['scripts']))
{
foreach ($data['scripts'] as $handle => $props)
{
$this->handleScriptAction('register', $handle, $props, $manifest);
}
}
} | php | public function registerAssets()
{
$data = $this->getData();
// Read the assets manifest file if it exists
$manifest = $this->loadManifest();
if (isset($data['styles']))
{
foreach ($data['styles'] as $handle => $props)
{
$this->handleStyleAction('register', $handle, $props, $manifest);
}
}
if (isset($data['scripts']))
{
foreach ($data['scripts'] as $handle => $props)
{
$this->handleScriptAction('register', $handle, $props, $manifest);
}
}
} | [
"public",
"function",
"registerAssets",
"(",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"getData",
"(",
")",
";",
"// Read the assets manifest file if it exists",
"$",
"manifest",
"=",
"$",
"this",
"->",
"loadManifest",
"(",
")",
";",
"if",
"(",
"isset",... | Register the assets before we eventually enqueue them | [
"Register",
"the",
"assets",
"before",
"we",
"eventually",
"enqueue",
"them"
] | ed2a9f2bbc3d194aa4df454b50aec43796fc68da | https://github.com/wp-jungle/baobab/blob/ed2a9f2bbc3d194aa4df454b50aec43796fc68da/src/Baobab/Configuration/Initializer/Assets.php#L56-L78 | train |
wp-jungle/baobab | src/Baobab/Configuration/Initializer/Assets.php | Assets.enqueueAssets | public function enqueueAssets()
{
$data = $this->getData();
if (isset($data['editor']))
{
// Tell the TinyMCE editor to use a custom stylesheet
add_editor_style($data['editor']);
}
if (isset($data['styles']))
{
foreach ($data['styles'] as $handle => $props)
{
$this->handleStyleAction('enqueue', $handle, $props);
}
}
if (isset($data['scripts']))
{
foreach ($data['scripts'] as $handle => $props)
{
$this->handleScriptAction('enqueue', $handle, $props);
}
}
} | php | public function enqueueAssets()
{
$data = $this->getData();
if (isset($data['editor']))
{
// Tell the TinyMCE editor to use a custom stylesheet
add_editor_style($data['editor']);
}
if (isset($data['styles']))
{
foreach ($data['styles'] as $handle => $props)
{
$this->handleStyleAction('enqueue', $handle, $props);
}
}
if (isset($data['scripts']))
{
foreach ($data['scripts'] as $handle => $props)
{
$this->handleScriptAction('enqueue', $handle, $props);
}
}
} | [
"public",
"function",
"enqueueAssets",
"(",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"getData",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"'editor'",
"]",
")",
")",
"{",
"// Tell the TinyMCE editor to use a custom stylesheet",
"add_edit... | Enqueue the assets | [
"Enqueue",
"the",
"assets"
] | ed2a9f2bbc3d194aa4df454b50aec43796fc68da | https://github.com/wp-jungle/baobab/blob/ed2a9f2bbc3d194aa4df454b50aec43796fc68da/src/Baobab/Configuration/Initializer/Assets.php#L83-L108 | train |
wp-jungle/baobab | src/Baobab/Configuration/Initializer/Assets.php | Assets.loadManifest | protected function loadManifest()
{
$manifestPath = Paths::assets('manifest.json');
if (file_exists($manifestPath))
{
return json_decode(file_get_contents($manifestPath), true);
}
return null;
} | php | protected function loadManifest()
{
$manifestPath = Paths::assets('manifest.json');
if (file_exists($manifestPath))
{
return json_decode(file_get_contents($manifestPath), true);
}
return null;
} | [
"protected",
"function",
"loadManifest",
"(",
")",
"{",
"$",
"manifestPath",
"=",
"Paths",
"::",
"assets",
"(",
"'manifest.json'",
")",
";",
"if",
"(",
"file_exists",
"(",
"$",
"manifestPath",
")",
")",
"{",
"return",
"json_decode",
"(",
"file_get_contents",
... | Read the manifest file that can be found at the root of the theme's asset folder.
@return object|null null if the file does not exist or an object representing the manifest data | [
"Read",
"the",
"manifest",
"file",
"that",
"can",
"be",
"found",
"at",
"the",
"root",
"of",
"the",
"theme",
"s",
"asset",
"folder",
"."
] | ed2a9f2bbc3d194aa4df454b50aec43796fc68da | https://github.com/wp-jungle/baobab/blob/ed2a9f2bbc3d194aa4df454b50aec43796fc68da/src/Baobab/Configuration/Initializer/Assets.php#L209-L219 | train |
ArgentCrusade/selectel-cloud-storage | src/Container.php | Container.objectData | protected function objectData($key, $default = null)
{
if (!$this->dataLoaded) {
$this->loadContainerData();
}
return isset($this->data[$key]) ? $this->data[$key] : $default;
} | php | protected function objectData($key, $default = null)
{
if (!$this->dataLoaded) {
$this->loadContainerData();
}
return isset($this->data[$key]) ? $this->data[$key] : $default;
} | [
"protected",
"function",
"objectData",
"(",
"$",
"key",
",",
"$",
"default",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"dataLoaded",
")",
"{",
"$",
"this",
"->",
"loadContainerData",
"(",
")",
";",
"}",
"return",
"isset",
"(",
"$",
... | Returns specific container data.
@param string $key
@param mixed $default = null
@return mixed | [
"Returns",
"specific",
"container",
"data",
"."
] | f085af14b496463dc30d4804eac8c5f574d121a4 | https://github.com/ArgentCrusade/selectel-cloud-storage/blob/f085af14b496463dc30d4804eac8c5f574d121a4/src/Container.php#L83-L90 | train |
ArgentCrusade/selectel-cloud-storage | src/Container.php | Container.loadContainerData | protected function loadContainerData()
{
// CloudStorage::containers and CloudStorage::getContainer methods did not
// produce any requests to Selectel API, since it may be unnecessary if
// user only wants to upload/manage files or delete container via API.
// If user really wants some container info, we will load
// it here on demand. This speeds up application a bit.
$response = $this->api->request('HEAD', $this->absolutePath());
if ($response->getStatusCode() !== 204) {
throw new ApiRequestFailedException('Container "'.$this->name().'" was not found.');
}
$this->dataLoaded = true;
// We will extract some headers from response
// and assign them as container data. Also
// we'll try to find any container Meta.
$this->data = [
'type' => $response->getHeaderLine('X-Container-Meta-Type'),
'count' => intval($response->getHeaderLine('X-Container-Object-Count')),
'bytes' => intval($response->getHeaderLine('X-Container-Bytes-Used')),
'rx_bytes' => intval($response->getHeaderLine('X-Received-Bytes')),
'tx_bytes' => intval($response->getHeaderLine('X-Transfered-Bytes')),
'meta' => $this->extractMetaData($response),
];
} | php | protected function loadContainerData()
{
// CloudStorage::containers and CloudStorage::getContainer methods did not
// produce any requests to Selectel API, since it may be unnecessary if
// user only wants to upload/manage files or delete container via API.
// If user really wants some container info, we will load
// it here on demand. This speeds up application a bit.
$response = $this->api->request('HEAD', $this->absolutePath());
if ($response->getStatusCode() !== 204) {
throw new ApiRequestFailedException('Container "'.$this->name().'" was not found.');
}
$this->dataLoaded = true;
// We will extract some headers from response
// and assign them as container data. Also
// we'll try to find any container Meta.
$this->data = [
'type' => $response->getHeaderLine('X-Container-Meta-Type'),
'count' => intval($response->getHeaderLine('X-Container-Object-Count')),
'bytes' => intval($response->getHeaderLine('X-Container-Bytes-Used')),
'rx_bytes' => intval($response->getHeaderLine('X-Received-Bytes')),
'tx_bytes' => intval($response->getHeaderLine('X-Transfered-Bytes')),
'meta' => $this->extractMetaData($response),
];
} | [
"protected",
"function",
"loadContainerData",
"(",
")",
"{",
"// CloudStorage::containers and CloudStorage::getContainer methods did not",
"// produce any requests to Selectel API, since it may be unnecessary if",
"// user only wants to upload/manage files or delete container via API.",
"// If use... | Container data lazy loader.
@throws \ArgentCrusade\Selectel\CloudStorage\Exceptions\ApiRequestFailedException | [
"Container",
"data",
"lazy",
"loader",
"."
] | f085af14b496463dc30d4804eac8c5f574d121a4 | https://github.com/ArgentCrusade/selectel-cloud-storage/blob/f085af14b496463dc30d4804eac8c5f574d121a4/src/Container.php#L97-L126 | train |
ArgentCrusade/selectel-cloud-storage | src/Container.php | Container.jsonSerialize | public function jsonSerialize()
{
return [
'name' => $this->name(),
'type' => $this->type(),
'files_count' => $this->filesCount(),
'size' => $this->size(),
'uploaded_bytes' => $this->uploadedBytes(),
'downloaded_bytes' => $this->downloadedBytes(),
];
} | php | public function jsonSerialize()
{
return [
'name' => $this->name(),
'type' => $this->type(),
'files_count' => $this->filesCount(),
'size' => $this->size(),
'uploaded_bytes' => $this->uploadedBytes(),
'downloaded_bytes' => $this->downloadedBytes(),
];
} | [
"public",
"function",
"jsonSerialize",
"(",
")",
"{",
"return",
"[",
"'name'",
"=>",
"$",
"this",
"->",
"name",
"(",
")",
",",
"'type'",
"=>",
"$",
"this",
"->",
"type",
"(",
")",
",",
"'files_count'",
"=>",
"$",
"this",
"->",
"filesCount",
"(",
")",... | JSON representation of container.
@return array | [
"JSON",
"representation",
"of",
"container",
"."
] | f085af14b496463dc30d4804eac8c5f574d121a4 | https://github.com/ArgentCrusade/selectel-cloud-storage/blob/f085af14b496463dc30d4804eac8c5f574d121a4/src/Container.php#L165-L175 | train |
ArgentCrusade/selectel-cloud-storage | src/Container.php | Container.setType | public function setType($type)
{
if ($this->type() === $type) {
return $type;
}
// Catch any API Request Exceptions here
// so we can replace exception message
// with more informative one.
try {
$this->setMeta(['Type' => $type]);
} catch (ApiRequestFailedException $e) {
throw new ApiRequestFailedException('Unable to set container type to "'.$type.'".', $e->getCode());
}
return $this->data['type'] = $type;
} | php | public function setType($type)
{
if ($this->type() === $type) {
return $type;
}
// Catch any API Request Exceptions here
// so we can replace exception message
// with more informative one.
try {
$this->setMeta(['Type' => $type]);
} catch (ApiRequestFailedException $e) {
throw new ApiRequestFailedException('Unable to set container type to "'.$type.'".', $e->getCode());
}
return $this->data['type'] = $type;
} | [
"public",
"function",
"setType",
"(",
"$",
"type",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"type",
"(",
")",
"===",
"$",
"type",
")",
"{",
"return",
"$",
"type",
";",
"}",
"// Catch any API Request Exceptions here",
"// so we can replace exception message",
"/... | Updates container type.
@param string $type Container type: 'public', 'private' or 'gallery'.
@throws \ArgentCrusade\Selectel\CloudStorage\Exceptions\ApiRequestFailedException
@return string | [
"Updates",
"container",
"type",
"."
] | f085af14b496463dc30d4804eac8c5f574d121a4 | https://github.com/ArgentCrusade/selectel-cloud-storage/blob/f085af14b496463dc30d4804eac8c5f574d121a4/src/Container.php#L278-L295 | train |
ArgentCrusade/selectel-cloud-storage | src/Container.php | Container.createDir | public function createDir($name)
{
$response = $this->api->request('PUT', $this->absolutePath($name), [
'headers' => [
'Content-Type' => 'application/directory',
],
]);
if ($response->getStatusCode() !== 201) {
throw new ApiRequestFailedException('Unable to create directory "'.$name.'".', $response->getStatusCode());
}
return $response->getHeaderLine('ETag');
} | php | public function createDir($name)
{
$response = $this->api->request('PUT', $this->absolutePath($name), [
'headers' => [
'Content-Type' => 'application/directory',
],
]);
if ($response->getStatusCode() !== 201) {
throw new ApiRequestFailedException('Unable to create directory "'.$name.'".', $response->getStatusCode());
}
return $response->getHeaderLine('ETag');
} | [
"public",
"function",
"createDir",
"(",
"$",
"name",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"api",
"->",
"request",
"(",
"'PUT'",
",",
"$",
"this",
"->",
"absolutePath",
"(",
"$",
"name",
")",
",",
"[",
"'headers'",
"=>",
"[",
"'Content-T... | Creates new directory.
@param string $name Directory name.
@throws \ArgentCrusade\Selectel\CloudStorage\Exceptions\ApiRequestFailedException
@return string | [
"Creates",
"new",
"directory",
"."
] | f085af14b496463dc30d4804eac8c5f574d121a4 | https://github.com/ArgentCrusade/selectel-cloud-storage/blob/f085af14b496463dc30d4804eac8c5f574d121a4/src/Container.php#L330-L343 | train |
ArgentCrusade/selectel-cloud-storage | src/Container.php | Container.deleteDir | public function deleteDir($name)
{
$response = $this->api->request('DELETE', $this->absolutePath($name));
if ($response->getStatusCode() !== 204) {
throw new ApiRequestFailedException('Unable to delete directory "'.$name.'".', $response->getStatusCode());
}
return true;
} | php | public function deleteDir($name)
{
$response = $this->api->request('DELETE', $this->absolutePath($name));
if ($response->getStatusCode() !== 204) {
throw new ApiRequestFailedException('Unable to delete directory "'.$name.'".', $response->getStatusCode());
}
return true;
} | [
"public",
"function",
"deleteDir",
"(",
"$",
"name",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"api",
"->",
"request",
"(",
"'DELETE'",
",",
"$",
"this",
"->",
"absolutePath",
"(",
"$",
"name",
")",
")",
";",
"if",
"(",
"$",
"response",
"-... | Deletes directory.
@param string $name Directory name.
@throws \ArgentCrusade\Selectel\CloudStorage\Exceptions\ApiRequestFailedException
@return bool | [
"Deletes",
"directory",
"."
] | f085af14b496463dc30d4804eac8c5f574d121a4 | https://github.com/ArgentCrusade/selectel-cloud-storage/blob/f085af14b496463dc30d4804eac8c5f574d121a4/src/Container.php#L354-L363 | train |
ArgentCrusade/selectel-cloud-storage | src/Container.php | Container.uploadFromString | public function uploadFromString($path, $contents, array $params = [], $verifyChecksum = true)
{
return $this->uploader->upload($this->api, $this->absolutePath($path), $contents, $params, $verifyChecksum);
} | php | public function uploadFromString($path, $contents, array $params = [], $verifyChecksum = true)
{
return $this->uploader->upload($this->api, $this->absolutePath($path), $contents, $params, $verifyChecksum);
} | [
"public",
"function",
"uploadFromString",
"(",
"$",
"path",
",",
"$",
"contents",
",",
"array",
"$",
"params",
"=",
"[",
"]",
",",
"$",
"verifyChecksum",
"=",
"true",
")",
"{",
"return",
"$",
"this",
"->",
"uploader",
"->",
"upload",
"(",
"$",
"this",
... | Uploads file contents from string. Returns ETag header value if upload was successful.
@param string $path Remote path.
@param string $contents File contents.
@param array $params = [] Upload params.
@param bool $verifyChecksum = true
@throws \ArgentCrusade\Selectel\CloudStorage\Exceptions\UploadFailedException
@return string | [
"Uploads",
"file",
"contents",
"from",
"string",
".",
"Returns",
"ETag",
"header",
"value",
"if",
"upload",
"was",
"successful",
"."
] | f085af14b496463dc30d4804eac8c5f574d121a4 | https://github.com/ArgentCrusade/selectel-cloud-storage/blob/f085af14b496463dc30d4804eac8c5f574d121a4/src/Container.php#L377-L380 | train |
ArgentCrusade/selectel-cloud-storage | src/Container.php | Container.uploadFromStream | public function uploadFromStream($path, $resource, array $params = [])
{
return $this->uploader->upload($this->api, $this->absolutePath($path), $resource, $params, false);
} | php | public function uploadFromStream($path, $resource, array $params = [])
{
return $this->uploader->upload($this->api, $this->absolutePath($path), $resource, $params, false);
} | [
"public",
"function",
"uploadFromStream",
"(",
"$",
"path",
",",
"$",
"resource",
",",
"array",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"uploader",
"->",
"upload",
"(",
"$",
"this",
"->",
"api",
",",
"$",
"this",
"->",
... | Uploads file from stream. Returns ETag header value if upload was successful.
@param string $path Remote path.
@param resource $resource Stream resource.
@param array $params = [] Upload params.
@throws \ArgentCrusade\Selectel\CloudStorage\Exceptions\UploadFailedException
@return string | [
"Uploads",
"file",
"from",
"stream",
".",
"Returns",
"ETag",
"header",
"value",
"if",
"upload",
"was",
"successful",
"."
] | f085af14b496463dc30d4804eac8c5f574d121a4 | https://github.com/ArgentCrusade/selectel-cloud-storage/blob/f085af14b496463dc30d4804eac8c5f574d121a4/src/Container.php#L393-L396 | train |
ArgentCrusade/selectel-cloud-storage | src/Container.php | Container.delete | public function delete()
{
$response = $this->api->request('DELETE', $this->absolutePath());
switch ($response->getStatusCode()) {
case 204:
// Container removed.
return;
case 404:
throw new ApiRequestFailedException('Container "'.$this->name().'" was not found.');
case 409:
throw new ApiRequestFailedException('Container must be empty.');
}
} | php | public function delete()
{
$response = $this->api->request('DELETE', $this->absolutePath());
switch ($response->getStatusCode()) {
case 204:
// Container removed.
return;
case 404:
throw new ApiRequestFailedException('Container "'.$this->name().'" was not found.');
case 409:
throw new ApiRequestFailedException('Container must be empty.');
}
} | [
"public",
"function",
"delete",
"(",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"api",
"->",
"request",
"(",
"'DELETE'",
",",
"$",
"this",
"->",
"absolutePath",
"(",
")",
")",
";",
"switch",
"(",
"$",
"response",
"->",
"getStatusCode",
"(",
"... | Deletes container. Container must be empty in order to perform this operation.
@throws \ArgentCrusade\Selectel\CloudStorage\Exceptions\ApiRequestFailedException | [
"Deletes",
"container",
".",
"Container",
"must",
"be",
"empty",
"in",
"order",
"to",
"perform",
"this",
"operation",
"."
] | f085af14b496463dc30d4804eac8c5f574d121a4 | https://github.com/ArgentCrusade/selectel-cloud-storage/blob/f085af14b496463dc30d4804eac8c5f574d121a4/src/Container.php#L403-L416 | train |
oliverklee/ext-oelib | Classes/Model/FrontEndUser.php | Tx_Oelib_Model_FrontEndUser.getName | public function getName()
{
if ($this->hasString('name')) {
$result = $this->getAsString('name');
} elseif ($this->hasFirstName() || $this->hasLastName()) {
$result = trim($this->getFirstName() . ' ' . $this->getLastName());
} else {
$result = $this->getUserName();
}
return $result;
} | php | public function getName()
{
if ($this->hasString('name')) {
$result = $this->getAsString('name');
} elseif ($this->hasFirstName() || $this->hasLastName()) {
$result = trim($this->getFirstName() . ' ' . $this->getLastName());
} else {
$result = $this->getUserName();
}
return $result;
} | [
"public",
"function",
"getName",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasString",
"(",
"'name'",
")",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"getAsString",
"(",
"'name'",
")",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"hasFirst... | Gets this user's real name.
First, the "name" field is checked. If that is empty, the fields
"first_name" and "last_name" are checked. If those are empty as well,
the user name is returned as a fallback value.
@return string the user's real name, will not be empty for valid records | [
"Gets",
"this",
"user",
"s",
"real",
"name",
"."
] | f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1 | https://github.com/oliverklee/ext-oelib/blob/f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1/Classes/Model/FrontEndUser.php#L93-L104 | train |
oliverklee/ext-oelib | Classes/Model/FrontEndUser.php | Tx_Oelib_Model_FrontEndUser.hasGroupMembership | public function hasGroupMembership($uidList)
{
if ($uidList === '') {
throw new \InvalidArgumentException('$uidList must not be empty.', 1331488635);
}
$isMember = false;
foreach (GeneralUtility::trimExplode(',', $uidList, true) as $uid) {
if ($this->getUserGroups()->hasUid($uid)) {
$isMember = true;
break;
}
}
return $isMember;
} | php | public function hasGroupMembership($uidList)
{
if ($uidList === '') {
throw new \InvalidArgumentException('$uidList must not be empty.', 1331488635);
}
$isMember = false;
foreach (GeneralUtility::trimExplode(',', $uidList, true) as $uid) {
if ($this->getUserGroups()->hasUid($uid)) {
$isMember = true;
break;
}
}
return $isMember;
} | [
"public",
"function",
"hasGroupMembership",
"(",
"$",
"uidList",
")",
"{",
"if",
"(",
"$",
"uidList",
"===",
"''",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'$uidList must not be empty.'",
",",
"1331488635",
")",
";",
"}",
"$",
"isMembe... | Checks whether this user is a member of at least one of the user groups
provided as comma-separated UID list.
@param string $uidList
comma-separated list of user group UIDs, can also consist of only
one UID, but must not be empty
@return bool TRUE if the user is member of at least one of the user groups provided, FALSE otherwise
@throws \InvalidArgumentException | [
"Checks",
"whether",
"this",
"user",
"is",
"a",
"member",
"of",
"at",
"least",
"one",
"of",
"the",
"user",
"groups",
"provided",
"as",
"comma",
"-",
"separated",
"UID",
"list",
"."
] | f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1 | https://github.com/oliverklee/ext-oelib/blob/f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1/Classes/Model/FrontEndUser.php#L435-L451 | train |
oliverklee/ext-oelib | Classes/Model/FrontEndUser.php | Tx_Oelib_Model_FrontEndUser.setGender | public function setGender($genderKey)
{
$validGenderKeys = [self::GENDER_MALE, self::GENDER_FEMALE, self::GENDER_UNKNOWN];
if (!in_array($genderKey, $validGenderKeys, true)) {
throw new \InvalidArgumentException(
'$genderKey must be one of the predefined constants, but actually is: ' . $genderKey,
1393329321
);
}
$this->setAsInteger('gender', $genderKey);
} | php | public function setGender($genderKey)
{
$validGenderKeys = [self::GENDER_MALE, self::GENDER_FEMALE, self::GENDER_UNKNOWN];
if (!in_array($genderKey, $validGenderKeys, true)) {
throw new \InvalidArgumentException(
'$genderKey must be one of the predefined constants, but actually is: ' . $genderKey,
1393329321
);
}
$this->setAsInteger('gender', $genderKey);
} | [
"public",
"function",
"setGender",
"(",
"$",
"genderKey",
")",
"{",
"$",
"validGenderKeys",
"=",
"[",
"self",
"::",
"GENDER_MALE",
",",
"self",
"::",
"GENDER_FEMALE",
",",
"self",
"::",
"GENDER_UNKNOWN",
"]",
";",
"if",
"(",
"!",
"in_array",
"(",
"$",
"g... | Sets the gender.
@param int $genderKey one of the predefined gender constants
@return void
@throws \InvalidArgumentException | [
"Sets",
"the",
"gender",
"."
] | f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1 | https://github.com/oliverklee/ext-oelib/blob/f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1/Classes/Model/FrontEndUser.php#L491-L502 | train |
oliverklee/ext-oelib | Classes/Model/FrontEndUser.php | Tx_Oelib_Model_FrontEndUser.getAge | public function getAge()
{
if (!$this->hasDateOfBirth()) {
return 0;
}
$currentTimestamp = $GLOBALS['EXEC_TIME'];
$birthTimestamp = $this->getDateOfBirth();
$currentYear = (int)strftime('%Y', $currentTimestamp);
$currentMonth = (int)strftime('%m', $currentTimestamp);
$currentDay = (int)strftime('%d', $currentTimestamp);
$birthYear = (int)strftime('%Y', $birthTimestamp);
$birthMonth = (int)strftime('%m', $birthTimestamp);
$birthDay = (int)strftime('%d', $birthTimestamp);
$age = $currentYear - $birthYear;
if ($currentMonth < $birthMonth) {
$age--;
} elseif ($currentMonth === $birthMonth) {
if ($currentDay < $birthDay) {
$age--;
}
}
return $age;
} | php | public function getAge()
{
if (!$this->hasDateOfBirth()) {
return 0;
}
$currentTimestamp = $GLOBALS['EXEC_TIME'];
$birthTimestamp = $this->getDateOfBirth();
$currentYear = (int)strftime('%Y', $currentTimestamp);
$currentMonth = (int)strftime('%m', $currentTimestamp);
$currentDay = (int)strftime('%d', $currentTimestamp);
$birthYear = (int)strftime('%Y', $birthTimestamp);
$birthMonth = (int)strftime('%m', $birthTimestamp);
$birthDay = (int)strftime('%d', $birthTimestamp);
$age = $currentYear - $birthYear;
if ($currentMonth < $birthMonth) {
$age--;
} elseif ($currentMonth === $birthMonth) {
if ($currentDay < $birthDay) {
$age--;
}
}
return $age;
} | [
"public",
"function",
"getAge",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasDateOfBirth",
"(",
")",
")",
"{",
"return",
"0",
";",
"}",
"$",
"currentTimestamp",
"=",
"$",
"GLOBALS",
"[",
"'EXEC_TIME'",
"]",
";",
"$",
"birthTimestamp",
"=",
"... | Returns this user's age in years.
Note: This function only works correctly for users that were born after
1970-01-01 and that were not born in the future.
@return int this user's age in years, will be 0 if this user has no birth date set | [
"Returns",
"this",
"user",
"s",
"age",
"in",
"years",
"."
] | f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1 | https://github.com/oliverklee/ext-oelib/blob/f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1/Classes/Model/FrontEndUser.php#L623-L650 | train |
oliverklee/ext-oelib | Classes/Model/FrontEndUser.php | Tx_Oelib_Model_FrontEndUser.getCountry | public function getCountry()
{
$countryCode = $this->getAsString('static_info_country');
if ($countryCode === '') {
return null;
}
try {
/** @var \Tx_Oelib_Mapper_Country $countryMapper */
$countryMapper = \Tx_Oelib_MapperRegistry::get(\Tx_Oelib_Mapper_Country::class);
/** @var \Tx_Oelib_Model_Country $country */
$country = $countryMapper->findByIsoAlpha3Code($countryCode);
} catch (\Tx_Oelib_Exception_NotFound $exception) {
$country = null;
}
return $country;
} | php | public function getCountry()
{
$countryCode = $this->getAsString('static_info_country');
if ($countryCode === '') {
return null;
}
try {
/** @var \Tx_Oelib_Mapper_Country $countryMapper */
$countryMapper = \Tx_Oelib_MapperRegistry::get(\Tx_Oelib_Mapper_Country::class);
/** @var \Tx_Oelib_Model_Country $country */
$country = $countryMapper->findByIsoAlpha3Code($countryCode);
} catch (\Tx_Oelib_Exception_NotFound $exception) {
$country = null;
}
return $country;
} | [
"public",
"function",
"getCountry",
"(",
")",
"{",
"$",
"countryCode",
"=",
"$",
"this",
"->",
"getAsString",
"(",
"'static_info_country'",
")",
";",
"if",
"(",
"$",
"countryCode",
"===",
"''",
")",
"{",
"return",
"null",
";",
"}",
"try",
"{",
"/** @var ... | Returns the country of this user as \Tx_Oelib_Model_Country.
Note: This function uses the "country code" field, not the free-text country field.
@return \Tx_Oelib_Model_Country the country of this user, will be NULL if no valid country has been set | [
"Returns",
"the",
"country",
"of",
"this",
"user",
"as",
"\\",
"Tx_Oelib_Model_Country",
"."
] | f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1 | https://github.com/oliverklee/ext-oelib/blob/f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1/Classes/Model/FrontEndUser.php#L679-L696 | train |
oliverklee/ext-oelib | Classes/Model/FrontEndUser.php | Tx_Oelib_Model_FrontEndUser.setCountry | public function setCountry(\Tx_Oelib_Model_Country $country = null)
{
$countryCode = ($country !== null) ? $country->getIsoAlpha3Code() : '';
$this->setAsString('static_info_country', $countryCode);
} | php | public function setCountry(\Tx_Oelib_Model_Country $country = null)
{
$countryCode = ($country !== null) ? $country->getIsoAlpha3Code() : '';
$this->setAsString('static_info_country', $countryCode);
} | [
"public",
"function",
"setCountry",
"(",
"\\",
"Tx_Oelib_Model_Country",
"$",
"country",
"=",
"null",
")",
"{",
"$",
"countryCode",
"=",
"(",
"$",
"country",
"!==",
"null",
")",
"?",
"$",
"country",
"->",
"getIsoAlpha3Code",
"(",
")",
":",
"''",
";",
"$"... | Sets the country of this user.
@param \Tx_Oelib_Model_Country $country
the country to set for this place, can be NULL for "no country"
@return void | [
"Sets",
"the",
"country",
"of",
"this",
"user",
"."
] | f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1 | https://github.com/oliverklee/ext-oelib/blob/f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1/Classes/Model/FrontEndUser.php#L706-L711 | train |
judev/php-intervaltree | src/IntervalTree.php | IntervalTree.search | public function search($interval)
{
if (is_null($this->top_node)) {
return array();
}
$result = $this->find_intervals($interval);
$result = array_values($result);
usort($result, function (RangeInterface $a, RangeInterface $b) {
$x = $a->getStart();
$y = $b->getStart();
$comparedValue = $this->compare($x, $y);
if ($comparedValue == 0) {
$x = $a->getEnd();
$y = $b->getEnd();
$comparedValue = $this->compare($x, $y);
}
return $comparedValue;
});
return $result;
} | php | public function search($interval)
{
if (is_null($this->top_node)) {
return array();
}
$result = $this->find_intervals($interval);
$result = array_values($result);
usort($result, function (RangeInterface $a, RangeInterface $b) {
$x = $a->getStart();
$y = $b->getStart();
$comparedValue = $this->compare($x, $y);
if ($comparedValue == 0) {
$x = $a->getEnd();
$y = $b->getEnd();
$comparedValue = $this->compare($x, $y);
}
return $comparedValue;
});
return $result;
} | [
"public",
"function",
"search",
"(",
"$",
"interval",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"top_node",
")",
")",
"{",
"return",
"array",
"(",
")",
";",
"}",
"$",
"result",
"=",
"$",
"this",
"->",
"find_intervals",
"(",
"$",
"inte... | Search for ranges that overlap the specified value or range.
@param mixed $interval Either a RangeInterface or a value.
@return array | [
"Search",
"for",
"ranges",
"that",
"overlap",
"the",
"specified",
"value",
"or",
"range",
"."
] | 3702f0d0c23f1c3b23da0e10fecdebe49973acb7 | https://github.com/judev/php-intervaltree/blob/3702f0d0c23f1c3b23da0e10fecdebe49973acb7/src/IntervalTree.php#L49-L74 | train |
VM9/orion-explorer-php-frame-work | src/Orion/NGSIAPIv2.php | NGSIAPIv2.post | public function post($url, $requestBody = null) {
$posturl = $this->url . $url;
return $this->restRequest($posturl, 'POST', $requestBody);
} | php | public function post($url, $requestBody = null) {
$posturl = $this->url . $url;
return $this->restRequest($posturl, 'POST', $requestBody);
} | [
"public",
"function",
"post",
"(",
"$",
"url",
",",
"$",
"requestBody",
"=",
"null",
")",
"{",
"$",
"posturl",
"=",
"$",
"this",
"->",
"url",
".",
"$",
"url",
";",
"return",
"$",
"this",
"->",
"restRequest",
"(",
"$",
"posturl",
",",
"'POST'",
",",... | Generic Post Request
@param mixed $url
@param mixed $requestBody
@return HTTPClient | [
"Generic",
"Post",
"Request"
] | f16005de36ec4b86e44eb47a4aa04e37fe5deca6 | https://github.com/VM9/orion-explorer-php-frame-work/blob/f16005de36ec4b86e44eb47a4aa04e37fe5deca6/src/Orion/NGSIAPIv2.php#L109-L112 | train |
vinicius73/SeoTools | src/Vinicius73/SEO/SitemapRun.php | SitemapRun.run | public function run()
{
$this->generator->addRaw(
array(
'location' => 'example.com',
'last_modified' => '2013-01-28',
'change_frequency' => 'weekly',
'priority' => '0.65'
)
);
$this->generator->addRaw(
array(
'location' => 'example.com/test',
'last_modified' => '2013-12-28',
'change_frequency' => 'weekly',
'priority' => '0.95'
)
);
$this->generator->addRaw(
array(
'location' => 'example.com/test/2',
'last_modified' => '2013-12-25',
'change_frequency' => 'weekly',
'priority' => '0.99'
)
);
return $this->generator->generate();
} | php | public function run()
{
$this->generator->addRaw(
array(
'location' => 'example.com',
'last_modified' => '2013-01-28',
'change_frequency' => 'weekly',
'priority' => '0.65'
)
);
$this->generator->addRaw(
array(
'location' => 'example.com/test',
'last_modified' => '2013-12-28',
'change_frequency' => 'weekly',
'priority' => '0.95'
)
);
$this->generator->addRaw(
array(
'location' => 'example.com/test/2',
'last_modified' => '2013-12-25',
'change_frequency' => 'weekly',
'priority' => '0.99'
)
);
return $this->generator->generate();
} | [
"public",
"function",
"run",
"(",
")",
"{",
"$",
"this",
"->",
"generator",
"->",
"addRaw",
"(",
"array",
"(",
"'location'",
"=>",
"'example.com'",
",",
"'last_modified'",
"=>",
"'2013-01-28'",
",",
"'change_frequency'",
"=>",
"'weekly'",
",",
"'priority'",
"=... | Run generator commands | [
"Run",
"generator",
"commands"
] | 5d2543482921713e0676c310ff8b23b2989443a1 | https://github.com/vinicius73/SeoTools/blob/5d2543482921713e0676c310ff8b23b2989443a1/src/Vinicius73/SEO/SitemapRun.php#L20-L50 | train |
oliverklee/ext-oelib | Classes/Email/SystemEmailFromBuilder.php | SystemEmailFromBuilder.canBuild | public function canBuild()
{
$configuration = $this->getEmailConfiguration();
$emailAddress = (string)$configuration['defaultMailFromAddress'];
return \filter_var($emailAddress, FILTER_VALIDATE_EMAIL) !== false;
} | php | public function canBuild()
{
$configuration = $this->getEmailConfiguration();
$emailAddress = (string)$configuration['defaultMailFromAddress'];
return \filter_var($emailAddress, FILTER_VALIDATE_EMAIL) !== false;
} | [
"public",
"function",
"canBuild",
"(",
")",
"{",
"$",
"configuration",
"=",
"$",
"this",
"->",
"getEmailConfiguration",
"(",
")",
";",
"$",
"emailAddress",
"=",
"(",
"string",
")",
"$",
"configuration",
"[",
"'defaultMailFromAddress'",
"]",
";",
"return",
"\... | Checks whether a valid email address has been set as defaultMailFromAddress.
@return bool | [
"Checks",
"whether",
"a",
"valid",
"email",
"address",
"has",
"been",
"set",
"as",
"defaultMailFromAddress",
"."
] | f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1 | https://github.com/oliverklee/ext-oelib/blob/f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1/Classes/Email/SystemEmailFromBuilder.php#L19-L25 | train |
oliverklee/ext-oelib | Classes/Domain/Model/Traits/CachedAssociationCount.php | CachedAssociationCount.getCachedRelationCount | protected function getCachedRelationCount($propertyName)
{
if (array_key_exists($propertyName, $this->cachedRelationCountsCount)) {
return $this->cachedRelationCountsCount[$propertyName];
}
$this->cachedRelationCountsCount[$propertyName] = $this->getUncachedRelationCount($propertyName);
return $this->cachedRelationCountsCount[$propertyName];
} | php | protected function getCachedRelationCount($propertyName)
{
if (array_key_exists($propertyName, $this->cachedRelationCountsCount)) {
return $this->cachedRelationCountsCount[$propertyName];
}
$this->cachedRelationCountsCount[$propertyName] = $this->getUncachedRelationCount($propertyName);
return $this->cachedRelationCountsCount[$propertyName];
} | [
"protected",
"function",
"getCachedRelationCount",
"(",
"$",
"propertyName",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"propertyName",
",",
"$",
"this",
"->",
"cachedRelationCountsCount",
")",
")",
"{",
"return",
"$",
"this",
"->",
"cachedRelationCountsCo... | Retrieves and caches the relation count for the given property.
@param string $propertyName the name of the relation (plural, lower camelCase)
@return int | [
"Retrieves",
"and",
"caches",
"the",
"relation",
"count",
"for",
"the",
"given",
"property",
"."
] | f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1 | https://github.com/oliverklee/ext-oelib/blob/f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1/Classes/Domain/Model/Traits/CachedAssociationCount.php#L34-L43 | train |
oliverklee/ext-oelib | Classes/Domain/Model/Traits/CachedAssociationCount.php | CachedAssociationCount.getUncachedRelationCount | protected function getUncachedRelationCount($propertyName)
{
if ($this->$propertyName instanceof LazyObjectStorage) {
$reflectionClass = new \ReflectionClass(LazyObjectStorage::class);
$reflectionProperty = $reflectionClass->getProperty('fieldValue');
$reflectionProperty->setAccessible(true);
$count = (int)$reflectionProperty->getValue($this->$propertyName);
} else {
$count = $this->$propertyName->count();
}
return $count;
} | php | protected function getUncachedRelationCount($propertyName)
{
if ($this->$propertyName instanceof LazyObjectStorage) {
$reflectionClass = new \ReflectionClass(LazyObjectStorage::class);
$reflectionProperty = $reflectionClass->getProperty('fieldValue');
$reflectionProperty->setAccessible(true);
$count = (int)$reflectionProperty->getValue($this->$propertyName);
} else {
$count = $this->$propertyName->count();
}
return $count;
} | [
"protected",
"function",
"getUncachedRelationCount",
"(",
"$",
"propertyName",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"$",
"propertyName",
"instanceof",
"LazyObjectStorage",
")",
"{",
"$",
"reflectionClass",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"LazyObjectSt... | Retrieves the relation count for the given property.
This methods tries to avoid database accesses by using the relation counter cache if the relation is still
a LazyObjectStorage. Otherwise, the normal COUNT query will be performed as a fallback.
This method does not cache its results.
@param string $propertyName the name of the relation (plural, lower camelCase)
@return int
@throws \ReflectionException | [
"Retrieves",
"the",
"relation",
"count",
"for",
"the",
"given",
"property",
"."
] | f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1 | https://github.com/oliverklee/ext-oelib/blob/f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1/Classes/Domain/Model/Traits/CachedAssociationCount.php#L71-L83 | train |
oliverklee/ext-oelib | Classes/PageFinder.php | Tx_Oelib_PageFinder.getPageUid | public function getPageUid()
{
switch ($this->getCurrentSource()) {
case self::SOURCE_MANUAL:
$result = $this->storedPageUid;
break;
case self::SOURCE_FRONT_END:
$result = (int)$this->getFrontEndController()->id;
break;
case self::SOURCE_BACK_END:
$result = (int)GeneralUtility::_GP('id');
break;
default:
$result = 0;
}
return $result;
} | php | public function getPageUid()
{
switch ($this->getCurrentSource()) {
case self::SOURCE_MANUAL:
$result = $this->storedPageUid;
break;
case self::SOURCE_FRONT_END:
$result = (int)$this->getFrontEndController()->id;
break;
case self::SOURCE_BACK_END:
$result = (int)GeneralUtility::_GP('id');
break;
default:
$result = 0;
}
return $result;
} | [
"public",
"function",
"getPageUid",
"(",
")",
"{",
"switch",
"(",
"$",
"this",
"->",
"getCurrentSource",
"(",
")",
")",
"{",
"case",
"self",
"::",
"SOURCE_MANUAL",
":",
"$",
"result",
"=",
"$",
"this",
"->",
"storedPageUid",
";",
"break",
";",
"case",
... | Returns the UID of the current page.
If manualPageUidSource is set to SOURCE_FRONT_END or SOURCE_BACK_END, this
function returns the UID set in this part. Otherwise starts with looking
into the manually set page UID, then if a FE page UID is present
and finally if a BE page UID is present.
@return int the ID of the current page, will be zero if no page is
present or no page source could be found | [
"Returns",
"the",
"UID",
"of",
"the",
"current",
"page",
"."
] | f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1 | https://github.com/oliverklee/ext-oelib/blob/f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1/Classes/PageFinder.php#L95-L112 | train |
oliverklee/ext-oelib | Classes/PageFinder.php | Tx_Oelib_PageFinder.getCurrentSource | public function getCurrentSource()
{
if ($this->manualPageUidSource !== self::SOURCE_AUTO) {
$result = $this->manualPageUidSource;
} elseif ($this->hasManualPageUid()) {
$result = self::SOURCE_MANUAL;
} elseif ($this->hasFrontEnd()) {
$result = self::SOURCE_FRONT_END;
} elseif ($this->hasBackEnd()) {
$result = self::SOURCE_BACK_END;
} else {
$result = self::NO_SOURCE_FOUND;
}
return $result;
} | php | public function getCurrentSource()
{
if ($this->manualPageUidSource !== self::SOURCE_AUTO) {
$result = $this->manualPageUidSource;
} elseif ($this->hasManualPageUid()) {
$result = self::SOURCE_MANUAL;
} elseif ($this->hasFrontEnd()) {
$result = self::SOURCE_FRONT_END;
} elseif ($this->hasBackEnd()) {
$result = self::SOURCE_BACK_END;
} else {
$result = self::NO_SOURCE_FOUND;
}
return $result;
} | [
"public",
"function",
"getCurrentSource",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"manualPageUidSource",
"!==",
"self",
"::",
"SOURCE_AUTO",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"manualPageUidSource",
";",
"}",
"elseif",
"(",
"$",
"this",
... | Returns the current source for the page UID.
@return int either SOURCE_BACK_END, SOURCE_FRONT_END or SOURCE_MANUAL,
will be NO_SOURCE_FOUND if no source could be detected | [
"Returns",
"the",
"current",
"source",
"for",
"the",
"page",
"UID",
"."
] | f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1 | https://github.com/oliverklee/ext-oelib/blob/f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1/Classes/PageFinder.php#L151-L166 | train |
wp-jungle/baobab | src/Baobab/Helper/Views.php | Views.pickView | public static function pickView($stack)
{
$viewRoot = trailingslashit(Paths::views());
foreach ($stack as $id)
{
$innerPath = str_replace('.', '/', $id);
$innerPath .= '.blade.php';
if (file_exists($viewRoot . $innerPath)) return $id;
}
return null;
} | php | public static function pickView($stack)
{
$viewRoot = trailingslashit(Paths::views());
foreach ($stack as $id)
{
$innerPath = str_replace('.', '/', $id);
$innerPath .= '.blade.php';
if (file_exists($viewRoot . $innerPath)) return $id;
}
return null;
} | [
"public",
"static",
"function",
"pickView",
"(",
"$",
"stack",
")",
"{",
"$",
"viewRoot",
"=",
"trailingslashit",
"(",
"Paths",
"::",
"views",
"(",
")",
")",
";",
"foreach",
"(",
"$",
"stack",
"as",
"$",
"id",
")",
"{",
"$",
"innerPath",
"=",
"str_re... | Pick the first view found in the stack
@param array $stack A list of view names by priority order
@return null|string The first view that really exists or null if no view was found | [
"Pick",
"the",
"first",
"view",
"found",
"in",
"the",
"stack"
] | ed2a9f2bbc3d194aa4df454b50aec43796fc68da | https://github.com/wp-jungle/baobab/blob/ed2a9f2bbc3d194aa4df454b50aec43796fc68da/src/Baobab/Helper/Views.php#L36-L47 | train |
wp-jungle/baobab | src/Baobab/Helper/Posts.php | Posts.mainPageTitle | public static function mainPageTitle()
{
if (is_home())
{
if (get_option('page_for_posts', true))
{
return get_the_title(get_option('page_for_posts', true));
}
else
{
return __('Latest Posts', 'baobab');
}
}
elseif (is_archive())
{
$term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy'));
if ($term)
{
return apply_filters('single_term_title', $term->name);
}
elseif (is_post_type_archive())
{
return apply_filters('the_title', get_queried_object()->labels->name);
}
elseif (is_day())
{
return sprintf(__('Daily Archives: %s', 'baobab'), get_the_date());
}
elseif (is_month())
{
return sprintf(__('Monthly Archives: %s', 'baobab'), get_the_date('F Y'));
}
elseif (is_year())
{
return sprintf(__('Yearly Archives: %s', 'baobab'), get_the_date('Y'));
}
elseif (is_author())
{
$author = get_queried_object();
return sprintf(__('Author Archives: %s', 'baobab'),
apply_filters('the_author', is_object($author) ? $author->display_name : null));
}
else
{
return single_cat_title('', false);
}
}
elseif (is_search())
{
return sprintf(__('Search Results for %s', 'baobab'), get_search_query());
}
elseif (is_404())
{
return __('Not Found', 'baobab');
}
else
{
return get_the_title();
}
} | php | public static function mainPageTitle()
{
if (is_home())
{
if (get_option('page_for_posts', true))
{
return get_the_title(get_option('page_for_posts', true));
}
else
{
return __('Latest Posts', 'baobab');
}
}
elseif (is_archive())
{
$term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy'));
if ($term)
{
return apply_filters('single_term_title', $term->name);
}
elseif (is_post_type_archive())
{
return apply_filters('the_title', get_queried_object()->labels->name);
}
elseif (is_day())
{
return sprintf(__('Daily Archives: %s', 'baobab'), get_the_date());
}
elseif (is_month())
{
return sprintf(__('Monthly Archives: %s', 'baobab'), get_the_date('F Y'));
}
elseif (is_year())
{
return sprintf(__('Yearly Archives: %s', 'baobab'), get_the_date('Y'));
}
elseif (is_author())
{
$author = get_queried_object();
return sprintf(__('Author Archives: %s', 'baobab'),
apply_filters('the_author', is_object($author) ? $author->display_name : null));
}
else
{
return single_cat_title('', false);
}
}
elseif (is_search())
{
return sprintf(__('Search Results for %s', 'baobab'), get_search_query());
}
elseif (is_404())
{
return __('Not Found', 'baobab');
}
else
{
return get_the_title();
}
} | [
"public",
"static",
"function",
"mainPageTitle",
"(",
")",
"{",
"if",
"(",
"is_home",
"(",
")",
")",
"{",
"if",
"(",
"get_option",
"(",
"'page_for_posts'",
",",
"true",
")",
")",
"{",
"return",
"get_the_title",
"(",
"get_option",
"(",
"'page_for_posts'",
"... | You can use this to output a proper title for your page. This handles special cases such as archive page titles,
taxonomy archives, etc.
@return string A nice page title | [
"You",
"can",
"use",
"this",
"to",
"output",
"a",
"proper",
"title",
"for",
"your",
"page",
".",
"This",
"handles",
"special",
"cases",
"such",
"as",
"archive",
"page",
"titles",
"taxonomy",
"archives",
"etc",
"."
] | ed2a9f2bbc3d194aa4df454b50aec43796fc68da | https://github.com/wp-jungle/baobab/blob/ed2a9f2bbc3d194aa4df454b50aec43796fc68da/src/Baobab/Helper/Posts.php#L20-L80 | train |
webeweb/jquery-datatables-bundle | Repository/DefaultDataTablesRepository.php | DefaultDataTablesRepository.buildDataTablesCountExported | protected function buildDataTablesCountExported(DataTablesProviderInterface $dtProvider) {
$prefix = $dtProvider->getPrefix();
$qb = $this->createQueryBuilder($prefix)
->select("COUNT(" . $prefix . ")");
return $qb;
} | php | protected function buildDataTablesCountExported(DataTablesProviderInterface $dtProvider) {
$prefix = $dtProvider->getPrefix();
$qb = $this->createQueryBuilder($prefix)
->select("COUNT(" . $prefix . ")");
return $qb;
} | [
"protected",
"function",
"buildDataTablesCountExported",
"(",
"DataTablesProviderInterface",
"$",
"dtProvider",
")",
"{",
"$",
"prefix",
"=",
"$",
"dtProvider",
"->",
"getPrefix",
"(",
")",
";",
"$",
"qb",
"=",
"$",
"this",
"->",
"createQueryBuilder",
"(",
"$",
... | Build a query builder "Count exported".
@param DataTablesProviderInterface $dtProvider The provider.
@return QueryBuilder Returns the query builder "Count exported". | [
"Build",
"a",
"query",
"builder",
"Count",
"exported",
"."
] | b53df9585a523fa1617128e6b467a5e574262a94 | https://github.com/webeweb/jquery-datatables-bundle/blob/b53df9585a523fa1617128e6b467a5e574262a94/Repository/DefaultDataTablesRepository.php#L35-L43 | train |
webeweb/jquery-datatables-bundle | Repository/DefaultDataTablesRepository.php | DefaultDataTablesRepository.buildDataTablesCountFiltered | protected function buildDataTablesCountFiltered(DataTablesWrapperInterface $dtWrapper) {
$prefix = $dtWrapper->getMapping()->getPrefix();
$qb = $this->createQueryBuilder($prefix)
->select("COUNT(" . $prefix . ")");
DataTablesRepositoryHelper::appendWhere($qb, $dtWrapper);
return $qb;
} | php | protected function buildDataTablesCountFiltered(DataTablesWrapperInterface $dtWrapper) {
$prefix = $dtWrapper->getMapping()->getPrefix();
$qb = $this->createQueryBuilder($prefix)
->select("COUNT(" . $prefix . ")");
DataTablesRepositoryHelper::appendWhere($qb, $dtWrapper);
return $qb;
} | [
"protected",
"function",
"buildDataTablesCountFiltered",
"(",
"DataTablesWrapperInterface",
"$",
"dtWrapper",
")",
"{",
"$",
"prefix",
"=",
"$",
"dtWrapper",
"->",
"getMapping",
"(",
")",
"->",
"getPrefix",
"(",
")",
";",
"$",
"qb",
"=",
"$",
"this",
"->",
"... | Build a query builder "Count filtered".
@param DataTablesWrapperInterface $dtWrapper The wrapper.
@return QueryBuilder Returns the query builder "Count filtered". | [
"Build",
"a",
"query",
"builder",
"Count",
"filtered",
"."
] | b53df9585a523fa1617128e6b467a5e574262a94 | https://github.com/webeweb/jquery-datatables-bundle/blob/b53df9585a523fa1617128e6b467a5e574262a94/Repository/DefaultDataTablesRepository.php#L51-L61 | train |
webeweb/jquery-datatables-bundle | Repository/DefaultDataTablesRepository.php | DefaultDataTablesRepository.buildDataTablesCountTotal | protected function buildDataTablesCountTotal(DataTablesWrapperInterface $dtWrapper) {
$prefix = $dtWrapper->getMapping()->getPrefix();
$qb = $this->createQueryBuilder($prefix)
->select("COUNT(" . $prefix . ")");
return $qb;
} | php | protected function buildDataTablesCountTotal(DataTablesWrapperInterface $dtWrapper) {
$prefix = $dtWrapper->getMapping()->getPrefix();
$qb = $this->createQueryBuilder($prefix)
->select("COUNT(" . $prefix . ")");
return $qb;
} | [
"protected",
"function",
"buildDataTablesCountTotal",
"(",
"DataTablesWrapperInterface",
"$",
"dtWrapper",
")",
"{",
"$",
"prefix",
"=",
"$",
"dtWrapper",
"->",
"getMapping",
"(",
")",
"->",
"getPrefix",
"(",
")",
";",
"$",
"qb",
"=",
"$",
"this",
"->",
"cre... | Build a query builder "Count total".
@param DataTablesWrapperInterface $dtWrapper The wrapper.
@return QueryBuilder Returns the query builder "Count total". | [
"Build",
"a",
"query",
"builder",
"Count",
"total",
"."
] | b53df9585a523fa1617128e6b467a5e574262a94 | https://github.com/webeweb/jquery-datatables-bundle/blob/b53df9585a523fa1617128e6b467a5e574262a94/Repository/DefaultDataTablesRepository.php#L69-L77 | train |
webeweb/jquery-datatables-bundle | Repository/DefaultDataTablesRepository.php | DefaultDataTablesRepository.buildDataTablesFindAll | protected function buildDataTablesFindAll(DataTablesWrapperInterface $dtWrapper) {
$prefix = $dtWrapper->getMapping()->getPrefix();
$qb = $this->createQueryBuilder($prefix)
->setFirstResult($dtWrapper->getRequest()->getStart());
if (0 < $dtWrapper->getRequest()->getLength()) {
$qb->setMaxResults($dtWrapper->getRequest()->getLength());
}
DataTablesRepositoryHelper::appendWhere($qb, $dtWrapper);
DataTablesRepositoryHelper::appendOrder($qb, $dtWrapper);
return $qb;
} | php | protected function buildDataTablesFindAll(DataTablesWrapperInterface $dtWrapper) {
$prefix = $dtWrapper->getMapping()->getPrefix();
$qb = $this->createQueryBuilder($prefix)
->setFirstResult($dtWrapper->getRequest()->getStart());
if (0 < $dtWrapper->getRequest()->getLength()) {
$qb->setMaxResults($dtWrapper->getRequest()->getLength());
}
DataTablesRepositoryHelper::appendWhere($qb, $dtWrapper);
DataTablesRepositoryHelper::appendOrder($qb, $dtWrapper);
return $qb;
} | [
"protected",
"function",
"buildDataTablesFindAll",
"(",
"DataTablesWrapperInterface",
"$",
"dtWrapper",
")",
"{",
"$",
"prefix",
"=",
"$",
"dtWrapper",
"->",
"getMapping",
"(",
")",
"->",
"getPrefix",
"(",
")",
";",
"$",
"qb",
"=",
"$",
"this",
"->",
"create... | Build a query builder "Find all".
@param DataTablesWrapperInterface $dtWrapper The wrapper.
@return QueryBuilder Returns the query builder "Find all". | [
"Build",
"a",
"query",
"builder",
"Find",
"all",
"."
] | b53df9585a523fa1617128e6b467a5e574262a94 | https://github.com/webeweb/jquery-datatables-bundle/blob/b53df9585a523fa1617128e6b467a5e574262a94/Repository/DefaultDataTablesRepository.php#L98-L112 | train |
webeweb/jquery-datatables-bundle | Helper/DataTablesExportHelper.php | DataTablesExportHelper.isWindows | public static function isWindows(Request $request) {
if (false === $request->headers->has("user-agent")) {
return false;
}
$dd = new DeviceDetector($request->headers->get("user-agent"));
$dd->parse();
$os = $dd->getOs("name");
return 1 === preg_match("/Windows/", $os);
} | php | public static function isWindows(Request $request) {
if (false === $request->headers->has("user-agent")) {
return false;
}
$dd = new DeviceDetector($request->headers->get("user-agent"));
$dd->parse();
$os = $dd->getOs("name");
return 1 === preg_match("/Windows/", $os);
} | [
"public",
"static",
"function",
"isWindows",
"(",
"Request",
"$",
"request",
")",
"{",
"if",
"(",
"false",
"===",
"$",
"request",
"->",
"headers",
"->",
"has",
"(",
"\"user-agent\"",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"dd",
"=",
"new",
... | Determines if the operating system is windows.
@param Request $request The request.
@return bool Returns true in case of success, false otherwise. | [
"Determines",
"if",
"the",
"operating",
"system",
"is",
"windows",
"."
] | b53df9585a523fa1617128e6b467a5e574262a94 | https://github.com/webeweb/jquery-datatables-bundle/blob/b53df9585a523fa1617128e6b467a5e574262a94/Helper/DataTablesExportHelper.php#L47-L59 | train |
wp-jungle/baobab | src/Baobab/Ajax/Ajax.php | Ajax.generateNonceField | public function generateNonceField($action)
{
$nonceName = $this->namespace . '_' . $action;
return wp_nonce_field(md5($nonceName), $nonceName, true, false);
} | php | public function generateNonceField($action)
{
$nonceName = $this->namespace . '_' . $action;
return wp_nonce_field(md5($nonceName), $nonceName, true, false);
} | [
"public",
"function",
"generateNonceField",
"(",
"$",
"action",
")",
"{",
"$",
"nonceName",
"=",
"$",
"this",
"->",
"namespace",
".",
"'_'",
".",
"$",
"action",
";",
"return",
"wp_nonce_field",
"(",
"md5",
"(",
"$",
"nonceName",
")",
",",
"$",
"nonceName... | Get the HTML hidden field to print in your form to protect it
@param string $action The ajax action you are referring to
@return string The HTML code to print in your form | [
"Get",
"the",
"HTML",
"hidden",
"field",
"to",
"print",
"in",
"your",
"form",
"to",
"protect",
"it"
] | ed2a9f2bbc3d194aa4df454b50aec43796fc68da | https://github.com/wp-jungle/baobab/blob/ed2a9f2bbc3d194aa4df454b50aec43796fc68da/src/Baobab/Ajax/Ajax.php#L88-L93 | train |
mocdk/MOC.Varnish | Classes/Service/CacheControlService.php | CacheControlService.getCacheTagsAndLifetime | protected function getCacheTagsAndLifetime()
{
$lifetime = null;
$tags = array();
$entriesMetadata = $this->contentCacheFrontend->getAllMetadata();
foreach ($entriesMetadata as $identifier => $metadata) {
$entryTags = isset($metadata['tags']) ? $metadata['tags'] : array();
$entryLifetime = isset($metadata['lifetime']) ? $metadata['lifetime'] : null;
if ($entryLifetime !== null) {
if ($lifetime === null) {
$lifetime = $entryLifetime;
} else {
$lifetime = min($lifetime, $entryLifetime);
}
}
$tags = array_unique(array_merge($tags, $entryTags));
}
return array($tags, $lifetime);
} | php | protected function getCacheTagsAndLifetime()
{
$lifetime = null;
$tags = array();
$entriesMetadata = $this->contentCacheFrontend->getAllMetadata();
foreach ($entriesMetadata as $identifier => $metadata) {
$entryTags = isset($metadata['tags']) ? $metadata['tags'] : array();
$entryLifetime = isset($metadata['lifetime']) ? $metadata['lifetime'] : null;
if ($entryLifetime !== null) {
if ($lifetime === null) {
$lifetime = $entryLifetime;
} else {
$lifetime = min($lifetime, $entryLifetime);
}
}
$tags = array_unique(array_merge($tags, $entryTags));
}
return array($tags, $lifetime);
} | [
"protected",
"function",
"getCacheTagsAndLifetime",
"(",
")",
"{",
"$",
"lifetime",
"=",
"null",
";",
"$",
"tags",
"=",
"array",
"(",
")",
";",
"$",
"entriesMetadata",
"=",
"$",
"this",
"->",
"contentCacheFrontend",
"->",
"getAllMetadata",
"(",
")",
";",
"... | Get cache tags and lifetime from the cache metadata that was extracted by the special cache frontend
@return array | [
"Get",
"cache",
"tags",
"and",
"lifetime",
"from",
"the",
"cache",
"metadata",
"that",
"was",
"extracted",
"by",
"the",
"special",
"cache",
"frontend"
] | f7f4cec4ceb0ce03ca259e896d8f75a645272759 | https://github.com/mocdk/MOC.Varnish/blob/f7f4cec4ceb0ce03ca259e896d8f75a645272759/Classes/Service/CacheControlService.php#L131-L150 | train |
mocdk/MOC.Varnish | Classes/Service/VarnishBanService.php | VarnishBanService.banAll | public function banAll($domains = null, $contentType = null)
{
$this->cacheInvalidator->invalidateRegex('.*', $contentType, $domains);
$this->logger->log(sprintf('Cleared all Varnish cache%s%s', $domains ? ' for domains "' . (is_array($domains) ? implode(', ', $domains) : $domains) . '"' : '', $contentType ? ' with content type "' . $contentType . '"' : ''));
$this->execute();
} | php | public function banAll($domains = null, $contentType = null)
{
$this->cacheInvalidator->invalidateRegex('.*', $contentType, $domains);
$this->logger->log(sprintf('Cleared all Varnish cache%s%s', $domains ? ' for domains "' . (is_array($domains) ? implode(', ', $domains) : $domains) . '"' : '', $contentType ? ' with content type "' . $contentType . '"' : ''));
$this->execute();
} | [
"public",
"function",
"banAll",
"(",
"$",
"domains",
"=",
"null",
",",
"$",
"contentType",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"cacheInvalidator",
"->",
"invalidateRegex",
"(",
"'.*'",
",",
"$",
"contentType",
",",
"$",
"domains",
")",
";",
"$",
... | Clear all cache in Varnish for a optionally given domain & content type.
The hosts parameter can either be a regular expression, e.g.
'^(www\.)?(this|that)\.com$' or an array of exact host names, e.g.
['example.com', 'other.net']. If the parameter is empty, all hosts
are matched.
@param array|string $domains The domains to flush, e.g. "example.com"
@param string $contentType The mime type to flush, e.g. "image/png"
@return void | [
"Clear",
"all",
"cache",
"in",
"Varnish",
"for",
"a",
"optionally",
"given",
"domain",
"&",
"content",
"type",
"."
] | f7f4cec4ceb0ce03ca259e896d8f75a645272759 | https://github.com/mocdk/MOC.Varnish/blob/f7f4cec4ceb0ce03ca259e896d8f75a645272759/Classes/Service/VarnishBanService.php#L87-L92 | train |
mocdk/MOC.Varnish | Classes/Service/VarnishBanService.php | VarnishBanService.banByTags | public function banByTags(array $tags, $domains = null)
{
if (count($this->settings['ignoredCacheTags']) > 0) {
$tags = array_diff($tags, $this->settings['ignoredCacheTags']);
}
/**
* Sanitize tags
* @see \Neos\Fusion\Core\Cache\ContentCache
*/
foreach ($tags as $key => $tag) {
$tags[$key] = strtr($tag, '.:', '_-');
}
// Set specific domain before invalidating tags
if ($domains) {
$this->varnishProxyClient->setDefaultBanHeader(ProxyClient\Varnish::HTTP_HEADER_HOST, is_array($domains) ? '^(' . implode('|', $domains) . ')$' : $domains);
}
$this->tagHandler->invalidateTags($tags);
// Unset specific domain after invalidating tags
if ($domains) {
$this->varnishProxyClient->setDefaultBanHeader(ProxyClient\Varnish::HTTP_HEADER_HOST, ProxyClient\Varnish::REGEX_MATCH_ALL);
}
$this->logger->log(sprintf('Cleared Varnish cache for tags "%s"%s', implode(',', $tags), $domains ? ' for domains "' . (is_array($domains) ? implode(', ', $domains) : $domains) . '"' : ''));
$this->execute();
} | php | public function banByTags(array $tags, $domains = null)
{
if (count($this->settings['ignoredCacheTags']) > 0) {
$tags = array_diff($tags, $this->settings['ignoredCacheTags']);
}
/**
* Sanitize tags
* @see \Neos\Fusion\Core\Cache\ContentCache
*/
foreach ($tags as $key => $tag) {
$tags[$key] = strtr($tag, '.:', '_-');
}
// Set specific domain before invalidating tags
if ($domains) {
$this->varnishProxyClient->setDefaultBanHeader(ProxyClient\Varnish::HTTP_HEADER_HOST, is_array($domains) ? '^(' . implode('|', $domains) . ')$' : $domains);
}
$this->tagHandler->invalidateTags($tags);
// Unset specific domain after invalidating tags
if ($domains) {
$this->varnishProxyClient->setDefaultBanHeader(ProxyClient\Varnish::HTTP_HEADER_HOST, ProxyClient\Varnish::REGEX_MATCH_ALL);
}
$this->logger->log(sprintf('Cleared Varnish cache for tags "%s"%s', implode(',', $tags), $domains ? ' for domains "' . (is_array($domains) ? implode(', ', $domains) : $domains) . '"' : ''));
$this->execute();
} | [
"public",
"function",
"banByTags",
"(",
"array",
"$",
"tags",
",",
"$",
"domains",
"=",
"null",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"settings",
"[",
"'ignoredCacheTags'",
"]",
")",
">",
"0",
")",
"{",
"$",
"tags",
"=",
"array_diff",... | Clear all cache in Varnish for given tags.
The hosts parameter can either be a regular expression, e.g.
'^(www\.)?(this|that)\.com$' or an array of exact host names, e.g.
['example.com', 'other.net']. If the parameter is empty, all hosts
are matched.
@param array $tags
@param array|string $domains The domain to flush, e.g. "example.com"
@return void | [
"Clear",
"all",
"cache",
"in",
"Varnish",
"for",
"given",
"tags",
"."
] | f7f4cec4ceb0ce03ca259e896d8f75a645272759 | https://github.com/mocdk/MOC.Varnish/blob/f7f4cec4ceb0ce03ca259e896d8f75a645272759/Classes/Service/VarnishBanService.php#L106-L131 | train |
Distilleries/Expendable | src/Distilleries/Expendable/Http/Router/Router.php | Router.addFallthroughRoute | protected function addFallthroughRoute($controller, $uri)
{
$missing = $this->any($uri.'/{_missing}', $controller.'@missingMethod');
$missing->where('_missing', '(.*)');
} | php | protected function addFallthroughRoute($controller, $uri)
{
$missing = $this->any($uri.'/{_missing}', $controller.'@missingMethod');
$missing->where('_missing', '(.*)');
} | [
"protected",
"function",
"addFallthroughRoute",
"(",
"$",
"controller",
",",
"$",
"uri",
")",
"{",
"$",
"missing",
"=",
"$",
"this",
"->",
"any",
"(",
"$",
"uri",
".",
"'/{_missing}'",
",",
"$",
"controller",
".",
"'@missingMethod'",
")",
";",
"$",
"miss... | Add a fallthrough route for a controller.
@param string $controller
@param string $uri
@return void | [
"Add",
"a",
"fallthrough",
"route",
"for",
"a",
"controller",
"."
] | badfdabb7fc78447906fc9856bd313f2f1dbae8d | https://github.com/Distilleries/Expendable/blob/badfdabb7fc78447906fc9856bd313f2f1dbae8d/src/Distilleries/Expendable/Http/Router/Router.php#L102-L106 | train |
oliverklee/ext-oelib | Classes/Db.php | Tx_Oelib_Db.select | public static function select(
$fields,
$tableNames,
$whereClause = '',
$groupBy = '',
$orderBy = '',
$limit = ''
) {
if ($tableNames === '') {
throw new \InvalidArgumentException('The table names must not be empty.', 1331488261);
}
if ($fields === '') {
throw new \InvalidArgumentException('$fields must not be empty.', 1331488270);
}
self::enableQueryLogging();
$dbResult = self::getDatabaseConnection()->exec_SELECTquery(
$fields,
$tableNames,
$whereClause,
$groupBy,
$orderBy,
$limit
);
if (!$dbResult) {
throw new \Tx_Oelib_Exception_Database();
}
return $dbResult;
} | php | public static function select(
$fields,
$tableNames,
$whereClause = '',
$groupBy = '',
$orderBy = '',
$limit = ''
) {
if ($tableNames === '') {
throw new \InvalidArgumentException('The table names must not be empty.', 1331488261);
}
if ($fields === '') {
throw new \InvalidArgumentException('$fields must not be empty.', 1331488270);
}
self::enableQueryLogging();
$dbResult = self::getDatabaseConnection()->exec_SELECTquery(
$fields,
$tableNames,
$whereClause,
$groupBy,
$orderBy,
$limit
);
if (!$dbResult) {
throw new \Tx_Oelib_Exception_Database();
}
return $dbResult;
} | [
"public",
"static",
"function",
"select",
"(",
"$",
"fields",
",",
"$",
"tableNames",
",",
"$",
"whereClause",
"=",
"''",
",",
"$",
"groupBy",
"=",
"''",
",",
"$",
"orderBy",
"=",
"''",
",",
"$",
"limit",
"=",
"''",
")",
"{",
"if",
"(",
"$",
"tab... | Executes a SELECT query.
@param string $fields list of fields to select, may be "*", must not be empty
@param string $tableNames comma-separated list of tables from which to select, must not be empty
@param string $whereClause WHERE clause, may be empty
@param string $groupBy GROUP BY field(s), may be empty
@param string $orderBy ORDER BY field(s), may be empty
@param string $limit LIMIT value ([begin,]max), may be empty
@return \mysqli_result MySQLi result object
@throws \InvalidArgumentException
@throws \Tx_Oelib_Exception_Database if an error has occurred | [
"Executes",
"a",
"SELECT",
"query",
"."
] | f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1 | https://github.com/oliverklee/ext-oelib/blob/f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1/Classes/Db.php#L316-L345 | train |
oliverklee/ext-oelib | Classes/Db.php | Tx_Oelib_Db.selectSingle | public static function selectSingle(
$fields,
$tableNames,
$whereClause = '',
$groupBy = '',
$orderBy = '',
$offset = 0
) {
$result = self::selectMultiple(
$fields,
$tableNames,
$whereClause,
$groupBy,
$orderBy,
$offset . ',' . 1
);
if (empty($result)) {
throw new \Tx_Oelib_Exception_EmptyQueryResult();
}
return $result[0];
} | php | public static function selectSingle(
$fields,
$tableNames,
$whereClause = '',
$groupBy = '',
$orderBy = '',
$offset = 0
) {
$result = self::selectMultiple(
$fields,
$tableNames,
$whereClause,
$groupBy,
$orderBy,
$offset . ',' . 1
);
if (empty($result)) {
throw new \Tx_Oelib_Exception_EmptyQueryResult();
}
return $result[0];
} | [
"public",
"static",
"function",
"selectSingle",
"(",
"$",
"fields",
",",
"$",
"tableNames",
",",
"$",
"whereClause",
"=",
"''",
",",
"$",
"groupBy",
"=",
"''",
",",
"$",
"orderBy",
"=",
"''",
",",
"$",
"offset",
"=",
"0",
")",
"{",
"$",
"result",
"... | Executes a SELECT query and returns the single result row as an
associative array.
If there is more than one matching record, only one will be returned.
@param string $fields list of fields to select, may be "*", must not be empty
@param string $tableNames
comma-separated list of tables from which to select, must not be empty
@param string $whereClause WHERE clause, may be empty
@param string $groupBy GROUP BY field(s), may be empty
@param string $orderBy ORDER BY field(s), may be empty
@param int $offset the offset to start the result for, must be >= 0
@return string[] the single result row, will not be empty
@throws \Tx_Oelib_Exception_EmptyQueryResult if there is no matching record | [
"Executes",
"a",
"SELECT",
"query",
"and",
"returns",
"the",
"single",
"result",
"row",
"as",
"an",
"associative",
"array",
"."
] | f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1 | https://github.com/oliverklee/ext-oelib/blob/f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1/Classes/Db.php#L365-L386 | train |
oliverklee/ext-oelib | Classes/Db.php | Tx_Oelib_Db.selectMultiple | public static function selectMultiple(
$fieldNames,
$tableNames,
$whereClause = '',
$groupBy = '',
$orderBy = '',
$limit = ''
) {
$result = [];
$dbResult = self::select(
$fieldNames,
$tableNames,
$whereClause,
$groupBy,
$orderBy,
$limit
);
$databaseConnection = self::getDatabaseConnection();
while ($recordData = $databaseConnection->sql_fetch_assoc($dbResult)) {
$result[] = $recordData;
}
$databaseConnection->sql_free_result($dbResult);
return $result;
} | php | public static function selectMultiple(
$fieldNames,
$tableNames,
$whereClause = '',
$groupBy = '',
$orderBy = '',
$limit = ''
) {
$result = [];
$dbResult = self::select(
$fieldNames,
$tableNames,
$whereClause,
$groupBy,
$orderBy,
$limit
);
$databaseConnection = self::getDatabaseConnection();
while ($recordData = $databaseConnection->sql_fetch_assoc($dbResult)) {
$result[] = $recordData;
}
$databaseConnection->sql_free_result($dbResult);
return $result;
} | [
"public",
"static",
"function",
"selectMultiple",
"(",
"$",
"fieldNames",
",",
"$",
"tableNames",
",",
"$",
"whereClause",
"=",
"''",
",",
"$",
"groupBy",
"=",
"''",
",",
"$",
"orderBy",
"=",
"''",
",",
"$",
"limit",
"=",
"''",
")",
"{",
"$",
"result... | Executes a SELECT query and returns the result rows as a two-dimensional
associative array.
@param string $fieldNames list of fields to select, may be "*", must not be empty
@param string $tableNames comma-separated list of tables from which to select, must not be empty
@param string $whereClause WHERE clause, may be empty
@param string $groupBy GROUP BY field(s), may be empty
@param string $orderBy ORDER BY field(s), may be empty
@param string $limit LIMIT value ([begin,]max), may be empty
@return array[] the query result rows, will be empty if there are no matching records | [
"Executes",
"a",
"SELECT",
"query",
"and",
"returns",
"the",
"result",
"rows",
"as",
"a",
"two",
"-",
"dimensional",
"associative",
"array",
"."
] | f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1 | https://github.com/oliverklee/ext-oelib/blob/f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1/Classes/Db.php#L401-L426 | train |
vinicius73/SeoTools | src/Vinicius73/SEO/Generators/MetaGenerator.php | MetaGenerator.generate | public function generate()
{
$this->loadWebmasterTags();
$title = $this->getTitle();
$description = $this->getDescription();
$keywords = $this->getKeywords();
$metatags = $this->metatags;
$html = array();
$html[] = "<title>$title</title>";
$html[] = sprintf('<meta name="description" itemprop="description" content="%s" />%s', $description, PHP_EOL);
if (!empty($keywords)) {
$html[] = sprintf('<meta name="keywords" content="%s" />%s', $keywords, PHP_EOL);
}
foreach ($metatags as $key => $value):
$name = $value[0];
$content = $value[1];
$html[] = sprintf('<meta %s="%s" content="%s" />%s', $name, $key, $content, PHP_EOL);
endforeach;
return implode(PHP_EOL, $html);
} | php | public function generate()
{
$this->loadWebmasterTags();
$title = $this->getTitle();
$description = $this->getDescription();
$keywords = $this->getKeywords();
$metatags = $this->metatags;
$html = array();
$html[] = "<title>$title</title>";
$html[] = sprintf('<meta name="description" itemprop="description" content="%s" />%s', $description, PHP_EOL);
if (!empty($keywords)) {
$html[] = sprintf('<meta name="keywords" content="%s" />%s', $keywords, PHP_EOL);
}
foreach ($metatags as $key => $value):
$name = $value[0];
$content = $value[1];
$html[] = sprintf('<meta %s="%s" content="%s" />%s', $name, $key, $content, PHP_EOL);
endforeach;
return implode(PHP_EOL, $html);
} | [
"public",
"function",
"generate",
"(",
")",
"{",
"$",
"this",
"->",
"loadWebmasterTags",
"(",
")",
";",
"$",
"title",
"=",
"$",
"this",
"->",
"getTitle",
"(",
")",
";",
"$",
"description",
"=",
"$",
"this",
"->",
"getDescription",
"(",
")",
";",
"$",... | Render the meta tags.
@return string | [
"Render",
"the",
"meta",
"tags",
"."
] | 5d2543482921713e0676c310ff8b23b2989443a1 | https://github.com/vinicius73/SeoTools/blob/5d2543482921713e0676c310ff8b23b2989443a1/src/Vinicius73/SEO/Generators/MetaGenerator.php#L88-L113 | train |
vinicius73/SeoTools | src/Vinicius73/SEO/Generators/MetaGenerator.php | MetaGenerator.fromObject | public function fromObject(MetaAware $object)
{
$data = $object->getMetaData();
if (array_key_exists('title', $data)) {
$this->setTitle($data['title']);
}
if (array_key_exists('description', $data)) {
$this->setDescription($data['description']);
}
if (array_key_exists('keywords', $data)) {
$this->setKeywords($data['keywords']);
}
} | php | public function fromObject(MetaAware $object)
{
$data = $object->getMetaData();
if (array_key_exists('title', $data)) {
$this->setTitle($data['title']);
}
if (array_key_exists('description', $data)) {
$this->setDescription($data['description']);
}
if (array_key_exists('keywords', $data)) {
$this->setKeywords($data['keywords']);
}
} | [
"public",
"function",
"fromObject",
"(",
"MetaAware",
"$",
"object",
")",
"{",
"$",
"data",
"=",
"$",
"object",
"->",
"getMetaData",
"(",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"'title'",
",",
"$",
"data",
")",
")",
"{",
"$",
"this",
"->",
"se... | Use the meta data of a MetaAware object.
@param MetaAware $object | [
"Use",
"the",
"meta",
"data",
"of",
"a",
"MetaAware",
"object",
"."
] | 5d2543482921713e0676c310ff8b23b2989443a1 | https://github.com/vinicius73/SeoTools/blob/5d2543482921713e0676c310ff8b23b2989443a1/src/Vinicius73/SEO/Generators/MetaGenerator.php#L120-L135 | train |
vinicius73/SeoTools | src/Vinicius73/SEO/Generators/MetaGenerator.php | MetaGenerator.setTitle | public function setTitle($title)
{
$title = strip_tags($title);
$this->title_session = $title;
$this->title = $title . $this->getDefault('separator') . $this->getDefault('title');
} | php | public function setTitle($title)
{
$title = strip_tags($title);
$this->title_session = $title;
$this->title = $title . $this->getDefault('separator') . $this->getDefault('title');
} | [
"public",
"function",
"setTitle",
"(",
"$",
"title",
")",
"{",
"$",
"title",
"=",
"strip_tags",
"(",
"$",
"title",
")",
";",
"$",
"this",
"->",
"title_session",
"=",
"$",
"title",
";",
"$",
"this",
"->",
"title",
"=",
"$",
"title",
".",
"$",
"this"... | Set the Meta title.
@param string $title | [
"Set",
"the",
"Meta",
"title",
"."
] | 5d2543482921713e0676c310ff8b23b2989443a1 | https://github.com/vinicius73/SeoTools/blob/5d2543482921713e0676c310ff8b23b2989443a1/src/Vinicius73/SEO/Generators/MetaGenerator.php#L142-L149 | train |
vinicius73/SeoTools | src/Vinicius73/SEO/Generators/MetaGenerator.php | MetaGenerator.setDescription | public function setDescription($description)
{
$description = strip_tags($description);
if (mb_strlen($description) > 160) {
$description = mb_substr($description, 0, 160);
}
$this->description = $description;
} | php | public function setDescription($description)
{
$description = strip_tags($description);
if (mb_strlen($description) > 160) {
$description = mb_substr($description, 0, 160);
}
$this->description = $description;
} | [
"public",
"function",
"setDescription",
"(",
"$",
"description",
")",
"{",
"$",
"description",
"=",
"strip_tags",
"(",
"$",
"description",
")",
";",
"if",
"(",
"mb_strlen",
"(",
"$",
"description",
")",
">",
"160",
")",
"{",
"$",
"description",
"=",
"mb_... | Set the Meta description.
@param string $description | [
"Set",
"the",
"Meta",
"description",
"."
] | 5d2543482921713e0676c310ff8b23b2989443a1 | https://github.com/vinicius73/SeoTools/blob/5d2543482921713e0676c310ff8b23b2989443a1/src/Vinicius73/SEO/Generators/MetaGenerator.php#L156-L165 | train |
vinicius73/SeoTools | src/Vinicius73/SEO/Generators/MetaGenerator.php | MetaGenerator.getKeywords | public function getKeywords()
{
$keywords = $this->keywords ? : $this->getDefault('keywords');
return (is_array($keywords)) ? implode(', ', $keywords) : $keywords;
} | php | public function getKeywords()
{
$keywords = $this->keywords ? : $this->getDefault('keywords');
return (is_array($keywords)) ? implode(', ', $keywords) : $keywords;
} | [
"public",
"function",
"getKeywords",
"(",
")",
"{",
"$",
"keywords",
"=",
"$",
"this",
"->",
"keywords",
"?",
":",
"$",
"this",
"->",
"getDefault",
"(",
"'keywords'",
")",
";",
"return",
"(",
"is_array",
"(",
"$",
"keywords",
")",
")",
"?",
"implode",
... | Get the Meta keywords.
@return string | [
"Get",
"the",
"Meta",
"keywords",
"."
] | 5d2543482921713e0676c310ff8b23b2989443a1 | https://github.com/vinicius73/SeoTools/blob/5d2543482921713e0676c310ff8b23b2989443a1/src/Vinicius73/SEO/Generators/MetaGenerator.php#L243-L247 | train |
vinicius73/SeoTools | src/Vinicius73/SEO/Generators/MetaGenerator.php | MetaGenerator.loadWebmasterTags | public function loadWebmasterTags()
{
foreach ($this->webmaster as $name => $value):
if (!empty($value)):
$meta = array_get(self::$webmasterTags, $name, $name);
$this->addMeta($meta, $value);
endif;
endforeach;
} | php | public function loadWebmasterTags()
{
foreach ($this->webmaster as $name => $value):
if (!empty($value)):
$meta = array_get(self::$webmasterTags, $name, $name);
$this->addMeta($meta, $value);
endif;
endforeach;
} | [
"public",
"function",
"loadWebmasterTags",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"webmaster",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
":",
"if",
"(",
"!",
"empty",
"(",
"$",
"value",
")",
")",
":",
"$",
"meta",
"=",
"array_get",
"("... | Load Webmaster tags | [
"Load",
"Webmaster",
"tags"
] | 5d2543482921713e0676c310ff8b23b2989443a1 | https://github.com/vinicius73/SeoTools/blob/5d2543482921713e0676c310ff8b23b2989443a1/src/Vinicius73/SEO/Generators/MetaGenerator.php#L293-L301 | train |
kenarkose/Tracker | src/Cruncher.php | Cruncher.getLastVisited | public function getLastVisited($locale = null, $query = null)
{
$query = $this->determineLocaleAndQuery($locale, $query);
$lastVisited = $query->orderBy('created_at', 'desc')->first();
return $lastVisited ? $lastVisited->created_at : null;
} | php | public function getLastVisited($locale = null, $query = null)
{
$query = $this->determineLocaleAndQuery($locale, $query);
$lastVisited = $query->orderBy('created_at', 'desc')->first();
return $lastVisited ? $lastVisited->created_at : null;
} | [
"public",
"function",
"getLastVisited",
"(",
"$",
"locale",
"=",
"null",
",",
"$",
"query",
"=",
"null",
")",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"determineLocaleAndQuery",
"(",
"$",
"locale",
",",
"$",
"query",
")",
";",
"$",
"lastVisited",
"="... | Returns the last visited date
@param string|null $locale
@param mixed $query
@return Carbon | [
"Returns",
"the",
"last",
"visited",
"date"
] | 8254ed559f9ec92c18a6090e97ad21ade2aeee40 | https://github.com/kenarkose/Tracker/blob/8254ed559f9ec92c18a6090e97ad21ade2aeee40/src/Cruncher.php#L37-L44 | train |
kenarkose/Tracker | src/Cruncher.php | Cruncher.getTotalVisitCount | public function getTotalVisitCount($locale = null, $query = null)
{
$query = $this->determineLocaleAndQuery($locale, $query);
return $query->count();
} | php | public function getTotalVisitCount($locale = null, $query = null)
{
$query = $this->determineLocaleAndQuery($locale, $query);
return $query->count();
} | [
"public",
"function",
"getTotalVisitCount",
"(",
"$",
"locale",
"=",
"null",
",",
"$",
"query",
"=",
"null",
")",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"determineLocaleAndQuery",
"(",
"$",
"locale",
",",
"$",
"query",
")",
";",
"return",
"$",
"que... | Gets the total visit count
@param string|null $locale
@param mixed $query
@return int | [
"Gets",
"the",
"total",
"visit",
"count"
] | 8254ed559f9ec92c18a6090e97ad21ade2aeee40 | https://github.com/kenarkose/Tracker/blob/8254ed559f9ec92c18a6090e97ad21ade2aeee40/src/Cruncher.php#L53-L58 | train |
kenarkose/Tracker | src/Cruncher.php | Cruncher.getTodayCount | public function getTodayCount($locale = null, $query = null)
{
$query = $this->determineLocaleAndQuery($locale, $query);
return $query->where('created_at', '>=', Carbon::today())->count();
} | php | public function getTodayCount($locale = null, $query = null)
{
$query = $this->determineLocaleAndQuery($locale, $query);
return $query->where('created_at', '>=', Carbon::today())->count();
} | [
"public",
"function",
"getTodayCount",
"(",
"$",
"locale",
"=",
"null",
",",
"$",
"query",
"=",
"null",
")",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"determineLocaleAndQuery",
"(",
"$",
"locale",
",",
"$",
"query",
")",
";",
"return",
"$",
"query",
... | Gets today's visit count
@param string|null $locale
@param mixed $query
@return int | [
"Gets",
"today",
"s",
"visit",
"count"
] | 8254ed559f9ec92c18a6090e97ad21ade2aeee40 | https://github.com/kenarkose/Tracker/blob/8254ed559f9ec92c18a6090e97ad21ade2aeee40/src/Cruncher.php#L67-L72 | train |
kenarkose/Tracker | src/Cruncher.php | Cruncher.getCountInBetween | public function getCountInBetween(Carbon $from, Carbon $until = null, $locale = null, $query = null, $cacheKey = null)
{
if (is_null($until))
{
$until = Carbon::now();
}
if ( ! is_null($cacheKey))
{
$count = $this->getCachedCountBetween($from, $until, $locale, $cacheKey);
if ( ! is_null($count))
{
return $count;
}
}
$query = $this->determineLocaleAndQuery($locale, $query);
$count = $query->whereBetween('created_at', [$from, $until])->count();
$this->cacheCountBetween($count, $from, $until, $locale, $cacheKey);
return $count;
} | php | public function getCountInBetween(Carbon $from, Carbon $until = null, $locale = null, $query = null, $cacheKey = null)
{
if (is_null($until))
{
$until = Carbon::now();
}
if ( ! is_null($cacheKey))
{
$count = $this->getCachedCountBetween($from, $until, $locale, $cacheKey);
if ( ! is_null($count))
{
return $count;
}
}
$query = $this->determineLocaleAndQuery($locale, $query);
$count = $query->whereBetween('created_at', [$from, $until])->count();
$this->cacheCountBetween($count, $from, $until, $locale, $cacheKey);
return $count;
} | [
"public",
"function",
"getCountInBetween",
"(",
"Carbon",
"$",
"from",
",",
"Carbon",
"$",
"until",
"=",
"null",
",",
"$",
"locale",
"=",
"null",
",",
"$",
"query",
"=",
"null",
",",
"$",
"cacheKey",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
... | Gets visit count in between dates
@param Carbon $from
@param Carbon|null $until
@param string|null $locale
@param mixed $query
@param string|null $cacheKey
@return int | [
"Gets",
"visit",
"count",
"in",
"between",
"dates"
] | 8254ed559f9ec92c18a6090e97ad21ade2aeee40 | https://github.com/kenarkose/Tracker/blob/8254ed559f9ec92c18a6090e97ad21ade2aeee40/src/Cruncher.php#L84-L108 | train |
kenarkose/Tracker | src/Cruncher.php | Cruncher.getCachedCountBetween | protected function getCachedCountBetween(Carbon $from, Carbon $until, $locale, $cacheKey)
{
$key = $this->makeBetweenCacheKey($from, $until, $locale, $cacheKey);
return $this->cache->get($key);
} | php | protected function getCachedCountBetween(Carbon $from, Carbon $until, $locale, $cacheKey)
{
$key = $this->makeBetweenCacheKey($from, $until, $locale, $cacheKey);
return $this->cache->get($key);
} | [
"protected",
"function",
"getCachedCountBetween",
"(",
"Carbon",
"$",
"from",
",",
"Carbon",
"$",
"until",
",",
"$",
"locale",
",",
"$",
"cacheKey",
")",
"{",
"$",
"key",
"=",
"$",
"this",
"->",
"makeBetweenCacheKey",
"(",
"$",
"from",
",",
"$",
"until",... | Gets the cached count if there is any
@param Carbon $from
@param Carbon $until
@param string $locale
@param string $cacheKey
@return int|null | [
"Gets",
"the",
"cached",
"count",
"if",
"there",
"is",
"any"
] | 8254ed559f9ec92c18a6090e97ad21ade2aeee40 | https://github.com/kenarkose/Tracker/blob/8254ed559f9ec92c18a6090e97ad21ade2aeee40/src/Cruncher.php#L119-L124 | train |
kenarkose/Tracker | src/Cruncher.php | Cruncher.cacheCountBetween | protected function cacheCountBetween($count, Carbon $from, Carbon $until, $locale, $cacheKey)
{
// Cache only if cacheKey is present
if ($cacheKey && ($until->timestamp < Carbon::now()->timestamp))
{
$key = $this->makeBetweenCacheKey($from, $until, $locale, $cacheKey);
$this->cache->put($key, $count, 525600);
}
} | php | protected function cacheCountBetween($count, Carbon $from, Carbon $until, $locale, $cacheKey)
{
// Cache only if cacheKey is present
if ($cacheKey && ($until->timestamp < Carbon::now()->timestamp))
{
$key = $this->makeBetweenCacheKey($from, $until, $locale, $cacheKey);
$this->cache->put($key, $count, 525600);
}
} | [
"protected",
"function",
"cacheCountBetween",
"(",
"$",
"count",
",",
"Carbon",
"$",
"from",
",",
"Carbon",
"$",
"until",
",",
"$",
"locale",
",",
"$",
"cacheKey",
")",
"{",
"// Cache only if cacheKey is present",
"if",
"(",
"$",
"cacheKey",
"&&",
"(",
"$",
... | Caches count between if cacheKey is present
@param int $count
@param Carbon $from
@param Carbon $until
@param string $locale
@param string $cacheKey | [
"Caches",
"count",
"between",
"if",
"cacheKey",
"is",
"present"
] | 8254ed559f9ec92c18a6090e97ad21ade2aeee40 | https://github.com/kenarkose/Tracker/blob/8254ed559f9ec92c18a6090e97ad21ade2aeee40/src/Cruncher.php#L135-L144 | train |
kenarkose/Tracker | src/Cruncher.php | Cruncher.makeBetweenCacheKey | protected function makeBetweenCacheKey(Carbon $from, Carbon $until, $locale, $cacheKey)
{
$key = 'tracker.between.' . $cacheKey . '.';
$key .= (is_null($locale) ? '' : $locale . '.');
return $key . $from->timestamp . '-' . $until->timestamp;
} | php | protected function makeBetweenCacheKey(Carbon $from, Carbon $until, $locale, $cacheKey)
{
$key = 'tracker.between.' . $cacheKey . '.';
$key .= (is_null($locale) ? '' : $locale . '.');
return $key . $from->timestamp . '-' . $until->timestamp;
} | [
"protected",
"function",
"makeBetweenCacheKey",
"(",
"Carbon",
"$",
"from",
",",
"Carbon",
"$",
"until",
",",
"$",
"locale",
",",
"$",
"cacheKey",
")",
"{",
"$",
"key",
"=",
"'tracker.between.'",
".",
"$",
"cacheKey",
".",
"'.'",
";",
"$",
"key",
".=",
... | Makes the cache key
@param Carbon $from
@param Carbon $until
@param string $locale
@param string $cacheKey
@return string | [
"Makes",
"the",
"cache",
"key"
] | 8254ed559f9ec92c18a6090e97ad21ade2aeee40 | https://github.com/kenarkose/Tracker/blob/8254ed559f9ec92c18a6090e97ad21ade2aeee40/src/Cruncher.php#L155-L161 | train |
kenarkose/Tracker | src/Cruncher.php | Cruncher.getRelativeYearCount | public function getRelativeYearCount($end = null, $locale = null, $query = null, $cacheKey = null)
{
if (is_null($end))
{
$end = Carbon::today();
}
return $this->getCountInBetween($end->copy()->subYear()->startOfDay(), $end->endOfDay(), $locale, $query, $cacheKey);
} | php | public function getRelativeYearCount($end = null, $locale = null, $query = null, $cacheKey = null)
{
if (is_null($end))
{
$end = Carbon::today();
}
return $this->getCountInBetween($end->copy()->subYear()->startOfDay(), $end->endOfDay(), $locale, $query, $cacheKey);
} | [
"public",
"function",
"getRelativeYearCount",
"(",
"$",
"end",
"=",
"null",
",",
"$",
"locale",
"=",
"null",
",",
"$",
"query",
"=",
"null",
",",
"$",
"cacheKey",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"end",
")",
")",
"{",
"$",
"... | Get relative year visit count
@param Carbon|null $end
@param string|null $locale
@param mixed $query
@param string|null $cacheKey
@return int | [
"Get",
"relative",
"year",
"visit",
"count"
] | 8254ed559f9ec92c18a6090e97ad21ade2aeee40 | https://github.com/kenarkose/Tracker/blob/8254ed559f9ec92c18a6090e97ad21ade2aeee40/src/Cruncher.php#L172-L180 | train |
kenarkose/Tracker | src/Cruncher.php | Cruncher.getRelativeMonthCount | public function getRelativeMonthCount($end = null, $locale = null, $query = null, $cacheKey = null)
{
if (is_null($end))
{
$end = Carbon::today();
}
return $this->getCountInBetween($end->copy()->subMonth()->addDay()->startOfDay(), $end->endOfDay(), $locale, $query, $cacheKey);
} | php | public function getRelativeMonthCount($end = null, $locale = null, $query = null, $cacheKey = null)
{
if (is_null($end))
{
$end = Carbon::today();
}
return $this->getCountInBetween($end->copy()->subMonth()->addDay()->startOfDay(), $end->endOfDay(), $locale, $query, $cacheKey);
} | [
"public",
"function",
"getRelativeMonthCount",
"(",
"$",
"end",
"=",
"null",
",",
"$",
"locale",
"=",
"null",
",",
"$",
"query",
"=",
"null",
",",
"$",
"cacheKey",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"end",
")",
")",
"{",
"$",
... | Get relative month visit count
@param Carbon|null $end
@param string|null $locale
@param mixed $query
@param string|null $cacheKey
@return int | [
"Get",
"relative",
"month",
"visit",
"count"
] | 8254ed559f9ec92c18a6090e97ad21ade2aeee40 | https://github.com/kenarkose/Tracker/blob/8254ed559f9ec92c18a6090e97ad21ade2aeee40/src/Cruncher.php#L191-L199 | train |
kenarkose/Tracker | src/Cruncher.php | Cruncher.getRelativeWeekCount | public function getRelativeWeekCount($end = null, $locale = null, $query = null, $cacheKey = null)
{
if (is_null($end))
{
$end = Carbon::today();
}
return $this->getCountInBetween($end->copy()->subWeek()->addDay()->startOfDay(), $end->endOfDay(), $locale, $query, $cacheKey);
} | php | public function getRelativeWeekCount($end = null, $locale = null, $query = null, $cacheKey = null)
{
if (is_null($end))
{
$end = Carbon::today();
}
return $this->getCountInBetween($end->copy()->subWeek()->addDay()->startOfDay(), $end->endOfDay(), $locale, $query, $cacheKey);
} | [
"public",
"function",
"getRelativeWeekCount",
"(",
"$",
"end",
"=",
"null",
",",
"$",
"locale",
"=",
"null",
",",
"$",
"query",
"=",
"null",
",",
"$",
"cacheKey",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"end",
")",
")",
"{",
"$",
"... | Get relative week visit count
@param Carbon|null $end
@param string|null $locale
@param mixed $query
@param string|null $cacheKey
@return int | [
"Get",
"relative",
"week",
"visit",
"count"
] | 8254ed559f9ec92c18a6090e97ad21ade2aeee40 | https://github.com/kenarkose/Tracker/blob/8254ed559f9ec92c18a6090e97ad21ade2aeee40/src/Cruncher.php#L210-L218 | train |
kenarkose/Tracker | src/Cruncher.php | Cruncher.getRelativeDayCount | public function getRelativeDayCount($end = null, $locale = null, $query = null, $cacheKey = null)
{
if (is_null($end))
{
$end = Carbon::today();
}
return $this->getCountInBetween($end, $end->copy()->endOfDay(), $locale, $query, $cacheKey);
} | php | public function getRelativeDayCount($end = null, $locale = null, $query = null, $cacheKey = null)
{
if (is_null($end))
{
$end = Carbon::today();
}
return $this->getCountInBetween($end, $end->copy()->endOfDay(), $locale, $query, $cacheKey);
} | [
"public",
"function",
"getRelativeDayCount",
"(",
"$",
"end",
"=",
"null",
",",
"$",
"locale",
"=",
"null",
",",
"$",
"query",
"=",
"null",
",",
"$",
"cacheKey",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"end",
")",
")",
"{",
"$",
"e... | Get relative day visit count
@param Carbon|null $end
@param string|null $locale
@param mixed $query
@param string|null $cacheKey
@return int | [
"Get",
"relative",
"day",
"visit",
"count"
] | 8254ed559f9ec92c18a6090e97ad21ade2aeee40 | https://github.com/kenarkose/Tracker/blob/8254ed559f9ec92c18a6090e97ad21ade2aeee40/src/Cruncher.php#L229-L237 | train |
kenarkose/Tracker | src/Cruncher.php | Cruncher.getCountForDay | public function getCountForDay(Carbon $day = null, $locale = null, $query = null, $cacheKey = null)
{
if (is_null($day))
{
$day = Carbon::now();
}
return $this->getCountInBetween($day->startOfDay(), $day->copy()->endOfDay(), $locale, $query, $cacheKey);
} | php | public function getCountForDay(Carbon $day = null, $locale = null, $query = null, $cacheKey = null)
{
if (is_null($day))
{
$day = Carbon::now();
}
return $this->getCountInBetween($day->startOfDay(), $day->copy()->endOfDay(), $locale, $query, $cacheKey);
} | [
"public",
"function",
"getCountForDay",
"(",
"Carbon",
"$",
"day",
"=",
"null",
",",
"$",
"locale",
"=",
"null",
",",
"$",
"query",
"=",
"null",
",",
"$",
"cacheKey",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"day",
")",
")",
"{",
"$... | Gets count for given day
@param Carbon|null $day
@param string|null $locale
@param mixed $query
@param string|null $cacheKey
@return int | [
"Gets",
"count",
"for",
"given",
"day"
] | 8254ed559f9ec92c18a6090e97ad21ade2aeee40 | https://github.com/kenarkose/Tracker/blob/8254ed559f9ec92c18a6090e97ad21ade2aeee40/src/Cruncher.php#L248-L256 | train |
kenarkose/Tracker | src/Cruncher.php | Cruncher.getCountPerMonth | public function getCountPerMonth(Carbon $from, Carbon $until = null, $locale = null, $query = null, $cacheKey = null)
{
return $this->getCountPer('Month', $from, $until, $locale, $query, $cacheKey);
} | php | public function getCountPerMonth(Carbon $from, Carbon $until = null, $locale = null, $query = null, $cacheKey = null)
{
return $this->getCountPer('Month', $from, $until, $locale, $query, $cacheKey);
} | [
"public",
"function",
"getCountPerMonth",
"(",
"Carbon",
"$",
"from",
",",
"Carbon",
"$",
"until",
"=",
"null",
",",
"$",
"locale",
"=",
"null",
",",
"$",
"query",
"=",
"null",
",",
"$",
"cacheKey",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",... | Get count per month in between
@param Carbon $from
@param Carbon|null $until
@param string|null $locale
@param mixed $query
@param string|null $cacheKey
@return array | [
"Get",
"count",
"per",
"month",
"in",
"between"
] | 8254ed559f9ec92c18a6090e97ad21ade2aeee40 | https://github.com/kenarkose/Tracker/blob/8254ed559f9ec92c18a6090e97ad21ade2aeee40/src/Cruncher.php#L268-L271 | train |
kenarkose/Tracker | src/Cruncher.php | Cruncher.getCountPer | protected function getCountPer($span, Carbon $from, Carbon $until = null, $locale = null, $query = null, $cacheKey = null)
{
$query = $this->determineLocaleAndQuery($locale, $query);
$statistics = [];
$labels = [];
if (is_null($until))
{
$until = Carbon::now();
}
$until->{'startOf' . $span}();
while ($until->gt($from))
{
$start = $until->copy();
$end = $until->copy()->{'endOf' . $span}();
$labels[] = $until->copy();
$statistics[] = $this->getCountInBetween($start, $end, $locale, clone $query, $cacheKey);
$until->{'sub' . $span}();
}
return [
array_reverse($statistics),
array_reverse($labels)
];
} | php | protected function getCountPer($span, Carbon $from, Carbon $until = null, $locale = null, $query = null, $cacheKey = null)
{
$query = $this->determineLocaleAndQuery($locale, $query);
$statistics = [];
$labels = [];
if (is_null($until))
{
$until = Carbon::now();
}
$until->{'startOf' . $span}();
while ($until->gt($from))
{
$start = $until->copy();
$end = $until->copy()->{'endOf' . $span}();
$labels[] = $until->copy();
$statistics[] = $this->getCountInBetween($start, $end, $locale, clone $query, $cacheKey);
$until->{'sub' . $span}();
}
return [
array_reverse($statistics),
array_reverse($labels)
];
} | [
"protected",
"function",
"getCountPer",
"(",
"$",
"span",
",",
"Carbon",
"$",
"from",
",",
"Carbon",
"$",
"until",
"=",
"null",
",",
"$",
"locale",
"=",
"null",
",",
"$",
"query",
"=",
"null",
",",
"$",
"cacheKey",
"=",
"null",
")",
"{",
"$",
"quer... | Gets count per timespan
@param string $span
@param Carbon $from
@param Carbon|null $until
@param string|null $locale
@param mixed $query
@param string|null $cacheKey
@return array | [
"Gets",
"count",
"per",
"timespan"
] | 8254ed559f9ec92c18a6090e97ad21ade2aeee40 | https://github.com/kenarkose/Tracker/blob/8254ed559f9ec92c18a6090e97ad21ade2aeee40/src/Cruncher.php#L314-L343 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.