@param string $imageSrc
@param bool $returnAll

@return LocallyStoredImage|null
972623
private function getLocallyStoredImage(string $imageSrc, bool $returnAll = false): ?LocallyStoredImage {
        $locallyStoredImages = ImageUtils::storeImagesToLocalFile([$imageSrc], $returnAll, $this->config());

        return array_shift($locallyStoredImages);
    }
699375
public function getResultRowObject($returnColumns = null, $omitColumns = null)
    {
        if (!$this->_resultRow) {
            return false;
        }

        $returnObject = new \stdClass();

        if (null !== $returnColumns) {

            $availableColumns = array_keys($this->_resultRow);
            foreach ((array) $returnColumns as $returnColumn) {
                if (in_array($returnColumn, $availableColumns)) {
                    $returnObject->{$returnColumn} = $this->_resultRow[$returnColumn];
                }
            }
            return $returnObject;
        } elseif (null !== $omitColumns) {

            $omitColumns = (array) $omitColumns;
            foreach ($this->_resultRow as $resultColumn => $resultValue) {
                if (!in_array($resultColumn, $omitColumns)) {
                    $returnObject->{$resultColumn} = $resultValue;
                }
            }
            return $returnObject;
        } else {

            foreach ($this->_resultRow as $resultColumn => $resultValue) {
                $returnObject->{$resultColumn} = $resultValue;
            }
            return $returnObject;
        }
    }
237777
private function formImagePath($imagePath, $imageSrc)
    {
        // Get old-way image path, remove full path to check file
        if (empty($imagePath)) {
            $path = $imageSrc;
        } else { // Use new CORRECT way
            $path = $imagePath . $imageSrc;
        }

        // form relative path to the image
        $dir = quotemeta(__SAMSON_BASE__);
        // TODO: WTF? Why do we need this, need comments!!!
        if (strpos($path, 'http://') === false) {
            if ($dir == '/') {
                return substr($path, 1);
            } else {
                return preg_replace('/' . addcslashes($dir, '/') . '/', '', $path);
            }
        }

        return $path;
    }
837138
public function getRawAggregate($returnType)
  {
    if ($returnType == DOC_TYPE_ARRAY) {
      $res = array();
      foreach ($this->_aggregate as $key => $value) {
        if ($value) {
          $tmp = CPS_Response::simpleXmlToArray($value);
          // multiple or one result - returned data format should be the same!
          if (isset($tmp['data'][0])) {
            // multiple results
            $res[$key] = $tmp['data'];
          } else {
            // one result
            $res[$key][] = $tmp['data'];
          }
          unset($tmp);
        } else {
          $res[$key] = array();
        }
      }
      return $res;
    } else if ($returnType == DOC_TYPE_STDCLASS) {
      $res = array();
      foreach ($this->_aggregate as $key => $value) {
        if ($value) {
          $tmp = CPS_Response::simpleXmlToStdClass($value);
          $res[$key] = $tmp->data;
          unset($tmp);
        } else {
          $res[$key] = new stdClass();
        }
      }
      return $res;
    }
    return $this->_aggregate;
  }
802120
public function query($selector, \DOMNode $context = null)
    {
        $this->enableRestoreInternal(true);

        if ($this->selector === null) {
            $this->selector = new Selector($this);
        }

        $nodes = $this->selector->get($selector, $context);

        $this->raise($this->exceptionlevel);

        $this->enableRestoreInternal(false);

        return $nodes;
    }
358464
protected function executeSubFields(ObjectType $returnType, array $fieldNodes, array $path, &$result)
    {
        $subFields            = [];
        $visitedFragmentNames = [];

        foreach ($fieldNodes as $fieldNode) {
            if (null !== $fieldNode->getSelectionSet()) {
                $subFields = $this->fieldCollector->collectFields(
                    $returnType,
                    $fieldNode->getSelectionSet(),
                    $subFields,
                    $visitedFragmentNames
                );
            }
        }

        if (!empty($subFields)) {
            return $this->executeFields($returnType, $result, $path, $subFields);
        }

        return $result;
    }
651214
public static function fromObject($data, $returnType = 'HpsCardinalMPIAuthenticateResponse')
    {
        $response = parent::fromObject($data, $returnType);
        $response->authenticateMethod = self::readDataKey($data, 'AuthenticateMethod');
        $response->authorizationCode = self::readDataKey($data, 'AuthorizationCode');
        $response->cardBin = self::readDataKey($data, 'CardBin');
        $response->cardEnrollmentMethod = self::readDataKey($data, 'CardEnrollmentMethod');
        $response->cardExpMonth = self::readDataKey($data, 'CardExpMonth');
        $response->cardExpYear = self::readDataKey($data, 'CardExpYear');
        $response->cardLastFour = self::readDataKey($data, 'CardLastFour');
        $response->cardType = self::readDataKey($data, 'CardType');
        $response->cardTypeName = self::readDataKey($data, 'CardTypeName');
        $response->longAccessToken = self::readDataKey($data, 'LongAccessToken');
        $response->mastercardAssignedId = self::readDataKey($data, 'MasterCardAssignedId');
        $response->nameOnCard = self::readDataKey($data, 'NameOnCard');
        $response->paResStatus = self::readDataKey($data, 'PaResStatus');
        $response->payPassWalletIndicator = self::readDataKey($data, 'PayPassWalletIndicator');
        $response->paymentProcessorOrderNumber = self::readDataKey($data, 'PaymentProcessorOrderNumber');
        $response->processorBillingAddress1 = self::readDataKey($data, 'ProcessorBillingAddress1');
        $response->processorBillingAddress2 = self::readDataKey($data, 'ProcessorBillingAddress2');
        $response->processorBillingCity = self::readDataKey($data, 'ProcessorBillingCity');
        $response->processorBillingCountryCode = self::readDataKey($data, 'ProcessorBillingCountryCode');
        $response->processorBillingFirstName = self::readDataKey($data, 'ProcessorBillingFirstName');
        $response->processorBillingLastName = self::readDataKey($data, 'ProcessorBillingLastName');
        $response->processorBillingMiddleName = self::readDataKey($data, 'ProcessorBillingMiddleName');
        $response->processorBillingPhone = self::readDataKey($data, 'ProcessorBillingPhone');
        $response->processorBillingPostalCode = self::readDataKey($data, 'ProcessorBillingPostalCode');
        $response->processorBillingState = self::readDataKey($data, 'ProcessorBillingState');
        $response->processorCavv = self::readDataKey($data, 'ProcessorCavv');
        $response->processorEciFlag = self::readDataKey($data, 'ProcessorEciFlag');
        $response->processorEmail = self::readDataKey($data, 'ProcessorEmail');
        $response->processorPayresStatus = self::readDataKey($data, 'ProcessorPayresStatus');
        $response->processorShippingAddress1 = self::readDataKey($data, 'ProcessorShippingAddress1');
        $response->processorShippingAddress2 = self::readDataKey($data, 'ProcessorShippingAddress2');
        $response->processorShippingCity = self::readDataKey($data, 'ProcessorShippingCity');
        $response->processorShippingCountryCode = self::readDataKey($data, 'ProcessorShippingCountryCode');
        $response->processorShippingFullName = self::readDataKey($data, 'ProcessorShippingFullName');
        $response->processorShippingPhone = self::readDataKey($data, 'ProcessorShippingPhone');
        $response->processorShippingPostalCode = self::readDataKey($data, 'ProcessorShippingPostalCode');
        $response->processorShippingState = self::readDataKey($data, 'ProcessorShippingState');
        $response->processorSignatureVerification = self::readDataKey($data, 'ProcessorSignatureVerification');
        $response->processorXid = self::readDataKey($data, 'ProcessorXid');
        $response->rewardExpMonth = self::readDataKey($data, 'RewardExpMonth');
        $response->rewardExpYear = self::readDataKey($data, 'RewardExpYear');
        $response->rewardId = self::readDataKey($data, 'RewardId');
        $response->rewardName = self::readDataKey($data, 'RewardName');
        $response->rewardNumber = self::readDataKey($data, 'RewardNumber');
        $response->scEnrollmentStatus = self::readDataKey($data, 'ScEnrollmentStatus');
        $response->signatureVerification = self::readDataKey($data, 'SignatureVerification');
        return $response;
    }
776262
public function images($regex = null, $attr = 'src')
    {
        /**
         * @var \DOMElement $node
         */
        $document = $this->_document;
        $data = [];
        foreach ($document->getQuery()->xpath("descendant::img[@$attr]", $this->_node) as $node) {
            $src = $document->absolutizeUrl($node->getAttribute($attr));

            if ($regex && !preg_match($regex, $src)) {
                continue;
            }

            $data[$node->getNodePath()] = $src;
        }

        return $data;
    }
727175
public function getObjectsByCollection(CollectionInterface $collection, callable $callback = null)
    {
        $iterator = $this->resourceRepository->findByCollectionNameIterator($collection->getName());
        $iteration = 0;
        foreach ($this->resourceRepository->iterate($iterator, $callback) as $resource) {
            /** @var PersistentResource $resource */
            $object = new StorageObject();
            $object->setFilename($resource->getFilename());
            $object->setSha1($resource->getSha1());
            $object->setMd5($resource->getMd5());
            $object->setFileSize($resource->getFileSize());
            $object->setStream(function () use ($resource) {
                return $this->getStreamByResource($resource);
            });
            yield $object;
            if (is_callable($callback)) {
                call_user_func($callback, $iteration, $object);
            }
            $iteration++;
        }
    }
816486
public static function hash_final($hasher, $returnRaw = false)
    {
        $hash = hash_final($hasher, true);

        if ((bool) $returnRaw) {
            return $hash;
        }

        //XXX should use Hasher class to keep track of key size
        return new Buffer($hash);
    }
1228531
public function listAll()
    {
        try {
            $return = [ ];
            $result = $this->getSoapClient()->ListImages();
            if ( isset($result->ListImagesResult) ) {
                $return = $this->getSoapClient()->backendListArrayToMultiAssocArray($result->ListImagesResult);
            }

            return $return;
        } catch ( SoapException $ex ) {
            throw new StatusException('Error while obtaining the list of all images' , $ex);
        }
    }
1275386
public static function setArrayReturnType($returnType)
    {
        if (($returnType == self::RETURN_ARRAY_AS_VALUE) ||
            ($returnType == self::RETURN_ARRAY_AS_ERROR) ||
            ($returnType == self::RETURN_ARRAY_AS_ARRAY)) {
            self::$returnArrayAsType = $returnType;
            return true;
        }
        return false;
    }
116219
public function getReverseImagesQuery($data, $inputs)
    {
        foreach ($inputs as $input) {
            $data[] = ['output' => $this->setData(['image' => ['url' => $input->getImage()]], 'input')];
        }

        return $data;
    }
565112
public function run($return = false)
    {
        $output = "";

        foreach ($this->stack as $view) { /** @var View $view */
            $data = $view->getData();

            if (! is_array($data)) {
                $data = array();
            }

            if ($view->getType() === View::PART_BODY_PLACEHOLDER) {
                throw new RendererException("The body placeholder isn't replaced!"); // @codeCoverageIgnore
            }

            if (! empty($this->globalData)) {
                $data = array_merge($data, $this->globalData);
            }

            $engineClass = $view->getEngine();
            /** @var RendererInterface $engine */
            $engine = $engineClass->newInstance();

            if (! $engine instanceof RendererInterface) { // @codeCoverageIgnore
                throw new RendererException("Engine is not instance of the RendererInterface."); // @codeCoverageIgnore
            } // @codeCoverageIgnore

            // Render it!
            $output .= $engine->render($view, $data);
        }

        // If we need to return. Then just return it.
        if ($return) {
            return $output;
        }

        // Instead, create response object and return it.
        return new Response($output, 200); // @codeCoverageIgnore
    }
566971
public function load($filename, array $vars = [], $return = false)
    {
        if ($filename instanceof \SplFileInfo) {
            return $this->page($filename->getRealPath(), array_merge($vars, $filename->getVars()));
        }

        if (strpos($filename, 'Pages') !== false) {
            return $this->page($filename, $vars, $return);
        }

        presenter()->merge($vars);

        if (false !== ($filePath = $this->getFilePath($filename))) {

            // Load Assets
            presenter()->assets->addFilePath(dirname($filePath) . DIRECTORY_SEPARATOR);

            presenter()->assets->loadCss(pathinfo($filePath, PATHINFO_FILENAME));
            presenter()->assets->loadJs(pathinfo($filePath, PATHINFO_FILENAME));

            if ($return === false) {
                if (presenter()->partials->hasPartial('content') === false) {
                    if (is_ajax()) {
                        parser()->loadFile($filePath);
                        $content = parser()->parse(presenter()->getArrayCopy());

                        presenter()->partials->addPartial('content', $content);
                    } else {
                        presenter()->partials->addPartial('content', $filePath);
                    }
                } else {
                    presenter()->partials->addPartial(pathinfo($filePath, PATHINFO_FILENAME), $filePath);
                }
            } else {
                parser()->loadFile($filePath);

                return parser()->parse(presenter()->getArrayCopy());
            }
        } else {
            $vars = presenter()->getArrayCopy();
            extract($vars);

            $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);

            $error = new ErrorException(
                'E_VIEW_NOT_FOUND',
                0,
                @$backtrace[ 0 ][ 'file' ],
                @$backtrace[ 0 ][ 'line' ],
                [trim($filename)]
            );

            unset($backtrace);

            ob_start();
            include output()->getFilePath('error');
            $content = ob_get_contents();
            ob_end_clean();

            if ($return === false) {
                if (presenter()->partials->hasPartial('content') === false) {
                    presenter()->addPartial('content', $content);
                } else {
                    presenter()->addPartial(pathinfo($filePath, PATHINFO_FILENAME), $content);
                }
            } else {
                return $content;
            }
        }
    }
734897
public function returnPath($returnPath = null)
    {
        if (!func_num_args()) {
            return $this->_returnPath;
        }
        $this->_returnPath = $returnPath;
        $headers = $this->headers();
        $headers['Return-Path'] = '<' . Mime::encodeEmail($returnPath) .'>';
        return $this;
    }
439119
public function getPhotoImage($data = null, $returnTableRow = true, $size = 0) {
		$result = $this->_getValueForPhotoImageBase($data, $returnTableRow, $size);

		return $result;
	}