예제 #1
0
 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());
         }
     }
 }
예제 #2
0
 /**
  * 储存单值以及 多值
  *
  * @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();
 }
예제 #3
0
 /**
  * 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);
 }