<?php
namespace Model;

class MetaData {
  private $data = ['type' => 'article', 'locale' => 'nl-nl'];

  public function set($prop, $val) {
    if($val) {
      $this->data[$prop] = $val;
    }
    return $this;
  }

  public function append($prop, $val) {
    if(array_key_exists($prop, $this->data)) {
      $this->data[$prop] .= $val;
    }
    return $this;
  }

  public function prepend($prop, $val) {
    if(array_key_exists($prop, $this->data)) {
      $this->data[$prop] = $val . $this->data[$prop];
    }
    return $this;
  }

  public function metaTags() {
    foreach($this->data as $prop => $val) {
      if($val) {
        echo "<meta property=\"og:$prop\" content=\"" . htmlentities($val) . "\" />\n";
      }
    }
  }
}
