public function getUniqueSlug($callback, $slug, array $args = array())
    {
        if (!is_callable($callback)) {
            throw new InvalidArgumentException(
                sprintf('First argument must be callable, received "%s"', gettype($callback))
            );
        }

        $count = 0;

        while (true) {
            $count++;

            if (call_user_func_array($callback, array_merge(array($slug), $args))) {
                // If dash can't be found, then add first
                if (!$this->isNumericSlug($slug)) {
                    $slug = sprintf('%s-%s', $slug, $count);
                } else {
                    $slug = $this->createUniqueNumericSlug($slug);
                }

            } else {
                break;
            }
        }

        return $slug;
    }
public function getUniqueSlug($callback, $slug, array $args = array())
    {
        if (!is_callable($callback)) {
            throw new InvalidArgumentException(
                sprintf('First argument must be callable, received "%s"', gettype($callback))
            );
        }

        $count = 0;

        while (true) {
            $count++;

            if (call_user_func_array($callback, array_merge(array($slug), $args))) {
                // If dash can't be found, then add first
                if (!$this->isNumericSlug($slug)) {
                    $slug = sprintf('%s-%s', $slug, $count);
                } else {
                    $slug = $this->createUniqueNumericSlug($slug);
                }

            } else {
                break;
            }
        }

        return $slug;
    }
public function getUniqueSlug ( $ callback , $ slug , array $ args = array ( ) ) { if ( ! is_callable ( $ callback ) ) { throw new InvalidArgumentException ( sprintf ( 'First argument must be callable, received "%s"' , gettype ( $ callback ) ) ) ; } $ count = 0 ; while ( true ) { $ count ++ ; if ( call_user_func_array ( $ callback , array_merge ( array ( $ slug ) , $ args ) ) ) { // If dash can't be found, then add first if ( ! $ this -> isNumericSlug ( $ slug ) ) { $ slug = sprintf ( '%s-%s' , $ slug , $ count ) ; } else { $ slug = $ this -> createUniqueNumericSlug ( $ slug ) ; } } else { break ; } } return $ slug ; }
Returns unique slug

@param callable $callback Callback function
@param string $slug
@param array $args Extra arguments to be passed to callback function
@throws \InvalidArgumentException If $callback isn't callable
@return string
Returns unique slug