<?php
/**
 * @package         Tassos Code Snippets
 * @version         1.0.1-RC2 Free
 *
 * @author          Tassos Marinos <info@tassos.gr>
 * @link            https://www.tassos.gr
 * @copyright       Copyright © 2026 Tassos Marinos All Rights Reserved
 * @license         GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
 */

namespace Tassos\CodeSnippets\Administrator\Snippet;

/**
 * JavaScript Snippet
 * 
 * Returns raw JavaScript code. The Location class handles
 * how to inject it (inline script or WebAsset).
 */
class JsSnippet extends Snippet
{
    /**
     * Display color used for the snippet (hex).
     *
     * @var string
     */
    protected $color = '#e5a329';

    /**
     * Run the snippet - returns raw JavaScript code
     *
     * @return string|null The JavaScript code or null if empty
     */
    public function run()
    {
        $code = $this->snippet->code ?? '';
        return empty(trim($code)) ? null : $code;
    }
}
