implode() public method

Concatenate values of a given key as a string.
public implode ( string $value, string $glue = null ) : string
$value string
$glue string
return string
Example #1
0
 protected function makeDistributedName()
 {
     $this->md5FileName = md5($this->getModel()->path . microtime(true)) . '.' . collect(explode('.', $this->getModel()->path))->last();
     $this->getModel()->old_name = $this->getModel()->path;
     $this->distributedPathCollection = collect([mb_substr($this->md5FileName, 0, 3), mb_substr($this->md5FileName, 3, 3), mb_substr($this->md5FileName, 6, 3)]);
     $this->getModel()->name = mb_substr($this->md5FileName, 9);
     $this->getModel()->distributed_path = $this->distributedPathCollection->implode($this->pathSeparator);
     $this->getModel()->path = $this->getModel()->distributed_path . $this->pathSeparator . $this->getModel()->name;
     return $this;
 }
 public function getCreatorsBatch(Collection $channelIds)
 {
     $ids = $channelIds->implode(',');
     $params = ['id' => $ids, 'maxResults' => 50];
     $result = $this->source->getCreator($params);
     return Channel::createData(collect($result['items']));
 }
Example #3
0
 /**
  * Get the account details of up to 100 users
  *
  * @param Collection $usernames
  * @return Collection
  */
 public function lookup(Collection $usernames)
 {
     $response = $this->client->get('users/lookup.json', ['query' => 'screen_name=' . $usernames->implode(','), 'http_errors' => false]);
     if ($response->getStatusCode() == Response::HTTP_NOT_FOUND) {
         return new Collection();
     }
     return new Collection(json_decode($response->getBody()));
 }
 public function getVideosBatch(Collection $videoIds, $cacheKey, $force = false)
 {
     $videoIdsString = $videoIds->implode(',');
     $params = ['maxResults' => 50, 'id' => $videoIdsString];
     if ($force === true) {
         Cache::forget($cacheKey);
     }
     $results = Cache::rememberForever($cacheKey, function () use($params) {
         return $this->source->getVideo($params);
     });
     return Video::createData(collect($results['items']));
 }
 /**
  *
  *  集合元素 转换成 字符串
  *
  * implode
  *
  */
 public function implode()
 {
     $val = $this->collection->map(function ($val, $key) {
         return $val['price'];
     });
     debug($val);
     //Desk,Chair,Bookcase,Door
     $implode = $this->collection->implode('product', ',');
     debug($implode);
     //1-2-3-4-5
     $implode = collect([1, 2, 3, 4, 5])->implode('-');
     debug($implode);
     return view('index');
 }
Example #6
0
 public function testImplode()
 {
     $data = new Collection([['name' => 'taylor', 'email' => 'foo'], ['name' => 'dayle', 'email' => 'bar']]);
     $this->assertEquals('foobar', $data->implode('email'));
     $this->assertEquals('foo,bar', $data->implode('email', ','));
     $data = new Collection(['taylor', 'dayle']);
     $this->assertEquals('taylordayle', $data->implode(''));
     $this->assertEquals('taylor,dayle', $data->implode(','));
 }
 /**
  * Requests the abstract request. But before it does so, it sets a few properties
  * on the request like the extended level, page and it's limit
  *
  * @param AbstractRequest $request
  * @return mixed
  * @throws \Wubs\Trakt\Request\Exception\HttpCodeException\RateLimitExceededException
  * @throws \Wubs\Trakt\Request\Exception\HttpCodeException\ServerErrorException
  * @throws \Wubs\Trakt\Request\Exception\HttpCodeException\ServerUnavailableException
  * @throws \Wubs\Trakt\Request\Exception\HttpCodeException\StatusCodeException
  */
 protected function request(AbstractRequest $request)
 {
     return $request->setExtended($this->extended->implode(','))->setPage($this->page)->setLimit($this->limit)->make($this->clientId, $this->client);
 }
 private function addProperties(Collection $properties)
 {
     $formatted = new Collection();
     $properties->each(function ($property) use($formatted) {
         $generator = new Property($this->apiNamespace . "\\" . $this->endpoint->implode("\\") . "\\" . $property, $this->filesystem);
         $formatted->push($generator->generate());
     });
     return $this->writeInTemplate('public_properties', "\n" . $formatted->implode("\n\n"));
 }