Skip to content

Commit 858c20b

Browse files
committed
refactor(Datasource\Lca\Boaviztapi\Client): factorization
1 parent 8a9ee16 commit 858c20b

File tree

1 file changed

+2
-11
lines changed

1 file changed

+2
-11
lines changed

src/DataSource/Lca/Boaviztapi/Client.php

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -100,20 +100,11 @@ public function get(string $endpoint, array $options = []): array
100100
*/
101101
public function createSource(): bool
102102
{
103-
$source_name = $this->getSourceName();
104103
// create a source in Source
105104
$source = new Source();
106-
$source->getFromDBByCrit([
107-
'name' => $source_name,
108-
]);
109-
if ($source->isNewItem()) {
110-
$id = $source->add([
111-
'name' => $source_name,
112-
]);
113-
return !$source->isNewID($id);
114-
}
105+
$source->getOrCreate([], ['name' => $this->getSourceName()]);
115106

116-
return true;
107+
return (!$source->isNewItem());
117108
}
118109

119110
/**

0 commit comments

Comments
 (0)