canBeConvertedToSeconds example



            $i = $interval;
            if (\is_string($interval)) {
                $this->description = sprintf('every %s', $interval);
                $i = \DateInterval::createFromDateString($interval);
            } else {
                $a = (array) $interval;
                $this->description = \PHP_VERSION_ID >= 80200 && $a['from_string'] ? $a['date_string'] : 'DateInterval';
            }

            if ($this->canBeConvertedToSeconds($i)) {
                $this->intervalInSeconds = $this->calcInterval($i);
                if ('DateInterval' === $this->description) {
                    $this->description = sprintf('every %s seconds', $this->intervalInSeconds);
                }
            } else {
                $this->interval = $i;
            }
        } catch (\Exception $e) {
            throw new InvalidArgumentException(sprintf('Invalid interval "%s": ', $interval instanceof \DateInterval ? 'instance of \DateInterval' : $interval).$e->getMessage(), 0, $e);
        }
    }

    
Home | Imprint | This part of the site doesn't use cookies.