1 | <?php |
||
27 | class FastForwarder |
||
28 | { |
||
29 | use SkipWhenTrait; |
||
30 | |||
31 | protected $numDays = 0; |
||
32 | |||
33 | /** @var DateInterval */ |
||
34 | protected $interval; |
||
35 | |||
36 | /** |
||
37 | * Static factory method for backward compatibility; see constructor for more details |
||
38 | * |
||
39 | * @param int|float $num_days |
||
40 | * @param array $skip_when |
||
41 | * @return static |
||
42 | */ |
||
43 | 20 | public static function createWithDays($num_days, array $skip_when = []) |
|
44 | { |
||
45 | 20 | return new static($num_days, $skip_when); |
|
46 | } |
||
47 | |||
48 | /** |
||
49 | * Creates an instance with a defined number of business days |
||
50 | * |
||
51 | * @param int|float $num_days the number of business days from the supplied date to |
||
52 | * the calculated date (non-integer values will be rounded up) |
||
53 | * @param array $skip_when pre-defined filters to add to skipWhen without testing |
||
54 | */ |
||
55 | 22 | public function __construct($num_days, array $skip_when = []) |
|
63 | |||
64 | /** |
||
65 | * Iterates through dates in steps of $this->interval until $this->numDays |
||
66 | * is zero. Then, if the current day is not a business day, iterate until |
||
67 | * the current day is a business day. Return the result in the same format |
||
68 | * as was supplied. |
||
69 | * |
||
70 | * @param DateTimeInterface $start_date |
||
71 | * @return DateTimeInterface clone of $start_date with a modified timestamp |
||
72 | */ |
||
73 | 20 | public function exec(DateTimeInterface $start_date) |
|
99 | } |
||
100 |