<?
namespace cms;
class Layout implements \ArrayAccess
{
  public function __construct( int $layout_id )
  {
    global $mdb;

    $result = $mdb -> get( 'pp_layouts', '*', [ 'id' => $layout_id ] );
    if ( \S::is_array_fix( $result ) ) foreach ( $result as $key => $val )
      $this -> $key = $val;
  }

  public function __get( $variable )
  {
    if ( array_key_exists( $variable, $this -> data ) )
      return $this -> $variable;
  }

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

  public function offsetExists( $offset )
  {
    return isset( $this -> $offset );
  }

  public function offsetGet( $offset )
  {
    return $this -> $offset;
  }

  public function offsetSet( $offset, $value )
  {
    $this -> $offset = $value;
  }

  public function offsetUnset( $offset )
  {
    unset( $this -> $offset );
  }
}