for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Nip\Collections\Traits;
use Traversable;
/**
* Class OperationsTrait
* @package Nip\Collections\Traits
*/
trait OperationsTrait
{
* Returns the number of parameters.
*
* @return int The number of parameters
public function count()
return count($this->items);
items
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
class MyClass { } $x = new MyClass(); $x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:
class MyClass { public $foo; } $x = new MyClass(); $x->foo = true;
}
* Returns number of items in $collection.
* @return int
public function size()
$result = 0;
foreach ($this as $value) {
$this
this<Nip\Collections\Traits\OperationsTrait>
$result++;
return $result;
* @return bool
public function isEmpty()
return $this->count() < 1;
public function isNotEmpty()
return !$this->isEmpty();
* @return $this
public function clear()
$this->rewind();
$this->items = [];
return $this;
* @return void
abstract public function rewind();
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: