<?php

declare(strict_types=1);

namespace App\Traits;

/**
 * Class StringableIdEntity
 */
trait StringableIdEntity
{
    public function __toString(): string
    {
        return (string) $this->id;
    }
}

<?php

declare(strict_types=1);

namespace App\Traits;

trait StringableIdEntity
{
    public function __toString(): string
    {
        return isset($this->id) ? (string) $this->id : '';
    }
}

Handle objects without an ID yet
Handle objects without an ID yet

This is used when we build log data and in some cases the thing being
logged hasn't been created yet when we run this method so we need to
account for the id not yet being set.
