public function deposit(Coin $coin) { $accounts = Analyze::start($coin->getSentence()); foreach ($accounts as $account) { if (strlen($account->getName()) > 5) { $this->store->store($account->getName(), $account->getAmount()); } } }
/** * 储存单值以及 多值 * * @param Coin $coin * @return void */ public function store(Coin $coin) { $value = $coin->getAccount(); $key = $coin->getKey(); if ($this->client instanceof Client) { $value = $value == null ? $this->value : $value; return $this->client->set($key, serialize($value)); } throw new CanNotStoreException(); }
/** * push a coin in suggest bank * * @param $coin * @throws Exception * @return bool */ public function push($coin = []) { if (!isset($coin['name']) or !isset($coin['data'])) { throw new Exception('Data parse error'); } $coin = Coin::parse($coin); $bank = $this->bank; return $bank->deposit($coin); }