ScriptFUSION\Porter\Porter::import PHP Method

import() public method

Imports data according to the design of the specified import specification.
public import ( ImportSpecification $specification ) : PorterRecords
$specification ScriptFUSION\Porter\Specification\ImportSpecification Import specification.
return ScriptFUSION\Porter\Collection\PorterRecords
    public function import(ImportSpecification $specification)
    {
        $specification = clone $specification;
        $records = $this->fetch($specification->getResource(), $specification->getCacheAdvice());
        if (!$records instanceof ProviderRecords) {
            $records = $this->createProviderRecords($records, $specification->getResource());
        }
        if ($specification->getFilter()) {
            $records = $this->filter($records, $specification->getFilter(), $specification->getContext());
        }
        if ($specification->getMapping()) {
            $records = $this->map($records, $specification->getMapping(), $specification->getContext());
        }
        return $this->createPorterRecords($records, $specification);
    }

Usage Example

Example #1
0
 public function testCacheUnavailable()
 {
     $this->setExpectedException(CacheUnavailableException::class);
     $this->porter->import($this->specification->setCacheAdvice(CacheAdvice::MUST_CACHE()));
 }