Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
3 / 3
CRAP
100.00% covered (success)
100.00%
36 / 36
GeneralTransformer
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
3 / 3
11
100.00% covered (success)
100.00%
36 / 36
 transform( OrderInterface $order, ExtractorResult $extractorResult )
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
6 / 6
 supports($propertyName)
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
3 / 3
 copyValue( OrderInterface $order, $propertyName, $value )
100.00% covered (success)
100.00%
1 / 1
9
100.00% covered (success)
100.00%
27 / 27
<?php
/**
 * @author Krzysztof Gzocha <krzysztof.gzocha@xsolve.pl>
 */
namespace Team3\PayU\Order\Transformer\UserOrder\Strategy;
use Team3\PayU\Order\Model\OrderInterface;
use Team3\PayU\Order\Transformer\UserOrder\TransformerProperties;
use Team3\PayU\Order\Transformer\UserOrder\TransformerPropertiesRegExp;
use Team3\PayU\PropertyExtractor\ExtractorResult;
class GeneralTransformer implements UserOrderTransformerStrategyInterface
{
    /**
     * @inheritdoc
     */
    public function transform(
        OrderInterface $order,
        ExtractorResult $extractorResult
    ) {
        $this->copyValue(
            $order,
            $extractorResult->getPropertyName(),
            $extractorResult->getValue()
        );
    }
    /**
     * Will return true if property name starts with "general."
     *
     * @inheritdoc
     */
    public function supports($propertyName)
    {
        return 1 === preg_match(
            TransformerPropertiesRegExp::GENERAL_REGEXP,
            $propertyName
        );
    }
    /**
     * @param OrderInterface $order
     * @param                $propertyName
     * @param                $value
     */
    private function copyValue(
        OrderInterface $order,
        $propertyName,
        $value
    ) {
        switch ($propertyName) {
            case TransformerProperties::GENERAL_CUSTOMER_IP:
                $order->setCustomerIp($value);
                break;
            case TransformerProperties::GENERAL_ORDER_ID:
                $order->setOrderId($value);
                break;
            case TransformerProperties::GENERAL_ADDITIONAL_DESC:
                $order->setAdditionalDescription($value);
                break;
            case TransformerProperties::GENERAL_CURRENCY_CODE:
                $order->setCurrencyCode($value);
                break;
            case TransformerProperties::GENERAL_DESCRIPTION:
                $order->setDescription($value);
                break;
            case TransformerProperties::GENERAL_MERCHANT_POS_ID:
                $order->setMerchantPosId($value);
                break;
            case TransformerProperties::GENERAL_SIGNATURE:
                $order->setSignature($value);
                break;
            case TransformerProperties::GENERAL_TOTAL_AMOUNT:
                $order->setTotalAmount($value);
                break;
            default:
        }
    }
}