PluginProbe
Matomo Analytics – Powerful, Privacy-First Insights for WordPress / 5.13.0
Matomo Analytics – Powerful, Privacy-First Insights for WordPress v5.13.0
5.13.0 5.12.1 5.12.0 5.11.1 5.11.0 5.10.2 5.10.1 trunk 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.3.0 1.3.1 1.3.2 4.0.0 4.0.1 4.0.2 4.0.3 All 83 releases
matomo / app / core / Period / Year.php
Year.php
85 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Matomo - free/libre analytics platform
5 *
6 * @link https://matomo.org
7 * @license https://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
8 */
9 namespace Piwik\Period;
10
11 use Piwik\Date;
12 use Piwik\Period;
13 class Year extends Period
14 {
15 public const PERIOD_ID = 4;
16 protected $label = 'year';
17 /**
18 * Returns the current period as a localized short string
19 *
20 * @return string
21 */
22 public function getLocalizedShortString()
23 {
24 return $this->getLocalizedLongString();
25 }
26 /**
27 * Returns the current period as a localized long string
28 *
29 * @return string
30 */
31 public function getLocalizedLongString()
32 {
33 //"2009"
34 $out = $this->getDateStart()->getLocalized(Date::DATE_FORMAT_YEAR);
35 return $out;
36 }
37 /**
38 * Returns the current period as a string
39 *
40 * @return string
41 */
42 public function getPrettyString()
43 {
44 $out = $this->getDateStart()->toString('Y');
45 return $out;
46 }
47 /**
48 * Generates the subperiods (one for each month of the year)
49 */
50 protected function generate()
51 {
52 if ($this->subperiodsProcessed) {
53 return;
54 }
55 parent::generate();
56 $year = $this->date->toString("Y");
57 for ($i = 1; $i <= 12; $i++) {
58 $this->addSubperiod(new \Piwik\Period\Month(Date::factory("{$year}-{$i}-01")));
59 }
60 }
61 /**
62 * Returns a list of strings representing the current period (one date per month).
63 *
64 * @param string $format
65 * @return array
66 */
67 public function toString($format = 'ignored')
68 {
69 $this->generate();
70 $stringMonth = array();
71 foreach ($this->subperiods as $month) {
72 $stringMonth[] = $month->getDateStart()->toString("Y") . "-" . $month->getDateStart()->toString("m") . "-01";
73 }
74 return $stringMonth;
75 }
76 public function getImmediateChildPeriodLabel()
77 {
78 return 'month';
79 }
80 public function getParentPeriodLabel()
81 {
82 return null;
83 }
84 }
85