Illuminate\Support\Collection::count PHP Method

count() public method

Count the number of items in the collection.
public count ( ) : integer
return integer
    public function count()
    {
        return count($this->items);
    }

Usage Example

Exemplo n.º 1
4
 public function getInitial()
 {
     $words = new Collection(explode(' ', $this->name));
     // if name contains single word, use first N character
     if ($words->count() === 1) {
         if ($this->name->length() >= $this->length) {
             return $this->name->substr(0, $this->length);
         }
         return (string) $words->first();
     }
     // otherwise, use initial char from each word
     $initials = new Collection();
     $words->each(function ($word) use($initials) {
         $initials->push(Stringy::create($word)->substr(0, 1));
     });
     return $initials->slice(0, $this->length)->implode('');
 }
All Usage Examples Of Illuminate\Support\Collection::count