public function apply($elem)
    {
        if ($this->outer->from === null || $this->outer->to === null) {
            throw new BuildException(
                "Both 'from' and 'to' must be set "
                . "in a map entry"
            );
        }

        // If we're on windows, then do the comparison ignoring case
        $cmpElem = $this->outer->onWindows ? strtolower($elem) : $elem;
        $cmpFrom = $this->outer->onWindows ? strtolower(
            str_replace('/', '\\', $this->outer->from)
        ) : $this->outer->from;

        // If the element starts with the configured prefix, then
        // convert the prefix to the configured 'to' value.

        if (StringHelper::startsWith($cmpFrom, $cmpElem)) {
            $len = strlen($this->outer->from);

            if ($len >= strlen($elem)) {
                $elem = $this->outer->to;
            } else {
                $elem = $this->outer->to . StringHelper::substring($elem, $len);
            }
        }

        return $elem;
    }