Common\Core\Model::addNumber PHP Method

addNumber() public static method

Add a number to the string
public static addNumber ( string $string ) : string
$string string The string where the number will be appended to.
return string
    public static function addNumber($string)
    {
        // split
        $chunks = explode('-', $string);
        // count the chunks
        $count = count($chunks);
        // get last chunk
        $last = $chunks[$count - 1];
        // is numeric
        if (\SpoonFilter::isNumeric($last)) {
            // remove last chunk
            array_pop($chunks);
            // join together, and increment the last one
            $string = implode('-', $chunks) . '-' . ((int) $last + 1);
        } else {
            // not numeric, so add -2
            $string .= '-2';
        }
        // return
        return $string;
    }