for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace Rinvex\Subscriptions\Services;
use Carbon\Carbon;
class Period
{
/**
* Starting date of the period.
*
* @var string
*/
protected $start;
* Ending date of the period.
protected $end;
* Interval.
protected $interval;
* Interval count.
* @var int
protected $period = 1;
* Create a new Period instance.
* @param string $interval
* @param int $count
* @param string $start
* @return void
@return
Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.
Please refer to the PHP core documentation on constructors.
public function __construct($interval = 'month', $count = 1, $start = '')
$this->interval = $interval;
if (empty($start)) {
$this->start = Carbon::now();
\Carbon\Carbon::now()
object<Carbon\Carbon>
string
$start
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..
} elseif (! $start instanceof Carbon) {
$this->start = new Carbon($start);
new \Carbon\Carbon($start)
} else {
$this->start = $start;
}
$this->period = $count;
$start = clone $this->start;
$method = 'add'.ucfirst($this->interval).'s';
$this->end = $start->{$method}($this->period);
* Get start date.
* @return \Carbon\Carbon
public function getStartDate(): Carbon
return $this->start;
* Get end date.
public function getEndDate(): Carbon
return $this->end;
* Get period interval.
* @return string
public function getInterval(): string
return $this->interval;
* Get period interval count.
* @return int
public function getIntervalCount(): int
return $this->period;
Adding a
@return
annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.