@param CardCollection $cards

@return CardCollection|false
336573
public static function onePair(CardCollection $cards)
    {
        $cards = $cards->switchAceValue();
        $pair = self::nNumberOfCardsInSet($cards, 2);

        if ($pair === null) {
            return false;
        }

        $otherCardsInResult = $cards->diff($pair)
            ->sortByValue()
            ->reverse()
            ->take(3)
        ;

        return $pair->merge($otherCardsInResult);
    }
1207520
public function cardDelete($card_id)
    {
        if (empty($card_id)) {
            $this->setError('缺少错误');

            return false;
        }

        $queryStr            = [];
        $queryStr['card_id'] = $card_id;

        $this->apitype = 'card';
        $this->module  = 'delete';
        $res           = $this->_post('', $queryStr);

        return $res;
    }
531690
public function getCard($cardId)
    {
        $result = $this->wechat->httpPost(self::WECHAT_CARD_LIST_GET_PREFIX, [
            'card_id' => $cardId
        ], [
            'access_token' => $this->wechat->getAccessToken()
        ]);
        return isset($result['errmsg']) && $result['errmsg'] === 'ok' ? $result : false;
    }
307303
public function toChannels($channels, $card)
	{
		$card = array_merge(['channel_uids' => $channels], $card);

		$card['canvas'] = isset($card['canvas']) ? $card['canvas'] : self::DEFAULT_CANVAS;

		return $this->request->send('POST', "/channels/cards", $card);
	}
278893
public function setCardData($cardData)
	{
		$this->validateInputIsCardNumber($cardData);

		$cardData = Request::formatCardNumber($cardData);

		$this->cardData = $cardData;

		return $this;
	}
1138908
public static function createStraightFlush(CardCollection $cards, Hand $hand): self
    {
        $highCard = $cards->sortByValue()->take(-1);
        $definition = sprintf('Straight Flush to %s', $highCard->first()->name());

        return new static(
            self::STRAIGHT_FLUSH,
            [$highCard->first()->value()],
            $cards,
            $definition,
            $hand
        );
    }
448364
public static function straight(CardCollection $cardCollection)
    {
        // a straight has to have a 5 or 10 in
        if ($cardCollection->whereValue(5)->count() === 0 && $cardCollection->whereValue(10)->count() === 0) {
            return false;
        }

        // we only care about the first instance of a card number
        $cardCollection = $cardCollection->uniqueByValue();

        // check with ace == 1
        $check = static::checkForStraight($cardCollection->sortByValue()->unique());
        if ($check !== false) {
            return $check;
        }

        // check with ace == 14
        $check = static::checkForStraight($cardCollection->switchAceValue()->sortByValue()->unique());
        if ($check !== false) {
            return $check;
        }

        return false;
    }
970001
public function getCard( CustomerVault\Card $card )
    {
        $card->setRequiredFields(array(
            'profileID',
            'id'
        ));
        $card->checkRequiredFields();

        $request = new Request(array(
            'method' => Request::GET,
            'uri' => $this->prepareURI("/profiles/" . $card->profileID . "/cards/" . $card->id),
        ));
        $response = $this->client->processRequest($request);
        $response['profileID'] = $card->profileID;

        return new CustomerVault\Card($response);
    }
560628
public function select(...$columns): CollectionInterface
    {
        return $this->map(
            function ($item) use ($columns) {
                $result = [];

                foreach ($columns as $column) {
                    if (isset($item[$column])) {
                        $result[$column] = $item[$column];
                    }
                }

                return $result;
            }
        );
    }
1285994
public function materializeCollection($collection)
    {
        $materializedCollection = new Collection();
        foreach ($collection as $resource) {
            $materializedCollection->add($this->materialize($resource));
        }
        return $materializedCollection;
    }
1254633
function (pack, card) {
    if (cardPacks[pack] && cardPacks[pack].cards[card]) {
      return cardPacks[pack].cards[card];
    }
  }
735406
public function publishCard(CardParams $cardParams)
    {
        $tokenContext = new TokenContext($cardParams->getIdentity(), 'publish');
        $token = $this->accessTokenProvider->getToken($tokenContext);

        $rawSignedModel = $this->generateRawCard(
            CardParams::create(
                [
                    CardParams::Identity       => $token->identity(),
                    CardParams::PrivateKey     => $cardParams->getPrivateKey(),
                    CardParams::PublicKey      => $cardParams->getPublicKey(),
                    CardParams::ExtraFields    => $cardParams->getExtraFields(),
                    CardParams::PreviousCardID => $cardParams->getPreviousCardID(),
                ]
            )
        );

        $card = $this->publishRawSignedModelWithToken($rawSignedModel, $token);

        if (!$this->cardVerifier->verifyCard($card)) {
            throw new CardVerificationException('Validation errors have been detected');
        }

        return $card;
    }
555635
private static function nNumberOfCardsInSet(CardCollection $cards, int $numberOfCardsOfType)
    {
        $judgedHand = $cards
            ->groupBy(function (Card $card) {
                return $card->value();
            })
            ->filter(function (CardCollection $group) use ($numberOfCardsOfType) {
                return $group->count() === $numberOfCardsOfType;
            })
            ->sortBy(function (CardCollection $group) {
                return $group->count();
            })
            ->values()
            ->last()
        ;

        return $judgedHand;
    }
5384
public static function create(array $params)
    {
        $publicKey = $params[self::PublicKey];
        $privateKey = $params[self::PrivateKey];

        $cardParams = new self($publicKey, $privateKey);

        if (array_key_exists(self::Identity, $params)) {
            $cardParams->identity = $params[self::Identity];
        }
        if (array_key_exists(self::PreviousCardID, $params)) {
            $cardParams->previousCardID = $params[self::PreviousCardID];
        }
        if (array_key_exists(self::ExtraFields, $params)) {
            $cardParams->extraFields = $params[self::ExtraFields];
        }

        return $cardParams;
    }
1295380
public function updateCard( CustomerVault\Card $card )
    {
        $card->setRequiredFields(array(
            'profileID',
            'id'
        ));
        $card->checkRequiredFields();
        $card->setRequiredFields(array());
        $card->setOptionalFields(array(
            'cardExpiry',
            'nickName',
            'merchantRefNum',
            'holderName',
            'billingAddressId',
            'defaultCardIndicator',
        ));

        $request = new Request(array(
            'method' => Request::PUT,
            'uri' => $this->prepareURI("/profiles/" . $card->profileID . "/cards/" . $card->id),
            'body' => $card
        ));
        $response = $this->client->processRequest($request);
        $response['profileID'] = $card->profileID;

        return new CustomerVault\Card($response);
    }
197058
public static function createTwoPair(CardCollection $cards, Hand $hand): self
    {
        $cardGroups = $cards->groupByValue();
        $firstCard = $cardGroups->get(0)->first();
        $secondCard = $cardGroups->get(1)->first();
        $kickerCard = $cardGroups->get(2)->first();

        $definition = sprintf(
            'Two Pair - %ss and %ss',
            $firstCard->name(),
            $secondCard->name()
        );

        return new static(
            self::TWO_PAIR,
            [$firstCard->value(), $secondCard->value(), $kickerCard->value()],
            $cards,
            $definition,
            $hand
        );
    }
339133
protected function removeCollection(Collection $collection) {
		$transaction = $this->getTransactionsManager()->get(true);
			
		foreach ($collection as $model) {
			$phalconModel = $this->createTableModel($model);
			$phalconModel->setTransaction($transaction);

			if (! $phalconModel->delete()) {
				$transaction->rollback();
			}
		}

		$transaction->commit();
		return true;
	}