Copied!
<?php
namespace Maknz\Slack;

class AttachmentField extends Payload implements Field
{
    /**
     * The required title field of the field.
     *
     * @var string
     */
    protected $title;

    /**
     * The required value of the field.
     *
     * @var string
     */
    protected $value;

    /**
     * Whether the value is short enough to fit side by side with
     * other values.
     *
     * @var bool
     */
    protected $short = false;

    /**
     * Internal attribute to property map.
     *
     * @var array
     */
    protected static $availableAttributes = [
        'title' => 'title',
        'value' => 'value',
        'short' => 'short',
    ];

    /**
     * Instantiate a new AttachmentField.
     *
     * @param array $attributes
     */
    public function __construct(array $attributes)
    {
        parent::__construct($attributes);
    }

    /**
     * Get the title of the field.
     *
     * @return string
     */
    public function getTitle()
    {
        return $this->title;
    }

    /**
     * Set the title of the field.
     *
     * @param string $title
     * @return $this
     */
    public function setTitle($title)
    {
        $this->title = $title;

        return $this;
    }

    /**
     * Get the value of the field.
     *
     * @return string
     */
    public function getValue()
    {
        return $this->value;
    }

    /**
     * Set the value of the field.
     *
     * @param string $value
     * @return $this
     */
    public function setValue($value)
    {
        $this->value = $value;

        return $this;
    }

    /**
     * Get whether this field is short enough for displaying
     * side-by-side with other fields.
     *
     * @return bool
     */
    public function getShort()
    {
        return $this->short;
    }

    /**
     * Set whether this field is short enough for displaying
     * side-by-side with other fields.
     *
     * @param string $value
     * @return $this
     */
    public function setShort($value)
    {
        $this->short = (bool) $value;

        return $this;
    }

    /**
     * Get the array representation of this attachment field.
     *
     * @return array
     */
    public function toArray()
    {
        return [
            'title' => $this->getTitle(),
            'value' => $this->getValue(),
            'short' => $this->getShort(),
        ];
    }
}
© 2026 Bruce Wells
Search Namespaces \ Classes
Configuration