![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/medad.corals.io/vendor/kreait/firebase-php/src/Firebase/RemoteConfig/ |
<?php declare(strict_types=1); namespace Kreait\Firebase\RemoteConfig; use JsonSerializable; /** * @phpstan-type RemoteConfigConditionShape array{ * name: non-empty-string, * expression: non-empty-string, * tagColor?: ?non-empty-string * } */ class Condition implements JsonSerializable { /** * @var non-empty-string */ private string $name; /** * @var non-empty-string */ private string $expression; private ?TagColor $tagColor; /** * @param non-empty-string $name * @param non-empty-string $expression */ private function __construct(string $name, string $expression, ?TagColor $tagColor = null) { $this->name = $name; $this->expression = $expression; $this->tagColor = $tagColor; } /** * @param RemoteConfigConditionShape $data */ public static function fromArray(array $data): self { return new self( $data['name'], $data['expression'], isset($data['tagColor']) ? new TagColor($data['tagColor']) : null, ); } /** * @param non-empty-string $name */ public static function named(string $name): self { return new self($name, 'false', null); } /** * @return non-empty-string */ public function name(): string { return $this->name; } /** * @return non-empty-string */ public function expression(): string { return $this->expression; } /** * @param non-empty-string $expression */ public function withExpression(string $expression): self { $condition = clone $this; $condition->expression = $expression; return $condition; } /** * @param TagColor|non-empty-string $tagColor */ public function withTagColor($tagColor): self { $tagColor = $tagColor instanceof TagColor ? $tagColor : new TagColor($tagColor); $condition = clone $this; $condition->tagColor = $tagColor; return $condition; } /** * @return RemoteConfigConditionShape */ public function toArray(): array { $array = [ 'name' => $this->name, 'expression' => $this->expression, ]; if ($this->tagColor !== null) { $array['tagColor'] = $this->tagColor->value(); } return $array; } /** * @return RemoteConfigConditionShape */ public function jsonSerialize(): array { return $this->toArray(); } }