<?php

namespace Drupal\restaurant\Registry;

#[\AllowDynamicProperties]

class Registry
{
  /**
  * singleton $instance
  */
  private static $instance = null;

  /**
  * cannot instantiate instance using new or copy
  */
  private function __construct(){}
  private function __copy() {}

  /**
  * return a singleton object
  */
  public static function getInstance()
  {
    if (self::$instance == null) {
      self::$instance = new Registry();
    }
    return self::$instance;
  }

  public function __set($name, $value)
  {
    $this->{$name} = $value;
  }

  public function __get($name)
  {
    return $this->{$name};
  }
}
