Example #1
0
 /**
  * Tests firstMatch
  *
  * @return void
  */
 public function testFirstMatch()
 {
     $items = [['id' => 1, 'name' => 'foo', 'thing' => ['parent_id' => 10]], ['id' => 2, 'name' => 'bar', 'thing' => ['parent_id' => 11]], ['id' => 3, 'name' => 'baz', 'thing' => ['parent_id' => 10]]];
     $collection = new Collection($items);
     $matched = $collection->firstMatch(['thing.parent_id' => 10]);
     $this->assertEquals(['id' => 1, 'name' => 'foo', 'thing' => ['parent_id' => 10]], $matched);
     $matched = $collection->firstMatch(['thing.parent_id' => 10, 'name' => 'baz']);
     $this->assertEquals(['id' => 3, 'name' => 'baz', 'thing' => ['parent_id' => 10]], $matched);
 }
 /**
  * Tests firstMatch
  *
  * @return void
  */
 public function testFirstMatch()
 {
     $this->assertFalse(defined('HHVM_VERSION'), 'Broken on HHVM');
     $items = [['id' => 1, 'name' => 'foo', 'thing' => ['parent_id' => 10]], ['id' => 2, 'name' => 'bar', 'thing' => ['parent_id' => 11]], ['id' => 3, 'name' => 'baz', 'thing' => ['parent_id' => 10]]];
     $collection = new Collection($items);
     $matched = $collection->firstMatch(['thing.parent_id' => 10]);
     $this->assertEquals(['id' => 1, 'name' => 'foo', 'thing' => ['parent_id' => 10]], $matched);
     $matched = $collection->firstMatch(['thing.parent_id' => 10, 'name' => 'baz']);
     $this->assertEquals(['id' => 3, 'name' => 'baz', 'thing' => ['parent_id' => 10]], $matched);
 }
Example #3
0
 public function getCurrent($user_id)
 {
     $gm_collection = new Collection($this->game_memberships);
     $current = $gm_collection->firstMatch(['member_id' => $user_id]);
     if (!$current->member) {
         return false;
     }
     return $current;
 }