当前位置: 首页>>代码示例>>PHP>>正文


PHP Collection::first方法代码示例

本文整理汇总了PHP中Collection::first方法的典型用法代码示例。如果您正苦于以下问题:PHP Collection::first方法的具体用法?PHP Collection::first怎么用?PHP Collection::first使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Collection的用法示例。


在下文中一共展示了Collection::first方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testFirst

 /**
  * @test Collection::first()
  */
 public function testFirst()
 {
     $this->buildEnvironment();
     $result = $this->collection->first();
     $expect = $this->source['a1'];
     $this->assertEquals($expect, $result);
 }
开发者ID:timoxeen,项目名称:php-commerceml,代码行数:10,代码来源:CollectionTest.php

示例2: _dumpCollection

 public static function _dumpCollection(Collection $collection)
 {
     if (is_object($collection->first()) and $collection->first() instanceof Model) {
         $output = "<span><strong>Collection of " . get_class($collection->first()) . " Models</strong></span>\n";
     } else {
         $output = "<span><strong>Collection object:</strong></span>\n";
     }
     foreach ($collection as $key => $value) {
         $output .= "  " . \Automatorm\Orm\Dump::format($key, $value);
     }
     return $output;
 }
开发者ID:brokencube,项目名称:automatorm,代码行数:12,代码来源:Dump.php

示例3: testPopPushPutShiftUnshiftInject

 public function testPopPushPutShiftUnshiftInject()
 {
     // pop
     $_3 = $this->collection->pop();
     $this->assertEquals($this->_3, $_3);
     $this->assertEquals($this->_2, $this->collection->last());
     $this->assertEquals(3, $this->collection->count());
     // push
     $this->collection->push($_3);
     $this->assertEquals($this->_3, $this->collection->last());
     // put
     $this->collection->put(2, 'test');
     $this->assertEquals('test', $this->collection->get(2));
     // shift
     $_0 = $this->collection->shift();
     $this->assertEquals($this->_0, $_0);
     $this->assertEquals($this->_1, $this->collection->first());
     $this->assertEquals(3, $this->collection->count());
     // unshift
     $this->collection->unshift($_0);
     $this->assertEquals($this->_0, $this->collection->first());
     // inject
     $this->collection->inject(2, 'test2');
     $this->assertEquals('test2', $this->collection->get(2));
     $this->assertEquals(5, $this->collection->count());
 }
开发者ID:dtkahl,项目名称:php-array-tools,代码行数:26,代码来源:CollectionTest.php

示例4: tags

 public function tags()
 {
     $collection = Collection::first();
     // Get all tags
     $tags = $collection->getTags();
     // Find how many are in the specified decks
     foreach ($tags as $tag) {
         $q = DB::table('cards')->select(DB::raw('count() as cards_count'), DB::raw('avg(ivl) as average_interval'))->join('notes', 'cards.nid', '=', 'notes.id')->where('tags', 'like', '%' . $tag . '%')->whereIn('did', $this->myDecks())->first();
         if ((int) $q->cards_count === 0) {
             continue;
         }
         $results[$tag] = ['tag' => $tag, 'count' => (int) $q->cards_count, 'value' => round($q->average_interval, 1)];
     }
     return Response::json($results);
 }
开发者ID:tomzx,项目名称:anki-charts,代码行数:15,代码来源:HomeController.php

示例5: first

 /** {@inheritdoc} */
 public function first()
 {
     $this->initialize();
     return $this->coll->first();
 }
开发者ID:richardmiller,项目名称:mongodb-odm,代码行数:6,代码来源:PersistentCollection.php

示例6: firstFile

 /**
  * Returns the first file of the Gist.
  *
  * @return GistFile
  */
 public function firstFile()
 {
     return $this->files->first();
 }
开发者ID:cybercog,项目名称:gistvote,代码行数:9,代码来源:Gist.php

示例7: testFirst

 public function testFirst()
 {
     $el = $this->collection->first();
     $this->assertEquals($this->_0, $el);
 }
开发者ID:dtkahl,项目名称:php-collection,代码行数:5,代码来源:CollectionTest.php

示例8: visibilitiesColInfo

 /**
  * Same as visibilityInfo, but for visibility collections
  */
 public static function visibilitiesColInfo(Collection $visibilities)
 {
     if ($visibilities->count() == 0) {
         return array('green', "Tout le monde");
     } elseif ($visibilities->count() == 1) {
         return self::visibilityInfo($visibilities->first());
     }
     $textes = array();
     foreach ($visibilities as $v) {
         list($color, $text) = self::visibilityInfo($v);
         $textes[] = $text;
     }
     return array('grey', implode(', ', $textes));
 }
开发者ID:netixx,项目名称:frankiz,代码行数:17,代码来源:user.php

示例9: testFirst

 public function testFirst()
 {
     $collection = new Collection(['a' => 'c', 'b' => 'd']);
     $this->assertSame('c', $collection->first());
 }
开发者ID:Raphhh,项目名称:trex-collection,代码行数:5,代码来源:CollectionValueAccessorTraitTest.php


注:本文中的Collection::first方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。