<?php
namespace Icing\Model\Entity;

use Cake\ORM\Entity;
use Cake\Utility\Inflector;

/**
 * Permission Entity
 *
 * @property string $id
 * @property string|null $role_id
 * @property string|null $permission_id
 */
class Permission extends Entity
{
    protected array $_accessible = [
        "*" => true,
        "id" => true
    ];

	protected function _getDescription($description = null) {
		if (empty($description) && !empty($this->id)) {
			if (str_contains($this->id, '.can')) {
				[$entity, $action] = pluginSplit($this->id);
				$description = Inflector::humanize(Inflector::underscore($action)) . ' '.$entity;
			} else {
				$description = Inflector::humanize($this->id);
			}
		}

		return $description;
	}
}
