WIP.
This commit is contained in:
parent
c32c5ff1a0
commit
864f2be68f
17
src/Output/AbstractOutput.php
Normal file
17
src/Output/AbstractOutput.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace StaticMapLite\Output;
|
||||
|
||||
abstract class AbstractOutput implements OutputInterface
|
||||
{
|
||||
public function sendHeader(): OutputInterface
|
||||
{
|
||||
header('Content-Type: image/png');
|
||||
$expires = 60 * 60 * 24 * 14;
|
||||
header('Pragma: public');
|
||||
header('Cache-Control: maxage=' . $expires);
|
||||
header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $expires) . ' GMT');
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace StaticMapLite\Output;
|
||||
|
||||
class CacheOutput implements OutputInterface
|
||||
class CacheOutput extends AbstractOutput
|
||||
{
|
||||
protected $filename;
|
||||
|
||||
@ -13,17 +13,6 @@ class CacheOutput implements OutputInterface
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function sendHeader(): OutputInterface
|
||||
{
|
||||
header('Content-Type: image/png');
|
||||
$expires = 60 * 60 * 24 * 14;
|
||||
header('Pragma: public');
|
||||
header('Cache-Control: maxage=' . $expires);
|
||||
header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $expires) . ' GMT');
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function sendImage(): void
|
||||
{
|
||||
echo file_get_contents($this->filename);
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace StaticMapLite\Output;
|
||||
|
||||
class ImageOutput implements OutputInterface
|
||||
class ImageOutput extends AbstractOutput
|
||||
{
|
||||
protected $image;
|
||||
|
||||
@ -13,17 +13,6 @@ class ImageOutput implements OutputInterface
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function sendHeader(): OutputInterface
|
||||
{
|
||||
header('Content-Type: image/png');
|
||||
$expires = 60 * 60 * 24 * 14;
|
||||
header('Pragma: public');
|
||||
header('Cache-Control: maxage=' . $expires);
|
||||
header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $expires) . ' GMT');
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function sendImage(): bool
|
||||
{
|
||||
return imagepng($this->image);
|
||||
|
@ -4,5 +4,6 @@ namespace StaticMapLite\Output;
|
||||
|
||||
interface OutputInterface
|
||||
{
|
||||
|
||||
public function sendHeader();
|
||||
public function sendImage();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user