コード例 #1
0
ファイル: MethodTest.php プロジェクト: Geekathon/reddit-clone
 public function testHasAccessToOriginalPhpFunctions()
 {
     $array = Arrays::from($this->array);
     $array = $array->intersect(array('foo' => 'bar', 'kal' => 'mon'));
     $this->assertEquals(array('foo' => 'bar'), $array->obtain());
     $string = String::repeat('foo', 2);
     $this->assertEquals('foofoo', $string);
     $string = String::from('   foo  ')->trim();
     $this->assertEquals('foo', $string->obtain());
 }
コード例 #2
0
ファイル: Arr.php プロジェクト: docit/support
 public static function from($arr = [])
 {
     return \Underscore\Types\Arrays::from($arr);
 }
コード例 #3
0
ファイル: Scraper.php プロジェクト: Kitchup/vdm-scraper
 /**
  * Retrieves the last $postCount from vdm
  *
  * @param  int $postCount : the number of entries to retrieve
  * @return mixed
  */
 protected function getLatestPosts($postCount)
 {
     // posts array is empty
     $posts = [];
     // starting at page 0 (source achitecture)
     $pageId = 0;
     // fetching until enough posts are retrieved
     while (Arrays::size($posts) < $postCount) {
         $dom = HtmlDomParser::file_get_html(sprintf($this->getBaseUrl(), $pageId));
         $domPosts = $dom->find('.article');
         $posts = Arrays::merge($posts, $domPosts);
         $pageId++;
     }
     // sorting by descending date and keeping only the $postCount first entries
     return Arrays::from($posts)->sort('date', 'desc')->first($postCount)->obtain();
 }
コード例 #4
0
 public function testCanDiffBetweenArrays()
 {
     $array = Arrays::diff($this->array, array('foo' => 'bar', 'ter' => 'kal'));
     $chain = Arrays::from($this->array)->diff(array('foo' => 'bar', 'ter' => 'kal'));
     $this->assertEquals(array('bis' => 'ter'), $array);
     $this->assertEquals(array('bis' => 'ter'), $chain->obtain());
 }
コード例 #5
0
 public function testCanParseToStringOnToString()
 {
     $array = Arrays::from($this->array);
     $this->assertEquals('{"foo":"bar","bis":"ter"}', $array->__toString());
 }