first commit
This commit is contained in:
40
vendor/php-flasher/flasher/Stamp/ContextStamp.php
vendored
Normal file
40
vendor/php-flasher/flasher/Stamp/ContextStamp.php
vendored
Normal file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the PHPFlasher package.
|
||||
* (c) Younes KHOUBZA <younes.khoubza@gmail.com>
|
||||
*/
|
||||
|
||||
namespace Flasher\Prime\Stamp;
|
||||
|
||||
final class ContextStamp implements StampInterface, PresentableStampInterface
|
||||
{
|
||||
/**
|
||||
* @var mixed[]
|
||||
*/
|
||||
private $context;
|
||||
|
||||
/**
|
||||
* @param mixed[] $context
|
||||
*/
|
||||
public function __construct(array $context)
|
||||
{
|
||||
$this->context = $context;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed[]
|
||||
*/
|
||||
public function getContext()
|
||||
{
|
||||
return $this->context;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function toArray()
|
||||
{
|
||||
return array('context' => $this->getContext());
|
||||
}
|
||||
}
|
62
vendor/php-flasher/flasher/Stamp/CreatedAtStamp.php
vendored
Normal file
62
vendor/php-flasher/flasher/Stamp/CreatedAtStamp.php
vendored
Normal file
@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the PHPFlasher package.
|
||||
* (c) Younes KHOUBZA <younes.khoubza@gmail.com>
|
||||
*/
|
||||
|
||||
namespace Flasher\Prime\Stamp;
|
||||
|
||||
final class CreatedAtStamp implements StampInterface, OrderableStampInterface, PresentableStampInterface
|
||||
{
|
||||
/**
|
||||
* @var \DateTime
|
||||
*/
|
||||
private $createdAt;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $format;
|
||||
|
||||
/**
|
||||
* @param string|null $format
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function __construct(\DateTime $createdAt = null, $format = null)
|
||||
{
|
||||
$this->createdAt = $createdAt ?: new \DateTime('now', new \DateTimeZone('Africa/Casablanca'));
|
||||
$this->format = $format ?: 'Y-m-d H:i:s';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function getCreatedAt()
|
||||
{
|
||||
return $this->createdAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function compare($orderable)
|
||||
{
|
||||
if (!$orderable instanceof self) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return $this->createdAt->getTimestamp() - $orderable->createdAt->getTimestamp();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function toArray()
|
||||
{
|
||||
$createdAt = $this->getCreatedAt();
|
||||
|
||||
return array('created_at' => $createdAt->format($this->format));
|
||||
}
|
||||
}
|
32
vendor/php-flasher/flasher/Stamp/DelayStamp.php
vendored
Normal file
32
vendor/php-flasher/flasher/Stamp/DelayStamp.php
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the PHPFlasher package.
|
||||
* (c) Younes KHOUBZA <younes.khoubza@gmail.com>
|
||||
*/
|
||||
|
||||
namespace Flasher\Prime\Stamp;
|
||||
|
||||
final class DelayStamp implements StampInterface
|
||||
{
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $delay;
|
||||
|
||||
/**
|
||||
* @param int $delay
|
||||
*/
|
||||
public function __construct($delay)
|
||||
{
|
||||
$this->delay = $delay;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getDelay()
|
||||
{
|
||||
return $this->delay;
|
||||
}
|
||||
}
|
40
vendor/php-flasher/flasher/Stamp/HandlerStamp.php
vendored
Normal file
40
vendor/php-flasher/flasher/Stamp/HandlerStamp.php
vendored
Normal file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the PHPFlasher package.
|
||||
* (c) Younes KHOUBZA <younes.khoubza@gmail.com>
|
||||
*/
|
||||
|
||||
namespace Flasher\Prime\Stamp;
|
||||
|
||||
final class HandlerStamp implements StampInterface, PresentableStampInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $handler;
|
||||
|
||||
/**
|
||||
* @param string $handler
|
||||
*/
|
||||
public function __construct($handler)
|
||||
{
|
||||
$this->handler = $handler;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getHandler()
|
||||
{
|
||||
return $this->handler;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function toArray()
|
||||
{
|
||||
return array('handler' => $this->getHandler());
|
||||
}
|
||||
}
|
32
vendor/php-flasher/flasher/Stamp/HopsStamp.php
vendored
Normal file
32
vendor/php-flasher/flasher/Stamp/HopsStamp.php
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the PHPFlasher package.
|
||||
* (c) Younes KHOUBZA <younes.khoubza@gmail.com>
|
||||
*/
|
||||
|
||||
namespace Flasher\Prime\Stamp;
|
||||
|
||||
final class HopsStamp implements StampInterface
|
||||
{
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $amount;
|
||||
|
||||
/**
|
||||
* @param int $amount
|
||||
*/
|
||||
public function __construct($amount)
|
||||
{
|
||||
$this->amount = $amount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getAmount()
|
||||
{
|
||||
return $this->amount;
|
||||
}
|
||||
}
|
18
vendor/php-flasher/flasher/Stamp/OrderableStampInterface.php
vendored
Normal file
18
vendor/php-flasher/flasher/Stamp/OrderableStampInterface.php
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the PHPFlasher package.
|
||||
* (c) Younes KHOUBZA <younes.khoubza@gmail.com>
|
||||
*/
|
||||
|
||||
namespace Flasher\Prime\Stamp;
|
||||
|
||||
interface OrderableStampInterface
|
||||
{
|
||||
/**
|
||||
* @param mixed $orderable
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function compare($orderable);
|
||||
}
|
16
vendor/php-flasher/flasher/Stamp/PresentableStampInterface.php
vendored
Normal file
16
vendor/php-flasher/flasher/Stamp/PresentableStampInterface.php
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the PHPFlasher package.
|
||||
* (c) Younes KHOUBZA <younes.khoubza@gmail.com>
|
||||
*/
|
||||
|
||||
namespace Flasher\Prime\Stamp;
|
||||
|
||||
interface PresentableStampInterface
|
||||
{
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function toArray();
|
||||
}
|
47
vendor/php-flasher/flasher/Stamp/PresetStamp.php
vendored
Normal file
47
vendor/php-flasher/flasher/Stamp/PresetStamp.php
vendored
Normal file
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the PHPFlasher package.
|
||||
* (c) Younes KHOUBZA <younes.khoubza@gmail.com>
|
||||
*/
|
||||
|
||||
namespace Flasher\Prime\Stamp;
|
||||
|
||||
final class PresetStamp implements StampInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $preset;
|
||||
|
||||
/**
|
||||
* @var array<string, mixed>
|
||||
*/
|
||||
private $parameters;
|
||||
|
||||
/**
|
||||
* @param string $preset
|
||||
* @param array<string, mixed> $parameters
|
||||
*/
|
||||
public function __construct($preset, array $parameters = array())
|
||||
{
|
||||
$this->preset = $preset;
|
||||
$this->parameters = $parameters;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getPreset()
|
||||
{
|
||||
return $this->preset;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function getParameters()
|
||||
{
|
||||
return $this->parameters;
|
||||
}
|
||||
}
|
52
vendor/php-flasher/flasher/Stamp/PriorityStamp.php
vendored
Normal file
52
vendor/php-flasher/flasher/Stamp/PriorityStamp.php
vendored
Normal file
@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the PHPFlasher package.
|
||||
* (c) Younes KHOUBZA <younes.khoubza@gmail.com>
|
||||
*/
|
||||
|
||||
namespace Flasher\Prime\Stamp;
|
||||
|
||||
final class PriorityStamp implements StampInterface, OrderableStampInterface, PresentableStampInterface
|
||||
{
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $priority;
|
||||
|
||||
/**
|
||||
* @param int $priority
|
||||
*/
|
||||
public function __construct($priority)
|
||||
{
|
||||
$this->priority = $priority;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getPriority()
|
||||
{
|
||||
return $this->priority;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function compare($orderable)
|
||||
{
|
||||
if (!$orderable instanceof self) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return $this->priority - $orderable->priority;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function toArray()
|
||||
{
|
||||
return array('priority' => $this->getPriority());
|
||||
}
|
||||
}
|
12
vendor/php-flasher/flasher/Stamp/StampInterface.php
vendored
Normal file
12
vendor/php-flasher/flasher/Stamp/StampInterface.php
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the PHPFlasher package.
|
||||
* (c) Younes KHOUBZA <younes.khoubza@gmail.com>
|
||||
*/
|
||||
|
||||
namespace Flasher\Prime\Stamp;
|
||||
|
||||
interface StampInterface
|
||||
{
|
||||
}
|
69
vendor/php-flasher/flasher/Stamp/TranslationStamp.php
vendored
Normal file
69
vendor/php-flasher/flasher/Stamp/TranslationStamp.php
vendored
Normal file
@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the PHPFlasher package.
|
||||
* (c) Younes KHOUBZA <younes.khoubza@gmail.com>
|
||||
*/
|
||||
|
||||
namespace Flasher\Prime\Stamp;
|
||||
|
||||
final class TranslationStamp implements StampInterface
|
||||
{
|
||||
/**
|
||||
* @var array<string, mixed>
|
||||
*/
|
||||
private $parameters;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
private $locale;
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $parameters
|
||||
* @param string|null $locale
|
||||
*/
|
||||
public function __construct($parameters = array(), $locale = null)
|
||||
{
|
||||
$order = self::parametersOrder($parameters, $locale);
|
||||
$parameters = $order['parameters'];
|
||||
$locale = $order['locale'];
|
||||
|
||||
$this->parameters = $parameters;
|
||||
$this->locale = $locale;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function getParameters()
|
||||
{
|
||||
return $this->parameters;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getLocale()
|
||||
{
|
||||
return $this->locale;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $parameters
|
||||
* @param mixed|null $locale
|
||||
*
|
||||
* @return array{parameters: array<string, mixed>, locale: string|null}
|
||||
*/
|
||||
public static function parametersOrder($parameters = array(), $locale = null)
|
||||
{
|
||||
if (\is_string($parameters)) {
|
||||
$locale = $parameters;
|
||||
$parameters = array();
|
||||
|
||||
@trigger_error('Since php-flasher/flasher v1.4, passing the locale as first parameter is deprecated and will be removed in v2.0. Use the second parameter instead.', \E_USER_DEPRECATED);
|
||||
}
|
||||
|
||||
return array('parameters' => $parameters, 'locale' => $locale); // @phpstan-ignore-line
|
||||
}
|
||||
}
|
32
vendor/php-flasher/flasher/Stamp/UnlessStamp.php
vendored
Normal file
32
vendor/php-flasher/flasher/Stamp/UnlessStamp.php
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the PHPFlasher package.
|
||||
* (c) Younes KHOUBZA <younes.khoubza@gmail.com>
|
||||
*/
|
||||
|
||||
namespace Flasher\Prime\Stamp;
|
||||
|
||||
final class UnlessStamp implements StampInterface
|
||||
{
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $condition;
|
||||
|
||||
/**
|
||||
* @param bool $condition
|
||||
*/
|
||||
public function __construct($condition)
|
||||
{
|
||||
$this->condition = $condition;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function getCondition()
|
||||
{
|
||||
return $this->condition;
|
||||
}
|
||||
}
|
77
vendor/php-flasher/flasher/Stamp/UuidStamp.php
vendored
Normal file
77
vendor/php-flasher/flasher/Stamp/UuidStamp.php
vendored
Normal file
@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the PHPFlasher package.
|
||||
* (c) Younes KHOUBZA <younes.khoubza@gmail.com>
|
||||
*/
|
||||
|
||||
namespace Flasher\Prime\Stamp;
|
||||
|
||||
use Flasher\Prime\Notification\Envelope;
|
||||
|
||||
final class UuidStamp implements StampInterface, PresentableStampInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $uuid;
|
||||
|
||||
/**
|
||||
* @param string|null $uuid
|
||||
*/
|
||||
public function __construct($uuid = null)
|
||||
{
|
||||
$this->uuid = $uuid ?: sprintf(
|
||||
'%04X%04X-%04X-%04X-%04X-%04X%04X%04X',
|
||||
mt_rand(0, 65535),
|
||||
mt_rand(0, 65535),
|
||||
mt_rand(0, 65535),
|
||||
mt_rand(16384, 20479),
|
||||
mt_rand(32768, 49151),
|
||||
mt_rand(0, 65535),
|
||||
mt_rand(0, 65535),
|
||||
mt_rand(0, 65535)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Envelope[]|Envelope... $envelopes
|
||||
*
|
||||
* @return array<string, Envelope>
|
||||
*/
|
||||
public static function indexByUuid($envelopes)
|
||||
{
|
||||
$envelopes = \is_array($envelopes) ? $envelopes : \func_get_args();
|
||||
|
||||
$map = array();
|
||||
|
||||
foreach ($envelopes as $envelope) {
|
||||
$uuidStamp = $envelope->get('Flasher\Prime\Stamp\UuidStamp');
|
||||
if (!$uuidStamp instanceof UuidStamp) {
|
||||
$uuidStamp = new UuidStamp(spl_object_hash($envelope));
|
||||
$envelope->withStamp($uuidStamp);
|
||||
}
|
||||
|
||||
$uuid = $uuidStamp->getUuid();
|
||||
$map[$uuid] = $envelope;
|
||||
}
|
||||
|
||||
return $map;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getUuid()
|
||||
{
|
||||
return $this->uuid;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function toArray()
|
||||
{
|
||||
return array('uuid' => $this->getUuid());
|
||||
}
|
||||
}
|
40
vendor/php-flasher/flasher/Stamp/ViewStamp.php
vendored
Normal file
40
vendor/php-flasher/flasher/Stamp/ViewStamp.php
vendored
Normal file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the PHPFlasher package.
|
||||
* (c) Younes KHOUBZA <younes.khoubza@gmail.com>
|
||||
*/
|
||||
|
||||
namespace Flasher\Prime\Stamp;
|
||||
|
||||
final class ViewStamp implements StampInterface, PresentableStampInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $view;
|
||||
|
||||
/**
|
||||
* @param string $template
|
||||
*/
|
||||
public function __construct($template)
|
||||
{
|
||||
$this->view = $template;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getView()
|
||||
{
|
||||
return $this->view;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function toArray()
|
||||
{
|
||||
return array('view' => $this->getView());
|
||||
}
|
||||
}
|
32
vendor/php-flasher/flasher/Stamp/WhenStamp.php
vendored
Normal file
32
vendor/php-flasher/flasher/Stamp/WhenStamp.php
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the PHPFlasher package.
|
||||
* (c) Younes KHOUBZA <younes.khoubza@gmail.com>
|
||||
*/
|
||||
|
||||
namespace Flasher\Prime\Stamp;
|
||||
|
||||
final class WhenStamp implements StampInterface
|
||||
{
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $condition;
|
||||
|
||||
/**
|
||||
* @param bool $condition
|
||||
*/
|
||||
public function __construct($condition)
|
||||
{
|
||||
$this->condition = $condition;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function getCondition()
|
||||
{
|
||||
return $this->condition;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user