Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
100.00% |
1 / 1 |
|
100.00% |
8 / 8 |
CRAP | |
100.00% |
12 / 12 |
| Product | |
100.00% |
1 / 1 |
|
100.00% |
8 / 8 |
8 | |
100.00% |
12 / 12 |
| getName() | |
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
|||
| setName($name) | |
100.00% |
1 / 1 |
1 | |
100.00% |
2 / 2 |
|||
| getQuantity() | |
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
|||
| setQuantity($quantity) | |
100.00% |
1 / 1 |
1 | |
100.00% |
2 / 2 |
|||
| getUnitPrice() | |
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
|||
| getUnitPriceForSerialization() | |
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
|||
| setUnitPrice(MoneyInterface $unitPrice) | |
100.00% |
1 / 1 |
1 | |
100.00% |
2 / 2 |
|||
| setUnitPriceFromDeserialization($price) | |
100.00% |
1 / 1 |
1 | |
100.00% |
2 / 2 |
|||
| <?php | |
| /** | |
| * @author Krzysztof Gzocha <krzysztof.gzocha@xsolve.pl> | |
| */ | |
| namespace Team3\PayU\Order\Model\Products; | |
| use Team3\PayU\Order\Model\IsFilledTrait; | |
| use Team3\PayU\Order\Model\Money\Money; | |
| use Team3\PayU\Order\Model\Money\MoneyInterface; | |
| use JMS\Serializer\Annotation as JMS; | |
| use Symfony\Component\Validator\Constraints as Assert; | |
| /** | |
| * Class Product | |
| * @package Team3\PayU\Order\Model\Products | |
| * @JMS\AccessorOrder("alphabetical") | |
| */ | |
| class Product implements ProductInterface | |
| { | |
| use IsFilledTrait; | |
| /** | |
| * @var string | |
| * @JMS\Type("string") | |
| * @Assert\NotBlank() | |
| */ | |
| protected $name; | |
| /** | |
| * @var MoneyInterface | |
| * @JMS\SerializedName("unitPrice") | |
| * @JMS\Accessor( | |
| * getter="getUnitPriceForSerialization", | |
| * setter="setUnitPriceFromDeserialization" | |
| * ) | |
| * @JMS\Type("integer") | |
| * @Assert\NotBlank() | |
| * @Assert\Valid() | |
| * @Assert\Type(type="object") | |
| */ | |
| protected $unitPrice; | |
| /** | |
| * @var int | |
| * @JMS\Type("integer") | |
| * @Assert\NotBlank() | |
| * @Assert\Type(type="integer") | |
| * @Assert\GreaterThan(0) | |
| */ | |
| protected $quantity; | |
| /** | |
| * @return string | |
| */ | |
| public function getName() | |
| { | |
| return $this->name; | |
| } | |
| /** | |
| * @param string $name | |
| * | |
| * @return Product | |
| */ | |
| public function setName($name) | |
| { | |
| $this->name = $name; | |
| return $this; | |
| } | |
| /** | |
| * @return int | |
| */ | |
| public function getQuantity() | |
| { | |
| return $this->quantity; | |
| } | |
| /** | |
| * @param int $quantity | |
| * | |
| * @return Product | |
| */ | |
| public function setQuantity($quantity) | |
| { | |
| $this->quantity = $quantity; | |
| return $this; | |
| } | |
| /** | |
| * @return MoneyInterface | |
| */ | |
| public function getUnitPrice() | |
| { | |
| return $this->unitPrice; | |
| } | |
| /** | |
| * @return int | |
| */ | |
| public function getUnitPriceForSerialization() | |
| { | |
| return $this->unitPrice->getValueWithoutSeparation(2); | |
| } | |
| /** | |
| * @param MoneyInterface $unitPrice | |
| * | |
| * @return Product | |
| */ | |
| public function setUnitPrice(MoneyInterface $unitPrice) | |
| { | |
| $this->unitPrice = $unitPrice; | |
| return $this; | |
| } | |
| /** | |
| * @param int $price | |
| * | |
| * @return $this | |
| */ | |
| public function setUnitPriceFromDeserialization($price) | |
| { | |
| $this->unitPrice = new Money($price / 100); | |
| return $this; | |
| } | |
| } |