public function convert(Expression $expression, NumberSystem $targetSystem)
    {
        $parsingResult   = $expression->value();
        $expressionParts = $this->getExpressionParts($expression);

        foreach ($expressionParts as $part) {
            $parsedPart = $this->parseExpressionPart($part, $expression->getNumberSystem(), $targetSystem);

            if ($parsedPart !== $part) {
                $parsingResult = preg_replace('/'.$part.'/', $parsedPart, $parsingResult, 1);
            }
        }

        return new Expression($parsingResult, $targetSystem);
    }
public function convert(Expression $expression, NumberSystem $targetSystem)
    {
        $parsingResult   = $expression->value();
        $expressionParts = $this->getExpressionParts($expression);

        foreach ($expressionParts as $part) {
            $parsedPart = $this->parseExpressionPart($part, $expression->getNumberSystem(), $targetSystem);

            if ($parsedPart !== $part) {
                $parsingResult = preg_replace('/'.$part.'/', $parsedPart, $parsingResult, 1);
            }
        }

        return new Expression($parsingResult, $targetSystem);
    }
public function convert ( Expression $ expression , NumberSystem $ targetSystem ) { $ parsingResult = $ expression -> value ( ) ; $ expressionParts = $ this -> getExpressionParts ( $ expression ) ; foreach ( $ expressionParts as $ part ) { $ parsedPart = $ this -> parseExpressionPart ( $ part , $ expression -> getNumberSystem ( ) , $ targetSystem ) ; if ( $ parsedPart !== $ part ) { $ parsingResult = preg_replace ( '/' . $ part . '/' , $ parsedPart , $ parsingResult , 1 ) ; } } return new Expression ( $ parsingResult , $ targetSystem ) ; }
Convert expression from one NumberSystem to another

@param Expression   $expression
@param NumberSystem $targetSystem

@return Expression
Convert expression from one NumberSystem to another