Skip to content

Commit 70f385b

Browse files
committed
Extract Tracker::listing()
1 parent 8132e67 commit 70f385b

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

src/Redmine/Api/Tracker.php

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -109,15 +109,7 @@ public function listing($forceUpdate = false)
109109
{
110110
@trigger_error('`' . __METHOD__ . '()` is deprecated since v2.7.0, use `' . __CLASS__ . '::listNames()` instead.', E_USER_DEPRECATED);
111111

112-
if (empty($this->trackers) || $forceUpdate) {
113-
$this->trackers = $this->list();
114-
}
115-
$ret = [];
116-
foreach ($this->trackers['trackers'] as $e) {
117-
$ret[$e['name']] = (int) $e['id'];
118-
}
119-
120-
return $ret;
112+
return $this->doListing($forceUpdate);
121113
}
122114

123115
/**
@@ -129,11 +121,27 @@ public function listing($forceUpdate = false)
129121
*/
130122
public function getIdByName($name)
131123
{
132-
$arr = $this->listing();
124+
$arr = $this->doListing(false);
125+
133126
if (!isset($arr[$name])) {
134127
return false;
135128
}
136129

137130
return $arr[(string) $name];
138131
}
132+
133+
private function doListing(bool $forceUpdate)
134+
{
135+
if (empty($this->trackers) || $forceUpdate) {
136+
$this->trackers = $this->list();
137+
}
138+
139+
$ret = [];
140+
141+
foreach ($this->trackers['trackers'] as $e) {
142+
$ret[$e['name']] = (int) $e['id'];
143+
}
144+
145+
return $ret;
146+
}
139147
}

0 commit comments

Comments
 (0)