1<?php
2
3namespace Sabre\VObject\Component;
4
5use Sabre\VObject;
6
7/**
8 * The VTimeZone component.
9 *
10 * This component adds functionality to a component, specific for VTIMEZONE
11 * components.
12 *
13 * @copyright Copyright (C) fruux GmbH (https://fruux.com/)
14 * @author Evert Pot (http://evertpot.com/)
15 * @license http://sabre.io/license/ Modified BSD License
16 */
17class VTimeZone extends VObject\Component
18{
19    /**
20     * Returns the PHP DateTimeZone for this VTIMEZONE component.
21     *
22     * If we can't accurately determine the timezone, this method will return
23     * UTC.
24     *
25     * @return \DateTimeZone
26     */
27    public function getTimeZone()
28    {
29        return VObject\TimeZoneUtil::getTimeZone((string) $this->TZID, $this->root);
30    }
31
32    /**
33     * A simple list of validation rules.
34     *
35     * This is simply a list of properties, and how many times they either
36     * must or must not appear.
37     *
38     * Possible values per property:
39     *   * 0 - Must not appear.
40     *   * 1 - Must appear exactly once.
41     *   * + - Must appear at least once.
42     *   * * - Can appear any number of times.
43     *   * ? - May appear, but not more than once.
44     *
45     * @var array
46     */
47    public function getValidationRules()
48    {
49        return [
50            'TZID' => 1,
51
52            'LAST-MODIFIED' => '?',
53            'TZURL' => '?',
54
55            // At least 1 STANDARD or DAYLIGHT must appear.
56            //
57            // The validator is not specific yet to pick this up, so these
58            // rules are too loose.
59            'STANDARD' => '*',
60            'DAYLIGHT' => '*',
61        ];
62    }
63}
64