public static function toResults(array $items) {

        $output = [];

        foreach ($items as $current) {

            if (false === ($current instanceof Select2ItemInterface)) {
                throw new InvalidArgumentException("The item must implements Select2ItemInterface");
            }

            $output[] = [
                "id"   => $current->getSelect2ItemId(),
                "text" => $current->getSelect2ItemText(),
            ];
        }

        return $output;
    }
public static function toResults(array $items) {

        $output = [];

        foreach ($items as $current) {

            if (false === ($current instanceof Select2ItemInterface)) {
                throw new InvalidArgumentException("The item must implements Select2ItemInterface");
            }

            $output[] = [
                "id"   => $current->getSelect2ItemId(),
                "text" => $current->getSelect2ItemText(),
            ];
        }

        return $output;
    }
public static function toResults ( array $ items ) { $ output = [ ] ; foreach ( $ items as $ current ) { if ( false === ( $ current instanceof Select2ItemInterface ) ) { throw new InvalidArgumentException ( "The item must implements Select2ItemInterface" ) ; } $ output [ ] = [ "id" => $ current -> getSelect2ItemId ( ) , "text" => $ current -> getSelect2ItemText ( ) , ] ; } return $ output ; }
Convert items into a "results" array.

@param Select2ItemInterface[] $items The items.
@return array Returns the "results" array.
@throws InvalidArgumentException Throws an invalid argument exception if an item does not implement Select2ItemInterface.
Convert items into a results array .