<?php
namespace Aqarmap\Bundle\MainBundle\Service;
class ThumbURL
{
private $config;
public function __construct(array $config)
{
$this->setConfig($config);
}
/**
* @param string $fileURI
* @param string $filter
*
* @return string
*/
public function generateURL($fileURI, $filter)
{
$i = 0;
if (\count($this->config['base_urls'])) {
$i = @hexdec(substr($fileURI, -10)) % \count($this->config['base_urls']);
}
$baseURL = trim($this->config['base_urls'][$i], '/');
return sprintf('%s/%s/%s/%s', $baseURL, $this->config['bucket'], $filter, trim($fileURI, '\/'));
}
/**
* @param array $config
*/
public function setConfig($config): void
{
$this->config = $config;
}
/**
* @return array
*/
public function getConfig()
{
return $this->config;
}
}