public function documents($values)
    {
        if ($values instanceof BatchCommandInterface) {
            $this->batch = $values;
        } elseif (is_array($values)) {

            $isBatch = true;
            $batch   = new BatchCommand();

            /**
             * @param mixed $value
             */
            $map = function ($value) use ($isBatch, $batch) {
                if (!$value instanceof Command) {
                    $isBatch = false;
                } else {
                    $batch->addCommand($value);
                }
            };

            array_map($map, $values);

            if (!$isBatch) {
                                throw new exceptions\BadMethodCallException("If an array is supplied, all elements must be a Command object.");
            }

            $this->batch = $batch;

        } else {
                        throw new exceptions\BadMethodCallException("Documents method only accepts arrays of Commands or BatchCommandInterface objects");
        }

        return $this;

    }
public function documents($values)
    {
        if ($values instanceof BatchCommandInterface) {
            $this->batch = $values;
        } elseif (is_array($values)) {

            $isBatch = true;
            $batch   = new BatchCommand();

            /**
             * @param mixed $value
             */
            $map = function ($value) use ($isBatch, $batch) {
                if (!$value instanceof Command) {
                    $isBatch = false;
                } else {
                    $batch->addCommand($value);
                }
            };

            array_map($map, $values);

            if (!$isBatch) {
                                throw new exceptions\BadMethodCallException("If an array is supplied, all elements must be a Command object.");
            }

            $this->batch = $batch;

        } else {
                        throw new exceptions\BadMethodCallException("Documents method only accepts arrays of Commands or BatchCommandInterface objects");
        }

        return $this;

    }
public function documents ( $ values ) { if ( $ values instanceof BatchCommandInterface ) { $ this -> batch = $ values ; } elseif ( is_array ( $ values ) ) { $ isBatch = true ; $ batch = new BatchCommand ( ) ; /**
             * @param mixed $value
             */ $ map = function ( $ value ) use ( $ isBatch , $ batch ) { if ( ! $ value instanceof Command ) { $ isBatch = false ; } else { $ batch -> addCommand ( $ value ) ; } } ; array_map ( $ map , $ values ) ; if ( ! $ isBatch ) { throw new exceptions \ BadMethodCallException ( "If an array is supplied, all elements must be a Command object." ) ; } $ this -> batch = $ batch ; } else { throw new exceptions \ BadMethodCallException ( "Documents method only accepts arrays of Commands or BatchCommandInterface objects" ) ; } return $ this ; }
Accepts an array of Commands or a BatchCommand

@param array|BatchCommandInterface $values

@return $this
@throws \Sherlock\common\exceptions\BadMethodCallException
Accepts an array of Commands or a BatchCommand