<?php
namespace ProVM\KI;

use ProVM\Common\Implementation\Model;

class Direccion extends Model {
  public function map($data): Model {
    $this->calle = $data->calle;
    $this->comuna = $data->comuna ?? '';
    $this->ciudad = $data->ciudad ?? '';
    return $this;
  }
  public function __toString(): string {
    $str = [$this->calle];
    if ($this->comuna != '') {
      $str []= $this->comuna;
    }
    if ($this->ciudad != '') {
      $str []= $this->ciudad;
    }
    return implode(', ', $str);
  }
  public function jsonSerialize() {
    return [
      'calle' => $this->calle,
      'comuna' => $this->comuna,
      'ciudad' => $this->ciudad
    ];
  }
}
