<?php

namespace App\JsonLd;

use JsonLd\ContextTypes\AbstractContext;
use JsonLd\ContextTypes\ImageObject;

class SoftwareApplication extends AbstractContext
{
    /**
     * Property structure
     *
     * @var array
     */
    protected $structure = [
        'name' => null,
        'description' => null,
        'url' => null,
        'applicationCategory' => null,
        'screenshot' => ImageObject::class,
    ];

    /**
     * Set the name attribute.
     *
     * @param  string  $value
     * @return string
     */
    protected function setNameAttribute($value)
    {
        return (string) $value;
    }

    /**
     * Set the description attribute.
     *
     * @param  string  $value
     * @return string
     */
    protected function setDescriptionAttribute($value)
    {
        return $this->truncate($value, 260);
    }

    /**
     * Set the url attribute.
     *
     * @param  string  $value
     * @return string
     */
    protected function setUrlAttribute($value)
    {
        return (string) $value;
    }

    /**
     * Set the application category attribute.
     *
     * @param  string  $value
     * @return string
     */
    protected function setApplicationCategoryAttribute($value)
    {
        return (string) $value;
    }

    /**
     * Set the screenshot attribute.
     *
     * @param  ImageObject|array  $value
     * @return ImageObject
     */
    protected function setScreenshotAttribute($value)
    {
        return new ImageObject([$value]);
    }
}
