Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
BaseMeasureRatio.php
1<?php
2
4
7
16abstract class BaseMeasureRatio extends BaseEntity
17{
18 public function __construct(MeasureRatioRepositoryContract $measureRatioRepository)
19 {
20 parent::__construct($measureRatioRepository);
21 }
22
23 public function setRatio(float $ratio): self
24 {
25 $this->setField('RATIO', $ratio);
26
27 return $this;
28 }
29
30 public function getRatio(): string
31 {
32 return $this->getField('RATIO');
33 }
34
35 public function isDefault(): bool
36 {
37 return $this->getField('IS_DEFAULT') === 'Y';
38 }
39
40 public function setDefault(bool $state = true): self
41 {
42 $this->setField('IS_DEFAULT', $state ? 'Y' : 'N');
43
44 return $this;
45 }
46
47 public function setProductId(int $productId): self
48 {
49 $this->setField('PRODUCT_ID', $productId);
50
51 return $this;
52 }
53
54 public function getProductId(): int
55 {
56 return (int)$this->getField('PRODUCT_ID');
57 }
58
59 protected function getFieldsMap(): array
60 {
61 return [
62 'ID' => MapTypeCaster::NULLABLE_INT,
63 'PRODUCT_ID' => MapTypeCaster::INT,
64 'RATIO' => MapTypeCaster::FLOAT,
65 'IS_DEFAULT' => MapTypeCaster::Y_OR_N,
66 ];
67 }
68}
setField(string $name, $value)
__construct(MeasureRatioRepositoryContract $measureRatioRepository)