BaguettePHP/mastodon-api

View on GitHub
src/Entity/Context.php

Summary

Maintainability
A
0 mins
Test Coverage
<?php

namespace Baguette\Mastodon\Entity;

/**
 * Context
 *
 * @author    USAMI Kenta <tadsan@zonu.me>
 * @copyright 2017 Baguette HQ
 * @license   https://www.gnu.org/licenses/gpl-3.0.html GPL-3.0
 * @see https://github.com/tootsuite/documentation/blob/master/Using-the-API/API.md#context
 * @property-read Status[] $ancestors   ancestors of the status in the conversation
 * @property-read Status[] $descendants descendants of the status in the conversation
 */
class Context extends Entity
{
    use \Teto\Object\TypedProperty;

    private static $property_types = [
        'ancestors'   => 'Baguette\Mastodon\Entity\Status[]',
        'descendants' => 'Baguette\Mastodon\Entity\Status[]',
    ];

    public function __construct(array $properties)
    {
        $this->setProperties(mapValues($properties, [
            'ancestors'   => [Status::class],
            'descendants' => [Status::class],
        ]));
    }

    /**
     * Returns context data as array
     *
     * @return array
     */
    public function toArray()
    {
        return [
            'ancestors'   => toArrayValue($this->ancestors),
            'descendants' => toArrayValue($this->descendants),
        ];
    }
}