Symbol.php 1005 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. namespace App\Yr\Forecast\Tabular\Time;
  3. class Symbol implements DiffInterface {
  4. private $number;
  5. private $numberEx;
  6. private $name;
  7. private $var;
  8. public function __construct(\SimpleXMLElement $xml) {
  9. $this->number = (int)$xml['number'];
  10. $this->numberEx = (int)$xml['numberEx'];
  11. $this->name = (string)$xml['name'];
  12. $this->var = (string)$xml['var'];
  13. }
  14. public function getNumber(): int {
  15. return $this->number;
  16. }
  17. public function getName(): string {
  18. return $this->name;
  19. }
  20. public function getVar(): string {
  21. return $this->var;
  22. }
  23. public function diff(DiffInterface $s): bool {
  24. if ($s instanceof Symbol)
  25. return $this->number != $s->getNumber();
  26. return false;
  27. }
  28. public function __toString(): string {
  29. return sprintf(
  30. "%s (%d, %d, %s)", $this->name,
  31. $this->number, $this->numberEx,
  32. $this->var
  33. );
  34. }
  35. }