<?php
namespace boru\ai\Asset;

class Attachment
{
    /** @var string|null */
    protected $id;

    /** @var string|null */
    protected $assetId;

    /** @var string|null */
    protected $kind;

    /** @var string|null */
    protected $detail;

    /** @var array */
    protected $metadata = array();

    public function id($value = null)
    {
        if ($value !== null) {
            $this->id = (string)$value;
            return $this;
        }
        return $this->id;
    }

    public function assetId($value = null)
    {
        if ($value !== null) {
            $this->assetId = (string)$value;
            return $this;
        }
        return $this->assetId;
    }

    public function kind($value = null)
    {
        if ($value !== null) {
            $this->kind = (string)$value;
            return $this;
        }
        return $this->kind;
    }

    public function detail($value = null)
    {
        if ($value !== null) {
            $this->detail = (string)$value;
            return $this;
        }
        return $this->detail;
    }

    public function metadata($key = null, $value = null)
    {
        if ($key === null) {
            return $this->metadata;
        }
        if (is_array($key)) {
            $this->metadata = $key;
            return $this;
        }
        if (func_num_args() > 1) {
            $this->metadata[$key] = $value;
            return $this;
        }
        return isset($this->metadata[$key]) ? $this->metadata[$key] : null;
    }

    public function toArray()
    {
        return array(
            'id' => $this->id(),
            'asset_id' => $this->assetId(),
            'kind' => $this->kind(),
            'detail' => $this->detail(),
            'metadata' => $this->metadata(),
        );
    }
}
