Protobuf\ScalarCollection::add PHP Метод

add() публичный Метод

Adds a value to this collection
public add ( scalar $value )
$value scalar
    public function add($value)
    {
        if (!is_scalar($value)) {
            throw new InvalidArgumentException(sprintf('Argument 1 passed to %s must be a scalar value, %s given', __METHOD__, is_object($value) ? get_class($value) : gettype($value)));
        }
        parent::offsetSet(null, $value);
    }

Usage Example

 /**
  * @expectedException InvalidArgumentException
  * @expectedExceptionMessage Argument 1 passed to Protobuf\ScalarCollection::add must be a scalar value, stdClass given
  */
 public function testInvalidArgumentExceptionAddObject()
 {
     $this->collection->add(new \stdClass());
 }