| @@ 121-136 (lines=16) @@ | ||
| 118 | * |
|
| 119 | * @return $this |
|
| 120 | */ |
|
| 121 | public function addBusinessDays($howManyDays) |
|
| 122 | { |
|
| 123 | if ($howManyDays < 1) { |
|
| 124 | throw new \InvalidArgumentException('The parameter $howManyDays must be greater than 0'); |
|
| 125 | } |
|
| 126 | ||
| 127 | $iterator = 0; |
|
| 128 | while ($iterator < $howManyDays) { |
|
| 129 | $this->getDate()->modify('+1 day'); |
|
| 130 | if ($this->isBusinessDay($this->getDate())) { |
|
| 131 | $iterator++; |
|
| 132 | } |
|
| 133 | } |
|
| 134 | ||
| 135 | return $this; |
|
| 136 | } |
|
| 137 | ||
| 138 | /** |
|
| 139 | * @param int $howManyDays |
|
| @@ 143-159 (lines=17) @@ | ||
| 140 | * |
|
| 141 | * @return $this |
|
| 142 | */ |
|
| 143 | public function subBusinessDays($howManyDays) |
|
| 144 | { |
|
| 145 | if ($howManyDays < 1) { |
|
| 146 | throw new \InvalidArgumentException('The parameter $howManyDays must be greater than 0'); |
|
| 147 | } |
|
| 148 | ||
| 149 | $iterator = 0; |
|
| 150 | while ($iterator < $howManyDays) { |
|
| 151 | if ($this->isBusinessDay($this->getDate())) { |
|
| 152 | $iterator++; |
|
| 153 | } |
|
| 154 | if ($iterator < $howManyDays) { //Don`t modify the date if we are on the last iteration |
|
| 155 | $this->getDate()->modify('-1 day'); |
|
| 156 | } |
|
| 157 | } |
|
| 158 | return $this; |
|
| 159 | } |
|
| 160 | ||
| 161 | /** |
|
| 162 | * @return \DateTime |
|