protected function guardType($items) : void {
        // this allows guardType($items) to receive
        // both a single item or an array of items
        if ( ! is_array($items)) {
            $items = array($items);
        }

        // throw an exception if any items are not
        // an instance of the required type
        foreach ($items as $item) {
            if ( ! $item instanceof $this->collectionType) {
                throw new \InvalidArgumentException(
                    "Got " . (is_object($item) ? get_class($item) : $item) . " but expected " . $this->collectionType
                );
            }
        }
    }
protected function guardType($items) : void {
        // this allows guardType($items) to receive
        // both a single item or an array of items
        if ( ! is_array($items)) {
            $items = array($items);
        }

        // throw an exception if any items are not
        // an instance of the required type
        foreach ($items as $item) {
            if ( ! $item instanceof $this->collectionType) {
                throw new \InvalidArgumentException(
                    "Got " . (is_object($item) ? get_class($item) : $item) . " but expected " . $this->collectionType
                );
            }
        }
    }
protected function guardType ( $ items ) : void { // this allows guardType($items) to receive // both a single item or an array of items if ( ! is_array ( $ items ) ) { $ items = array ( $ items ) ; } // throw an exception if any items are not // an instance of the required type foreach ( $ items as $ item ) { if ( ! $ item instanceof $ this -> collectionType ) { throw new \ InvalidArgumentException ( "Got " . ( is_object ( $ item ) ? get_class ( $ item ) : $ item ) . " but expected " . $ this -> collectionType ) ; } } }
ensure that items added to the collection conform to
the defined collection type

@param $items
ensure that items added to the collection conform to the defined collection type