@param string $name
@param mixed  $data
@param string $destination
@param string $type

@return $this
551416
public function collect($name, $data, $destination = DataCollection::DESTINATION_PROFILER, $type = null)
    {
        $this->collectedKeys[] = $name;

        $dataCollection = new DataCollection($name, $data, $destination, $type);
        $this->data[$this->handleDataKey($name)] = $dataCollection;

        return $this;
    }
329997
public function get($type, $name)
    {
        return isset($this->clients[$type][$name]) ? $this->clients[$type][$name] : null;
    }
1046358
public function dataset(string $name, string $type, $data)
    {
        if ($data instanceof Collection) {
            $data = $data->toArray();
        }

        $dataset = new $this->dataset($name, $type, $data);

        array_push($this->datasets, $dataset);

        return $dataset;
    }
1263749
public function setDatafield(
        $name,
        $value,
        $type = 'string',
        $visibility = 'private'
    ) {
        $this->datafields[] = [
            'name' => $name,
            'value' => $value,
            'type' => $type,
            'visibility' => $visibility,
        ];

        return $this->datafields;
    }
1095850
protected function filterByTranslatableColumn($name, $type, $value)
    {
        $translation = $this->model->getTranslationModel();

        return $this->query->whereHas('translations', function ($query) use ($translation, $name, $type, $value) {
            return $query = $this->applyQueryElementByType($query, $translation->getTable(), $name, $type, $value);
        });
    }
461463
protected function _create(array $data, $type, $id = null, array $parameters = []) {
        return $this->__create($data, $this->index(), $type, $id, $parameters);
    }
520565
public function addReference(&$data, $type)
    {
        if (!$this->validate($data)) {
            return false;
        }

        $this->store[$type][] =& $data;
        return $data;
    }
373828
protected function write($name, $type, $source, $dependencies = array())
    {
        $types = array(
            'script' => 'script',
            'style'  => 'style',
            'js'     => 'script',
            'css'    => 'style'
        );

        if (array_key_exists($type, $types))
        {
            $type = $types[$type];

            $this->register($type, $name, $source, $dependencies, array());
        }

        return $this;
    }
533631
public function publish($type, $data)
    {
        $context = $this->_context;

        $packet = $context->header;

        $packet['type'] = $type;
        $packet['data'] = $data;

        /** @noinspection PhpUndefinedMethodInspection */
        /** @var \Redis $redis */
        $redis = $this->redis->getConnection();
        $r = $redis->publish($context->channel, json_encode($packet, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES));
        if ($r <= 0) {
            $this->_enabled = false;
            $this->_last_checked = microtime(true);
        }

        return $r;
    }
941700
public static function getInstance($type, $data = null)
    {
        $classname = self::classname($type);

        if (!isset(self::$__instances[$classname])) {
            $instance = new $classname();
            self::$__instances[$classname] = $instance;
        }

        $instance = clone self::$__instances[$classname];

        if ($data) {
            $instance->unserialize($data);
        }

        return $instance;
    }
1354009
public static function passive(string $name, Type $type): self
    {
        $self = new self($name, $type);
        $self->passive = true;

        return $self;
    }
1306732
public function bind($name, \Closure $type)
    {
        $name = '\\'.ltrim($name, '\\');
        $this->bindings[$name] = $type;
    }
344323
protected function recurse(&$data, $name = null, $type = null)
    {
        if (is_scalar($data)) {
            $this->makeScalarDefinition($data, $name, $type);

            return;
        }

        if ($this->maxDepth > 0 && $this->depth >= $this->maxDepth) {
            $this->out[] = "{$this->makeDefinition($type, null, $name)} " .
            "<em style='color:#999;'>... depth limit reached</em>";

            return;
        }

        if ($this->isCircularReference($data)) {
            $this->out[] = "{$this->makeDefinition($type, null, $name)} " .
            "<em style='color:#999;'>... cirular reference omitted</em>";

            return;
        }

        $this->registerObject($data);

        $iterable = $data;
        $lpad     = str_repeat($this->indentWith, $this->depth);

        if (is_array($iterable)) {
            $len  = count($iterable);
            $type = $type ? : 'array';

            $this->out[] = "{$this->makeDefinition($type, $len, $name)} {";

            $this->depth++;

            foreach ($iterable as $key => $val) {
                $valType = gettype($val);
                if ($val instanceof EntityInterface) {
                    $valType = $val->calledClassName();
                }
                elseif (is_object($val)) {
                    $valType = get_class($val);
                }

                $this->recurse($val, $key, $valType);
            }

            $this->depth--;

            $this->out[] = "{$lpad}}";
        }
        elseif (is_object($iterable)) {
            $len  = count($iterable);
            $type = $type ? : get_class($iterable);
            
            if (!($iterable instanceof Traversable)) {
                $iterable = get_object_vars($data);
            }

            $this->out[] = "{$this->makeDefinition($type, $len, $name)} {";

            $this->depth++;

            foreach ($iterable as $key => $val) {
                if (!isset($iterable->$key) && !isset($iterable[$key])) {
                    continue;
                }

                $valType = $iterable instanceof EntityInterface ? $iterable->typeof($key) : null;
                $this->recurse($val, $key, $valType);
            }

            $this->depth--;

            $this->out[] = "{$lpad}}";
        }

        $this->deregisterObject($data);
    }
723539
public function exchange($name, $type = ExchangeType::DIRECT, array $options = [])
    {
        return $this->exchanges[$name] = (new ExchangeBuilder($this, $name, $type))->options($options);
    }
451935
public function setCustomActions($name, $data = null)
    {
        $actions = is_array($name) ? $name : [$name => $data];

        foreach ($actions as $key => $value) {
            $this->customActions[$key] = $value;
        }

        return $this;
    }
1233450
public static function autoDelete(string $name, Type $type): self
    {
        $self = new self($name, $type);
        $self->autoDelete = true;
        $self->durable = false;

        return $self;
    }
959223
protected static function init(string $type = 'string', string $key = null, string $name = null)
    {
        $instance = new static();

        $instance->key($key);
        $instance->field['type'] = $type;

        if ($name) $instance->field['name'] = $name;

        return $instance;
    }