{@inheritDoc}
@throws Exceptions\TooManyLoopsException
199383
public function escape($data, $safeCount = 0)
    {
        $safeCount++;
        if ($this->safeLoopCount < $safeCount) {
            throw new Exceptions\TooManyLoopsException("Too many loops '{$safeCount}'");
        }
        if (\is_array($data)) {
            if (\count($data) === 0) {
                $data = '';
            } else {
                foreach ($data as $i => $v) {
                    $data[$i] = $this->escape($v, $safeCount);
                }
            }
        } else {
            $data = $this->getDriver()->escape($data);
        }

        return $data;
    }
477676
private function load(iterable $data, $item, $key, bool $flush, int &$flushCounter, int &$totalCounter): void
    {
        try {
            ($this->load)($data, $key, $this);
            $this->eventDispatcher->dispatch(new ItemEvent(EtlEvents::LOAD, $item, $key, $this));
        } catch (\Throwable $e) {
            /** @var ItemExceptionEvent $event */
            $event = $this->eventDispatcher->dispatch(new ItemExceptionEvent(EtlEvents::LOAD_EXCEPTION, $item, $key, $this, $e));
            if ($event->shouldThrowException()) {
                throw $e;
            }
            $flushCounter--;
            $totalCounter--;
        }

        if (true === $flush) {
            $this->flush($flushCounter, true);
        }
    }
322020
private function executeUpserts(ClassMetadata $class, array $documents)
    {
        $persister = $this->getDocumentPersister($class->name);

        foreach ($documents as $oid => $document) {
            try {
                $persister->upsert($document);
                $persister->handleCollections($document);

                unset($this->documentUpserts[$oid]);
            } catch (\Aws\DynamoDb\Exception\DynamoDbException $e) {
                unset($this->documentUpserts[$oid]);

                throw $e;
            }

            $this->lifecycleEventManager->postPersist($class, $document);
        }
    }
672650
public function tryAnException()
    {
        try {
            $iterator = $this->endpoint->listRecords('foobardoesnotexist');
            $iterator->current();
        } catch (\Phpoaipmh\Exception\OaipmhException $e) {
            throw $e;
        }
    }
285500
public function spin($lambda, $wait = 15,$errorCallback = null)
   {
       $time = time();
       $stopTime = $time + $wait;
       while (time() < $stopTime)
       {
           try {
               if ($lambda($this)) {
                   return;
               }
           } catch (\Exception $e) {
               // do nothing
           }

           usleep(250000);
       }
       if($errorCallback !== null){
           $errorCallback($this);
       }
       throw new \Exception("Spin function timed out after {$wait} seconds");
   }
673189
public function sync(MountManager $mountManager, string $from, string $to, array $config = []): void
    {
        if (!$mountManager->has($from)) {
            throw new Exception\RuntimeException("Path \"$from\" does not exist.");
        }

        $metadata = $mountManager->getMetadata($from);
        $fileExists = $mountManager->has($to);
        if ($metadata && 'file' == $metadata['type']) {
            $sourceIsNewer = false;
            if ($fileExists) {
                $toMetadata = $mountManager->getMetadata($to);
                $sourceIsNewer = $toMetadata && $metadata['timestamp'] > $toMetadata['timestamp'];
            }

            if (!$fileExists || $sourceIsNewer) {
                $this->putFile($mountManager, $from, $to, $config);
            }
        } else {
            $this->syncDirectory($mountManager, $from, $to, $config);
        }

    }
216232
public function handle($files)
    {
        if (is_array($files)) {
            return $this->handleMultipleFiles($files);
        }
        if (is_object($files)) {
            return $this->handleSingleFile($files);
        }
        throw new \Exception("Dados inválidos para upload");
    }
604173
public function rewind()
    {
        if ($this->_index < 0) {
            $this->_row = $this->_statement->fetch();
            $this->_index = 0;
        } else {
            throw new \LogicException('DataReader cannot rewind. It is a forward-only reader.');
        }
    }
1318133
public function load($objectID) {
        $object = $this->read($objectID);

        if (count($object) === 0) {
            throw new RuntimeException('Object not found');
        }

        if (!array_key_exists('objecttype', $object)) {
            throw new RuntimeException(sprintf(
                'Object %s has no type',
                $objectID
            ));
        }

        $cmdbObjectTypeCategories = new CMDBObjectTypeCategories($this->api);

        $object += $cmdbObjectTypeCategories->readByID(
            $object['objecttype']
        );

        $cmdbCategory = new CMDBCategory($this->api);

        $categoryTypes = ['catg', 'cats', 'custom'];

        $cmdbCategoryInfo = new CMDBCategoryInfo($this->api);
        $blacklistedCategoryConstants = $cmdbCategoryInfo->getVirtualCategoryConstants();

        foreach ($categoryTypes as $categoryType) {
            if (!array_key_exists($categoryType, $object)) {
                continue;
            }

            $categoryConstants = [];

            for ($i = 0; $i < count($object[$categoryType]); $i++) {
                if (!array_key_exists('const', $object[$categoryType][$i])) {
                    throw new RuntimeException(
                        'Information about categories is broken. Constant is missing.'
                    );
                }

                $categoryConstant = $object[$categoryType][$i]['const'];

                if (in_array($categoryConstant, $blacklistedCategoryConstants)) {
                    continue;
                }

                $object[$categoryType][$i]['entries'] = [];

                $categoryConstants[] = $categoryConstant;
            }

            $categoryEntries = $cmdbCategory->batchRead([$objectID], $categoryConstants);

            for ($i = 0; $i < count($categoryConstants); $i++) {
                $index = -1;
                $entries = [];

                foreach ($object[$categoryType] as $key => $category) {
                    if ($category['const'] === $categoryConstants[$i]) {
                        $index = $key;
                        $entries = $categoryEntries[$i];
                        break;
                    }
                }

                $object[$categoryType][$index]['entries'] = $entries;
            }
        }

        return $object;
    }
162821
protected function loadHasOne(
        Collection $relations,
        HasOneOrMany $relationClass,
        Model $relationModel,
        Model $model,
        Builder $query,
        $direction
    ) {
        $this->loadHasOneOrMany($relations, $relationClass, $relationModel, $model, $query, $direction);
    }
873761
public function prepareForSerialization()
    {
        if ($this->action['uses'] instanceof Closure) {
            throw new LogicException("Unable to prepare route [{$this->uri}] for serialization. Uses Closure.");
        }

        $this->compileRoute();

        unset($this->router, $this->container);
    }
267880
public function setFields($fields): self
    {
        if (!is_iterable($fields)) {
            throw new Exception(sprintf('%s() expects argument passed to be iterable, %s given', __METHOD__, gettype($fields)));
        }

        $this->fields = [];
        foreach ($fields as $field) {
            $this->addField(...$field);
        }

        return $this;
    }
61139
public function setRefid(Reference $r)
    {
        if ($this->type !== null || $this->from !== null || $this->to !== null) {
            throw DataType::tooManyAttributes();
        }
        parent::setRefid($r);
    }
1010235
public function addDocuments(
        $documents,
        $allowDups = false,
        $overwritePending = true,
        $overwriteCommitted = true,
        $commitWithin = 0
    ) {
        $overwriteVal = $allowDups ? 'false' : 'true';
        $commitWithin = (int) $commitWithin;
        $commitWithinString = $commitWithin > 0 ? " commitWithin=\"{$commitWithin}\"" : '';

        $rawPost = "<add overwrite=\"{$overwriteVal}\"{$commitWithinString}>";
        foreach ($documents as $document) {
            if ($document instanceof \Apache_Solr_Document) {
                $rawPost .= $this->_documentToXmlFragment($document);
            }
        }
        $rawPost .= '</add>';

        return $this->add($rawPost);
    }
687012
public function unserialize($serialized) : void
    {
        $doc = DOMDocumentFactory::fromString(unserialize($serialized));
        $this->element = $doc->documentElement;
    }
636478
public function readExtendedMetadata($meta, array &$config)
    {
        $class = $this->getMetaReflectionClass($meta);
        /* @var $relationOverrides RelationOverrides */
        if (!($relationOverrides = $this->reader->getClassAnnotation($class, RelationOverrides::class))) {
            return;
        }

        $config['relationOverrides'] = [];

        /* @var $relationOverride RelationOverride */
        foreach ($relationOverrides->value as $relationOverride) {
            $fieldName = $relationOverride->name;

            if (!$class->hasProperty($fieldName)) {
                throw new MappingException(sprintf(
                    "Property %s doesn't exist",
                    $meta->getName() . '::$' . $fieldName
                ));
            }

            if ($meta->isMappedSuperclass && !$class->getProperty($fieldName)->isPrivate() ||
                $meta->isInheritedField($fieldName) ||
                $meta->hasField($fieldName))
            {
                continue;
            }

            $config['relationOverrides'][] = $relationOverride;
        }
    }
322704
protected function loadBelongsTo(
        Collection $relations,
        BelongsTo $relationClass,
        Model $relationModel,
        Model $model,
        Builder $query,
        $direction
    ) {
        $foreignKey = $relationClass->getOwnerKey();
        $ownerKey = $relationClass->getForeignKey();

        $ownerTable = $model->getTable();
        $foreignTable = $relationModel->getTable();

        $ownerColumn = implode('.', [$ownerTable, $ownerKey]);
        $foreignColumn = implode('.', [$foreignTable, $foreignKey]);
        $sortedColumnRaw = '`'.$foreignTable.'`.`'.$relations->last().'`';
        $sortedColumnAlias = implode('__', [$foreignTable, $relations->last()]);

        $this->sortedColumnAlias = $sortedColumnAlias;

        $query
            ->addSelect([DB::raw($sortedColumnRaw.' AS '.$sortedColumnAlias)])
            ->join($foreignTable, $foreignColumn, '=', $ownerColumn, 'left');
    }