src/Charcoal/Property/FileProperty.php
public function renderFileRenamePattern($from, $to, $args = null)
    {
        if (!is_string($from)) {
            throw new InvalidArgumentException(sprintf(
                'The target to rename must be a string, received %s',
                (is_object($from) ? get_class($from) : gettype($from))
            ));
        }

        if (!is_string($to)) {
            throw new InvalidArgumentException(sprintf(
                'The rename pattern must be a string, received %s',
                (is_object($to) ? get_class($to) : gettype($to))
            ));
        }

        $info = pathinfo($from);
        $args = $this->renamePatternArgs($info, $args);

        $to = strtr($to, $args);
        if (strpos($to, '{{') !== false) {
            preg_match_all('~\{\{\s*(.*?)\s*\}\}~i', $to, $matches);

            throw new UnexpectedValueException(sprintf(
                'The rename pattern failed. Leftover tokens found: %s',
                implode(', ', $matches[1])
            ));
        }

        $to = str_replace($info['basename'], $to, $from);

        return $to;
    }
public function renderFileRenamePattern($from, $to, $args = null)
    {
        if (!is_string($from)) {
            throw new InvalidArgumentException(sprintf(
                'The target to rename must be a string, received %s',
                (is_object($from) ? get_class($from) : gettype($from))
            ));
        }

        if (!is_string($to)) {
            throw new InvalidArgumentException(sprintf(
                'The rename pattern must be a string, received %s',
                (is_object($to) ? get_class($to) : gettype($to))
            ));
        }

        $info = pathinfo($from);
        $args = $this->renamePatternArgs($info, $args);

        $to = strtr($to, $args);
        if (strpos($to, '{{') !== false) {
            preg_match_all('~\{\{\s*(.*?)\s*\}\}~i', $to, $matches);

            throw new UnexpectedValueException(sprintf(
                'The rename pattern failed. Leftover tokens found: %s',
                implode(', ', $matches[1])
            ));
        }

        $to = str_replace($info['basename'], $to, $from);

        return $to;
    }
public function renderFileRenamePattern ( $ from , $ to , $ args = null ) { if ( ! is_string ( $ from ) ) { throw new InvalidArgumentException ( sprintf ( 'The target to rename must be a string, received %s' , ( is_object ( $ from ) ? get_class ( $ from ) : gettype ( $ from ) ) ) ) ; } if ( ! is_string ( $ to ) ) { throw new InvalidArgumentException ( sprintf ( 'The rename pattern must be a string, received %s' , ( is_object ( $ to ) ? get_class ( $ to ) : gettype ( $ to ) ) ) ) ; } $ info = pathinfo ( $ from ) ; $ args = $ this -> renamePatternArgs ( $ info , $ args ) ; $ to = strtr ( $ to , $ args ) ; if ( strpos ( $ to , '{{' ) !== false ) { preg_match_all ( '~\{\{\s*(.*?)\s*\}\}~i' , $ to , $ matches ) ; throw new UnexpectedValueException ( sprintf ( 'The rename pattern failed. Leftover tokens found: %s' , implode ( ', ' , $ matches [ 1 ] ) ) ) ; } $ to = str_replace ( $ info [ 'basename' ] , $ to , $ from ) ; return $ to ; }
Render the given file to the given pattern.

This method does not rename the given path.

@uses   strtr() To replace tokens in the form `{{foobar}}`.
@param  string         $from The string being rendered.
@param  string         $to   The pattern replacing $from.
@param  array|callable $args Extra rename tokens.
@throws InvalidArgumentException If the given arguments are invalid.
@throws UnexpectedValueException If the renaming failed.
@return string Returns the rendered target.
Render the given file to the given pattern .