blob: 4ab28a2864b0e4e7e5a164e9b3956a92bccb3c12 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
<?php
class FreshRSS_Tag extends Minz_Model {
/**
* @var int
*/
private $id = 0;
/**
* @var string
*/
private $name;
/**
* @var array<string,mixed>
*/
private $attributes = [];
/**
* @var int
*/
private $nbEntries = -1;
/**
* @var int
*/
private $nbUnread = -1;
public function __construct(string $name = '') {
$this->_name($name);
}
public function id(): int {
return $this->id;
}
/**
* @param int|string $value
*/
public function _id($value): void {
$this->id = (int)$value;
}
public function name(): string {
return $this->name;
}
public function _name(string $value): void {
$this->name = trim($value);
}
/**
* @phpstan-return ($key is non-empty-string ? mixed : array<string,mixed>)
* @return array<string,mixed>|mixed|null
*/
public function attributes(string $key = '') {
if ($key === '') {
return $this->attributes;
} else {
return $this->attributes[$key] ?? null;
}
}
/** @param string|array<mixed>|bool|int|null $value Value, not HTML-encoded */
public function _attributes(string $key, $value = null): void {
if ($key == '') {
if (is_string($value)) {
$value = json_decode($value, true);
}
if (is_array($value)) {
$this->attributes = $value;
}
} elseif ($value === null) {
unset($this->attributes[$key]);
} else {
$this->attributes[$key] = $value;
}
}
public function nbEntries(): int {
if ($this->nbEntries < 0) {
$tagDAO = FreshRSS_Factory::createTagDao();
$this->nbEntries = $tagDAO->countEntries($this->id()) ?: 0;
}
return $this->nbEntries;
}
/**
* @param string|int $value
*/
public function _nbEntries($value): void {
$this->nbEntries = (int)$value;
}
public function nbUnread(): int {
if ($this->nbUnread < 0) {
$tagDAO = FreshRSS_Factory::createTagDao();
$this->nbUnread = $tagDAO->countNotRead($this->id()) ?: 0;
}
return $this->nbUnread;
}
/**
* @param string|int $value
*/
public function _nbUnread($value): void {
$this->nbUnread = (int)$value;
}
}
|