File: MonthCalc.php Lines 7 to 26
7 * たとえば 3/31 の1ヶ月前は 2/28 とする。
8 */
9class MonthCalc {
10    /**
11     * 
12     * @param \DateTime $dt
13     * @param int $offset
14     * @return \DateTime
15     */
Type Class Description
pmd ShortVariable Avoid variables with short names like $dt. Configured minimum length is 3.
16
Type Class Description
pmd ShortVariable Avoid variables with short names like $dt. Configured minimum length is 3.
    public function calc(\DateTime $dt, $offset) {
17        if($offset === null) {
18            $offset = 1;
19        }
20
21        $result = clone $dt;
22
23        $day = $dt->format('j');
24        if($offset >= 0) {
25            $dayOfNextMonth = $result->add(new \DateInterval('P'.$offset.'M'))->format('j');
26        } else {