<commit_before><?php
/**
 * BEAR.Resource
 *
 * @package BEAR.Resource
 * @license http://opensource.org/licenses/bsd-license.php BSD
 */
namespace BEAR\Resource;

/**
 * Abstract resource object
 *
 * @package BEAR.Resource
 * @author  <NAME> <<EMAIL>>
 */
abstract class AbstractObject implements Object, \ArrayAccess, \Countable, \IteratorAggregate
{
    use ArrayAccess;

    /**
     * URI
     *
     * @var string
     */
    public $uri = '';

    /**
     * Resource code
     *
     * @var int
     */
    public $code = 200;

    /**
     * Resource header
     *
     * @var array
     */
    public $headers = [];

    /**
     * Resource body
     *
     * @var mixed
     */
    public $body;

    /**
     * Resource representation
     *
     * @var string
     */
    public $representation;

    /**
     * Renderer
     *
     * @var string
     */
    private $renderer = '';

    /**
     * Constructor
     */
    public function __construct()
    {
        $this->body = new \ArrayObject;
    }

    public function __wakeup()
    {
    }

    /**
     * Set renderer
     *
     * @param Stringer $stringer
     *
     * @Inject(optional = true)
     */
    public function setRederer(Renderable $renderer)
    {
        $this->renderer = $renderer;
    }

    /**
     * Transfer
     *
     * Transfer representational state
     */
    public function send()
    {
        $this->sender->send($this);
    }

    /**
     * Return representational string
     *
     * Return object hash if representation renderer is not set.
     *
     * @return string
     */
    public function __toString()
    {
        if (! $this->renderer) {
            return '';
        }
        if ($this->renderer) {
            if (is_null($this->representation)) {
                try {
                    $this->representation = $this->renderer->render($this);
                } catch (\Exception $e) {
                    error_log((string)$e);
                    return '';
                }
                $string = $this->representation;
            } else {
                $string = get_class($this) . '#' . md5(serialize($this->body));
            }
            return $string;
        }
    }
}<commit_msg>Empty string representation if exception.<commit_after><?php
/**
 * BEAR.Resource
 *
 * @package BEAR.Resource
 * @license http://opensource.org/licenses/bsd-license.php BSD
 */
namespace BEAR\Resource;

/**
 * Abstract resource object
 *
 * @package BEAR.Resource
 * @author  <NAME> <<EMAIL>>
 */
abstract class AbstractObject implements Object, \ArrayAccess, \Countable, \IteratorAggregate
{
    use ArrayAccess;

    /**
     * URI
     *
     * @var string
     */
    public $uri = '';

    /**
     * Resource code
     *
     * @var int
     */
    public $code = 200;

    /**
     * Resource header
     *
     * @var array
     */
    public $headers = [];

    /**
     * Resource body
     *
     * @var mixed
     */
    public $body;

    /**
     * Resource representation
     *
     * @var string
     */
    public $representation;

    /**
     * Renderer
     *
     * @var string
     */
    private $renderer = '';

    /**
     * Constructor
     */
    public function __construct()
    {
        $this->body = new \ArrayObject;
    }

    public function __wakeup()
    {
    }

    /**
     * Set renderer
     *
     * @param Stringer $stringer
     *
     * @Inject(optional = true)
     */
    public function setRederer(Renderable $renderer)
    {
        $this->renderer = $renderer;
    }

    /**
     * Transfer
     *
     * Transfer representational state
     */
    public function send()
    {
        $this->sender->send($this);
    }

    /**
     * Return representational string
     *
     * Return object hash if representation renderer is not set.
     *
     * @return string
     */
    public function __toString()
    {
        if (! $this->renderer) {
            return '';
        }
        if ($this->renderer) {
            if (is_null($this->representation)) {
                try {
                    $this->representation = $this->renderer->render($this);
                } catch (\Exception $e) {
                    $this->representation = '';
                    error_log((string)$e);
                }
                $string = $this->representation;
            } else {
                $string = get_class($this) . '#' . md5(serialize($this->body));
            }
            return $string;
        }
    }
}
{'fraction_non_alphanumeric': 0.13429522752497225, 'fraction_numerical': 0.0017758046614872365, 'mean_word_length': 1.4622950819672131, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 34, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5091354', 'n_tokens_mistral': 1318, 'n_tokens_neox': 1283, 'n_words': 270}