protected function filterDuplicatesFromArray(array $values)
    {
        $uniqueItems = [];
        foreach ($values as $value) {
            $uniqueItems[md5(serialize($value))] = $value;
        }
        $result = array_values($uniqueItems);
        if (count($result) === 1) {
            return $result[0];
        }
        return $result;
    }
protected function filterDuplicatesFromArray(array $values)
    {
        $uniqueItems = [];
        foreach ($values as $value) {
            $uniqueItems[md5(serialize($value))] = $value;
        }
        $result = array_values($uniqueItems);
        if (count($result) === 1) {
            return $result[0];
        }
        return $result;
    }
protected function filterDuplicatesFromArray ( array $ values ) { $ uniqueItems = [ ] ; foreach ( $ values as $ value ) { $ uniqueItems [ md5 ( serialize ( $ value ) ) ] = $ value ; } $ result = array_values ( $ uniqueItems ) ; if ( count ( $ result ) === 1 ) { return $ result [ 0 ] ; } return $ result ; }
Compact an array of items to avoid adding the same value more than once.
If the result contains only one item, that item is returned directly.

@param array $values array of values
@return mixed
Compact an array of items to avoid adding the same value more than once . If the result contains only one item that item is returned directly .