本文整理汇总了PHP中Map::contains方法的典型用法代码示例。如果您正苦于以下问题:PHP Map::contains方法的具体用法?PHP Map::contains怎么用?PHP Map::contains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Map
的用法示例。
在下文中一共展示了Map::contains方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
function __construct(array $expansion, Map $tags, Map $scope)
{
$this->expansion = $this->compile($expansion, $scope);
if ($tags->contains('·unsafe')) {
$this->unsafe = false;
}
$this->recursive = $tags->contains('·recursion');
}
示例2: getPlayerRelation
/**
* Checks an relation to the indicated user.
*
* @param integer $userid
*
* @return boolean True if a relation exists, false if not
*/
protected function getPlayerRelation($userid)
{
if (!$userid || !$this->userid) {
return false;
}
$this->loadPlayerRelations();
if ($this->players->size() > 0 && $this->players->contains($userid)) {
return true;
}
return false;
}
示例3: groupBy
/**
* {@inheritdoc}
*/
public function groupBy(callable $discriminator) : MapInterface
{
if ($this->size() === 0) {
throw new GroupEmptySequenceException();
}
$map = null;
foreach ($this->values as $value) {
$key = $discriminator($value);
if ($map === null) {
$type = gettype($key);
$map = new Map($type === 'object' ? get_class($key) : $type, SequenceInterface::class);
}
if ($map->contains($key)) {
$map = $map->put($key, $map->get($key)->add($value));
} else {
$map = $map->put($key, new self($value));
}
}
return $map;
}