/** * Gets the associated time-zone rules. * <p> * The rules will always return this offset when queried. * The implementation class is immutable, thread-safe and serializable. * * @return ZoneRules the rules, not null */ public function getRules() { return ZoneRules::ofOffset($this); }
/** * SPI method to get the rules for the zone ID. * <p> * This loads the rules for the specified zone ID. * The provider implementation must validate that the zone ID is valid and * available, throwing a {@code ZoneRulesException} if it is not. * The result of the method in the valid case depends on the caching flag. * <p> * If the provider implementation is not dynamic, then the result of the * method must be the non-null set of rules selected by the ID. * <p> * If the provider implementation is dynamic, then the flag gives the option * of preventing the returned rules from being cached in {@link ZoneId}. * When the flag is true, the provider is permitted to return null, where * null will prevent the rules from being cached in {@code ZoneId}. * When the flag is false, the provider must return non-null rules. * * @param string $zoneId the zone ID as defined by {@code ZoneId}, not null * @param bool $forCaching whether the rules are being queried for caching, * true if the returned rules will be cached by {@code ZoneId}, * false if they will be returned to the user without being cached in {@code ZoneId} * @return ZoneRules the rules, null if {@code forCaching} is true and this * is a dynamic provider that wants to prevent caching in {@code ZoneId}, * otherwise not null * @throws ZoneRulesException if rules cannot be obtained for the zone ID */ protected function provideRules($zoneId, $forCaching) { return ZoneRules::ofOffset(ZoneOffset::ofHours(1)); }