예제 #1
0
파일: Expansion.php 프로젝트: lastguest/yay
 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
0
 /**
  * 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
0
 /**
  * {@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;
 }