<?php
namespace Claromentis\Core\ORM\Behaviors;

$GLOBALS["__65da1b1ec2d6653e8a0" . "ab7848e536215"] = (@$GLOBALS["__65da1b1ec2d6653e8a0ab7848e53" . "6215"] ?: array()) + array("_d5aab080ef90d" . "0e0aeec9b29c03" . "836f2" => base64_decode("TWV0YWRhdGEgbXVzdCBiZSBhbiBhcnJheSBvZiBtZXRhZGF0YSB2YWx1ZXMgb3IgY" . "W4gaW5zdGFuY2Ugb2Yg"), "_b255eba" . "fd5b8bb4" . "5110cd2d" . "b0604fa4" . "4" => base64_decode("bWV0YWRhd" . "GE="), "_7f628626dd1d55c" . "71b1fc0932ffd1d2" . "c" => base64_decode("aXNfYXJyYX" . "k="), "_c006f837e2824506391e30" . "88e0b02cea" => base64_decode("IG9" . "yIA" . "=="));
use Analogue\ORM\EntityCollection;
use Analogue\ORM\Mappable;
use Illuminate\Support\Collection;
use ProxyManager\Proxy\ProxyInterface;
use Claromentis\Core\ORM\Entity\Metadata as MetadataEntity;






















trait Metadata
{
    
    
    
    
    
    
    protected $metadata;
    
    
    
    
    
    
    public abstract function getMetadataAggregation() : int;
    
    
    
    
    
    
    public function getMetadataObjectId() : int
    {
        return $this->id;
    }
    
    
    
    
    
    
    public function getMetadataSetId() : int
    {
        return 0;
    }
    
    
    
    
    
    
    
    
    
    
    public function getMetadataAttribute($elements) : MetadataEntity
    {
        
        
        if (!$this->metadata) {
            $aggregation = $this->getMetadataAggregation();
            $object_id = $this->getMetadataObjectId();
            $set_id = $this->getMetadataSetId();
            $this->metadata = new MetadataEntity($this, $aggregation, $object_id, $set_id);
            $this->metadata->elements = $elements ?: new EntityCollection();
        }
        return $this->metadata;
    }
    
    
    
    
    
    
    
    
    
    public function setMetadataAttribute($metadata)
    {
        if (!$metadata instanceof MetadataEntity && !$metadata instanceof Collection && !$GLOBALS["__65da1b1ec2d6" . "653e8a0ab7848e" . "536215"]["_7f628626dd1d55c71b1fc0932ffd1d" . "2c"]($metadata)) {
            throw new \InvalidArgumentException($GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"]["_d5aab080ef90d0e" . "0aeec9b29c03836f" . "2"] . Collection::class . $GLOBALS["__65da1b1ec2d6653e8a0ab784" . "8e536215"]["_c006f837e282450" . "6391e3088e0b02ce" . "a"] . MetadataEntity::class);
        }
        
        
        if ($metadata instanceof MetadataEntity) {
            $this->attributes[$GLOBALS["__65da1b1ec2d6653e8a0ab7848e" . "536215"]["_b255ebafd5b8bb4" . "5110cd2db0604fa4" . "4"]] = $metadata->getElements()->flatten()->filter();
        }
        if ($metadata instanceof Collection) {
            $this->attributes[$GLOBALS["__65da1b1ec2d6653e8a0ab784" . "8e536215"]["_b255ebafd5b8bb451" . "10cd2db0604fa44"]] = $metadata->flatten()->filter();
        }
        
        
        if ($GLOBALS["__65da1b1ec2d6653e8a0ab784" . "8e536215"]["_7f628626dd1d55c71b1fc0932ffd1d2" . "c"]($metadata)) {
            $metadataEntity = $this->getMetadataAttribute(null);
            $metadataEntity->setValues($metadata);
        }
    }
}