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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
CradlePHP/cradle-system | src/Helpers.php | Helpers.getFieldset | public static function getFieldset($name) {
if (!isset(self::$fieldsets[$name])) {
try {
self::$fieldsets[$name] = Fieldset::i($name);
} catch (Exception $e) {
return false;
}
}
return self::$fieldsets[$name];
} | php | public static function getFieldset($name) {
if (!isset(self::$fieldsets[$name])) {
try {
self::$fieldsets[$name] = Fieldset::i($name);
} catch (Exception $e) {
return false;
}
}
return self::$fieldsets[$name];
} | [
"public",
"static",
"function",
"getFieldset",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"fieldsets",
"[",
"$",
"name",
"]",
")",
")",
"{",
"try",
"{",
"self",
"::",
"$",
"fieldsets",
"[",
"$",
"name",
"]",
"=",... | Returns a cached fieldset
@param *string $name
@return Fieldset|false | [
"Returns",
"a",
"cached",
"fieldset"
] | 3dda31fbc7e4523fdcc87e18a7ab852116cbdc6c | https://github.com/CradlePHP/cradle-system/blob/3dda31fbc7e4523fdcc87e18a7ab852116cbdc6c/src/Helpers.php#L46-L56 | train |
CradlePHP/cradle-system | src/Helpers.php | Helpers.getSchema | public static function getSchema($name) {
if (!isset(self::$schemas[$name])) {
try {
self::$schemas[$name] = Schema::i($name);
} catch (Exception $e) {
return false;
}
}
return self::$schemas[$name];
} | php | public static function getSchema($name) {
if (!isset(self::$schemas[$name])) {
try {
self::$schemas[$name] = Schema::i($name);
} catch (Exception $e) {
return false;
}
}
return self::$schemas[$name];
} | [
"public",
"static",
"function",
"getSchema",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"schemas",
"[",
"$",
"name",
"]",
")",
")",
"{",
"try",
"{",
"self",
"::",
"$",
"schemas",
"[",
"$",
"name",
"]",
"=",
"Sc... | Returns a cached schema
@param *string $name
@return Schema | [
"Returns",
"a",
"cached",
"schema"
] | 3dda31fbc7e4523fdcc87e18a7ab852116cbdc6c | https://github.com/CradlePHP/cradle-system/blob/3dda31fbc7e4523fdcc87e18a7ab852116cbdc6c/src/Helpers.php#L65-L75 | train |
CradlePHP/cradle-system | src/Helpers.php | Helpers.getFormatTemplate | public static function getFormatTemplate($name) {
$file = sprintf(
'%s/Model/template/format/%s.html',
__DIR__,
$name
);
if (!file_exists($file)) {
return null;
}
if (!isset(self::$templates[$name])) {
self::$templates[$name] = file_get_contents($file);
}
return self::$templates[$name];
} | php | public static function getFormatTemplate($name) {
$file = sprintf(
'%s/Model/template/format/%s.html',
__DIR__,
$name
);
if (!file_exists($file)) {
return null;
}
if (!isset(self::$templates[$name])) {
self::$templates[$name] = file_get_contents($file);
}
return self::$templates[$name];
} | [
"public",
"static",
"function",
"getFormatTemplate",
"(",
"$",
"name",
")",
"{",
"$",
"file",
"=",
"sprintf",
"(",
"'%s/Model/template/format/%s.html'",
",",
"__DIR__",
",",
"$",
"name",
")",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"file",
")",
")",
... | Returns a format template
@param *string $name
@return Schema | [
"Returns",
"a",
"format",
"template"
] | 3dda31fbc7e4523fdcc87e18a7ab852116cbdc6c | https://github.com/CradlePHP/cradle-system/blob/3dda31fbc7e4523fdcc87e18a7ab852116cbdc6c/src/Helpers.php#L84-L100 | train |
oasmobile/php-http | src/SilexKernel.php | SilexKernel.isGranted | public function isGranted($attributes, $object = null)
{
if (!$this->offsetExists('security.authorization_checker')) {
return false;
}
$checker = $this['security.authorization_checker'];
if ($checker instanceof AuthorizationCheckerInterface) {
try {
return $checker->isGranted($attributes, $object);
} catch (AuthenticationCredentialsNotFoundException $e) {
// authentication not found is considered not granted,
// there is no need to throw an exception out in this case
mdebug("Authentication credential not found, isGranted will return false. msg = %s", $e->getMessage());
return false;
}
}
else {
return false;
}
} | php | public function isGranted($attributes, $object = null)
{
if (!$this->offsetExists('security.authorization_checker')) {
return false;
}
$checker = $this['security.authorization_checker'];
if ($checker instanceof AuthorizationCheckerInterface) {
try {
return $checker->isGranted($attributes, $object);
} catch (AuthenticationCredentialsNotFoundException $e) {
// authentication not found is considered not granted,
// there is no need to throw an exception out in this case
mdebug("Authentication credential not found, isGranted will return false. msg = %s", $e->getMessage());
return false;
}
}
else {
return false;
}
} | [
"public",
"function",
"isGranted",
"(",
"$",
"attributes",
",",
"$",
"object",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"offsetExists",
"(",
"'security.authorization_checker'",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"checker",
... | Checks if the attributes are granted against the current authentication token and optionally supplied object.
@param mixed $attributes
@param mixed $object
@return bool | [
"Checks",
"if",
"the",
"attributes",
"are",
"granted",
"against",
"the",
"current",
"authentication",
"token",
"and",
"optionally",
"supplied",
"object",
"."
] | a7570893742286c30222c393891aeb6857064f37 | https://github.com/oasmobile/php-http/blob/a7570893742286c30222c393891aeb6857064f37/src/SilexKernel.php#L512-L533 | train |
firebrandhq/silverstripe-hail | src/Models/Publication.php | Publication.processFeaturedArticle | private function processFeaturedArticle($articleData)
{
if ($articleData) {
$article = Article::get()->filter(['HailID' => $articleData['id']])->first();
if (!$article) {
$article = new Article();
$article->importHailData($articleData);
}
$heroImage = $article->HeroImageID;
$heroVideo = $article->HeroVideoID;
$article = $article->ID;
} else {
$article = null;
}
$this->FeaturedArticleID = $article;
if (isset($heroImage) && $heroImage) {
$this->HeroImageID = $heroImage;
}
if (isset($heroVideo) && $heroVideo) {
$this->HeroVideoID = $heroVideo;
}
} | php | private function processFeaturedArticle($articleData)
{
if ($articleData) {
$article = Article::get()->filter(['HailID' => $articleData['id']])->first();
if (!$article) {
$article = new Article();
$article->importHailData($articleData);
}
$heroImage = $article->HeroImageID;
$heroVideo = $article->HeroVideoID;
$article = $article->ID;
} else {
$article = null;
}
$this->FeaturedArticleID = $article;
if (isset($heroImage) && $heroImage) {
$this->HeroImageID = $heroImage;
}
if (isset($heroVideo) && $heroVideo) {
$this->HeroVideoID = $heroVideo;
}
} | [
"private",
"function",
"processFeaturedArticle",
"(",
"$",
"articleData",
")",
"{",
"if",
"(",
"$",
"articleData",
")",
"{",
"$",
"article",
"=",
"Article",
"::",
"get",
"(",
")",
"->",
"filter",
"(",
"[",
"'HailID'",
"=>",
"$",
"articleData",
"[",
"'id'... | Attach the featured article to this publication if there is one
@param array $articleData | [
"Attach",
"the",
"featured",
"article",
"to",
"this",
"publication",
"if",
"there",
"is",
"one"
] | fd655b7a568f8d5f6a8f888f39368618596f794e | https://github.com/firebrandhq/silverstripe-hail/blob/fd655b7a568f8d5f6a8f888f39368618596f794e/src/Models/Publication.php#L143-L170 | train |
flipboxfactory/craft-ember | src/records/SortableTrait.php | SortableTrait.ensureSortOrder | protected function ensureSortOrder(
array $sortOrderCondition = [],
string $sortOrderAttribute = 'sortOrder'
) {
if ($this->getAttribute($sortOrderAttribute) === null) {
$this->setAttribute(
$sortOrderAttribute,
$this->nextSortOrder(
$sortOrderCondition,
$sortOrderAttribute
)
);
}
} | php | protected function ensureSortOrder(
array $sortOrderCondition = [],
string $sortOrderAttribute = 'sortOrder'
) {
if ($this->getAttribute($sortOrderAttribute) === null) {
$this->setAttribute(
$sortOrderAttribute,
$this->nextSortOrder(
$sortOrderCondition,
$sortOrderAttribute
)
);
}
} | [
"protected",
"function",
"ensureSortOrder",
"(",
"array",
"$",
"sortOrderCondition",
"=",
"[",
"]",
",",
"string",
"$",
"sortOrderAttribute",
"=",
"'sortOrder'",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getAttribute",
"(",
"$",
"sortOrderAttribute",
")",
"==="... | Ensure a sort order is set. If a sort order is not provided, it will be added to the end.
@param array $sortOrderCondition
@param string $sortOrderAttribute | [
"Ensure",
"a",
"sort",
"order",
"is",
"set",
".",
"If",
"a",
"sort",
"order",
"is",
"not",
"provided",
"it",
"will",
"be",
"added",
"to",
"the",
"end",
"."
] | 9185b885b404b1cb272a0983023eb7c6c0df61c8 | https://github.com/flipboxfactory/craft-ember/blob/9185b885b404b1cb272a0983023eb7c6c0df61c8/src/records/SortableTrait.php#L105-L118 | train |
flipboxfactory/craft-ember | src/records/SortableTrait.php | SortableTrait.nextSortOrder | protected function nextSortOrder(
array $sortOrderCondition = [],
string $sortOrderAttribute = 'sortOrder'
): int {
$maxSortOrder = $this->sortOrderQuery(
$sortOrderCondition,
$sortOrderAttribute
)->max('[[' . $sortOrderAttribute . ']]');
return ++$maxSortOrder;
} | php | protected function nextSortOrder(
array $sortOrderCondition = [],
string $sortOrderAttribute = 'sortOrder'
): int {
$maxSortOrder = $this->sortOrderQuery(
$sortOrderCondition,
$sortOrderAttribute
)->max('[[' . $sortOrderAttribute . ']]');
return ++$maxSortOrder;
} | [
"protected",
"function",
"nextSortOrder",
"(",
"array",
"$",
"sortOrderCondition",
"=",
"[",
"]",
",",
"string",
"$",
"sortOrderAttribute",
"=",
"'sortOrder'",
")",
":",
"int",
"{",
"$",
"maxSortOrder",
"=",
"$",
"this",
"->",
"sortOrderQuery",
"(",
"$",
"so... | Get the next available sort order available
@param array $sortOrderCondition
@param string $sortOrderAttribute
@return int | [
"Get",
"the",
"next",
"available",
"sort",
"order",
"available"
] | 9185b885b404b1cb272a0983023eb7c6c0df61c8 | https://github.com/flipboxfactory/craft-ember/blob/9185b885b404b1cb272a0983023eb7c6c0df61c8/src/records/SortableTrait.php#L200-L210 | train |
flipboxfactory/craft-ember | src/records/SortableTrait.php | SortableTrait.sortOrderQuery | protected function sortOrderQuery(
array $sortOrderCondition = [],
string $sortOrderAttribute = 'sortOrder'
): ActiveQuery {
return static::find()
->andWhere($sortOrderCondition)
->orderBy([
$sortOrderAttribute => SORT_ASC,
'dateUpdated' => SORT_DESC
]);
} | php | protected function sortOrderQuery(
array $sortOrderCondition = [],
string $sortOrderAttribute = 'sortOrder'
): ActiveQuery {
return static::find()
->andWhere($sortOrderCondition)
->orderBy([
$sortOrderAttribute => SORT_ASC,
'dateUpdated' => SORT_DESC
]);
} | [
"protected",
"function",
"sortOrderQuery",
"(",
"array",
"$",
"sortOrderCondition",
"=",
"[",
"]",
",",
"string",
"$",
"sortOrderAttribute",
"=",
"'sortOrder'",
")",
":",
"ActiveQuery",
"{",
"return",
"static",
"::",
"find",
"(",
")",
"->",
"andWhere",
"(",
... | Creates a sort order query which will display all siblings ordered by their sort order
@param array $sortOrderCondition
@param string $sortOrderAttribute
@return ActiveQuery | [
"Creates",
"a",
"sort",
"order",
"query",
"which",
"will",
"display",
"all",
"siblings",
"ordered",
"by",
"their",
"sort",
"order"
] | 9185b885b404b1cb272a0983023eb7c6c0df61c8 | https://github.com/flipboxfactory/craft-ember/blob/9185b885b404b1cb272a0983023eb7c6c0df61c8/src/records/SortableTrait.php#L220-L230 | train |
flipboxfactory/craft-ember | src/records/SortableTrait.php | SortableTrait.saveNewOrder | protected function saveNewOrder(
array $sortOrder,
string $targetAttribute,
array $sortOrderCondition = [],
string $sortOrderAttribute = 'sortOrder'
): bool {
foreach ($sortOrder as $target => $order) {
Craft::$app->getDb()->createCommand()
->update(
static::tableName(),
[$sortOrderAttribute => $order],
array_merge(
$sortOrderCondition,
[
$targetAttribute => $target
]
)
)
->execute();
}
return true;
} | php | protected function saveNewOrder(
array $sortOrder,
string $targetAttribute,
array $sortOrderCondition = [],
string $sortOrderAttribute = 'sortOrder'
): bool {
foreach ($sortOrder as $target => $order) {
Craft::$app->getDb()->createCommand()
->update(
static::tableName(),
[$sortOrderAttribute => $order],
array_merge(
$sortOrderCondition,
[
$targetAttribute => $target
]
)
)
->execute();
}
return true;
} | [
"protected",
"function",
"saveNewOrder",
"(",
"array",
"$",
"sortOrder",
",",
"string",
"$",
"targetAttribute",
",",
"array",
"$",
"sortOrderCondition",
"=",
"[",
"]",
",",
"string",
"$",
"sortOrderAttribute",
"=",
"'sortOrder'",
")",
":",
"bool",
"{",
"foreac... | Saves a new sort order.
@param array $sortOrder The new sort order that needs to be saved. The 'key' represents the target value and
the 'value' represent the sort order.
@param string $targetAttribute The target attribute that the new order is keyed on.
@param array $sortOrderCondition Additional condition params used to accurately identify the sort order that
need to be changed. For example, some sort orders may be site specific, therefore passing a 'siteId' condition
would only apply the re-ordering to the specified site.
@param string $sortOrderAttribute The sort order attribute that needs to be updated
@return bool
@throws \yii\db\Exception | [
"Saves",
"a",
"new",
"sort",
"order",
"."
] | 9185b885b404b1cb272a0983023eb7c6c0df61c8 | https://github.com/flipboxfactory/craft-ember/blob/9185b885b404b1cb272a0983023eb7c6c0df61c8/src/records/SortableTrait.php#L245-L267 | train |
flipboxfactory/craft-ember | src/helpers/QueryHelper.php | QueryHelper.parseBaseParam | public static function parseBaseParam(&$value, &$join): bool
{
// Force array
if (!is_array($value)) {
$value = [$value];
}
// Get join type ('and' , 'or')
$join = self::getJoinType($value, $join);
// Check for object array (via 'id' key)
if ($id = self::findIdFromObjectArray($value)) {
$value = [$id];
return true;
}
return false;
} | php | public static function parseBaseParam(&$value, &$join): bool
{
// Force array
if (!is_array($value)) {
$value = [$value];
}
// Get join type ('and' , 'or')
$join = self::getJoinType($value, $join);
// Check for object array (via 'id' key)
if ($id = self::findIdFromObjectArray($value)) {
$value = [$id];
return true;
}
return false;
} | [
"public",
"static",
"function",
"parseBaseParam",
"(",
"&",
"$",
"value",
",",
"&",
"$",
"join",
")",
":",
"bool",
"{",
"// Force array",
"if",
"(",
"!",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"[",
"$",
"value",
"]",
";",
... | Standard param parsing.
@param $value
@param $join
@return bool
@deprecated | [
"Standard",
"param",
"parsing",
"."
] | 9185b885b404b1cb272a0983023eb7c6c0df61c8 | https://github.com/flipboxfactory/craft-ember/blob/9185b885b404b1cb272a0983023eb7c6c0df61c8/src/helpers/QueryHelper.php#L185-L202 | train |
flipboxfactory/craft-ember | src/helpers/QueryHelper.php | QueryHelper.prependOperator | private static function prependOperator($value, $operator = null)
{
if ($operator) {
$operator = StringHelper::toLowerCase($operator);
if (in_array($operator, static::$operators) || $operator === 'not') {
if (is_array($value)) {
$values = [];
foreach ($value as $v) {
$values[] = $operator . ($operator === 'not' ? ' ' : '') . $v;
}
return $values;
}
return $operator . ($operator === 'not' ? ' ' : '') . $value;
}
}
return $value;
} | php | private static function prependOperator($value, $operator = null)
{
if ($operator) {
$operator = StringHelper::toLowerCase($operator);
if (in_array($operator, static::$operators) || $operator === 'not') {
if (is_array($value)) {
$values = [];
foreach ($value as $v) {
$values[] = $operator . ($operator === 'not' ? ' ' : '') . $v;
}
return $values;
}
return $operator . ($operator === 'not' ? ' ' : '') . $value;
}
}
return $value;
} | [
"private",
"static",
"function",
"prependOperator",
"(",
"$",
"value",
",",
"$",
"operator",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"operator",
")",
"{",
"$",
"operator",
"=",
"StringHelper",
"::",
"toLowerCase",
"(",
"$",
"operator",
")",
";",
"if",
"... | Prepend the operator to a value
@param $value
@param null $operator
@return string|array
@deprecated | [
"Prepend",
"the",
"operator",
"to",
"a",
"value"
] | 9185b885b404b1cb272a0983023eb7c6c0df61c8 | https://github.com/flipboxfactory/craft-ember/blob/9185b885b404b1cb272a0983023eb7c6c0df61c8/src/helpers/QueryHelper.php#L354-L376 | train |
flipboxfactory/craft-ember | src/helpers/QueryHelper.php | QueryHelper.parseParamOperator | private static function parseParamOperator(&$value)
{
foreach (static::$operators as $testOperator) {
// Does the value start with this operator?
$operatorLength = strlen($testOperator);
if (strncmp(
StringHelper::toLowerCase($value),
$testOperator,
$operatorLength
) == 0
) {
$value = mb_substr($value, $operatorLength);
if ($testOperator == 'not ') {
return 'not';
} else {
return $testOperator;
}
}
}
return '';
} | php | private static function parseParamOperator(&$value)
{
foreach (static::$operators as $testOperator) {
// Does the value start with this operator?
$operatorLength = strlen($testOperator);
if (strncmp(
StringHelper::toLowerCase($value),
$testOperator,
$operatorLength
) == 0
) {
$value = mb_substr($value, $operatorLength);
if ($testOperator == 'not ') {
return 'not';
} else {
return $testOperator;
}
}
}
return '';
} | [
"private",
"static",
"function",
"parseParamOperator",
"(",
"&",
"$",
"value",
")",
"{",
"foreach",
"(",
"static",
"::",
"$",
"operators",
"as",
"$",
"testOperator",
")",
"{",
"// Does the value start with this operator?",
"$",
"operatorLength",
"=",
"strlen",
"("... | Extracts the operator from a DB param and returns it.
@param string &$value Te param value.
@return string The operator.
@deprecated | [
"Extracts",
"the",
"operator",
"from",
"a",
"DB",
"param",
"and",
"returns",
"it",
"."
] | 9185b885b404b1cb272a0983023eb7c6c0df61c8 | https://github.com/flipboxfactory/craft-ember/blob/9185b885b404b1cb272a0983023eb7c6c0df61c8/src/helpers/QueryHelper.php#L405-L428 | train |
Vectorface/cache | src/CacheHelper.php | CacheHelper.fetch | public static function fetch(Cache $cache, $key, $callback, $args, $ttl = 300)
{
if (!(is_string($key))) {
throw new \Exception('Cache key must be a string');
}
$item = $cache->get($key);
if ($item === false) {
$item = static::runCallback($callback, $args);
if (isset($item)) {
$cache->set($key, $item, $ttl);
}
}
return $item;
} | php | public static function fetch(Cache $cache, $key, $callback, $args, $ttl = 300)
{
if (!(is_string($key))) {
throw new \Exception('Cache key must be a string');
}
$item = $cache->get($key);
if ($item === false) {
$item = static::runCallback($callback, $args);
if (isset($item)) {
$cache->set($key, $item, $ttl);
}
}
return $item;
} | [
"public",
"static",
"function",
"fetch",
"(",
"Cache",
"$",
"cache",
",",
"$",
"key",
",",
"$",
"callback",
",",
"$",
"args",
",",
"$",
"ttl",
"=",
"300",
")",
"{",
"if",
"(",
"!",
"(",
"is_string",
"(",
"$",
"key",
")",
")",
")",
"{",
"throw",... | Implement the mechanics of caching the result of a heavy function call.
For example, if one has a function like so:
public static function getLargeDatasetFromDB($arg1, $arg2) {
// Lots of SQL/compute
return $giantDataSet;
}
One could cache this by adding cache calls to the top/bottom. CacheHelper::fetch can automatate this:
function getLargeDataset($arg1, $arg2) {
$key = "SomeClass::LargeDataset($arg1,$arg2)";
$cache = new APCCache();
return CacheHelper::fetch($cache, $key, [SomeClass, 'getLargeDatasetFromDB'], [$arg1, $arg2], 600);
}
@param Cache $cache The cache from/to which the values should be retrieved/set.
@param string $key The cache key which should store the value.
@param callable $callback A callable which is expected to return a value to be cached.
@param mixed[] $args The arguments to be passed to the callback, if it needs to be called.
@param int $ttl If a value is to be set in the cache, set this expiry time (in seconds).
@return mixed The value stored in the cache, or returned by the callback. | [
"Implement",
"the",
"mechanics",
"of",
"caching",
"the",
"result",
"of",
"a",
"heavy",
"function",
"call",
"."
] | 159f4aeaf639da7a1f7e1d4e5e719a279442658b | https://github.com/Vectorface/cache/blob/159f4aeaf639da7a1f7e1d4e5e719a279442658b/src/CacheHelper.php#L34-L49 | train |
Vectorface/cache | src/CacheHelper.php | CacheHelper.runCallback | protected static function runCallback($callback, $args)
{
if (!is_array($args)) {
$args = isset($args) ? array($args) : array();
}
return call_user_func_array($callback, $args);
} | php | protected static function runCallback($callback, $args)
{
if (!is_array($args)) {
$args = isset($args) ? array($args) : array();
}
return call_user_func_array($callback, $args);
} | [
"protected",
"static",
"function",
"runCallback",
"(",
"$",
"callback",
",",
"$",
"args",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"args",
")",
")",
"{",
"$",
"args",
"=",
"isset",
"(",
"$",
"args",
")",
"?",
"array",
"(",
"$",
"args",
")"... | Run the callback, normalizing the arguments.
@param callable $callback The callable to be executed to fetch the value the cache.
@param mixed[] $args The argument(s) to the callback function.
@return mixed The value returned by the callback. | [
"Run",
"the",
"callback",
"normalizing",
"the",
"arguments",
"."
] | 159f4aeaf639da7a1f7e1d4e5e719a279442658b | https://github.com/Vectorface/cache/blob/159f4aeaf639da7a1f7e1d4e5e719a279442658b/src/CacheHelper.php#L58-L64 | train |
JanDC/css-from-html-extractor | src/Css/Rule/Processor.php | Processor.splitIntoSeparateMediaQueries | public function splitIntoSeparateMediaQueries($rulesString)
{
// Intelligently break up rules, preserving mediaquery context and such
$mediaQuerySelector = '/@media[^{]+\{([\s\S]+?\})\s*\}/';
$mediaQueryMatches = [];
preg_match_all($mediaQuerySelector, $rulesString, $mediaQueryMatches);
$remainingRuleSet = $rulesString;
$queryParts = [];
foreach (reset($mediaQueryMatches) as $mediaQueryMatch) {
$tokenisedRules = explode($mediaQueryMatch, $remainingRuleSet);
$queryParts[] = reset($tokenisedRules);
$queryParts[] = $mediaQueryMatch;
if (count($tokenisedRules) === 2) {
$remainingRuleSet = end($tokenisedRules);
} else {
$remainingRuleSet = '';
}
}
if (!empty($remainingRuleSet)) {
$queryParts[] = $remainingRuleSet;
}
$indexedRules = [];
foreach ($queryParts as $part) {
if (strpos($part, '@media') === false) {
$indexedRules[][''] = (array)explode('}', $part);
continue;
}
$mediaQueryString = substr($part, 0, strpos($part, '{'));
// No need for print css
if (trim($mediaQueryString) === '@media print') {
continue;
}
$mediaQueryRules = substr($part, strpos($part, '{') + 1);
$mediaQueryRules = substr($mediaQueryRules, 0, -1);
$indexedRules[][$mediaQueryString] = (array)explode('}', $mediaQueryRules);
}
return $indexedRules;
} | php | public function splitIntoSeparateMediaQueries($rulesString)
{
// Intelligently break up rules, preserving mediaquery context and such
$mediaQuerySelector = '/@media[^{]+\{([\s\S]+?\})\s*\}/';
$mediaQueryMatches = [];
preg_match_all($mediaQuerySelector, $rulesString, $mediaQueryMatches);
$remainingRuleSet = $rulesString;
$queryParts = [];
foreach (reset($mediaQueryMatches) as $mediaQueryMatch) {
$tokenisedRules = explode($mediaQueryMatch, $remainingRuleSet);
$queryParts[] = reset($tokenisedRules);
$queryParts[] = $mediaQueryMatch;
if (count($tokenisedRules) === 2) {
$remainingRuleSet = end($tokenisedRules);
} else {
$remainingRuleSet = '';
}
}
if (!empty($remainingRuleSet)) {
$queryParts[] = $remainingRuleSet;
}
$indexedRules = [];
foreach ($queryParts as $part) {
if (strpos($part, '@media') === false) {
$indexedRules[][''] = (array)explode('}', $part);
continue;
}
$mediaQueryString = substr($part, 0, strpos($part, '{'));
// No need for print css
if (trim($mediaQueryString) === '@media print') {
continue;
}
$mediaQueryRules = substr($part, strpos($part, '{') + 1);
$mediaQueryRules = substr($mediaQueryRules, 0, -1);
$indexedRules[][$mediaQueryString] = (array)explode('}', $mediaQueryRules);
}
return $indexedRules;
} | [
"public",
"function",
"splitIntoSeparateMediaQueries",
"(",
"$",
"rulesString",
")",
"{",
"// Intelligently break up rules, preserving mediaquery context and such",
"$",
"mediaQuerySelector",
"=",
"'/@media[^{]+\\{([\\s\\S]+?\\})\\s*\\}/'",
";",
"$",
"mediaQueryMatches",
"=",
"[",
... | Split a string into seperate rules
@param string $rulesString
@return array | [
"Split",
"a",
"string",
"into",
"seperate",
"rules"
] | e471a1e9ea00f800cb20e014079050cb2d9ad57c | https://github.com/JanDC/css-from-html-extractor/blob/e471a1e9ea00f800cb20e014079050cb2d9ad57c/src/Css/Rule/Processor.php#L19-L71 | train |
JanDC/css-from-html-extractor | src/Css/Rule/Processor.php | Processor.convertToObjects | public function convertToObjects($media, $rule, $originalOrder)
{
$rule = $this->cleanup($rule);
$chunks = explode('{', $rule);
$selectorIdentifier = 0;
$ruleIdentifier = 1;
if (!isset($chunks[$ruleIdentifier])) {
return [];
}
$propertiesProcessor = new PropertyProcessor();
$rules = [];
$selectors = (array)explode(',', trim($chunks[$selectorIdentifier]));
$properties = $propertiesProcessor->splitIntoSeparateProperties($chunks[$ruleIdentifier]);
foreach ($selectors as $selector) {
$selector = trim($selector);
$specificity = $this->calculateSpecificityBasedOnASelector($selector);
$rules[] = new Rule(
$media,
$selector,
$propertiesProcessor->convertArrayToObjects($properties, $specificity),
$specificity,
$originalOrder
);
}
return $rules;
} | php | public function convertToObjects($media, $rule, $originalOrder)
{
$rule = $this->cleanup($rule);
$chunks = explode('{', $rule);
$selectorIdentifier = 0;
$ruleIdentifier = 1;
if (!isset($chunks[$ruleIdentifier])) {
return [];
}
$propertiesProcessor = new PropertyProcessor();
$rules = [];
$selectors = (array)explode(',', trim($chunks[$selectorIdentifier]));
$properties = $propertiesProcessor->splitIntoSeparateProperties($chunks[$ruleIdentifier]);
foreach ($selectors as $selector) {
$selector = trim($selector);
$specificity = $this->calculateSpecificityBasedOnASelector($selector);
$rules[] = new Rule(
$media,
$selector,
$propertiesProcessor->convertArrayToObjects($properties, $specificity),
$specificity,
$originalOrder
);
}
return $rules;
} | [
"public",
"function",
"convertToObjects",
"(",
"$",
"media",
",",
"$",
"rule",
",",
"$",
"originalOrder",
")",
"{",
"$",
"rule",
"=",
"$",
"this",
"->",
"cleanup",
"(",
"$",
"rule",
")",
";",
"$",
"chunks",
"=",
"explode",
"(",
"'{'",
",",
"$",
"ru... | Convert a rule-string into an object
@param string $media
@param string $rule
@param int $originalOrder
@return array | [
"Convert",
"a",
"rule",
"-",
"string",
"into",
"an",
"object"
] | e471a1e9ea00f800cb20e014079050cb2d9ad57c | https://github.com/JanDC/css-from-html-extractor/blob/e471a1e9ea00f800cb20e014079050cb2d9ad57c/src/Css/Rule/Processor.php#L98-L129 | train |
appaydin/pd-mailer | SwiftMailer/SendListener.php | SendListener.logCreate | private function logCreate(\Swift_Mime_SimpleMessage $message, $status, $templateID, $language)
{
// Check Message
if (null === $message->getId() || empty($message->getId())) {
return false;
}
// Create Log
$class = $this->bag->get('pd_mailer.mail_log_class');
$this->log = new $class;
$this->log->setMailId($message->getId());
$this->log->setFrom($message->getFrom());
$this->log->setTo($message->getTo());
$this->log->setSubject($message->getSubject());
$this->log->setBody($message->getBody());
$this->log->setContentType($message->getContentType());
$this->log->setDate($message->getDate());
$this->log->setHeader($message->getHeaders()->toString());
$this->log->setReplyTo($message->getReplyTo());
$this->log->setStatus($status);
$this->log->setTemplateId($templateID);
$this->log->setLanguage($language);
// Save
$this->entityManager->persist($this->log);
$this->entityManager->flush();
return true;
} | php | private function logCreate(\Swift_Mime_SimpleMessage $message, $status, $templateID, $language)
{
// Check Message
if (null === $message->getId() || empty($message->getId())) {
return false;
}
// Create Log
$class = $this->bag->get('pd_mailer.mail_log_class');
$this->log = new $class;
$this->log->setMailId($message->getId());
$this->log->setFrom($message->getFrom());
$this->log->setTo($message->getTo());
$this->log->setSubject($message->getSubject());
$this->log->setBody($message->getBody());
$this->log->setContentType($message->getContentType());
$this->log->setDate($message->getDate());
$this->log->setHeader($message->getHeaders()->toString());
$this->log->setReplyTo($message->getReplyTo());
$this->log->setStatus($status);
$this->log->setTemplateId($templateID);
$this->log->setLanguage($language);
// Save
$this->entityManager->persist($this->log);
$this->entityManager->flush();
return true;
} | [
"private",
"function",
"logCreate",
"(",
"\\",
"Swift_Mime_SimpleMessage",
"$",
"message",
",",
"$",
"status",
",",
"$",
"templateID",
",",
"$",
"language",
")",
"{",
"// Check Message",
"if",
"(",
"null",
"===",
"$",
"message",
"->",
"getId",
"(",
")",
"|... | Create Mail Log.
@param \Swift_Mime_SimpleMessage $message
@param $status
@param $templateID
@param $language
@return bool | [
"Create",
"Mail",
"Log",
"."
] | c701cf6778e9c8991ae4b74dbf5e7d3d77310c0f | https://github.com/appaydin/pd-mailer/blob/c701cf6778e9c8991ae4b74dbf5e7d3d77310c0f/SwiftMailer/SendListener.php#L161-L189 | train |
appaydin/pd-mailer | SwiftMailer/SendListener.php | SendListener.logUpdate | private function logUpdate(\Swift_Mime_SimpleMessage $message, $status)
{
// Check Message
if (null === $message->getId() || empty($message->getId())) {
return false;
}
// Update Data
$this->log->setStatus($status);
$this->log->setDate($message->getDate());
// Save || Update
$this->entityManager->persist($this->log);
$this->entityManager->flush();
return true;
} | php | private function logUpdate(\Swift_Mime_SimpleMessage $message, $status)
{
// Check Message
if (null === $message->getId() || empty($message->getId())) {
return false;
}
// Update Data
$this->log->setStatus($status);
$this->log->setDate($message->getDate());
// Save || Update
$this->entityManager->persist($this->log);
$this->entityManager->flush();
return true;
} | [
"private",
"function",
"logUpdate",
"(",
"\\",
"Swift_Mime_SimpleMessage",
"$",
"message",
",",
"$",
"status",
")",
"{",
"// Check Message",
"if",
"(",
"null",
"===",
"$",
"message",
"->",
"getId",
"(",
")",
"||",
"empty",
"(",
"$",
"message",
"->",
"getId... | Update Log Status & Date.
@param \Swift_Mime_SimpleMessage $message
@param $status
@return bool | [
"Update",
"Log",
"Status",
"&",
"Date",
"."
] | c701cf6778e9c8991ae4b74dbf5e7d3d77310c0f | https://github.com/appaydin/pd-mailer/blob/c701cf6778e9c8991ae4b74dbf5e7d3d77310c0f/SwiftMailer/SendListener.php#L199-L215 | train |
CradlePHP/cradle-system | src/Fieldset.php | Fieldset.getFields | public function getFields()
{
$results = [];
if (!isset($this->data['fields'])
|| empty($this->data['fields'])
) {
return $results;
}
$table = $this->data['name'];
foreach ($this->data['fields'] as $field) {
$name = $table . '_' . $field['name'];
$results[$name] = $field;
}
return $results;
} | php | public function getFields()
{
$results = [];
if (!isset($this->data['fields'])
|| empty($this->data['fields'])
) {
return $results;
}
$table = $this->data['name'];
foreach ($this->data['fields'] as $field) {
$name = $table . '_' . $field['name'];
$results[$name] = $field;
}
return $results;
} | [
"public",
"function",
"getFields",
"(",
")",
"{",
"$",
"results",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"data",
"[",
"'fields'",
"]",
")",
"||",
"empty",
"(",
"$",
"this",
"->",
"data",
"[",
"'fields'",
"]",
")",
... | Returns All fields
@return array | [
"Returns",
"All",
"fields"
] | 3dda31fbc7e4523fdcc87e18a7ab852116cbdc6c | https://github.com/CradlePHP/cradle-system/blob/3dda31fbc7e4523fdcc87e18a7ab852116cbdc6c/src/Fieldset.php#L104-L120 | train |
CradlePHP/cradle-system | src/Fieldset.php | Fieldset.getFileFieldNames | public function getFileFieldNames()
{
$results = [];
if (!isset($this->data['fields'])
|| empty($this->data['fields'])
) {
return $results;
}
$table = $this->data['name'];
foreach ($this->data['fields'] as $field) {
$name = $table . '_' . $field['name'];
if (in_array(
$field['field']['type'],
[
'file',
'image',
'filelist',
'imagelist'
]
)
) {
$results[] = $name;
}
}
return $results;
} | php | public function getFileFieldNames()
{
$results = [];
if (!isset($this->data['fields'])
|| empty($this->data['fields'])
) {
return $results;
}
$table = $this->data['name'];
foreach ($this->data['fields'] as $field) {
$name = $table . '_' . $field['name'];
if (in_array(
$field['field']['type'],
[
'file',
'image',
'filelist',
'imagelist'
]
)
) {
$results[] = $name;
}
}
return $results;
} | [
"public",
"function",
"getFileFieldNames",
"(",
")",
"{",
"$",
"results",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"data",
"[",
"'fields'",
"]",
")",
"||",
"empty",
"(",
"$",
"this",
"->",
"data",
"[",
"'fields'",
"]",
... | Returns All files
@return array | [
"Returns",
"All",
"files"
] | 3dda31fbc7e4523fdcc87e18a7ab852116cbdc6c | https://github.com/CradlePHP/cradle-system/blob/3dda31fbc7e4523fdcc87e18a7ab852116cbdc6c/src/Fieldset.php#L127-L155 | train |
CradlePHP/cradle-system | src/Fieldset.php | Fieldset.getRequiredFieldNames | public function getRequiredFieldNames()
{
$results = [];
if (!isset($this->data['fields']) || empty($this->data['fields'])) {
return $results;
}
$table = $this->data['name'];
foreach ($this->data['fields'] as $field) {
$name = $table . '_' . $field['name'];
if (!isset($field['validation'])) {
continue;
}
foreach ($field['validation'] as $validation) {
if ($validation['method'] === 'required') {
$results[] = $name;
break;
}
}
}
return $results;
} | php | public function getRequiredFieldNames()
{
$results = [];
if (!isset($this->data['fields']) || empty($this->data['fields'])) {
return $results;
}
$table = $this->data['name'];
foreach ($this->data['fields'] as $field) {
$name = $table . '_' . $field['name'];
if (!isset($field['validation'])) {
continue;
}
foreach ($field['validation'] as $validation) {
if ($validation['method'] === 'required') {
$results[] = $name;
break;
}
}
}
return $results;
} | [
"public",
"function",
"getRequiredFieldNames",
"(",
")",
"{",
"$",
"results",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"data",
"[",
"'fields'",
"]",
")",
"||",
"empty",
"(",
"$",
"this",
"->",
"data",
"[",
"'fields'",
"]... | Returns a list of required fields
@return array | [
"Returns",
"a",
"list",
"of",
"required",
"fields"
] | 3dda31fbc7e4523fdcc87e18a7ab852116cbdc6c | https://github.com/CradlePHP/cradle-system/blob/3dda31fbc7e4523fdcc87e18a7ab852116cbdc6c/src/Fieldset.php#L231-L254 | train |
CradlePHP/cradle-system | src/Fieldset.php | Fieldset.getSlugableFieldNames | public function getSlugableFieldNames($primary = false)
{
$results = [];
if ($primary) {
$results[] = $primary;
}
if (!isset($this->data['fields']) || empty($this->data['fields'])) {
return $results;
}
$table = $this->data['name'];
foreach ($this->data['fields'] as $field) {
$name = $table . '_' . $field['name'];
if (isset($field['type'])) {
if ($field['type'] === 'slug') {
$results[] = $name;
}
}
}
return $results;
} | php | public function getSlugableFieldNames($primary = false)
{
$results = [];
if ($primary) {
$results[] = $primary;
}
if (!isset($this->data['fields']) || empty($this->data['fields'])) {
return $results;
}
$table = $this->data['name'];
foreach ($this->data['fields'] as $field) {
$name = $table . '_' . $field['name'];
if (isset($field['type'])) {
if ($field['type'] === 'slug') {
$results[] = $name;
}
}
}
return $results;
} | [
"public",
"function",
"getSlugableFieldNames",
"(",
"$",
"primary",
"=",
"false",
")",
"{",
"$",
"results",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"primary",
")",
"{",
"$",
"results",
"[",
"]",
"=",
"$",
"primary",
";",
"}",
"if",
"(",
"!",
"isset",
... | Returns slug fields
@param string|false $primary
@return array | [
"Returns",
"slug",
"fields"
] | 3dda31fbc7e4523fdcc87e18a7ab852116cbdc6c | https://github.com/CradlePHP/cradle-system/blob/3dda31fbc7e4523fdcc87e18a7ab852116cbdc6c/src/Fieldset.php#L263-L285 | train |
CradlePHP/cradle-system | src/Fieldset.php | Fieldset.getUniqueFieldNames | public function getUniqueFieldNames()
{
$results = [ $this->getPrimaryFieldName() ];
if (!isset($this->data['fields']) || empty($this->data['fields'])) {
return $results;
}
$table = $this->data['name'];
foreach ($this->data['fields'] as $field) {
$name = $table . '_' . $field['name'];
if ($field['field']['type'] === 'uuid') {
$results[] = $name;
continue;
}
if (!isset($field['validation'])) {
continue;
}
foreach ($field['validation'] as $validation) {
if ($validation['method'] === 'unique') {
$results[] = $name;
}
}
}
return $results;
} | php | public function getUniqueFieldNames()
{
$results = [ $this->getPrimaryFieldName() ];
if (!isset($this->data['fields']) || empty($this->data['fields'])) {
return $results;
}
$table = $this->data['name'];
foreach ($this->data['fields'] as $field) {
$name = $table . '_' . $field['name'];
if ($field['field']['type'] === 'uuid') {
$results[] = $name;
continue;
}
if (!isset($field['validation'])) {
continue;
}
foreach ($field['validation'] as $validation) {
if ($validation['method'] === 'unique') {
$results[] = $name;
}
}
}
return $results;
} | [
"public",
"function",
"getUniqueFieldNames",
"(",
")",
"{",
"$",
"results",
"=",
"[",
"$",
"this",
"->",
"getPrimaryFieldName",
"(",
")",
"]",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"data",
"[",
"'fields'",
"]",
")",
"||",
"empty",
"("... | Returns a list of unique fields
@return array | [
"Returns",
"a",
"list",
"of",
"unique",
"fields"
] | 3dda31fbc7e4523fdcc87e18a7ab852116cbdc6c | https://github.com/CradlePHP/cradle-system/blob/3dda31fbc7e4523fdcc87e18a7ab852116cbdc6c/src/Fieldset.php#L292-L320 | train |
ahand/mobileesp | PHP/mdetect.php | uagent_info.uagent_info | function uagent_info()
{
$this->useragent = isset($_SERVER['HTTP_USER_AGENT'])?strtolower($_SERVER['HTTP_USER_AGENT']):'';
$this->httpaccept = isset($_SERVER['HTTP_ACCEPT'])?strtolower($_SERVER['HTTP_ACCEPT']):'';
//Let's initialize some values to save cycles later.
$this->InitDeviceScan();
} | php | function uagent_info()
{
$this->useragent = isset($_SERVER['HTTP_USER_AGENT'])?strtolower($_SERVER['HTTP_USER_AGENT']):'';
$this->httpaccept = isset($_SERVER['HTTP_ACCEPT'])?strtolower($_SERVER['HTTP_ACCEPT']):'';
//Let's initialize some values to save cycles later.
$this->InitDeviceScan();
} | [
"function",
"uagent_info",
"(",
")",
"{",
"$",
"this",
"->",
"useragent",
"=",
"isset",
"(",
"$",
"_SERVER",
"[",
"'HTTP_USER_AGENT'",
"]",
")",
"?",
"strtolower",
"(",
"$",
"_SERVER",
"[",
"'HTTP_USER_AGENT'",
"]",
")",
":",
"''",
";",
"$",
"this",
"-... | The object initializer. Initializes several default variables. | [
"The",
"object",
"initializer",
".",
"Initializes",
"several",
"default",
"variables",
"."
] | c02055dbe9baee63aab11438f4d7b5d25075d347 | https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L225-L232 | train |
ahand/mobileesp | PHP/mdetect.php | uagent_info.InitDeviceScan | function InitDeviceScan()
{
//Save these properties to speed processing
global $isWebkit, $isIphone, $isAndroid, $isAndroidPhone;
$this->isWebkit = $this->DetectWebkit();
$this->isIphone = $this->DetectIphone();
$this->isAndroid = $this->DetectAndroid();
$this->isAndroidPhone = $this->DetectAndroidPhone();
//These tiers are the most useful for web development
global $isMobilePhone, $isTierTablet, $isTierIphone;
$this->isMobilePhone = $this->DetectMobileQuick();
$this->isTierIphone = $this->DetectTierIphone();
$this->isTierTablet = $this->DetectTierTablet();
//Optional: Comment these out if you NEVER use them.
global $isTierRichCss, $isTierGenericMobile;
$this->isTierRichCss = $this->DetectTierRichCss();
$this->isTierGenericMobile = $this->DetectTierOtherPhones();
$this->initCompleted = $this->true;
} | php | function InitDeviceScan()
{
//Save these properties to speed processing
global $isWebkit, $isIphone, $isAndroid, $isAndroidPhone;
$this->isWebkit = $this->DetectWebkit();
$this->isIphone = $this->DetectIphone();
$this->isAndroid = $this->DetectAndroid();
$this->isAndroidPhone = $this->DetectAndroidPhone();
//These tiers are the most useful for web development
global $isMobilePhone, $isTierTablet, $isTierIphone;
$this->isMobilePhone = $this->DetectMobileQuick();
$this->isTierIphone = $this->DetectTierIphone();
$this->isTierTablet = $this->DetectTierTablet();
//Optional: Comment these out if you NEVER use them.
global $isTierRichCss, $isTierGenericMobile;
$this->isTierRichCss = $this->DetectTierRichCss();
$this->isTierGenericMobile = $this->DetectTierOtherPhones();
$this->initCompleted = $this->true;
} | [
"function",
"InitDeviceScan",
"(",
")",
"{",
"//Save these properties to speed processing\r",
"global",
"$",
"isWebkit",
",",
"$",
"isIphone",
",",
"$",
"isAndroid",
",",
"$",
"isAndroidPhone",
";",
"$",
"this",
"->",
"isWebkit",
"=",
"$",
"this",
"->",
"DetectW... | Initialize Key Stored Values. | [
"Initialize",
"Key",
"Stored",
"Values",
"."
] | c02055dbe9baee63aab11438f4d7b5d25075d347 | https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L236-L257 | train |
ahand/mobileesp | PHP/mdetect.php | uagent_info.DetectIphone | function DetectIphone()
{
if ($this->initCompleted == $this->true ||
$this->isIphone == $this->true)
return $this->isIphone;
if (stripos($this->useragent, $this->deviceIphone) > -1)
{
//The iPad and iPod Touch say they're an iPhone. So let's disambiguate.
if ($this->DetectIpad() == $this->true ||
$this->DetectIpod() == $this->true)
return $this->false;
//Yay! It's an iPhone!
else
return $this->true;
}
else
return $this->false;
} | php | function DetectIphone()
{
if ($this->initCompleted == $this->true ||
$this->isIphone == $this->true)
return $this->isIphone;
if (stripos($this->useragent, $this->deviceIphone) > -1)
{
//The iPad and iPod Touch say they're an iPhone. So let's disambiguate.
if ($this->DetectIpad() == $this->true ||
$this->DetectIpod() == $this->true)
return $this->false;
//Yay! It's an iPhone!
else
return $this->true;
}
else
return $this->false;
} | [
"function",
"DetectIphone",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"initCompleted",
"==",
"$",
"this",
"->",
"true",
"||",
"$",
"this",
"->",
"isIphone",
"==",
"$",
"this",
"->",
"true",
")",
"return",
"$",
"this",
"->",
"isIphone",
";",
"if",
... | Detects if the current device is an iPhone. | [
"Detects",
"if",
"the",
"current",
"device",
"is",
"an",
"iPhone",
"."
] | c02055dbe9baee63aab11438f4d7b5d25075d347 | https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L280-L298 | train |
ahand/mobileesp | PHP/mdetect.php | uagent_info.DetectIpod | function DetectIpod()
{
if (stripos($this->useragent, $this->deviceIpod) > -1)
return $this->true;
else
return $this->false;
} | php | function DetectIpod()
{
if (stripos($this->useragent, $this->deviceIpod) > -1)
return $this->true;
else
return $this->false;
} | [
"function",
"DetectIpod",
"(",
")",
"{",
"if",
"(",
"stripos",
"(",
"$",
"this",
"->",
"useragent",
",",
"$",
"this",
"->",
"deviceIpod",
")",
">",
"-",
"1",
")",
"return",
"$",
"this",
"->",
"true",
";",
"else",
"return",
"$",
"this",
"->",
"false... | Detects if the current device is an iPod Touch. | [
"Detects",
"if",
"the",
"current",
"device",
"is",
"an",
"iPod",
"Touch",
"."
] | c02055dbe9baee63aab11438f4d7b5d25075d347 | https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L302-L308 | train |
ahand/mobileesp | PHP/mdetect.php | uagent_info.DetectIpad | function DetectIpad()
{
if (stripos($this->useragent, $this->deviceIpad) > -1 &&
$this->DetectWebkit() == $this->true)
return $this->true;
else
return $this->false;
} | php | function DetectIpad()
{
if (stripos($this->useragent, $this->deviceIpad) > -1 &&
$this->DetectWebkit() == $this->true)
return $this->true;
else
return $this->false;
} | [
"function",
"DetectIpad",
"(",
")",
"{",
"if",
"(",
"stripos",
"(",
"$",
"this",
"->",
"useragent",
",",
"$",
"this",
"->",
"deviceIpad",
")",
">",
"-",
"1",
"&&",
"$",
"this",
"->",
"DetectWebkit",
"(",
")",
"==",
"$",
"this",
"->",
"true",
")",
... | Detects if the current device is an iPad tablet. | [
"Detects",
"if",
"the",
"current",
"device",
"is",
"an",
"iPad",
"tablet",
"."
] | c02055dbe9baee63aab11438f4d7b5d25075d347 | https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L312-L319 | train |
ahand/mobileesp | PHP/mdetect.php | uagent_info.DetectIphoneOrIpod | function DetectIphoneOrIpod()
{
//We repeat the searches here because some iPods may report themselves as an iPhone, which would be okay.
if ($this->DetectIphone() == $this->true ||
$this->DetectIpod() == $this->true)
return $this->true;
else
return $this->false;
} | php | function DetectIphoneOrIpod()
{
//We repeat the searches here because some iPods may report themselves as an iPhone, which would be okay.
if ($this->DetectIphone() == $this->true ||
$this->DetectIpod() == $this->true)
return $this->true;
else
return $this->false;
} | [
"function",
"DetectIphoneOrIpod",
"(",
")",
"{",
"//We repeat the searches here because some iPods may report themselves as an iPhone, which would be okay.\r",
"if",
"(",
"$",
"this",
"->",
"DetectIphone",
"(",
")",
"==",
"$",
"this",
"->",
"true",
"||",
"$",
"this",
"->"... | Detects if the current device is an iPhone or iPod Touch. | [
"Detects",
"if",
"the",
"current",
"device",
"is",
"an",
"iPhone",
"or",
"iPod",
"Touch",
"."
] | c02055dbe9baee63aab11438f4d7b5d25075d347 | https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L323-L331 | train |
ahand/mobileesp | PHP/mdetect.php | uagent_info.DetectAndroid | function DetectAndroid()
{
if ($this->initCompleted == $this->true ||
$this->isAndroid == $this->true)
return $this->isAndroid;
if ((stripos($this->useragent, $this->deviceAndroid) > -1)
|| ($this->DetectGoogleTV() == $this->true))
return $this->true;
return $this->false;
} | php | function DetectAndroid()
{
if ($this->initCompleted == $this->true ||
$this->isAndroid == $this->true)
return $this->isAndroid;
if ((stripos($this->useragent, $this->deviceAndroid) > -1)
|| ($this->DetectGoogleTV() == $this->true))
return $this->true;
return $this->false;
} | [
"function",
"DetectAndroid",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"initCompleted",
"==",
"$",
"this",
"->",
"true",
"||",
"$",
"this",
"->",
"isAndroid",
"==",
"$",
"this",
"->",
"true",
")",
"return",
"$",
"this",
"->",
"isAndroid",
";",
"if... | Also detects Google TV. | [
"Also",
"detects",
"Google",
"TV",
"."
] | c02055dbe9baee63aab11438f4d7b5d25075d347 | https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L348-L359 | train |
ahand/mobileesp | PHP/mdetect.php | uagent_info.DetectAndroidTablet | function DetectAndroidTablet()
{
//First, let's make sure we're on an Android device.
if ($this->DetectAndroid() == $this->false)
return $this->false;
//Special check for Android devices with Opera Mobile/Mini. They should NOT report here.
if ($this->DetectOperaMobile() == $this->true)
return $this->false;
//Otherwise, if it's Android and does NOT have 'mobile' in it, Google says it's a tablet.
if (stripos($this->useragent, $this->mobile) > -1)
return $this->false;
else
return $this->true;
} | php | function DetectAndroidTablet()
{
//First, let's make sure we're on an Android device.
if ($this->DetectAndroid() == $this->false)
return $this->false;
//Special check for Android devices with Opera Mobile/Mini. They should NOT report here.
if ($this->DetectOperaMobile() == $this->true)
return $this->false;
//Otherwise, if it's Android and does NOT have 'mobile' in it, Google says it's a tablet.
if (stripos($this->useragent, $this->mobile) > -1)
return $this->false;
else
return $this->true;
} | [
"function",
"DetectAndroidTablet",
"(",
")",
"{",
"//First, let's make sure we're on an Android device.\r",
"if",
"(",
"$",
"this",
"->",
"DetectAndroid",
"(",
")",
"==",
"$",
"this",
"->",
"false",
")",
"return",
"$",
"this",
"->",
"false",
";",
"//Special check ... | Google says these devices will have 'Android' and NOT 'mobile' in their user agent. | [
"Google",
"says",
"these",
"devices",
"will",
"have",
"Android",
"and",
"NOT",
"mobile",
"in",
"their",
"user",
"agent",
"."
] | c02055dbe9baee63aab11438f4d7b5d25075d347 | https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L390-L405 | train |
ahand/mobileesp | PHP/mdetect.php | uagent_info.DetectAndroidWebKit | function DetectAndroidWebKit()
{
if (($this->DetectAndroid() == $this->true) &&
($this->DetectWebkit() == $this->true))
return $this->true;
else
return $this->false;
} | php | function DetectAndroidWebKit()
{
if (($this->DetectAndroid() == $this->true) &&
($this->DetectWebkit() == $this->true))
return $this->true;
else
return $this->false;
} | [
"function",
"DetectAndroidWebKit",
"(",
")",
"{",
"if",
"(",
"(",
"$",
"this",
"->",
"DetectAndroid",
"(",
")",
"==",
"$",
"this",
"->",
"true",
")",
"&&",
"(",
"$",
"this",
"->",
"DetectWebkit",
"(",
")",
"==",
"$",
"this",
"->",
"true",
")",
")",... | the browser is based on WebKit. | [
"the",
"browser",
"is",
"based",
"on",
"WebKit",
"."
] | c02055dbe9baee63aab11438f4d7b5d25075d347 | https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L410-L417 | train |
ahand/mobileesp | PHP/mdetect.php | uagent_info.DetectGoogleTV | function DetectGoogleTV()
{
if (stripos($this->useragent, $this->deviceGoogleTV) > -1)
return $this->true;
else
return $this->false;
} | php | function DetectGoogleTV()
{
if (stripos($this->useragent, $this->deviceGoogleTV) > -1)
return $this->true;
else
return $this->false;
} | [
"function",
"DetectGoogleTV",
"(",
")",
"{",
"if",
"(",
"stripos",
"(",
"$",
"this",
"->",
"useragent",
",",
"$",
"this",
"->",
"deviceGoogleTV",
")",
">",
"-",
"1",
")",
"return",
"$",
"this",
"->",
"true",
";",
"else",
"return",
"$",
"this",
"->",
... | Detects if the current device is a GoogleTV. | [
"Detects",
"if",
"the",
"current",
"device",
"is",
"a",
"GoogleTV",
"."
] | c02055dbe9baee63aab11438f4d7b5d25075d347 | https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L421-L427 | train |
ahand/mobileesp | PHP/mdetect.php | uagent_info.DetectWebkit | function DetectWebkit()
{
if ($this->initCompleted == $this->true ||
$this->isWebkit == $this->true)
return $this->isWebkit;
if (stripos($this->useragent, $this->engineWebKit) > -1)
return $this->true;
else
return $this->false;
} | php | function DetectWebkit()
{
if ($this->initCompleted == $this->true ||
$this->isWebkit == $this->true)
return $this->isWebkit;
if (stripos($this->useragent, $this->engineWebKit) > -1)
return $this->true;
else
return $this->false;
} | [
"function",
"DetectWebkit",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"initCompleted",
"==",
"$",
"this",
"->",
"true",
"||",
"$",
"this",
"->",
"isWebkit",
"==",
"$",
"this",
"->",
"true",
")",
"return",
"$",
"this",
"->",
"isWebkit",
";",
"if",
... | Detects if the current browser is based on WebKit. | [
"Detects",
"if",
"the",
"current",
"browser",
"is",
"based",
"on",
"WebKit",
"."
] | c02055dbe9baee63aab11438f4d7b5d25075d347 | https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L431-L441 | train |
ahand/mobileesp | PHP/mdetect.php | uagent_info.DetectWindowsPhone | function DetectWindowsPhone()
{
if (($this->DetectWindowsPhone7() == $this->true)
|| ($this->DetectWindowsPhone8() == $this->true)
|| ($this->DetectWindowsPhone10() == $this->true))
return $this->true;
else
return $this->false;
} | php | function DetectWindowsPhone()
{
if (($this->DetectWindowsPhone7() == $this->true)
|| ($this->DetectWindowsPhone8() == $this->true)
|| ($this->DetectWindowsPhone10() == $this->true))
return $this->true;
else
return $this->false;
} | [
"function",
"DetectWindowsPhone",
"(",
")",
"{",
"if",
"(",
"(",
"$",
"this",
"->",
"DetectWindowsPhone7",
"(",
")",
"==",
"$",
"this",
"->",
"true",
")",
"||",
"(",
"$",
"this",
"->",
"DetectWindowsPhone8",
"(",
")",
"==",
"$",
"this",
"->",
"true",
... | Windows Phone 7, 8, or 10 device. | [
"Windows",
"Phone",
"7",
"8",
"or",
"10",
"device",
"."
] | c02055dbe9baee63aab11438f4d7b5d25075d347 | https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L447-L455 | train |
ahand/mobileesp | PHP/mdetect.php | uagent_info.DetectWindowsMobile | function DetectWindowsMobile()
{
if ($this->DetectWindowsPhone() == $this->true)
return $this->false;
//Most devices use 'Windows CE', but some report 'iemobile'
// and some older ones report as 'PIE' for Pocket IE.
if (stripos($this->useragent, $this->deviceWinMob) > -1 ||
stripos($this->useragent, $this->deviceIeMob) > -1 ||
stripos($this->useragent, $this->enginePie) > -1)
return $this->true;
//Test for Windows Mobile PPC but not old Macintosh PowerPC.
if (stripos($this->useragent, $this->devicePpc) > -1
&& !(stripos($this->useragent, $this->deviceMacPpc) > 1))
return $this->true;
//Test for certain Windwos Mobile-based HTC devices.
if (stripos($this->useragent, $this->manuHtc) > -1 &&
stripos($this->useragent, $this->deviceWindows) > -1)
return $this->true;
if ($this->DetectWapWml() == $this->true &&
stripos($this->useragent, $this->deviceWindows) > -1)
return $this->true;
else
return $this->false;
} | php | function DetectWindowsMobile()
{
if ($this->DetectWindowsPhone() == $this->true)
return $this->false;
//Most devices use 'Windows CE', but some report 'iemobile'
// and some older ones report as 'PIE' for Pocket IE.
if (stripos($this->useragent, $this->deviceWinMob) > -1 ||
stripos($this->useragent, $this->deviceIeMob) > -1 ||
stripos($this->useragent, $this->enginePie) > -1)
return $this->true;
//Test for Windows Mobile PPC but not old Macintosh PowerPC.
if (stripos($this->useragent, $this->devicePpc) > -1
&& !(stripos($this->useragent, $this->deviceMacPpc) > 1))
return $this->true;
//Test for certain Windwos Mobile-based HTC devices.
if (stripos($this->useragent, $this->manuHtc) > -1 &&
stripos($this->useragent, $this->deviceWindows) > -1)
return $this->true;
if ($this->DetectWapWml() == $this->true &&
stripos($this->useragent, $this->deviceWindows) > -1)
return $this->true;
else
return $this->false;
} | [
"function",
"DetectWindowsMobile",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"DetectWindowsPhone",
"(",
")",
"==",
"$",
"this",
"->",
"true",
")",
"return",
"$",
"this",
"->",
"false",
";",
"//Most devices use 'Windows CE', but some report 'iemobile' \r",
"// ... | Focuses on Windows Mobile 6.xx and earlier. | [
"Focuses",
"on",
"Windows",
"Mobile",
"6",
".",
"xx",
"and",
"earlier",
"."
] | c02055dbe9baee63aab11438f4d7b5d25075d347 | https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L491-L515 | train |
ahand/mobileesp | PHP/mdetect.php | uagent_info.DetectBlackBerry | function DetectBlackBerry()
{
if ((stripos($this->useragent, $this->deviceBB) > -1) ||
(stripos($this->httpaccept, $this->vndRIM) > -1))
return $this->true;
if ($this->DetectBlackBerry10Phone() == $this->true)
return $this->true;
else
return $this->false;
} | php | function DetectBlackBerry()
{
if ((stripos($this->useragent, $this->deviceBB) > -1) ||
(stripos($this->httpaccept, $this->vndRIM) > -1))
return $this->true;
if ($this->DetectBlackBerry10Phone() == $this->true)
return $this->true;
else
return $this->false;
} | [
"function",
"DetectBlackBerry",
"(",
")",
"{",
"if",
"(",
"(",
"stripos",
"(",
"$",
"this",
"->",
"useragent",
",",
"$",
"this",
"->",
"deviceBB",
")",
">",
"-",
"1",
")",
"||",
"(",
"stripos",
"(",
"$",
"this",
"->",
"httpaccept",
",",
"$",
"this"... | Includes BB10 OS, but excludes the PlayBook. | [
"Includes",
"BB10",
"OS",
"but",
"excludes",
"the",
"PlayBook",
"."
] | c02055dbe9baee63aab11438f4d7b5d25075d347 | https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L520-L529 | train |
ahand/mobileesp | PHP/mdetect.php | uagent_info.DetectBlackBerry10Phone | function DetectBlackBerry10Phone()
{
if ((stripos($this->useragent, $this->deviceBB10) > -1) &&
(stripos($this->useragent, $this->mobile) > -1))
return $this->true;
else
return $this->false;
} | php | function DetectBlackBerry10Phone()
{
if ((stripos($this->useragent, $this->deviceBB10) > -1) &&
(stripos($this->useragent, $this->mobile) > -1))
return $this->true;
else
return $this->false;
} | [
"function",
"DetectBlackBerry10Phone",
"(",
")",
"{",
"if",
"(",
"(",
"stripos",
"(",
"$",
"this",
"->",
"useragent",
",",
"$",
"this",
"->",
"deviceBB10",
")",
">",
"-",
"1",
")",
"&&",
"(",
"stripos",
"(",
"$",
"this",
"->",
"useragent",
",",
"$",
... | Excludes tablets. | [
"Excludes",
"tablets",
"."
] | c02055dbe9baee63aab11438f4d7b5d25075d347 | https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L534-L541 | train |
ahand/mobileesp | PHP/mdetect.php | uagent_info.DetectBlackBerryTouch | function DetectBlackBerryTouch()
{
if ((stripos($this->useragent, $this->deviceBBStorm) > -1) ||
(stripos($this->useragent, $this->deviceBBTorch) > -1) ||
(stripos($this->useragent, $this->deviceBBBoldTouch) > -1) ||
(stripos($this->useragent, $this->deviceBBCurveTouch) > -1))
return $this->true;
else
return $this->false;
} | php | function DetectBlackBerryTouch()
{
if ((stripos($this->useragent, $this->deviceBBStorm) > -1) ||
(stripos($this->useragent, $this->deviceBBTorch) > -1) ||
(stripos($this->useragent, $this->deviceBBBoldTouch) > -1) ||
(stripos($this->useragent, $this->deviceBBCurveTouch) > -1))
return $this->true;
else
return $this->false;
} | [
"function",
"DetectBlackBerryTouch",
"(",
")",
"{",
"if",
"(",
"(",
"stripos",
"(",
"$",
"this",
"->",
"useragent",
",",
"$",
"this",
"->",
"deviceBBStorm",
")",
">",
"-",
"1",
")",
"||",
"(",
"stripos",
"(",
"$",
"this",
"->",
"useragent",
",",
"$",... | a large screen, such as the Storm, Torch, and Bold Touch. Excludes the Playbook. | [
"a",
"large",
"screen",
"such",
"as",
"the",
"Storm",
"Torch",
"and",
"Bold",
"Touch",
".",
"Excludes",
"the",
"Playbook",
"."
] | c02055dbe9baee63aab11438f4d7b5d25075d347 | https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L570-L579 | train |
ahand/mobileesp | PHP/mdetect.php | uagent_info.DetectBlackBerryHigh | function DetectBlackBerryHigh()
{
//Disambiguate for BlackBerry OS 6 or 7 (WebKit) browser
if ($this->DetectBlackBerryWebKit() == $this->true)
return $this->false;
if ($this->DetectBlackBerry() == $this->true)
{
if (($this->DetectBlackBerryTouch() == $this->true) ||
stripos($this->useragent, $this->deviceBBBold) > -1 ||
stripos($this->useragent, $this->deviceBBTour) > -1 ||
stripos($this->useragent, $this->deviceBBCurve) > -1)
{
return $this->true;
}
else
return $this->false;
}
else
return $this->false;
} | php | function DetectBlackBerryHigh()
{
//Disambiguate for BlackBerry OS 6 or 7 (WebKit) browser
if ($this->DetectBlackBerryWebKit() == $this->true)
return $this->false;
if ($this->DetectBlackBerry() == $this->true)
{
if (($this->DetectBlackBerryTouch() == $this->true) ||
stripos($this->useragent, $this->deviceBBBold) > -1 ||
stripos($this->useragent, $this->deviceBBTour) > -1 ||
stripos($this->useragent, $this->deviceBBCurve) > -1)
{
return $this->true;
}
else
return $this->false;
}
else
return $this->false;
} | [
"function",
"DetectBlackBerryHigh",
"(",
")",
"{",
"//Disambiguate for BlackBerry OS 6 or 7 (WebKit) browser\r",
"if",
"(",
"$",
"this",
"->",
"DetectBlackBerryWebKit",
"(",
")",
"==",
"$",
"this",
"->",
"true",
")",
"return",
"$",
"this",
"->",
"false",
";",
"if"... | Excludes the new BlackBerry OS 6 and 7 browser!! | [
"Excludes",
"the",
"new",
"BlackBerry",
"OS",
"6",
"and",
"7",
"browser!!"
] | c02055dbe9baee63aab11438f4d7b5d25075d347 | https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L586-L605 | train |
ahand/mobileesp | PHP/mdetect.php | uagent_info.DetectS60OssBrowser | function DetectS60OssBrowser()
{
//First, test for WebKit, then make sure it's either Symbian or S60.
if ($this->DetectWebkit() == $this->true)
{
if (stripos($this->useragent, $this->deviceSymbian) > -1 ||
stripos($this->useragent, $this->deviceS60) > -1)
{
return $this->true;
}
else
return $this->false;
}
else
return $this->false;
} | php | function DetectS60OssBrowser()
{
//First, test for WebKit, then make sure it's either Symbian or S60.
if ($this->DetectWebkit() == $this->true)
{
if (stripos($this->useragent, $this->deviceSymbian) > -1 ||
stripos($this->useragent, $this->deviceS60) > -1)
{
return $this->true;
}
else
return $this->false;
}
else
return $this->false;
} | [
"function",
"DetectS60OssBrowser",
"(",
")",
"{",
"//First, test for WebKit, then make sure it's either Symbian or S60.\r",
"if",
"(",
"$",
"this",
"->",
"DetectWebkit",
"(",
")",
"==",
"$",
"this",
"->",
"true",
")",
"{",
"if",
"(",
"stripos",
"(",
"$",
"this",
... | Detects if the current browser is the Nokia S60 Open Source Browser. | [
"Detects",
"if",
"the",
"current",
"browser",
"is",
"the",
"Nokia",
"S60",
"Open",
"Source",
"Browser",
"."
] | c02055dbe9baee63aab11438f4d7b5d25075d347 | https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L629-L644 | train |
ahand/mobileesp | PHP/mdetect.php | uagent_info.DetectSymbianOS | function DetectSymbianOS()
{
if (stripos($this->useragent, $this->deviceSymbian) > -1 ||
stripos($this->useragent, $this->deviceS60) > -1 ||
stripos($this->useragent, $this->deviceS70) > -1 ||
stripos($this->useragent, $this->deviceS80) > -1 ||
stripos($this->useragent, $this->deviceS90) > -1)
return $this->true;
else
return $this->false;
} | php | function DetectSymbianOS()
{
if (stripos($this->useragent, $this->deviceSymbian) > -1 ||
stripos($this->useragent, $this->deviceS60) > -1 ||
stripos($this->useragent, $this->deviceS70) > -1 ||
stripos($this->useragent, $this->deviceS80) > -1 ||
stripos($this->useragent, $this->deviceS90) > -1)
return $this->true;
else
return $this->false;
} | [
"function",
"DetectSymbianOS",
"(",
")",
"{",
"if",
"(",
"stripos",
"(",
"$",
"this",
"->",
"useragent",
",",
"$",
"this",
"->",
"deviceSymbian",
")",
">",
"-",
"1",
"||",
"stripos",
"(",
"$",
"this",
"->",
"useragent",
",",
"$",
"this",
"->",
"devic... | or other browsers running on these devices. | [
"or",
"other",
"browsers",
"running",
"on",
"these",
"devices",
"."
] | c02055dbe9baee63aab11438f4d7b5d25075d347 | https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L650-L660 | train |
ahand/mobileesp | PHP/mdetect.php | uagent_info.DetectPalmOS | function DetectPalmOS()
{
//Most devices nowadays report as 'Palm', but some older ones reported as Blazer or Xiino.
if (stripos($this->useragent, $this->devicePalm) > -1 ||
stripos($this->useragent, $this->engineBlazer) > -1 ||
stripos($this->useragent, $this->engineXiino) > -1)
{
//Make sure it's not WebOS first
if ($this->DetectPalmWebOS() == $this->true)
return $this->false;
else
return $this->true;
}
else
return $this->false;
} | php | function DetectPalmOS()
{
//Most devices nowadays report as 'Palm', but some older ones reported as Blazer or Xiino.
if (stripos($this->useragent, $this->devicePalm) > -1 ||
stripos($this->useragent, $this->engineBlazer) > -1 ||
stripos($this->useragent, $this->engineXiino) > -1)
{
//Make sure it's not WebOS first
if ($this->DetectPalmWebOS() == $this->true)
return $this->false;
else
return $this->true;
}
else
return $this->false;
} | [
"function",
"DetectPalmOS",
"(",
")",
"{",
"//Most devices nowadays report as 'Palm', but some older ones reported as Blazer or Xiino.\r",
"if",
"(",
"stripos",
"(",
"$",
"this",
"->",
"useragent",
",",
"$",
"this",
"->",
"devicePalm",
")",
">",
"-",
"1",
"||",
"strip... | Detects if the current browser is on a PalmOS device. | [
"Detects",
"if",
"the",
"current",
"browser",
"is",
"on",
"a",
"PalmOS",
"device",
"."
] | c02055dbe9baee63aab11438f4d7b5d25075d347 | https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L665-L680 | train |
ahand/mobileesp | PHP/mdetect.php | uagent_info.DetectPalmWebOS | function DetectPalmWebOS()
{
if (stripos($this->useragent, $this->deviceWebOS) > -1)
return $this->true;
else
return $this->false;
} | php | function DetectPalmWebOS()
{
if (stripos($this->useragent, $this->deviceWebOS) > -1)
return $this->true;
else
return $this->false;
} | [
"function",
"DetectPalmWebOS",
"(",
")",
"{",
"if",
"(",
"stripos",
"(",
"$",
"this",
"->",
"useragent",
",",
"$",
"this",
"->",
"deviceWebOS",
")",
">",
"-",
"1",
")",
"return",
"$",
"this",
"->",
"true",
";",
"else",
"return",
"$",
"this",
"->",
... | running the new WebOS. | [
"running",
"the",
"new",
"WebOS",
"."
] | c02055dbe9baee63aab11438f4d7b5d25075d347 | https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L686-L692 | train |
ahand/mobileesp | PHP/mdetect.php | uagent_info.DetectWebOSTablet | function DetectWebOSTablet()
{
if ((stripos($this->useragent, $this->deviceWebOShp) > -1)
&& (stripos($this->useragent, $this->deviceTablet) > -1))
return $this->true;
else
return $this->false;
} | php | function DetectWebOSTablet()
{
if ((stripos($this->useragent, $this->deviceWebOShp) > -1)
&& (stripos($this->useragent, $this->deviceTablet) > -1))
return $this->true;
else
return $this->false;
} | [
"function",
"DetectWebOSTablet",
"(",
")",
"{",
"if",
"(",
"(",
"stripos",
"(",
"$",
"this",
"->",
"useragent",
",",
"$",
"this",
"->",
"deviceWebOShp",
")",
">",
"-",
"1",
")",
"&&",
"(",
"stripos",
"(",
"$",
"this",
"->",
"useragent",
",",
"$",
"... | Detects if the current browser is on an HP tablet running WebOS. | [
"Detects",
"if",
"the",
"current",
"browser",
"is",
"on",
"an",
"HP",
"tablet",
"running",
"WebOS",
"."
] | c02055dbe9baee63aab11438f4d7b5d25075d347 | https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L696-L703 | train |
ahand/mobileesp | PHP/mdetect.php | uagent_info.DetectWebOSTV | function DetectWebOSTV()
{
if ((stripos($this->useragent, $this->deviceWebOStv) > -1)
&& (stripos($this->useragent, $this->smartTV2) > -1))
return $this->true;
else
return $this->false;
} | php | function DetectWebOSTV()
{
if ((stripos($this->useragent, $this->deviceWebOStv) > -1)
&& (stripos($this->useragent, $this->smartTV2) > -1))
return $this->true;
else
return $this->false;
} | [
"function",
"DetectWebOSTV",
"(",
")",
"{",
"if",
"(",
"(",
"stripos",
"(",
"$",
"this",
"->",
"useragent",
",",
"$",
"this",
"->",
"deviceWebOStv",
")",
">",
"-",
"1",
")",
"&&",
"(",
"stripos",
"(",
"$",
"this",
"->",
"useragent",
",",
"$",
"this... | Detects if the current browser is on a WebOS smart TV. | [
"Detects",
"if",
"the",
"current",
"browser",
"is",
"on",
"a",
"WebOS",
"smart",
"TV",
"."
] | c02055dbe9baee63aab11438f4d7b5d25075d347 | https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L707-L714 | train |
ahand/mobileesp | PHP/mdetect.php | uagent_info.DetectOperaMobile | function DetectOperaMobile()
{
if ((stripos($this->useragent, $this->engineOpera) > -1) &&
((stripos($this->useragent, $this->mini) > -1) ||
(stripos($this->useragent, $this->mobi) > -1)))
return $this->true;
return $this->false;
} | php | function DetectOperaMobile()
{
if ((stripos($this->useragent, $this->engineOpera) > -1) &&
((stripos($this->useragent, $this->mini) > -1) ||
(stripos($this->useragent, $this->mobi) > -1)))
return $this->true;
return $this->false;
} | [
"function",
"DetectOperaMobile",
"(",
")",
"{",
"if",
"(",
"(",
"stripos",
"(",
"$",
"this",
"->",
"useragent",
",",
"$",
"this",
"->",
"engineOpera",
")",
">",
"-",
"1",
")",
"&&",
"(",
"(",
"stripos",
"(",
"$",
"this",
"->",
"useragent",
",",
"$"... | Detects if the current browser is Opera Mobile or Mini. | [
"Detects",
"if",
"the",
"current",
"browser",
"is",
"Opera",
"Mobile",
"or",
"Mini",
"."
] | c02055dbe9baee63aab11438f4d7b5d25075d347 | https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L719-L727 | train |
ahand/mobileesp | PHP/mdetect.php | uagent_info.DetectGarminNuvifone | function DetectGarminNuvifone()
{
if (stripos($this->useragent, $this->deviceNuvifone) > -1)
return $this->true;
else
return $this->false;
} | php | function DetectGarminNuvifone()
{
if (stripos($this->useragent, $this->deviceNuvifone) > -1)
return $this->true;
else
return $this->false;
} | [
"function",
"DetectGarminNuvifone",
"(",
")",
"{",
"if",
"(",
"stripos",
"(",
"$",
"this",
"->",
"useragent",
",",
"$",
"this",
"->",
"deviceNuvifone",
")",
">",
"-",
"1",
")",
"return",
"$",
"this",
"->",
"true",
";",
"else",
"return",
"$",
"this",
... | Detects if a Garmin Nuvifone device. | [
"Detects",
"if",
"a",
"Garmin",
"Nuvifone",
"device",
"."
] | c02055dbe9baee63aab11438f4d7b5d25075d347 | https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L754-L760 | train |
ahand/mobileesp | PHP/mdetect.php | uagent_info.DetectBada | function DetectBada()
{
if (stripos($this->useragent, $this->deviceBada) > -1)
return $this->true;
else
return $this->false;
} | php | function DetectBada()
{
if (stripos($this->useragent, $this->deviceBada) > -1)
return $this->true;
else
return $this->false;
} | [
"function",
"DetectBada",
"(",
")",
"{",
"if",
"(",
"stripos",
"(",
"$",
"this",
"->",
"useragent",
",",
"$",
"this",
"->",
"deviceBada",
")",
">",
"-",
"1",
")",
"return",
"$",
"this",
"->",
"true",
";",
"else",
"return",
"$",
"this",
"->",
"false... | Detects a device running the Bada OS from Samsung. | [
"Detects",
"a",
"device",
"running",
"the",
"Bada",
"OS",
"from",
"Samsung",
"."
] | c02055dbe9baee63aab11438f4d7b5d25075d347 | https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L764-L770 | train |
ahand/mobileesp | PHP/mdetect.php | uagent_info.DetectTizen | function DetectTizen()
{
if ((stripos($this->useragent, $this->deviceTizen) > -1)
&& (stripos($this->useragent, $this->mobile) > -1))
return $this->true;
else
return $this->false;
} | php | function DetectTizen()
{
if ((stripos($this->useragent, $this->deviceTizen) > -1)
&& (stripos($this->useragent, $this->mobile) > -1))
return $this->true;
else
return $this->false;
} | [
"function",
"DetectTizen",
"(",
")",
"{",
"if",
"(",
"(",
"stripos",
"(",
"$",
"this",
"->",
"useragent",
",",
"$",
"this",
"->",
"deviceTizen",
")",
">",
"-",
"1",
")",
"&&",
"(",
"stripos",
"(",
"$",
"this",
"->",
"useragent",
",",
"$",
"this",
... | Detects a device running the Tizen smartphone OS. | [
"Detects",
"a",
"device",
"running",
"the",
"Tizen",
"smartphone",
"OS",
"."
] | c02055dbe9baee63aab11438f4d7b5d25075d347 | https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L774-L781 | train |
ahand/mobileesp | PHP/mdetect.php | uagent_info.DetectTizenTV | function DetectTizenTV()
{
if ((stripos($this->useragent, $this->deviceTizen) > -1)
&& (stripos($this->useragent, $this->smartTV1) > -1))
return $this->true;
else
return $this->false;
} | php | function DetectTizenTV()
{
if ((stripos($this->useragent, $this->deviceTizen) > -1)
&& (stripos($this->useragent, $this->smartTV1) > -1))
return $this->true;
else
return $this->false;
} | [
"function",
"DetectTizenTV",
"(",
")",
"{",
"if",
"(",
"(",
"stripos",
"(",
"$",
"this",
"->",
"useragent",
",",
"$",
"this",
"->",
"deviceTizen",
")",
">",
"-",
"1",
")",
"&&",
"(",
"stripos",
"(",
"$",
"this",
"->",
"useragent",
",",
"$",
"this",... | Detects if the current browser is on a Tizen smart TV. | [
"Detects",
"if",
"the",
"current",
"browser",
"is",
"on",
"a",
"Tizen",
"smart",
"TV",
"."
] | c02055dbe9baee63aab11438f4d7b5d25075d347 | https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L785-L792 | train |
ahand/mobileesp | PHP/mdetect.php | uagent_info.DetectMeego | function DetectMeego()
{
if (stripos($this->useragent, $this->deviceMeego) > -1)
return $this->true;
else
return $this->false;
} | php | function DetectMeego()
{
if (stripos($this->useragent, $this->deviceMeego) > -1)
return $this->true;
else
return $this->false;
} | [
"function",
"DetectMeego",
"(",
")",
"{",
"if",
"(",
"stripos",
"(",
"$",
"this",
"->",
"useragent",
",",
"$",
"this",
"->",
"deviceMeego",
")",
">",
"-",
"1",
")",
"return",
"$",
"this",
"->",
"true",
";",
"else",
"return",
"$",
"this",
"->",
"fal... | Detects a device running the Meego OS. | [
"Detects",
"a",
"device",
"running",
"the",
"Meego",
"OS",
"."
] | c02055dbe9baee63aab11438f4d7b5d25075d347 | https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L796-L802 | train |
ahand/mobileesp | PHP/mdetect.php | uagent_info.DetectMeegoPhone | function DetectMeegoPhone()
{
if ((stripos($this->useragent, $this->deviceMeego) > -1)
&& (stripos($this->useragent, $this->mobi) > -1))
return $this->true;
else
return $this->false;
} | php | function DetectMeegoPhone()
{
if ((stripos($this->useragent, $this->deviceMeego) > -1)
&& (stripos($this->useragent, $this->mobi) > -1))
return $this->true;
else
return $this->false;
} | [
"function",
"DetectMeegoPhone",
"(",
")",
"{",
"if",
"(",
"(",
"stripos",
"(",
"$",
"this",
"->",
"useragent",
",",
"$",
"this",
"->",
"deviceMeego",
")",
">",
"-",
"1",
")",
"&&",
"(",
"stripos",
"(",
"$",
"this",
"->",
"useragent",
",",
"$",
"thi... | Detects a phone running the Meego OS. | [
"Detects",
"a",
"phone",
"running",
"the",
"Meego",
"OS",
"."
] | c02055dbe9baee63aab11438f4d7b5d25075d347 | https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L806-L813 | train |
ahand/mobileesp | PHP/mdetect.php | uagent_info.DetectSailfish | function DetectSailfish()
{
if (stripos($this->useragent, $this->deviceSailfish) > -1)
return $this->true;
else
return $this->false;
} | php | function DetectSailfish()
{
if (stripos($this->useragent, $this->deviceSailfish) > -1)
return $this->true;
else
return $this->false;
} | [
"function",
"DetectSailfish",
"(",
")",
"{",
"if",
"(",
"stripos",
"(",
"$",
"this",
"->",
"useragent",
",",
"$",
"this",
"->",
"deviceSailfish",
")",
">",
"-",
"1",
")",
"return",
"$",
"this",
"->",
"true",
";",
"else",
"return",
"$",
"this",
"->",
... | Detects a device running the Sailfish OS. | [
"Detects",
"a",
"device",
"running",
"the",
"Sailfish",
"OS",
"."
] | c02055dbe9baee63aab11438f4d7b5d25075d347 | https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L862-L868 | train |
ahand/mobileesp | PHP/mdetect.php | uagent_info.DetectSailfishPhone | function DetectSailfishPhone()
{
if (($this->DetectSailfish() == $this->true) &&
(stripos($this->useragent, $this->mobile) > -1))
return $this->true;
return $this->false;
} | php | function DetectSailfishPhone()
{
if (($this->DetectSailfish() == $this->true) &&
(stripos($this->useragent, $this->mobile) > -1))
return $this->true;
return $this->false;
} | [
"function",
"DetectSailfishPhone",
"(",
")",
"{",
"if",
"(",
"(",
"$",
"this",
"->",
"DetectSailfish",
"(",
")",
"==",
"$",
"this",
"->",
"true",
")",
"&&",
"(",
"stripos",
"(",
"$",
"this",
"->",
"useragent",
",",
"$",
"this",
"->",
"mobile",
")",
... | Detects a phone running the Sailfish OS. | [
"Detects",
"a",
"phone",
"running",
"the",
"Sailfish",
"OS",
"."
] | c02055dbe9baee63aab11438f4d7b5d25075d347 | https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L872-L879 | train |
ahand/mobileesp | PHP/mdetect.php | uagent_info.DetectUbuntu | function DetectUbuntu()
{
if (($this->DetectUbuntuPhone() == $this->true)
|| ($this->DetectUbuntuTablet() == $this->true))
return $this->true;
else
return $this->false;
} | php | function DetectUbuntu()
{
if (($this->DetectUbuntuPhone() == $this->true)
|| ($this->DetectUbuntuTablet() == $this->true))
return $this->true;
else
return $this->false;
} | [
"function",
"DetectUbuntu",
"(",
")",
"{",
"if",
"(",
"(",
"$",
"this",
"->",
"DetectUbuntuPhone",
"(",
")",
"==",
"$",
"this",
"->",
"true",
")",
"||",
"(",
"$",
"this",
"->",
"DetectUbuntuTablet",
"(",
")",
"==",
"$",
"this",
"->",
"true",
")",
"... | Detects a mobile device running the Ubuntu Mobile OS. | [
"Detects",
"a",
"mobile",
"device",
"running",
"the",
"Ubuntu",
"Mobile",
"OS",
"."
] | c02055dbe9baee63aab11438f4d7b5d25075d347 | https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L883-L890 | train |
ahand/mobileesp | PHP/mdetect.php | uagent_info.DetectUbuntuPhone | function DetectUbuntuPhone()
{
if ((stripos($this->useragent, $this->deviceUbuntu) > -1) &&
(stripos($this->useragent, $this->mobile) > -1))
return $this->true;
return $this->false;
} | php | function DetectUbuntuPhone()
{
if ((stripos($this->useragent, $this->deviceUbuntu) > -1) &&
(stripos($this->useragent, $this->mobile) > -1))
return $this->true;
return $this->false;
} | [
"function",
"DetectUbuntuPhone",
"(",
")",
"{",
"if",
"(",
"(",
"stripos",
"(",
"$",
"this",
"->",
"useragent",
",",
"$",
"this",
"->",
"deviceUbuntu",
")",
">",
"-",
"1",
")",
"&&",
"(",
"stripos",
"(",
"$",
"this",
"->",
"useragent",
",",
"$",
"t... | Detects a phone running the Ubuntu Mobile OS. | [
"Detects",
"a",
"phone",
"running",
"the",
"Ubuntu",
"Mobile",
"OS",
"."
] | c02055dbe9baee63aab11438f4d7b5d25075d347 | https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L894-L901 | train |
ahand/mobileesp | PHP/mdetect.php | uagent_info.DetectUbuntuTablet | function DetectUbuntuTablet()
{
if ((stripos($this->useragent, $this->deviceUbuntu) > -1) &&
(stripos($this->useragent, $this->deviceTablet) > -1))
return $this->true;
return $this->false;
} | php | function DetectUbuntuTablet()
{
if ((stripos($this->useragent, $this->deviceUbuntu) > -1) &&
(stripos($this->useragent, $this->deviceTablet) > -1))
return $this->true;
return $this->false;
} | [
"function",
"DetectUbuntuTablet",
"(",
")",
"{",
"if",
"(",
"(",
"stripos",
"(",
"$",
"this",
"->",
"useragent",
",",
"$",
"this",
"->",
"deviceUbuntu",
")",
">",
"-",
"1",
")",
"&&",
"(",
"stripos",
"(",
"$",
"this",
"->",
"useragent",
",",
"$",
"... | Detects a tablet running the Ubuntu Mobile OS. | [
"Detects",
"a",
"tablet",
"running",
"the",
"Ubuntu",
"Mobile",
"OS",
"."
] | c02055dbe9baee63aab11438f4d7b5d25075d347 | https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L905-L912 | train |
ahand/mobileesp | PHP/mdetect.php | uagent_info.DetectDangerHiptop | function DetectDangerHiptop()
{
if (stripos($this->useragent, $this->deviceDanger) > -1 ||
stripos($this->useragent, $this->deviceHiptop) > -1)
return $this->true;
else
return $this->false;
} | php | function DetectDangerHiptop()
{
if (stripos($this->useragent, $this->deviceDanger) > -1 ||
stripos($this->useragent, $this->deviceHiptop) > -1)
return $this->true;
else
return $this->false;
} | [
"function",
"DetectDangerHiptop",
"(",
")",
"{",
"if",
"(",
"stripos",
"(",
"$",
"this",
"->",
"useragent",
",",
"$",
"this",
"->",
"deviceDanger",
")",
">",
"-",
"1",
"||",
"stripos",
"(",
"$",
"this",
"->",
"useragent",
",",
"$",
"this",
"->",
"dev... | Detects the Danger Hiptop device. | [
"Detects",
"the",
"Danger",
"Hiptop",
"device",
"."
] | c02055dbe9baee63aab11438f4d7b5d25075d347 | https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L916-L923 | train |
ahand/mobileesp | PHP/mdetect.php | uagent_info.DetectSonyMylo | function DetectSonyMylo()
{
if ((stripos($this->useragent, $this->manuSony) > -1) &&
((stripos($this->useragent, $this->qtembedded) > -1) ||
(stripos($this->useragent, $this->mylocom2) > -1)))
return $this->true;
else
return $this->false;
} | php | function DetectSonyMylo()
{
if ((stripos($this->useragent, $this->manuSony) > -1) &&
((stripos($this->useragent, $this->qtembedded) > -1) ||
(stripos($this->useragent, $this->mylocom2) > -1)))
return $this->true;
else
return $this->false;
} | [
"function",
"DetectSonyMylo",
"(",
")",
"{",
"if",
"(",
"(",
"stripos",
"(",
"$",
"this",
"->",
"useragent",
",",
"$",
"this",
"->",
"manuSony",
")",
">",
"-",
"1",
")",
"&&",
"(",
"(",
"stripos",
"(",
"$",
"this",
"->",
"useragent",
",",
"$",
"t... | Detects if the current browser is a Sony Mylo device. | [
"Detects",
"if",
"the",
"current",
"browser",
"is",
"a",
"Sony",
"Mylo",
"device",
"."
] | c02055dbe9baee63aab11438f4d7b5d25075d347 | https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L927-L935 | train |
ahand/mobileesp | PHP/mdetect.php | uagent_info.DetectMaemoTablet | function DetectMaemoTablet()
{
if (stripos($this->useragent, $this->maemo) > -1)
return $this->true;
//For Nokia N810, must be Linux + Tablet, or else it could be something else.
if ((stripos($this->useragent, $this->linux) > -1)
&& (stripos($this->useragent, $this->deviceTablet) > -1)
&& ($this->DetectWebOSTablet() == $this->false)
&& ($this->DetectAndroid() == $this->false))
return $this->true;
else
return $this->false;
} | php | function DetectMaemoTablet()
{
if (stripos($this->useragent, $this->maemo) > -1)
return $this->true;
//For Nokia N810, must be Linux + Tablet, or else it could be something else.
if ((stripos($this->useragent, $this->linux) > -1)
&& (stripos($this->useragent, $this->deviceTablet) > -1)
&& ($this->DetectWebOSTablet() == $this->false)
&& ($this->DetectAndroid() == $this->false))
return $this->true;
else
return $this->false;
} | [
"function",
"DetectMaemoTablet",
"(",
")",
"{",
"if",
"(",
"stripos",
"(",
"$",
"this",
"->",
"useragent",
",",
"$",
"this",
"->",
"maemo",
")",
">",
"-",
"1",
")",
"return",
"$",
"this",
"->",
"true",
";",
"//For Nokia N810, must be Linux + Tablet, or else ... | Detects if the current device is on one of the Maemo-based Nokia Internet Tablets. | [
"Detects",
"if",
"the",
"current",
"device",
"is",
"on",
"one",
"of",
"the",
"Maemo",
"-",
"based",
"Nokia",
"Internet",
"Tablets",
"."
] | c02055dbe9baee63aab11438f4d7b5d25075d347 | https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L939-L951 | train |
ahand/mobileesp | PHP/mdetect.php | uagent_info.DetectGameConsole | function DetectGameConsole()
{
if ($this->DetectSonyPlaystation() == $this->true)
return $this->true;
else if ($this->DetectNintendo() == $this->true)
return $this->true;
else if ($this->DetectXbox() == $this->true)
return $this->true;
else
return $this->false;
} | php | function DetectGameConsole()
{
if ($this->DetectSonyPlaystation() == $this->true)
return $this->true;
else if ($this->DetectNintendo() == $this->true)
return $this->true;
else if ($this->DetectXbox() == $this->true)
return $this->true;
else
return $this->false;
} | [
"function",
"DetectGameConsole",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"DetectSonyPlaystation",
"(",
")",
"==",
"$",
"this",
"->",
"true",
")",
"return",
"$",
"this",
"->",
"true",
";",
"else",
"if",
"(",
"$",
"this",
"->",
"DetectNintendo",
"("... | Includes many handheld consoles. | [
"Includes",
"many",
"handheld",
"consoles",
"."
] | c02055dbe9baee63aab11438f4d7b5d25075d347 | https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L966-L976 | train |
ahand/mobileesp | PHP/mdetect.php | uagent_info.DetectSonyPlaystation | function DetectSonyPlaystation()
{
if (stripos($this->useragent, $this->devicePlaystation) > -1)
return $this->true;
else
return $this->false;
} | php | function DetectSonyPlaystation()
{
if (stripos($this->useragent, $this->devicePlaystation) > -1)
return $this->true;
else
return $this->false;
} | [
"function",
"DetectSonyPlaystation",
"(",
")",
"{",
"if",
"(",
"stripos",
"(",
"$",
"this",
"->",
"useragent",
",",
"$",
"this",
"->",
"devicePlaystation",
")",
">",
"-",
"1",
")",
"return",
"$",
"this",
"->",
"true",
";",
"else",
"return",
"$",
"this"... | Detects if the current device is a Sony Playstation. | [
"Detects",
"if",
"the",
"current",
"device",
"is",
"a",
"Sony",
"Playstation",
"."
] | c02055dbe9baee63aab11438f4d7b5d25075d347 | https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L980-L986 | train |
ahand/mobileesp | PHP/mdetect.php | uagent_info.DetectGamingHandheld | function DetectGamingHandheld()
{
if ((stripos($this->useragent, $this->devicePlaystation) > -1) &&
(stripos($this->useragent, $this->devicePlaystationVita) > -1))
return $this->true;
else
return $this->false;
} | php | function DetectGamingHandheld()
{
if ((stripos($this->useragent, $this->devicePlaystation) > -1) &&
(stripos($this->useragent, $this->devicePlaystationVita) > -1))
return $this->true;
else
return $this->false;
} | [
"function",
"DetectGamingHandheld",
"(",
")",
"{",
"if",
"(",
"(",
"stripos",
"(",
"$",
"this",
"->",
"useragent",
",",
"$",
"this",
"->",
"devicePlaystation",
")",
">",
"-",
"1",
")",
"&&",
"(",
"stripos",
"(",
"$",
"this",
"->",
"useragent",
",",
"... | a touchscreen and modern iPhone-class browser. Includes the Playstation Vita. | [
"a",
"touchscreen",
"and",
"modern",
"iPhone",
"-",
"class",
"browser",
".",
"Includes",
"the",
"Playstation",
"Vita",
"."
] | c02055dbe9baee63aab11438f4d7b5d25075d347 | https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L991-L998 | train |
ahand/mobileesp | PHP/mdetect.php | uagent_info.DetectNintendo | function DetectNintendo()
{
if (stripos($this->useragent, $this->deviceNintendo) > -1 ||
stripos($this->useragent, $this->deviceWii) > -1 ||
stripos($this->useragent, $this->deviceNintendoDs) > -1)
return $this->true;
else
return $this->false;
} | php | function DetectNintendo()
{
if (stripos($this->useragent, $this->deviceNintendo) > -1 ||
stripos($this->useragent, $this->deviceWii) > -1 ||
stripos($this->useragent, $this->deviceNintendoDs) > -1)
return $this->true;
else
return $this->false;
} | [
"function",
"DetectNintendo",
"(",
")",
"{",
"if",
"(",
"stripos",
"(",
"$",
"this",
"->",
"useragent",
",",
"$",
"this",
"->",
"deviceNintendo",
")",
">",
"-",
"1",
"||",
"stripos",
"(",
"$",
"this",
"->",
"useragent",
",",
"$",
"this",
"->",
"devic... | Detects if the current device is a Nintendo game device. | [
"Detects",
"if",
"the",
"current",
"device",
"is",
"a",
"Nintendo",
"game",
"device",
"."
] | c02055dbe9baee63aab11438f4d7b5d25075d347 | https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L1002-L1010 | train |
ahand/mobileesp | PHP/mdetect.php | uagent_info.DetectXbox | function DetectXbox()
{
if (stripos($this->useragent, $this->deviceXbox) > -1)
return $this->true;
else
return $this->false;
} | php | function DetectXbox()
{
if (stripos($this->useragent, $this->deviceXbox) > -1)
return $this->true;
else
return $this->false;
} | [
"function",
"DetectXbox",
"(",
")",
"{",
"if",
"(",
"stripos",
"(",
"$",
"this",
"->",
"useragent",
",",
"$",
"this",
"->",
"deviceXbox",
")",
">",
"-",
"1",
")",
"return",
"$",
"this",
"->",
"true",
";",
"else",
"return",
"$",
"this",
"->",
"false... | Detects if the current device is a Microsoft Xbox. | [
"Detects",
"if",
"the",
"current",
"device",
"is",
"a",
"Microsoft",
"Xbox",
"."
] | c02055dbe9baee63aab11438f4d7b5d25075d347 | https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L1014-L1020 | train |
ahand/mobileesp | PHP/mdetect.php | uagent_info.DetectBrewDevice | function DetectBrewDevice()
{
if (stripos($this->useragent, $this->deviceBrew) > -1)
return $this->true;
else
return $this->false;
} | php | function DetectBrewDevice()
{
if (stripos($this->useragent, $this->deviceBrew) > -1)
return $this->true;
else
return $this->false;
} | [
"function",
"DetectBrewDevice",
"(",
")",
"{",
"if",
"(",
"stripos",
"(",
"$",
"this",
"->",
"useragent",
",",
"$",
"this",
"->",
"deviceBrew",
")",
">",
"-",
"1",
")",
"return",
"$",
"this",
"->",
"true",
";",
"else",
"return",
"$",
"this",
"->",
... | Detects whether the device is a Brew-powered device. | [
"Detects",
"whether",
"the",
"device",
"is",
"a",
"Brew",
"-",
"powered",
"device",
"."
] | c02055dbe9baee63aab11438f4d7b5d25075d347 | https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L1024-L1030 | train |
ahand/mobileesp | PHP/mdetect.php | uagent_info.DetectWapWml | function DetectWapWml()
{
if (stripos($this->httpaccept, $this->vndwap) > -1 ||
stripos($this->httpaccept, $this->wml) > -1)
return $this->true;
else
return $this->false;
} | php | function DetectWapWml()
{
if (stripos($this->httpaccept, $this->vndwap) > -1 ||
stripos($this->httpaccept, $this->wml) > -1)
return $this->true;
else
return $this->false;
} | [
"function",
"DetectWapWml",
"(",
")",
"{",
"if",
"(",
"stripos",
"(",
"$",
"this",
"->",
"httpaccept",
",",
"$",
"this",
"->",
"vndwap",
")",
">",
"-",
"1",
"||",
"stripos",
"(",
"$",
"this",
"->",
"httpaccept",
",",
"$",
"this",
"->",
"wml",
")",
... | Detects whether the device supports WAP or WML. | [
"Detects",
"whether",
"the",
"device",
"supports",
"WAP",
"or",
"WML",
"."
] | c02055dbe9baee63aab11438f4d7b5d25075d347 | https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L1034-L1041 | train |
ahand/mobileesp | PHP/mdetect.php | uagent_info.DetectMidpCapable | function DetectMidpCapable()
{
if (stripos($this->useragent, $this->deviceMidp) > -1 ||
stripos($this->httpaccept, $this->deviceMidp) > -1)
return $this->true;
else
return $this->false;
} | php | function DetectMidpCapable()
{
if (stripos($this->useragent, $this->deviceMidp) > -1 ||
stripos($this->httpaccept, $this->deviceMidp) > -1)
return $this->true;
else
return $this->false;
} | [
"function",
"DetectMidpCapable",
"(",
")",
"{",
"if",
"(",
"stripos",
"(",
"$",
"this",
"->",
"useragent",
",",
"$",
"this",
"->",
"deviceMidp",
")",
">",
"-",
"1",
"||",
"stripos",
"(",
"$",
"this",
"->",
"httpaccept",
",",
"$",
"this",
"->",
"devic... | Detects if the current device supports MIDP, a mobile Java technology. | [
"Detects",
"if",
"the",
"current",
"device",
"supports",
"MIDP",
"a",
"mobile",
"Java",
"technology",
"."
] | c02055dbe9baee63aab11438f4d7b5d25075d347 | https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L1045-L1052 | train |
ahand/mobileesp | PHP/mdetect.php | uagent_info.DetectMobileQuick | function DetectMobileQuick()
{
if ($this->initCompleted == $this->true ||
$this->isMobilePhone == $this->true)
return $this->isMobilePhone;
//Let's exclude tablets
if ($this->isTierTablet == $this->true)
return $this->false;
//Most mobile browsing is done on smartphones
if ($this->DetectSmartphone() == $this->true)
return $this->true;
//Catch-all for many mobile devices
if (stripos($this->useragent, $this->mobile) > -1)
return $this->true;
if ($this->DetectOperaMobile() == $this->true)
return $this->true;
//We also look for Kindle devices
if ($this->DetectKindle() == $this->true ||
$this->DetectAmazonSilk() == $this->true)
return $this->true;
if (($this->DetectWapWml() == $this->true)
|| ($this->DetectMidpCapable() == $this->true)
|| ($this->DetectBrewDevice() == $this->true))
return $this->true;
if ((stripos($this->useragent, $this->engineNetfront) > -1)
|| (stripos($this->useragent, $this->engineUpBrowser) > -1))
return $this->true;
return $this->false;
} | php | function DetectMobileQuick()
{
if ($this->initCompleted == $this->true ||
$this->isMobilePhone == $this->true)
return $this->isMobilePhone;
//Let's exclude tablets
if ($this->isTierTablet == $this->true)
return $this->false;
//Most mobile browsing is done on smartphones
if ($this->DetectSmartphone() == $this->true)
return $this->true;
//Catch-all for many mobile devices
if (stripos($this->useragent, $this->mobile) > -1)
return $this->true;
if ($this->DetectOperaMobile() == $this->true)
return $this->true;
//We also look for Kindle devices
if ($this->DetectKindle() == $this->true ||
$this->DetectAmazonSilk() == $this->true)
return $this->true;
if (($this->DetectWapWml() == $this->true)
|| ($this->DetectMidpCapable() == $this->true)
|| ($this->DetectBrewDevice() == $this->true))
return $this->true;
if ((stripos($this->useragent, $this->engineNetfront) > -1)
|| (stripos($this->useragent, $this->engineUpBrowser) > -1))
return $this->true;
return $this->false;
} | [
"function",
"DetectMobileQuick",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"initCompleted",
"==",
"$",
"this",
"->",
"true",
"||",
"$",
"this",
"->",
"isMobilePhone",
"==",
"$",
"this",
"->",
"true",
")",
"return",
"$",
"this",
"->",
"isMobilePhone",
... | as well as smartphone-class devices. Excludes Apple iPads and other modern tablets. | [
"as",
"well",
"as",
"smartphone",
"-",
"class",
"devices",
".",
"Excludes",
"Apple",
"iPads",
"and",
"other",
"modern",
"tablets",
"."
] | c02055dbe9baee63aab11438f4d7b5d25075d347 | https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L1082-L1118 | train |
ahand/mobileesp | PHP/mdetect.php | uagent_info.DetectMobileLong | function DetectMobileLong()
{
if ($this->DetectMobileQuick() == $this->true)
return $this->true;
if ($this->DetectGameConsole() == $this->true)
return $this->true;
if (($this->DetectDangerHiptop() == $this->true)
|| ($this->DetectMaemoTablet() == $this->true)
|| ($this->DetectSonyMylo() == $this->true)
|| ($this->DetectArchos() == $this->true))
return $this->true;
if ((stripos($this->useragent, $this->devicePda) > -1) &&
!(stripos($this->useragent, $this->disUpdate) > -1))
return $this->true;
//Detect older phones from certain manufacturers and operators.
if ((stripos($this->useragent, $this->uplink) > -1)
|| (stripos($this->useragent, $this->engineOpenWeb) > -1)
|| (stripos($this->useragent, $this->manuSamsung1) > -1)
|| (stripos($this->useragent, $this->manuSonyEricsson) > -1)
|| (stripos($this->useragent, $this->manuericsson) > -1)
|| (stripos($this->useragent, $this->svcDocomo) > -1)
|| (stripos($this->useragent, $this->svcKddi) > -1)
|| (stripos($this->useragent, $this->svcVodafone) > -1))
return $this->true;
return $this->false;
} | php | function DetectMobileLong()
{
if ($this->DetectMobileQuick() == $this->true)
return $this->true;
if ($this->DetectGameConsole() == $this->true)
return $this->true;
if (($this->DetectDangerHiptop() == $this->true)
|| ($this->DetectMaemoTablet() == $this->true)
|| ($this->DetectSonyMylo() == $this->true)
|| ($this->DetectArchos() == $this->true))
return $this->true;
if ((stripos($this->useragent, $this->devicePda) > -1) &&
!(stripos($this->useragent, $this->disUpdate) > -1))
return $this->true;
//Detect older phones from certain manufacturers and operators.
if ((stripos($this->useragent, $this->uplink) > -1)
|| (stripos($this->useragent, $this->engineOpenWeb) > -1)
|| (stripos($this->useragent, $this->manuSamsung1) > -1)
|| (stripos($this->useragent, $this->manuSonyEricsson) > -1)
|| (stripos($this->useragent, $this->manuericsson) > -1)
|| (stripos($this->useragent, $this->svcDocomo) > -1)
|| (stripos($this->useragent, $this->svcKddi) > -1)
|| (stripos($this->useragent, $this->svcVodafone) > -1))
return $this->true;
return $this->false;
} | [
"function",
"DetectMobileLong",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"DetectMobileQuick",
"(",
")",
"==",
"$",
"this",
"->",
"true",
")",
"return",
"$",
"this",
"->",
"true",
";",
"if",
"(",
"$",
"this",
"->",
"DetectGameConsole",
"(",
")",
"... | but no promises on thoroughness! | [
"but",
"no",
"promises",
"on",
"thoroughness!"
] | c02055dbe9baee63aab11438f4d7b5d25075d347 | https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L1127-L1156 | train |
ahand/mobileesp | PHP/mdetect.php | uagent_info.DetectTierIphone | function DetectTierIphone()
{
if ($this->initCompleted == $this->true ||
$this->isTierIphone == $this->true)
return $this->isTierIphone;
if (($this->DetectIphoneOrIpod() == $this->true)
|| ($this->DetectAndroidPhone() == $this->true)
|| ($this->DetectWindowsPhone() == $this->true)
|| ($this->DetectBlackBerry10Phone() == $this->true)
|| ($this->DetectPalmWebOS() == $this->true)
|| ($this->DetectBada() == $this->true)
|| ($this->DetectTizen() == $this->true)
|| ($this->DetectFirefoxOSPhone() == $this->true)
|| ($this->DetectSailfishPhone() == $this->true)
|| ($this->DetectUbuntuPhone() == $this->true)
|| ($this->DetectGamingHandheld() == $this->true))
return $this->true;
//Note: BB10 phone is in the previous paragraph
if (($this->DetectBlackBerryWebKit() == $this->true) &&
($this->DetectBlackBerryTouch() == $this->true))
return $this->true;
else
return $this->false;
} | php | function DetectTierIphone()
{
if ($this->initCompleted == $this->true ||
$this->isTierIphone == $this->true)
return $this->isTierIphone;
if (($this->DetectIphoneOrIpod() == $this->true)
|| ($this->DetectAndroidPhone() == $this->true)
|| ($this->DetectWindowsPhone() == $this->true)
|| ($this->DetectBlackBerry10Phone() == $this->true)
|| ($this->DetectPalmWebOS() == $this->true)
|| ($this->DetectBada() == $this->true)
|| ($this->DetectTizen() == $this->true)
|| ($this->DetectFirefoxOSPhone() == $this->true)
|| ($this->DetectSailfishPhone() == $this->true)
|| ($this->DetectUbuntuPhone() == $this->true)
|| ($this->DetectGamingHandheld() == $this->true))
return $this->true;
//Note: BB10 phone is in the previous paragraph
if (($this->DetectBlackBerryWebKit() == $this->true) &&
($this->DetectBlackBerryTouch() == $this->true))
return $this->true;
else
return $this->false;
} | [
"function",
"DetectTierIphone",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"initCompleted",
"==",
"$",
"this",
"->",
"true",
"||",
"$",
"this",
"->",
"isTierIphone",
"==",
"$",
"this",
"->",
"true",
")",
"return",
"$",
"this",
"->",
"isTierIphone",
"... | Includes iPhone, iPod Touch, Android, Windows Phone, BB10, Playstation Vita, etc. | [
"Includes",
"iPhone",
"iPod",
"Touch",
"Android",
"Windows",
"Phone",
"BB10",
"Playstation",
"Vita",
"etc",
"."
] | c02055dbe9baee63aab11438f4d7b5d25075d347 | https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L1191-L1217 | train |
ahand/mobileesp | PHP/mdetect.php | uagent_info.DetectTierRichCss | function DetectTierRichCss()
{
if ($this->initCompleted == $this->true ||
$this->isTierRichCss == $this->true)
return $this->isTierRichCss;
if ($this->DetectMobileQuick() == $this->true)
{
//Exclude iPhone Tier and e-Ink Kindle devices
if (($this->DetectTierIphone() == $this->true) ||
($this->DetectKindle() == $this->true))
return $this->false;
//The following devices are explicitly ok.
if ($this->DetectWebkit() == $this->true) //Any WebKit
return $this->true;
if ($this->DetectS60OssBrowser() == $this->true)
return $this->true;
//Note: 'High' BlackBerry devices ONLY
if ($this->DetectBlackBerryHigh() == $this->true)
return $this->true;
//Older Windows 'Mobile' isn't good enough for iPhone Tier.
if ($this->DetectWindowsMobile() == $this->true)
return $this->true;
if (stripos($this->useragent, $this->engineTelecaQ) > -1)
return $this->true;
//default
else
return $this->false;
}
else
return $this->false;
} | php | function DetectTierRichCss()
{
if ($this->initCompleted == $this->true ||
$this->isTierRichCss == $this->true)
return $this->isTierRichCss;
if ($this->DetectMobileQuick() == $this->true)
{
//Exclude iPhone Tier and e-Ink Kindle devices
if (($this->DetectTierIphone() == $this->true) ||
($this->DetectKindle() == $this->true))
return $this->false;
//The following devices are explicitly ok.
if ($this->DetectWebkit() == $this->true) //Any WebKit
return $this->true;
if ($this->DetectS60OssBrowser() == $this->true)
return $this->true;
//Note: 'High' BlackBerry devices ONLY
if ($this->DetectBlackBerryHigh() == $this->true)
return $this->true;
//Older Windows 'Mobile' isn't good enough for iPhone Tier.
if ($this->DetectWindowsMobile() == $this->true)
return $this->true;
if (stripos($this->useragent, $this->engineTelecaQ) > -1)
return $this->true;
//default
else
return $this->false;
}
else
return $this->false;
} | [
"function",
"DetectTierRichCss",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"initCompleted",
"==",
"$",
"this",
"->",
"true",
"||",
"$",
"this",
"->",
"isTierRichCss",
"==",
"$",
"this",
"->",
"true",
")",
"return",
"$",
"this",
"->",
"isTierRichCss",
... | Excludes all iPhone Tier devices. | [
"Excludes",
"all",
"iPhone",
"Tier",
"devices",
"."
] | c02055dbe9baee63aab11438f4d7b5d25075d347 | https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L1225-L1260 | train |
ahand/mobileesp | PHP/mdetect.php | uagent_info.DetectTierOtherPhones | function DetectTierOtherPhones()
{
if ($this->initCompleted == $this->true ||
$this->isTierGenericMobile == $this->true)
return $this->isTierGenericMobile;
//Exclude devices in the other 2 categories
if (($this->DetectMobileLong() == $this->true)
&& ($this->DetectTierIphone() == $this->false)
&& ($this->DetectTierRichCss() == $this->false))
return $this->true;
else
return $this->false;
} | php | function DetectTierOtherPhones()
{
if ($this->initCompleted == $this->true ||
$this->isTierGenericMobile == $this->true)
return $this->isTierGenericMobile;
//Exclude devices in the other 2 categories
if (($this->DetectMobileLong() == $this->true)
&& ($this->DetectTierIphone() == $this->false)
&& ($this->DetectTierRichCss() == $this->false))
return $this->true;
else
return $this->false;
} | [
"function",
"DetectTierOtherPhones",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"initCompleted",
"==",
"$",
"this",
"->",
"true",
"||",
"$",
"this",
"->",
"isTierGenericMobile",
"==",
"$",
"this",
"->",
"true",
")",
"return",
"$",
"this",
"->",
"isTier... | but excludes the iPhone and RichCSS Tier devices. | [
"but",
"excludes",
"the",
"iPhone",
"and",
"RichCSS",
"Tier",
"devices",
"."
] | c02055dbe9baee63aab11438f4d7b5d25075d347 | https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L1266-L1279 | train |
plank/laravel-metable | src/DataType/Registry.php | Registry.getHandlerForType | public function getHandlerForType(string $type) : HandlerInterface
{
if ($this->hasHandlerForType($type)) {
return $this->handlers[$type];
}
throw DataTypeException::handlerNotFound($type);
} | php | public function getHandlerForType(string $type) : HandlerInterface
{
if ($this->hasHandlerForType($type)) {
return $this->handlers[$type];
}
throw DataTypeException::handlerNotFound($type);
} | [
"public",
"function",
"getHandlerForType",
"(",
"string",
"$",
"type",
")",
":",
"HandlerInterface",
"{",
"if",
"(",
"$",
"this",
"->",
"hasHandlerForType",
"(",
"$",
"type",
")",
")",
"{",
"return",
"$",
"this",
"->",
"handlers",
"[",
"$",
"type",
"]",
... | Retrieve the handler assigned to a given type identifier.
@param string $type
@throws DataTypeException if no handler is found.
@return HandlerInterface | [
"Retrieve",
"the",
"handler",
"assigned",
"to",
"a",
"given",
"type",
"identifier",
"."
] | 414aa3707d8f91170e505ed7228bb74e31d8e35b | https://github.com/plank/laravel-metable/blob/414aa3707d8f91170e505ed7228bb74e31d8e35b/src/DataType/Registry.php#L43-L50 | train |
plank/laravel-metable | src/DataType/Registry.php | Registry.getTypeForValue | public function getTypeForValue($value) : string
{
foreach ($this->handlers as $type => $handler) {
if ($handler->canHandleValue($value)) {
return $type;
}
}
throw DataTypeException::handlerNotFoundForValue($value);
} | php | public function getTypeForValue($value) : string
{
foreach ($this->handlers as $type => $handler) {
if ($handler->canHandleValue($value)) {
return $type;
}
}
throw DataTypeException::handlerNotFoundForValue($value);
} | [
"public",
"function",
"getTypeForValue",
"(",
"$",
"value",
")",
":",
"string",
"{",
"foreach",
"(",
"$",
"this",
"->",
"handlers",
"as",
"$",
"type",
"=>",
"$",
"handler",
")",
"{",
"if",
"(",
"$",
"handler",
"->",
"canHandleValue",
"(",
"$",
"value",... | Find a data type Handler that is able to operate on the value, return the type identifier associated with it.
@param mixed $value
@throws DataTypeException if no handler can handle the value.
@return string | [
"Find",
"a",
"data",
"type",
"Handler",
"that",
"is",
"able",
"to",
"operate",
"on",
"the",
"value",
"return",
"the",
"type",
"identifier",
"associated",
"with",
"it",
"."
] | 414aa3707d8f91170e505ed7228bb74e31d8e35b | https://github.com/plank/laravel-metable/blob/414aa3707d8f91170e505ed7228bb74e31d8e35b/src/DataType/Registry.php#L85-L94 | train |
plank/laravel-metable | src/Metable.php | Metable.setMeta | public function setMeta(string $key, $value)
{
if ($this->hasMeta($key)) {
$meta = $this->getMetaRecord($key);
$meta->setAttribute('value', $value);
$meta->save();
} else {
$meta = $this->makeMeta($key, $value);
$this->meta()->save($meta);
}
// Update cached relationship, if necessary.
if ($this->relationLoaded('meta')) {
$this->meta[$key] = $meta;
}
} | php | public function setMeta(string $key, $value)
{
if ($this->hasMeta($key)) {
$meta = $this->getMetaRecord($key);
$meta->setAttribute('value', $value);
$meta->save();
} else {
$meta = $this->makeMeta($key, $value);
$this->meta()->save($meta);
}
// Update cached relationship, if necessary.
if ($this->relationLoaded('meta')) {
$this->meta[$key] = $meta;
}
} | [
"public",
"function",
"setMeta",
"(",
"string",
"$",
"key",
",",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasMeta",
"(",
"$",
"key",
")",
")",
"{",
"$",
"meta",
"=",
"$",
"this",
"->",
"getMetaRecord",
"(",
"$",
"key",
")",
";",
"... | Add or update the value of the `Meta` at a given key.
@param string $key
@param mixed $value | [
"Add",
"or",
"update",
"the",
"value",
"of",
"the",
"Meta",
"at",
"a",
"given",
"key",
"."
] | 414aa3707d8f91170e505ed7228bb74e31d8e35b | https://github.com/plank/laravel-metable/blob/414aa3707d8f91170e505ed7228bb74e31d8e35b/src/Metable.php#L48-L63 | train |
plank/laravel-metable | src/Metable.php | Metable.syncMeta | public function syncMeta($array)
{
$meta = [];
foreach ($array as $key => $value) {
$meta[$key] = $this->makeMeta($key, $value);
}
$this->meta()->delete();
$this->meta()->saveMany($meta);
// Update cached relationship.
$collection = $this->makeMeta()->newCollection($meta);
$this->setRelation('meta', $collection);
} | php | public function syncMeta($array)
{
$meta = [];
foreach ($array as $key => $value) {
$meta[$key] = $this->makeMeta($key, $value);
}
$this->meta()->delete();
$this->meta()->saveMany($meta);
// Update cached relationship.
$collection = $this->makeMeta()->newCollection($meta);
$this->setRelation('meta', $collection);
} | [
"public",
"function",
"syncMeta",
"(",
"$",
"array",
")",
"{",
"$",
"meta",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"array",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"meta",
"[",
"$",
"key",
"]",
"=",
"$",
"this",
"->",
"makeMeta",... | Replace all associated `Meta` with the keys and values provided.
@param array|Traversable $array
@return void | [
"Replace",
"all",
"associated",
"Meta",
"with",
"the",
"keys",
"and",
"values",
"provided",
"."
] | 414aa3707d8f91170e505ed7228bb74e31d8e35b | https://github.com/plank/laravel-metable/blob/414aa3707d8f91170e505ed7228bb74e31d8e35b/src/Metable.php#L72-L86 | train |
plank/laravel-metable | src/Metable.php | Metable.getMeta | public function getMeta(string $key, $default = null)
{
if ($this->hasMeta($key)) {
return $this->getMetaRecord($key)->getAttribute('value');
}
return $default;
} | php | public function getMeta(string $key, $default = null)
{
if ($this->hasMeta($key)) {
return $this->getMetaRecord($key)->getAttribute('value');
}
return $default;
} | [
"public",
"function",
"getMeta",
"(",
"string",
"$",
"key",
",",
"$",
"default",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasMeta",
"(",
"$",
"key",
")",
")",
"{",
"return",
"$",
"this",
"->",
"getMetaRecord",
"(",
"$",
"key",
")",
"... | Retrieve the value of the `Meta` at a given key.
@param string $key
@param mixed $default Fallback value if no Meta is found.
@return mixed | [
"Retrieve",
"the",
"value",
"of",
"the",
"Meta",
"at",
"a",
"given",
"key",
"."
] | 414aa3707d8f91170e505ed7228bb74e31d8e35b | https://github.com/plank/laravel-metable/blob/414aa3707d8f91170e505ed7228bb74e31d8e35b/src/Metable.php#L96-L103 | train |
plank/laravel-metable | src/Metable.php | Metable.scopeWhereHasMeta | public function scopeWhereHasMeta(Builder $q, $key)
{
$q->whereHas('meta', function (Builder $q) use ($key) {
$q->whereIn('key', (array) $key);
});
} | php | public function scopeWhereHasMeta(Builder $q, $key)
{
$q->whereHas('meta', function (Builder $q) use ($key) {
$q->whereIn('key', (array) $key);
});
} | [
"public",
"function",
"scopeWhereHasMeta",
"(",
"Builder",
"$",
"q",
",",
"$",
"key",
")",
"{",
"$",
"q",
"->",
"whereHas",
"(",
"'meta'",
",",
"function",
"(",
"Builder",
"$",
"q",
")",
"use",
"(",
"$",
"key",
")",
"{",
"$",
"q",
"->",
"whereIn",
... | Query scope to restrict the query to records which have `Meta` attached to a given key.
If an array of keys is passed instead, will restrict the query to records having one or more Meta with any of the keys.
@param Builder $q
@param string|array $key
@return void | [
"Query",
"scope",
"to",
"restrict",
"the",
"query",
"to",
"records",
"which",
"have",
"Meta",
"attached",
"to",
"a",
"given",
"key",
"."
] | 414aa3707d8f91170e505ed7228bb74e31d8e35b | https://github.com/plank/laravel-metable/blob/414aa3707d8f91170e505ed7228bb74e31d8e35b/src/Metable.php#L174-L179 | train |
plank/laravel-metable | src/Metable.php | Metable.scopeWhereDoesntHaveMeta | public function scopeWhereDoesntHaveMeta(Builder $q, $key)
{
$q->whereDoesntHave('meta', function (Builder $q) use ($key) {
$q->whereIn('key', (array) $key);
});
} | php | public function scopeWhereDoesntHaveMeta(Builder $q, $key)
{
$q->whereDoesntHave('meta', function (Builder $q) use ($key) {
$q->whereIn('key', (array) $key);
});
} | [
"public",
"function",
"scopeWhereDoesntHaveMeta",
"(",
"Builder",
"$",
"q",
",",
"$",
"key",
")",
"{",
"$",
"q",
"->",
"whereDoesntHave",
"(",
"'meta'",
",",
"function",
"(",
"Builder",
"$",
"q",
")",
"use",
"(",
"$",
"key",
")",
"{",
"$",
"q",
"->",... | Query scope to restrict the query to records which doesnt have `Meta` attached to a given key.
If an array of keys is passed instead, will restrict the query to records having one or more Meta with any of the keys.
@param Builder $q
@param string|array $key
@return void | [
"Query",
"scope",
"to",
"restrict",
"the",
"query",
"to",
"records",
"which",
"doesnt",
"have",
"Meta",
"attached",
"to",
"a",
"given",
"key",
"."
] | 414aa3707d8f91170e505ed7228bb74e31d8e35b | https://github.com/plank/laravel-metable/blob/414aa3707d8f91170e505ed7228bb74e31d8e35b/src/Metable.php#L191-L196 | train |
plank/laravel-metable | src/Metable.php | Metable.scopeWhereHasMetaKeys | public function scopeWhereHasMetaKeys(Builder $q, array $keys)
{
$q->whereHas('meta', function (Builder $q) use ($keys) {
$q->whereIn('key', $keys);
}, '=', count($keys));
} | php | public function scopeWhereHasMetaKeys(Builder $q, array $keys)
{
$q->whereHas('meta', function (Builder $q) use ($keys) {
$q->whereIn('key', $keys);
}, '=', count($keys));
} | [
"public",
"function",
"scopeWhereHasMetaKeys",
"(",
"Builder",
"$",
"q",
",",
"array",
"$",
"keys",
")",
"{",
"$",
"q",
"->",
"whereHas",
"(",
"'meta'",
",",
"function",
"(",
"Builder",
"$",
"q",
")",
"use",
"(",
"$",
"keys",
")",
"{",
"$",
"q",
"-... | Query scope to restrict the query to records which have `Meta` for all of the provided keys.
@param Builder $q
@param array $keys
@return void | [
"Query",
"scope",
"to",
"restrict",
"the",
"query",
"to",
"records",
"which",
"have",
"Meta",
"for",
"all",
"of",
"the",
"provided",
"keys",
"."
] | 414aa3707d8f91170e505ed7228bb74e31d8e35b | https://github.com/plank/laravel-metable/blob/414aa3707d8f91170e505ed7228bb74e31d8e35b/src/Metable.php#L206-L211 | train |
plank/laravel-metable | src/Metable.php | Metable.scopeWhereMeta | public function scopeWhereMeta(Builder $q, string $key, $operator, $value = null)
{
// Shift arguments if no operator is present.
if (!isset($value)) {
$value = $operator;
$operator = '=';
}
// Convert value to its serialized version for comparison.
if (!is_string($value)) {
$value = $this->makeMeta($key, $value)->getRawValue();
}
$q->whereHas('meta', function (Builder $q) use ($key, $operator, $value) {
$q->where('key', $key);
$q->where('value', $operator, $value);
});
} | php | public function scopeWhereMeta(Builder $q, string $key, $operator, $value = null)
{
// Shift arguments if no operator is present.
if (!isset($value)) {
$value = $operator;
$operator = '=';
}
// Convert value to its serialized version for comparison.
if (!is_string($value)) {
$value = $this->makeMeta($key, $value)->getRawValue();
}
$q->whereHas('meta', function (Builder $q) use ($key, $operator, $value) {
$q->where('key', $key);
$q->where('value', $operator, $value);
});
} | [
"public",
"function",
"scopeWhereMeta",
"(",
"Builder",
"$",
"q",
",",
"string",
"$",
"key",
",",
"$",
"operator",
",",
"$",
"value",
"=",
"null",
")",
"{",
"// Shift arguments if no operator is present.",
"if",
"(",
"!",
"isset",
"(",
"$",
"value",
")",
"... | Query scope to restrict the query to records which have `Meta` with a specific key and value.
If the `$value` parameter is omitted, the $operator parameter will be considered the value.
Values will be serialized to a string before comparison. If using the `>`, `>=`, `<`, or `<=` comparison operators, note that the value will be compared as a string. If comparing numeric values, use `Metable::scopeWhereMetaNumeric()` instead.
@param Builder $q
@param string $key
@param mixed $operator
@param mixed $value
@return void | [
"Query",
"scope",
"to",
"restrict",
"the",
"query",
"to",
"records",
"which",
"have",
"Meta",
"with",
"a",
"specific",
"key",
"and",
"value",
"."
] | 414aa3707d8f91170e505ed7228bb74e31d8e35b | https://github.com/plank/laravel-metable/blob/414aa3707d8f91170e505ed7228bb74e31d8e35b/src/Metable.php#L227-L244 | train |
plank/laravel-metable | src/Metable.php | Metable.scopeWhereMetaNumeric | public function scopeWhereMetaNumeric(Builder $q, string $key, string $operator, $value)
{
// Since we are manually interpolating into the query,
// escape the operator to protect against injection.
$validOperators = ['<', '<=', '>', '>=', '=', '<>', '!='];
$operator = in_array($operator, $validOperators) ? $operator : '=';
$field = $q->getQuery()->getGrammar()->wrap($this->meta()->getRelated()->getTable().'.value');
$q->whereHas('meta', function (Builder $q) use ($key, $operator, $value, $field) {
$q->where('key', $key);
$q->whereRaw("cast({$field} as decimal) {$operator} ?", [(float) $value]);
});
} | php | public function scopeWhereMetaNumeric(Builder $q, string $key, string $operator, $value)
{
// Since we are manually interpolating into the query,
// escape the operator to protect against injection.
$validOperators = ['<', '<=', '>', '>=', '=', '<>', '!='];
$operator = in_array($operator, $validOperators) ? $operator : '=';
$field = $q->getQuery()->getGrammar()->wrap($this->meta()->getRelated()->getTable().'.value');
$q->whereHas('meta', function (Builder $q) use ($key, $operator, $value, $field) {
$q->where('key', $key);
$q->whereRaw("cast({$field} as decimal) {$operator} ?", [(float) $value]);
});
} | [
"public",
"function",
"scopeWhereMetaNumeric",
"(",
"Builder",
"$",
"q",
",",
"string",
"$",
"key",
",",
"string",
"$",
"operator",
",",
"$",
"value",
")",
"{",
"// Since we are manually interpolating into the query,",
"// escape the operator to protect against injection.",... | Query scope to restrict the query to records which have `Meta` with a specific key and numeric value.
Performs numeric comparison instead of string comparison.
@param Builder $q
@param string $key
@param string $operator
@param int|float $value
@return void | [
"Query",
"scope",
"to",
"restrict",
"the",
"query",
"to",
"records",
"which",
"have",
"Meta",
"with",
"a",
"specific",
"key",
"and",
"numeric",
"value",
"."
] | 414aa3707d8f91170e505ed7228bb74e31d8e35b | https://github.com/plank/laravel-metable/blob/414aa3707d8f91170e505ed7228bb74e31d8e35b/src/Metable.php#L258-L270 | train |
plank/laravel-metable | src/Metable.php | Metable.scopeWhereMetaIn | public function scopeWhereMetaIn(Builder $q, string $key, array $values)
{
$values = array_map(function ($val) use ($key) {
return is_string($val) ? $val : $this->makeMeta($key, $val)->getRawValue();
}, $values);
$q->whereHas('meta', function (Builder $q) use ($key, $values) {
$q->where('key', $key);
$q->whereIn('value', $values);
});
} | php | public function scopeWhereMetaIn(Builder $q, string $key, array $values)
{
$values = array_map(function ($val) use ($key) {
return is_string($val) ? $val : $this->makeMeta($key, $val)->getRawValue();
}, $values);
$q->whereHas('meta', function (Builder $q) use ($key, $values) {
$q->where('key', $key);
$q->whereIn('value', $values);
});
} | [
"public",
"function",
"scopeWhereMetaIn",
"(",
"Builder",
"$",
"q",
",",
"string",
"$",
"key",
",",
"array",
"$",
"values",
")",
"{",
"$",
"values",
"=",
"array_map",
"(",
"function",
"(",
"$",
"val",
")",
"use",
"(",
"$",
"key",
")",
"{",
"return",
... | Query scope to restrict the query to records which have `Meta` with a specific key and a value within a specified set of options.
@param Builder $q
@param string $key
@param array $values
@return void | [
"Query",
"scope",
"to",
"restrict",
"the",
"query",
"to",
"records",
"which",
"have",
"Meta",
"with",
"a",
"specific",
"key",
"and",
"a",
"value",
"within",
"a",
"specified",
"set",
"of",
"options",
"."
] | 414aa3707d8f91170e505ed7228bb74e31d8e35b | https://github.com/plank/laravel-metable/blob/414aa3707d8f91170e505ed7228bb74e31d8e35b/src/Metable.php#L281-L291 | train |
plank/laravel-metable | src/Metable.php | Metable.scopeOrderByMeta | public function scopeOrderByMeta(Builder $q, string $key, string $direction = 'asc', $strict = false)
{
$table = $this->joinMetaTable($q, $key, $strict ? 'inner' : 'left');
$q->orderBy("{$table}.value", $direction);
} | php | public function scopeOrderByMeta(Builder $q, string $key, string $direction = 'asc', $strict = false)
{
$table = $this->joinMetaTable($q, $key, $strict ? 'inner' : 'left');
$q->orderBy("{$table}.value", $direction);
} | [
"public",
"function",
"scopeOrderByMeta",
"(",
"Builder",
"$",
"q",
",",
"string",
"$",
"key",
",",
"string",
"$",
"direction",
"=",
"'asc'",
",",
"$",
"strict",
"=",
"false",
")",
"{",
"$",
"table",
"=",
"$",
"this",
"->",
"joinMetaTable",
"(",
"$",
... | Query scope to order the query results by the string value of an attached meta.
@param Builder $q
@param string $key
@param string $direction
@param bool $strict if true, will exclude records that do not have meta for the provided `$key`.
@return void | [
"Query",
"scope",
"to",
"order",
"the",
"query",
"results",
"by",
"the",
"string",
"value",
"of",
"an",
"attached",
"meta",
"."
] | 414aa3707d8f91170e505ed7228bb74e31d8e35b | https://github.com/plank/laravel-metable/blob/414aa3707d8f91170e505ed7228bb74e31d8e35b/src/Metable.php#L303-L307 | train |
plank/laravel-metable | src/Metable.php | Metable.scopeOrderByMetaNumeric | public function scopeOrderByMetaNumeric(Builder $q, string $key, string $direction = 'asc', $strict = false)
{
$table = $this->joinMetaTable($q, $key, $strict ? 'inner' : 'left');
$direction = strtolower($direction) == 'asc' ? 'asc' : 'desc';
$field = $q->getQuery()->getGrammar()->wrap("{$table}.value");
$q->orderByRaw("cast({$field} as decimal) $direction");
} | php | public function scopeOrderByMetaNumeric(Builder $q, string $key, string $direction = 'asc', $strict = false)
{
$table = $this->joinMetaTable($q, $key, $strict ? 'inner' : 'left');
$direction = strtolower($direction) == 'asc' ? 'asc' : 'desc';
$field = $q->getQuery()->getGrammar()->wrap("{$table}.value");
$q->orderByRaw("cast({$field} as decimal) $direction");
} | [
"public",
"function",
"scopeOrderByMetaNumeric",
"(",
"Builder",
"$",
"q",
",",
"string",
"$",
"key",
",",
"string",
"$",
"direction",
"=",
"'asc'",
",",
"$",
"strict",
"=",
"false",
")",
"{",
"$",
"table",
"=",
"$",
"this",
"->",
"joinMetaTable",
"(",
... | Query scope to order the query results by the numeric value of an attached meta.
@param Builder $q
@param string $key
@param string $direction
@param bool $strict if true, will exclude records that do not have meta for the provided `$key`.
@return void | [
"Query",
"scope",
"to",
"order",
"the",
"query",
"results",
"by",
"the",
"numeric",
"value",
"of",
"an",
"attached",
"meta",
"."
] | 414aa3707d8f91170e505ed7228bb74e31d8e35b | https://github.com/plank/laravel-metable/blob/414aa3707d8f91170e505ed7228bb74e31d8e35b/src/Metable.php#L319-L326 | train |
plank/laravel-metable | src/Metable.php | Metable.joinMetaTable | private function joinMetaTable(Builder $q, string $key, $type = 'left')
{
$relation = $this->meta();
$metaTable = $relation->getRelated()->getTable();
// Create an alias for the join, to allow the same
// table to be joined multiple times for different keys.
$alias = $metaTable.'__'.$key;
// If no explicit select columns are specified,
// avoid column collision by excluding meta table from select.
if (!$q->getQuery()->columns) {
$q->select($this->getTable().'.*');
}
// Join the meta table to the query
$q->join("{$metaTable} as {$alias}", function (JoinClause $q) use ($relation, $key, $alias) {
// Laravel 5.4 changed the method names here
$foreign_key = method_exists($relation, 'getForeignKeyName') ? $relation->getForeignKeyName() : $relation->getPlainForeignKey();
$type = method_exists($relation, 'getForeignKeyName') ? $relation->getMorphType() : $relation->getPlainMorphType();
$q->on($relation->getQualifiedParentKeyName(), '=', $alias.'.'.$foreign_key)
->where($alias.'.key', '=', $key)
->where($alias.'.'.$type, '=', get_class($this));
}, null, null, $type);
// Return the alias so that the calling context can
// reference the table.
return $alias;
} | php | private function joinMetaTable(Builder $q, string $key, $type = 'left')
{
$relation = $this->meta();
$metaTable = $relation->getRelated()->getTable();
// Create an alias for the join, to allow the same
// table to be joined multiple times for different keys.
$alias = $metaTable.'__'.$key;
// If no explicit select columns are specified,
// avoid column collision by excluding meta table from select.
if (!$q->getQuery()->columns) {
$q->select($this->getTable().'.*');
}
// Join the meta table to the query
$q->join("{$metaTable} as {$alias}", function (JoinClause $q) use ($relation, $key, $alias) {
// Laravel 5.4 changed the method names here
$foreign_key = method_exists($relation, 'getForeignKeyName') ? $relation->getForeignKeyName() : $relation->getPlainForeignKey();
$type = method_exists($relation, 'getForeignKeyName') ? $relation->getMorphType() : $relation->getPlainMorphType();
$q->on($relation->getQualifiedParentKeyName(), '=', $alias.'.'.$foreign_key)
->where($alias.'.key', '=', $key)
->where($alias.'.'.$type, '=', get_class($this));
}, null, null, $type);
// Return the alias so that the calling context can
// reference the table.
return $alias;
} | [
"private",
"function",
"joinMetaTable",
"(",
"Builder",
"$",
"q",
",",
"string",
"$",
"key",
",",
"$",
"type",
"=",
"'left'",
")",
"{",
"$",
"relation",
"=",
"$",
"this",
"->",
"meta",
"(",
")",
";",
"$",
"metaTable",
"=",
"$",
"relation",
"->",
"g... | Join the meta table to the query.
@param Builder $q
@param string $key
@param string $type Join type.
@return string | [
"Join",
"the",
"meta",
"table",
"to",
"the",
"query",
"."
] | 414aa3707d8f91170e505ed7228bb74e31d8e35b | https://github.com/plank/laravel-metable/blob/414aa3707d8f91170e505ed7228bb74e31d8e35b/src/Metable.php#L337-L366 | train |
plank/laravel-metable | src/Metable.php | Metable.getMetaCollection | private function getMetaCollection()
{
if (!$this->relationLoaded('meta')) {
$this->setRelation('meta', $this->meta()->get());
}
return $this->getRelation('meta');
} | php | private function getMetaCollection()
{
if (!$this->relationLoaded('meta')) {
$this->setRelation('meta', $this->meta()->get());
}
return $this->getRelation('meta');
} | [
"private",
"function",
"getMetaCollection",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"relationLoaded",
"(",
"'meta'",
")",
")",
"{",
"$",
"this",
"->",
"setRelation",
"(",
"'meta'",
",",
"$",
"this",
"->",
"meta",
"(",
")",
"->",
"get",
"(",... | fetch all meta for the model, if necessary.
In Laravel versions prior to 5.3, relations that are lazy loaded by the
`getRelationFromMethod()` method ( invoked by the `__get()` magic method)
are not passed through the `setRelation()` method, so we load the relation
manually.
@return mixed | [
"fetch",
"all",
"meta",
"for",
"the",
"model",
"if",
"necessary",
"."
] | 414aa3707d8f91170e505ed7228bb74e31d8e35b | https://github.com/plank/laravel-metable/blob/414aa3707d8f91170e505ed7228bb74e31d8e35b/src/Metable.php#L378-L385 | train |
plank/laravel-metable | src/Metable.php | Metable.makeMeta | protected function makeMeta(string $key = '', $value = '') : Meta
{
$className = $this->getMetaClassName();
$meta = new $className([
'key' => $key,
'value' => $value,
]);
return $meta;
} | php | protected function makeMeta(string $key = '', $value = '') : Meta
{
$className = $this->getMetaClassName();
$meta = new $className([
'key' => $key,
'value' => $value,
]);
return $meta;
} | [
"protected",
"function",
"makeMeta",
"(",
"string",
"$",
"key",
"=",
"''",
",",
"$",
"value",
"=",
"''",
")",
":",
"Meta",
"{",
"$",
"className",
"=",
"$",
"this",
"->",
"getMetaClassName",
"(",
")",
";",
"$",
"meta",
"=",
"new",
"$",
"className",
... | Create a new `Meta` record.
@param string $key
@param mixed $value
@return Meta | [
"Create",
"a",
"new",
"Meta",
"record",
"."
] | 414aa3707d8f91170e505ed7228bb74e31d8e35b | https://github.com/plank/laravel-metable/blob/414aa3707d8f91170e505ed7228bb74e31d8e35b/src/Metable.php#L418-L428 | train |
plank/laravel-metable | src/DataType/ModelCollectionHandler.php | ModelCollectionHandler.loadModels | private function loadModels(array $items)
{
$classes = [];
$results = [];
// Retrieve a list of keys to load from each class.
foreach ($items as $item) {
if (!is_null($item['key'])) {
$classes[$item['class']][] = $item['key'];
}
}
// Iterate list of classes and load all records matching a key.
foreach ($classes as $class => $keys) {
$model = new $class();
$results[$class] = $model->whereIn($model->getKeyName(), $keys)->get()->keyBy($model->getKeyName());
}
return $results;
} | php | private function loadModels(array $items)
{
$classes = [];
$results = [];
// Retrieve a list of keys to load from each class.
foreach ($items as $item) {
if (!is_null($item['key'])) {
$classes[$item['class']][] = $item['key'];
}
}
// Iterate list of classes and load all records matching a key.
foreach ($classes as $class => $keys) {
$model = new $class();
$results[$class] = $model->whereIn($model->getKeyName(), $keys)->get()->keyBy($model->getKeyName());
}
return $results;
} | [
"private",
"function",
"loadModels",
"(",
"array",
"$",
"items",
")",
"{",
"$",
"classes",
"=",
"[",
"]",
";",
"$",
"results",
"=",
"[",
"]",
";",
"// Retrieve a list of keys to load from each class.",
"foreach",
"(",
"$",
"items",
"as",
"$",
"item",
")",
... | Load each model instance, grouped by class.
@param array $items
@return array | [
"Load",
"each",
"model",
"instance",
"grouped",
"by",
"class",
"."
] | 414aa3707d8f91170e505ed7228bb74e31d8e35b | https://github.com/plank/laravel-metable/blob/414aa3707d8f91170e505ed7228bb74e31d8e35b/src/DataType/ModelCollectionHandler.php#L75-L94 | train |
plank/laravel-metable | src/MetableServiceProvider.php | MetableServiceProvider.registerDataTypeRegistry | protected function registerDataTypeRegistry()
{
$this->app->singleton(Registry::class, function () {
$registry = new Registry();
foreach (config('metable.datatypes') as $handler) {
$registry->addHandler(new $handler());
}
return $registry;
});
$this->app->alias(Registry::class, 'metable.datatype.registry');
} | php | protected function registerDataTypeRegistry()
{
$this->app->singleton(Registry::class, function () {
$registry = new Registry();
foreach (config('metable.datatypes') as $handler) {
$registry->addHandler(new $handler());
}
return $registry;
});
$this->app->alias(Registry::class, 'metable.datatype.registry');
} | [
"protected",
"function",
"registerDataTypeRegistry",
"(",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"singleton",
"(",
"Registry",
"::",
"class",
",",
"function",
"(",
")",
"{",
"$",
"registry",
"=",
"new",
"Registry",
"(",
")",
";",
"foreach",
"(",
"conf... | Add the DataType Registry to the service container.
@return void | [
"Add",
"the",
"DataType",
"Registry",
"to",
"the",
"service",
"container",
"."
] | 414aa3707d8f91170e505ed7228bb74e31d8e35b | https://github.com/plank/laravel-metable/blob/414aa3707d8f91170e505ed7228bb74e31d8e35b/src/MetableServiceProvider.php#L53-L64 | train |
plank/laravel-metable | src/Meta.php | Meta.getValueAttribute | public function getValueAttribute()
{
if (!isset($this->cachedValue)) {
$this->cachedValue = $this->getDataTypeRegistry()
->getHandlerForType($this->type)
->unserializeValue($this->attributes['value']);
}
return $this->cachedValue;
} | php | public function getValueAttribute()
{
if (!isset($this->cachedValue)) {
$this->cachedValue = $this->getDataTypeRegistry()
->getHandlerForType($this->type)
->unserializeValue($this->attributes['value']);
}
return $this->cachedValue;
} | [
"public",
"function",
"getValueAttribute",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"cachedValue",
")",
")",
"{",
"$",
"this",
"->",
"cachedValue",
"=",
"$",
"this",
"->",
"getDataTypeRegistry",
"(",
")",
"->",
"getHandlerForType",
... | Accessor for value.
Will unserialize the value before returning it.
Successive access will be loaded from cache.
@return mixed | [
"Accessor",
"for",
"value",
"."
] | 414aa3707d8f91170e505ed7228bb74e31d8e35b | https://github.com/plank/laravel-metable/blob/414aa3707d8f91170e505ed7228bb74e31d8e35b/src/Meta.php#L65-L74 | train |
plank/laravel-metable | src/Meta.php | Meta.setValueAttribute | public function setValueAttribute($value)
{
$registry = $this->getDataTypeRegistry();
$this->attributes['type'] = $registry->getTypeForValue($value);
$this->attributes['value'] = $registry->getHandlerForType($this->type)
->serializeValue($value);
$this->cachedValue = null;
} | php | public function setValueAttribute($value)
{
$registry = $this->getDataTypeRegistry();
$this->attributes['type'] = $registry->getTypeForValue($value);
$this->attributes['value'] = $registry->getHandlerForType($this->type)
->serializeValue($value);
$this->cachedValue = null;
} | [
"public",
"function",
"setValueAttribute",
"(",
"$",
"value",
")",
"{",
"$",
"registry",
"=",
"$",
"this",
"->",
"getDataTypeRegistry",
"(",
")",
";",
"$",
"this",
"->",
"attributes",
"[",
"'type'",
"]",
"=",
"$",
"registry",
"->",
"getTypeForValue",
"(",
... | Mutator for value.
The `type` attribute will be automatically updated to match the datatype of the input.
@param mixed $value | [
"Mutator",
"for",
"value",
"."
] | 414aa3707d8f91170e505ed7228bb74e31d8e35b | https://github.com/plank/laravel-metable/blob/414aa3707d8f91170e505ed7228bb74e31d8e35b/src/Meta.php#L83-L92 | train |
SimplyCodedSoftware/integration-messaging | src/Messaging/Config/MessagingSystemConfiguration.php | MessagingSystemConfiguration.buildMessagingSystemFromConfiguration | public function buildMessagingSystemFromConfiguration(ReferenceSearchService $referenceSearchService): ConfiguredMessagingSystem
{
foreach ($this->messageHandlerBuilders as $messageHandlerBuilder) {
if (!array_key_exists($messageHandlerBuilder->getInputMessageChannelName(), $this->channelBuilders)) {
if (array_key_exists($messageHandlerBuilder->getInputMessageChannelName(), $this->defaultChannelBuilders)) {
$this->channelBuilders[$messageHandlerBuilder->getInputMessageChannelName()] = $this->defaultChannelBuilders[$messageHandlerBuilder->getInputMessageChannelName()];
} else {
$this->channelBuilders[$messageHandlerBuilder->getInputMessageChannelName()] = SimpleMessageChannelBuilder::createDirectMessageChannel($messageHandlerBuilder->getInputMessageChannelName());
}
}
}
$interfaceToCallRegistry = InterfaceToCallRegistry::createWithInterfaces($this->interfacesToCall);
$converters = [];
foreach ($this->converterBuilders as $converterBuilder) {
$converters[] = $converterBuilder->build($referenceSearchService);
}
$referenceSearchService = InMemoryReferenceSearchService::createWithReferenceService($referenceSearchService, [
ConversionService::REFERENCE_NAME => AutoCollectionConversionService::createWith($converters),
InterfaceToCallRegistry::REFERENCE_NAME => $interfaceToCallRegistry
]);
$channelResolver = $this->createChannelResolver($referenceSearchService);
$this->configureInterceptors($interfaceToCallRegistry);
/** @var GatewayBuilder[][] $preparedGateways */
$preparedGateways = [];
foreach ($this->gatewayBuilders as $gatewayBuilder) {
$preparedGateways[$gatewayBuilder->getReferenceName()][] = $gatewayBuilder;
}
$gateways = $this->configureGateways($preparedGateways, $referenceSearchService, $channelResolver);
$consumerEndpointFactory = new ConsumerEndpointFactory($channelResolver, $referenceSearchService, $this->consumerFactories, $this->pollingMetadata);
$consumers = [];
foreach ($this->messageHandlerBuilders as $messageHandlerBuilder) {
$consumers[] = $consumerEndpointFactory->createForMessageHandler($messageHandlerBuilder);
}
foreach ($this->channelAdapters as $channelAdapter) {
$consumers[] = $channelAdapter->build($channelResolver, $referenceSearchService, array_key_exists($channelAdapter->getEndpointId(), $this->pollingMetadata) ? $this->pollingMetadata[$channelAdapter->getEndpointId()] : null);
}
return MessagingSystem::create($consumers, $gateways, $channelResolver);
} | php | public function buildMessagingSystemFromConfiguration(ReferenceSearchService $referenceSearchService): ConfiguredMessagingSystem
{
foreach ($this->messageHandlerBuilders as $messageHandlerBuilder) {
if (!array_key_exists($messageHandlerBuilder->getInputMessageChannelName(), $this->channelBuilders)) {
if (array_key_exists($messageHandlerBuilder->getInputMessageChannelName(), $this->defaultChannelBuilders)) {
$this->channelBuilders[$messageHandlerBuilder->getInputMessageChannelName()] = $this->defaultChannelBuilders[$messageHandlerBuilder->getInputMessageChannelName()];
} else {
$this->channelBuilders[$messageHandlerBuilder->getInputMessageChannelName()] = SimpleMessageChannelBuilder::createDirectMessageChannel($messageHandlerBuilder->getInputMessageChannelName());
}
}
}
$interfaceToCallRegistry = InterfaceToCallRegistry::createWithInterfaces($this->interfacesToCall);
$converters = [];
foreach ($this->converterBuilders as $converterBuilder) {
$converters[] = $converterBuilder->build($referenceSearchService);
}
$referenceSearchService = InMemoryReferenceSearchService::createWithReferenceService($referenceSearchService, [
ConversionService::REFERENCE_NAME => AutoCollectionConversionService::createWith($converters),
InterfaceToCallRegistry::REFERENCE_NAME => $interfaceToCallRegistry
]);
$channelResolver = $this->createChannelResolver($referenceSearchService);
$this->configureInterceptors($interfaceToCallRegistry);
/** @var GatewayBuilder[][] $preparedGateways */
$preparedGateways = [];
foreach ($this->gatewayBuilders as $gatewayBuilder) {
$preparedGateways[$gatewayBuilder->getReferenceName()][] = $gatewayBuilder;
}
$gateways = $this->configureGateways($preparedGateways, $referenceSearchService, $channelResolver);
$consumerEndpointFactory = new ConsumerEndpointFactory($channelResolver, $referenceSearchService, $this->consumerFactories, $this->pollingMetadata);
$consumers = [];
foreach ($this->messageHandlerBuilders as $messageHandlerBuilder) {
$consumers[] = $consumerEndpointFactory->createForMessageHandler($messageHandlerBuilder);
}
foreach ($this->channelAdapters as $channelAdapter) {
$consumers[] = $channelAdapter->build($channelResolver, $referenceSearchService, array_key_exists($channelAdapter->getEndpointId(), $this->pollingMetadata) ? $this->pollingMetadata[$channelAdapter->getEndpointId()] : null);
}
return MessagingSystem::create($consumers, $gateways, $channelResolver);
} | [
"public",
"function",
"buildMessagingSystemFromConfiguration",
"(",
"ReferenceSearchService",
"$",
"referenceSearchService",
")",
":",
"ConfiguredMessagingSystem",
"{",
"foreach",
"(",
"$",
"this",
"->",
"messageHandlerBuilders",
"as",
"$",
"messageHandlerBuilder",
")",
"{"... | Initialize messaging system from current configuration
@param ReferenceSearchService $referenceSearchService
@return ConfiguredMessagingSystem
@throws NoConsumerFactoryForBuilderException
@throws MessagingException | [
"Initialize",
"messaging",
"system",
"from",
"current",
"configuration"
] | d2d19c64f115adb554952962853a047d40be08bd | https://github.com/SimplyCodedSoftware/integration-messaging/blob/d2d19c64f115adb554952962853a047d40be08bd/src/Messaging/Config/MessagingSystemConfiguration.php#L430-L475 | train |
opis-colibri/framework | src/ItemCollectors/RouteCollector.php | RouteCollector.all | public function all(string $path, callable $action, string $name = null): HttpRoute
{
return $this->handle($path, $action, ['GET', 'POST', 'PUT', 'PATCH', 'DELETE'], $name);
} | php | public function all(string $path, callable $action, string $name = null): HttpRoute
{
return $this->handle($path, $action, ['GET', 'POST', 'PUT', 'PATCH', 'DELETE'], $name);
} | [
"public",
"function",
"all",
"(",
"string",
"$",
"path",
",",
"callable",
"$",
"action",
",",
"string",
"$",
"name",
"=",
"null",
")",
":",
"HttpRoute",
"{",
"return",
"$",
"this",
"->",
"handle",
"(",
"$",
"path",
",",
"$",
"action",
",",
"[",
"'G... | Defines a new route that will intercept all HTTP requests
@param string $path The path to match
@param callable $action An action that will be executed
@param string $name (optional) Route name
@return HttpRoute | [
"Defines",
"a",
"new",
"route",
"that",
"will",
"intercept",
"all",
"HTTP",
"requests"
] | 22b2f0ed31876a05c9a7813c6881d2ba2b5039b8 | https://github.com/opis-colibri/framework/blob/22b2f0ed31876a05c9a7813c6881d2ba2b5039b8/src/ItemCollectors/RouteCollector.php#L113-L116 | train |
opis-colibri/framework | src/ItemCollectors/RouteCollector.php | RouteCollector.handle | protected function handle(string $path, callable $action, $method, string $name = null): HttpRoute
{
if (!is_array($method)) {
$method = [$method];
}
/** @var HttpRoute $route */
$route = $this->data->createRoute($this->prefix . $path, $action, $name);
$route->method(...$method);
return $route;
} | php | protected function handle(string $path, callable $action, $method, string $name = null): HttpRoute
{
if (!is_array($method)) {
$method = [$method];
}
/** @var HttpRoute $route */
$route = $this->data->createRoute($this->prefix . $path, $action, $name);
$route->method(...$method);
return $route;
} | [
"protected",
"function",
"handle",
"(",
"string",
"$",
"path",
",",
"callable",
"$",
"action",
",",
"$",
"method",
",",
"string",
"$",
"name",
"=",
"null",
")",
":",
"HttpRoute",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"method",
")",
")",
"{",
"... | Defines a new route
@param string $path The path to match
@param callable $action An action that will be executed
@param string|array $method Request's method
@param string $name (optional) Route name
@return HttpRoute | [
"Defines",
"a",
"new",
"route"
] | 22b2f0ed31876a05c9a7813c6881d2ba2b5039b8 | https://github.com/opis-colibri/framework/blob/22b2f0ed31876a05c9a7813c6881d2ba2b5039b8/src/ItemCollectors/RouteCollector.php#L198-L207 | train |
zicht/menu-bundle | src/Zicht/Bundle/MenuBundle/Menu/Builder.php | Builder.build | public function build($name, Request $request)
{
$ret = $this->factory->createItem($name);
$menus = $this->loadRoots($request);
if (!isset($menus[$name])) {
return $ret;
}
$requestLocale = $request->get('_locale');
if (!isset($this->menus[$requestLocale][$name])) {
$rootIdToNameMap = array_combine(array_column($menus, 0), array_keys($menus));
if (in_array($name, $this->preloadMenus)) {
$menusToLoad = [];
foreach ($this->preloadMenus as $preloadMenuName) {
if (!isset($menus[$preloadMenuName])) {
continue;
}
$menusToLoad[$preloadMenuName] = $menus[$preloadMenuName];
}
} else {
$menusToLoad[$name] = $menus[$name];
}
$query = 'SELECT root, menu_item.* FROM menu_item WHERE ';
$i = 0;
// `$vals` contains [id, lft, rgt]
foreach ($menusToLoad as $vals) {
if ($i ++ > 0) {
$query .= ' OR ';
}
$query .= vsprintf('(root=%d AND lft BETWEEN %d AND %d AND id <> root)', $vals);
}
$query .= ' ORDER BY root, lft';
foreach ($this->em->getConnection()->query($query)->fetchAll(\PDO::FETCH_GROUP) as $rootId => $menu) {
if (!isset($rootIdToNameMap)) {
continue;
}
$menuName = $rootIdToNameMap[$rootId];
$this->menus[$requestLocale][$menuName]= $this->factory->createItem($menuName);
$this->addMenuItemHierarchy(
$request,
$this->menuItemEntity->buildTree($menu),
$this->menus[$requestLocale][$menuName]
);
}
}
if (isset($this->menus[$requestLocale][$name])) {
$ret = $this->menus[$requestLocale][$name];
if (is_callable([$ret, 'setCurrentUri'])) {
$ret->setCurrentUri($request->getRequestUri());
}
}
return $ret;
} | php | public function build($name, Request $request)
{
$ret = $this->factory->createItem($name);
$menus = $this->loadRoots($request);
if (!isset($menus[$name])) {
return $ret;
}
$requestLocale = $request->get('_locale');
if (!isset($this->menus[$requestLocale][$name])) {
$rootIdToNameMap = array_combine(array_column($menus, 0), array_keys($menus));
if (in_array($name, $this->preloadMenus)) {
$menusToLoad = [];
foreach ($this->preloadMenus as $preloadMenuName) {
if (!isset($menus[$preloadMenuName])) {
continue;
}
$menusToLoad[$preloadMenuName] = $menus[$preloadMenuName];
}
} else {
$menusToLoad[$name] = $menus[$name];
}
$query = 'SELECT root, menu_item.* FROM menu_item WHERE ';
$i = 0;
// `$vals` contains [id, lft, rgt]
foreach ($menusToLoad as $vals) {
if ($i ++ > 0) {
$query .= ' OR ';
}
$query .= vsprintf('(root=%d AND lft BETWEEN %d AND %d AND id <> root)', $vals);
}
$query .= ' ORDER BY root, lft';
foreach ($this->em->getConnection()->query($query)->fetchAll(\PDO::FETCH_GROUP) as $rootId => $menu) {
if (!isset($rootIdToNameMap)) {
continue;
}
$menuName = $rootIdToNameMap[$rootId];
$this->menus[$requestLocale][$menuName]= $this->factory->createItem($menuName);
$this->addMenuItemHierarchy(
$request,
$this->menuItemEntity->buildTree($menu),
$this->menus[$requestLocale][$menuName]
);
}
}
if (isset($this->menus[$requestLocale][$name])) {
$ret = $this->menus[$requestLocale][$name];
if (is_callable([$ret, 'setCurrentUri'])) {
$ret->setCurrentUri($request->getRequestUri());
}
}
return $ret;
} | [
"public",
"function",
"build",
"(",
"$",
"name",
",",
"Request",
"$",
"request",
")",
"{",
"$",
"ret",
"=",
"$",
"this",
"->",
"factory",
"->",
"createItem",
"(",
"$",
"name",
")",
";",
"$",
"menus",
"=",
"$",
"this",
"->",
"loadRoots",
"(",
"$",
... | Create the menu based on the doctrine model.
@param string $name
@param \Symfony\Component\HttpFoundation\Request $request
@return ItemInterface
@throws \InvalidArgumentException | [
"Create",
"the",
"menu",
"based",
"on",
"the",
"doctrine",
"model",
"."
] | b6f22d50025297ad686c8f3afb7b6afe736b7f97 | https://github.com/zicht/menu-bundle/blob/b6f22d50025297ad686c8f3afb7b6afe736b7f97/src/Zicht/Bundle/MenuBundle/Menu/Builder.php#L103-L166 | train |
zicht/menu-bundle | src/Zicht/Bundle/MenuBundle/Menu/Builder.php | Builder.getRootItemByName | public function getRootItemByName($name, $request)
{
$menus = $this->loadRoots($request);
if (!isset($menus[$name])) {
return null;
}
return $this->menuItemEntity->find($menus[$name][0]);
} | php | public function getRootItemByName($name, $request)
{
$menus = $this->loadRoots($request);
if (!isset($menus[$name])) {
return null;
}
return $this->menuItemEntity->find($menus[$name][0]);
} | [
"public",
"function",
"getRootItemByName",
"(",
"$",
"name",
",",
"$",
"request",
")",
"{",
"$",
"menus",
"=",
"$",
"this",
"->",
"loadRoots",
"(",
"$",
"request",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"menus",
"[",
"$",
"name",
"]",
")",
... | Get the root item based on the specified name and request.
@param string $name
@param Request $request
@return mixed | [
"Get",
"the",
"root",
"item",
"based",
"on",
"the",
"specified",
"name",
"and",
"request",
"."
] | b6f22d50025297ad686c8f3afb7b6afe736b7f97 | https://github.com/zicht/menu-bundle/blob/b6f22d50025297ad686c8f3afb7b6afe736b7f97/src/Zicht/Bundle/MenuBundle/Menu/Builder.php#L175-L184 | train |
zicht/menu-bundle | src/Zicht/Bundle/MenuBundle/Menu/Builder.php | Builder.hasRootItemByName | public function hasRootItemByName($name, $request)
{
$menus = $this->loadRoots($request);
return isset($menus[$name]);
} | php | public function hasRootItemByName($name, $request)
{
$menus = $this->loadRoots($request);
return isset($menus[$name]);
} | [
"public",
"function",
"hasRootItemByName",
"(",
"$",
"name",
",",
"$",
"request",
")",
"{",
"$",
"menus",
"=",
"$",
"this",
"->",
"loadRoots",
"(",
"$",
"request",
")",
";",
"return",
"isset",
"(",
"$",
"menus",
"[",
"$",
"name",
"]",
")",
";",
"}"... | Check if a root item exists.
@param string $name
@param Request $request
@return bool | [
"Check",
"if",
"a",
"root",
"item",
"exists",
"."
] | b6f22d50025297ad686c8f3afb7b6afe736b7f97 | https://github.com/zicht/menu-bundle/blob/b6f22d50025297ad686c8f3afb7b6afe736b7f97/src/Zicht/Bundle/MenuBundle/Menu/Builder.php#L193-L197 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.