diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 11:30:08 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 11:30:08 +0000 |
commit | 4ce65d59ca91871cfd126497158200a818720bce (patch) | |
tree | e277def01fc7eba7dbc21c4a4ae5576e8aa2cf1f /vendor/simshaun/recurr/src/Recurr/Transformer/Constraint | |
parent | Initial commit. (diff) | |
download | icinga-php-library-4ce65d59ca91871cfd126497158200a818720bce.tar.xz icinga-php-library-4ce65d59ca91871cfd126497158200a818720bce.zip |
Adding upstream version 0.13.1.upstream/0.13.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/simshaun/recurr/src/Recurr/Transformer/Constraint')
3 files changed, 209 insertions, 0 deletions
diff --git a/vendor/simshaun/recurr/src/Recurr/Transformer/Constraint/AfterConstraint.php b/vendor/simshaun/recurr/src/Recurr/Transformer/Constraint/AfterConstraint.php new file mode 100644 index 0000000..3baf9a0 --- /dev/null +++ b/vendor/simshaun/recurr/src/Recurr/Transformer/Constraint/AfterConstraint.php @@ -0,0 +1,64 @@ +<?php + +/* + * Copyright 2014 Shaun Simmons + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Recurr\Transformer\Constraint; + +use Recurr\Transformer\Constraint; + +class AfterConstraint extends Constraint +{ + + protected $stopsTransformer = false; + + /** @var \DateTimeInterface */ + protected $after; + + /** @var bool */ + protected $inc; + + /** + * @param \DateTimeInterface $after + * @param bool $inc Include date if it equals $after. + */ + public function __construct(\DateTimeInterface $after, $inc = false) + { + $this->after = $after; + $this->inc = $inc; + } + + /** + * Passes if $date is after $after + * + * {@inheritdoc} + */ + public function test(\DateTimeInterface $date) + { + if ($this->inc) { + return $date >= $this->after; + } + + return $date > $this->after; + } + + /** + * @return \DateTimeInterface + */ + public function getAfter() + { + return $this->after; + } + + /** + * @return bool + */ + public function isInc() + { + return $this->inc; + } +} diff --git a/vendor/simshaun/recurr/src/Recurr/Transformer/Constraint/BeforeConstraint.php b/vendor/simshaun/recurr/src/Recurr/Transformer/Constraint/BeforeConstraint.php new file mode 100644 index 0000000..aa94525 --- /dev/null +++ b/vendor/simshaun/recurr/src/Recurr/Transformer/Constraint/BeforeConstraint.php @@ -0,0 +1,64 @@ +<?php + +/* + * Copyright 2014 Shaun Simmons + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Recurr\Transformer\Constraint; + +use Recurr\Transformer\Constraint; + +class BeforeConstraint extends Constraint +{ + + protected $stopsTransformer = true; + + /** @var \DateTimeInterface */ + protected $before; + + /** @var bool */ + protected $inc; + + /** + * @param \DateTimeInterface $before + * @param bool $inc Include date if it equals $before. + */ + public function __construct(\DateTimeInterface $before, $inc = false) + { + $this->before = $before; + $this->inc = $inc; + } + + /** + * Passes if $date is before $before + * + * {@inheritdoc} + */ + public function test(\DateTimeInterface $date) + { + if ($this->inc) { + return $date <= $this->before; + } + + return $date < $this->before; + } + + /** + * @return \DateTimeInterface + */ + public function getBefore() + { + return $this->before; + } + + /** + * @return bool + */ + public function isInc() + { + return $this->inc; + } +} diff --git a/vendor/simshaun/recurr/src/Recurr/Transformer/Constraint/BetweenConstraint.php b/vendor/simshaun/recurr/src/Recurr/Transformer/Constraint/BetweenConstraint.php new file mode 100644 index 0000000..f16d491 --- /dev/null +++ b/vendor/simshaun/recurr/src/Recurr/Transformer/Constraint/BetweenConstraint.php @@ -0,0 +1,81 @@ +<?php + +/* + * Copyright 2014 Shaun Simmons + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Recurr\Transformer\Constraint; + +use Recurr\Transformer\Constraint; + +class BetweenConstraint extends Constraint +{ + + protected $stopsTransformer = false; + + /** @var \DateTimeInterface */ + protected $before; + + /** @var \DateTimeInterface */ + protected $after; + + /** @var bool */ + protected $inc; + + /** + * @param \DateTimeInterface $after + * @param \DateTimeInterface $before + * @param bool $inc Include date if it equals $after or $before. + */ + public function __construct(\DateTimeInterface $after, \DateTimeInterface $before, $inc = false) + { + $this->after = $after; + $this->before = $before; + $this->inc = $inc; + } + + /** + * Passes if $date is between $after and $before + * + * {@inheritdoc} + */ + public function test(\DateTimeInterface $date) + { + if ($date > $this->before) { + $this->stopsTransformer = true; + } + + if ($this->inc) { + return $date >= $this->after && $date <= $this->before; + } + + return $date > $this->after && $date < $this->before; + } + + /** + * @return \DateTimeInterface + */ + public function getBefore() + { + return $this->before; + } + + /** + * @return \DateTimeInterface + */ + public function getAfter() + { + return $this->after; + } + + /** + * @return bool + */ + public function isInc() + { + return $this->inc; + } +} |