|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace SplitIO\ThinSdk\Link\Protocol\V1; |
| 4 | + |
| 5 | +use SplitIO\ThinSdk\Foundation\Lang\Enforce; |
| 6 | + |
| 7 | +class SplitViewResult |
| 8 | +{ |
| 9 | + private /*string*/ $name; |
| 10 | + private /*string*/ $trafficType; |
| 11 | + private /*bool*/ $killed; |
| 12 | + private /*array*/ $treatments; |
| 13 | + private /*int*/ $changeNumber; |
| 14 | + private /*array*/ $configs; |
| 15 | + |
| 16 | + public function __construct(string $name, string $trafficType, bool $killed, array $treatments, int $changeNumber, ?array $configs) |
| 17 | + { |
| 18 | + $this->name = $name; |
| 19 | + $this->trafficType = $trafficType; |
| 20 | + $this->killed = $killed; |
| 21 | + $this->treatments = $treatments; |
| 22 | + $this->changeNumber = $changeNumber; |
| 23 | + $this->configs = $configs; |
| 24 | + } |
| 25 | + |
| 26 | + public function getName(): string |
| 27 | + { |
| 28 | + return $this->name; |
| 29 | + } |
| 30 | + |
| 31 | + public function getTrafficType(): string |
| 32 | + { |
| 33 | + return $this->trafficType; |
| 34 | + } |
| 35 | + |
| 36 | + public function getKilled(): bool |
| 37 | + { |
| 38 | + return $this->killed; |
| 39 | + } |
| 40 | + |
| 41 | + public function getTreatments(): array |
| 42 | + { |
| 43 | + return $this->treatments; |
| 44 | + } |
| 45 | + |
| 46 | + public function getChangeNumber(): int |
| 47 | + { |
| 48 | + return $this->changeNumber; |
| 49 | + } |
| 50 | + |
| 51 | + public function getConfigs(): ?array |
| 52 | + { |
| 53 | + return $this->configs; |
| 54 | + } |
| 55 | + public static function fromRaw(array $raw): SplitViewResult |
| 56 | + { |
| 57 | + return new SplitViewResult( |
| 58 | + Enforce::isString($raw['n']), |
| 59 | + Enforce::isString($raw['t']), |
| 60 | + Enforce::isBool($raw['k']), |
| 61 | + Enforce::isArray($raw['s']), |
| 62 | + Enforce::isInt($raw['c']), |
| 63 | + isset($raw['f']) ? Enforce::isArray($raw['f']) : null |
| 64 | + ); |
| 65 | + } |
| 66 | +} |
0 commit comments