@@ 86-99 (lines=14) @@ | ||
83 | * |
|
84 | * @return Account |
|
85 | */ |
|
86 | public function findOrCreateAccount($name, array $data = []) |
|
87 | { |
|
88 | $account = $this->findAccount($name); |
|
89 | ||
90 | if ($account instanceof Account) { |
|
91 | return $account; |
|
92 | } |
|
93 | ||
94 | if (empty($data)) { |
|
95 | $data = ['name' => $name]; |
|
96 | } |
|
97 | ||
98 | return $this->createAccount($data); |
|
99 | } |
|
100 | ||
101 | /** |
|
102 | * Update or create an account. |
|
@@ 109-122 (lines=14) @@ | ||
106 | * |
|
107 | * @return Account |
|
108 | */ |
|
109 | public function updateOrCreateAccount($name, array $data = []) |
|
110 | { |
|
111 | $account = $this->findAccount($name); |
|
112 | ||
113 | if ($account instanceof Account) { |
|
114 | return $this->updateAccount($account->id, $data); |
|
115 | } |
|
116 | ||
117 | if (empty($data)) { |
|
118 | $data = ['name' => $name]; |
|
119 | } |
|
120 | ||
121 | return $this->createAccount($data); |
|
122 | } |
|
123 | } |
|
124 |