public function map(callable $func): self
    {
        $intervals = [];
        foreach ($this->intervals as $offset => $interval) {
            $intervals[$offset] = $func($interval, $offset);
        }

        if ($intervals === $this->intervals) {
            return $this;
        }

        $mapped = new self();
        $mapped->intervals = $intervals;

        return $mapped;
    }
public function map(callable $func): self
    {
        $intervals = [];
        foreach ($this->intervals as $offset => $interval) {
            $intervals[$offset] = $func($interval, $offset);
        }

        if ($intervals === $this->intervals) {
            return $this;
        }

        $mapped = new self();
        $mapped->intervals = $intervals;

        return $mapped;
    }
public function map ( callable $ func ) : self { $ intervals = [ ] ; foreach ( $ this -> intervals as $ offset => $ interval ) { $ intervals [ $ offset ] = $ func ( $ interval , $ offset ) ; } if ( $ intervals === $ this -> intervals ) { return $ this ; } $ mapped = new self ( ) ; $ mapped -> intervals = $ intervals ; return $ mapped ; }
Returns an instance where the given function is applied to each element in
the collection. The callable MUST return a Period object and takes a Period
and its associated key as argument.

This method MUST retain the state of the current instance, and return
an instance that contains the returned intervals.
Returns an instance where the given function is applied to each element in the collection . The callable MUST return a Period object and takes a Period and its associated key as argument .