{"id":49296,"date":"2024-12-02T17:41:57","date_gmt":"2024-12-02T09:41:57","guid":{"rendered":"https:\/\/fwq.ai\/blog\/49296\/"},"modified":"2024-12-02T17:41:57","modified_gmt":"2024-12-02T09:41:57","slug":"%e4%b8%80%e5%89%af%e7%ba%b8%e7%89%8c","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/49296\/","title":{"rendered":"\u4e00\u526f\u7eb8\u724c"},"content":{"rendered":"<p><b><\/b> <\/p>\n<h1>\u4e00\u526f\u7eb8\u724c<\/h1>\n<p><span style=\"cursor: pointer\"><i><\/i>\u6536\u85cf<\/span> <\/p>\n<p>\u672c\u7bc7\u6587\u7ae0\u7ed9\u5927\u5bb6\u5206\u4eab\u300a\u4e00\u526f\u7eb8\u724c\u300b\uff0c\u8986\u76d6\u4e86\u6587\u7ae0\u7684\u5e38\u89c1\u57fa\u7840\u77e5\u8bc6\uff0c\u5176\u5b9e\u4e00\u4e2a\u8bed\u8a00\u7684\u5168\u90e8\u77e5\u8bc6\u70b9\u4e00\u7bc7\u6587\u7ae0\u662f\u4e0d\u53ef\u80fd\u8bf4\u5b8c\u7684\uff0c\u4f46\u5e0c\u671b\u901a\u8fc7\u8fd9\u4e9b\u95ee\u9898\uff0c\u8ba9\u8bfb\u8005\u5bf9\u81ea\u5df1\u7684\u638c\u63e1\u7a0b\u5ea6\u6709\u4e00\u5b9a\u7684\u8ba4\u8bc6(B \u6570)\uff0c\u4ece\u800c\u5f25\u8865\u81ea\u5df1\u7684\u4e0d\u8db3\uff0c\u66f4\u597d\u7684\u638c\u63e1\u5b83\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241126\/173261094367458b7f206f4.jpg\" class=\"aligncenter\" title=\"\u4e00\u526f\u7eb8\u724c\u63d2\u56fe\" alt=\"\u4e00\u526f\u7eb8\u724c\u63d2\u56fe\" \/><\/p>\n<p>\u6211\u6700\u8fd1\u4e00\u76f4\u5728\u4e0e verbs \u548c livewire \u5408\u4f5c\uff0c\u5e76\u8ba4\u4e3a\u5c1d\u8bd5\u521b\u5efa\u4e00\u4e9b\u6211\u559c\u6b22\u73a9\u7684\u7eb8\u724c\u6e38\u620f\u662f\u4e00\u4e2a\u6709\u8da3\u7684\u5b9e\u9a8c\u3002<\/p>\n<p>\u4e3a\u4e86\u4fc3\u8fdb\u8fd9\u4e00\u70b9\uff0c\u6211\u9700\u8981\u5b9a\u4e49\u4e00\u526f\u5361\u7247\uff0c\u6211\u53ef\u4ee5\u5728\u4e4b\u540e\u4ece\u4e8b\u7684\u4efb\u4f55\u9879\u76ee\u4e2d\u4f7f\u7528\u5b83\u3002<\/p>\n<p>\u4e00\u526f\u724c\u9700\u8981\u5305\u542b card\u3001deck \u548c cardcollection \u7c7b\u3002\u4e00\u5f20\u724c\u5e94\u6709\u82b1\u8272\u548c\u6570\u503c\uff0c\u4e00\u526f\u724c\u5e94\u7531 52 \u5f20\u724c\u7ec4\u6210\u3002\u56e0\u4e3a\u82b1\u8272\u548c\u6570\u503c\u90fd\u662f\u4e3a\u4e00\u526f\u724c\u5b9a\u4e49\u7684\uff0c\u6240\u4ee5\u6211\u53ef\u4ee5\u4f7f\u7528\u679a\u4e3e\u6765\u8868\u793a\u724c\u7684\u5c5e\u6027\u3002<\/p>\n<p>cardcollection \u7c7b\u5141\u8bb8\u6211\u4ee5 verbs \u72b6\u6001\u5b89\u5168\u5730\u5b58\u50a8\u5361\u7247\u96c6\u5408\u3002<\/p>\n<pre>&lt;?php\n\/\/ cards\/enums\/suit.php\n\ndeclare(strict_types=1);\n\nnamespace cards\\enums;\n\nenum suit: string\n{\n    case clubs = 'clubs';\n    case diamonds = 'diamonds';\n    case hearts = 'hearts';\n    case spades = 'spades';\n}\n<\/pre>\n<pre>&lt;?php\n\/\/ cards\/enums\/value.php\n\ndeclare(strict_types=1);\n\nnamespace cards\\enums;\n\nenum value: string\n{\n    case two = 'two';\n    case three = 'three';\n    case four = 'four';\n    case five = 'five';\n    case six = 'six';\n    case seven = 'seven';\n    case eight = 'eight';\n    case nine = 'nine';\n    case ten = 'ten';\n    case jack = 'jack';\n    case queen = 'queen';\n    case king = 'king';\n    case ace = 'ace';\n}\n<\/pre>\n<pre>&lt;?php\n\/\/ cards\/card.php\n\ndeclare(strict_types=1);\n\nnamespace cards;\n\nuse cards\\enums\\suit;\nuse cards\\enums\\value;\n\nfinal readonly class card\n{\n    public function __construct(\n        public suit $suit,\n        public value $value,\n    ) {}\n}\n<\/pre>\n<pre>&lt;?php\n\/\/ cards\/cardcollection.php\n\ndeclare(strict_types=1);\n\nnamespace cards;\n\nuse illuminate\\support\\collection;\nuse symfony\\component\\serializer\\normalizer\\denormalizerinterface;\nuse symfony\\component\\serializer\\normalizer\\normalizerinterface;\nuse thunk\\verbs\\serializedbyverbs;\n\nclass cardcollection extends collection implements serializedbyverbs\n{\n    public static function deserializeforverbs(mixed $data, denormalizerinterface $denormalizer): static\n    {\n        return static::make($data)\n            -&gt;map(fn($serialized) =&gt; card::deserializeforverbs($serialized, $denormalizer));\n    }\n\n    public function serializeforverbs(normalizerinterface $normalizer): string|array\n    {\n        return $this-&gt;map(fn(card $card) =&gt; $card-&gt;serializeforverbs($normalizer))-&gt;tojson();\n    }\n}\n<\/pre>\n<pre>&lt;?php\n\/\/ Cards\/Deck.php\n\ndeclare(strict_types=1);\n\nnamespace Cards;\n\nuse Cards\\Enums\\Suit;\nuse Cards\\Enums\\Value;\n\nfinal class Deck\n{\n    public CardCollection $cards;\n\n    public function __construct()\n    {\n        $this-&gt;cards = CardCollection::make([]);\n\n        collect(CardSuit::cases())\n            -&gt;each(function (CardSuit $suit): void {\n                collect(CardValue::cases())\n                    -&gt;each(function (CardValue $value) use ($suit): void {\n                        $this-&gt;cards-&gt;push(new Card($suit, $value));\n                    });\n            });\n\n        $this-&gt;shuffle();\n    }\n\n    public function shuffle(): void\n    {\n        $this-&gt;cards = $this-&gt;cards\n            -&gt;shuffle()\n            -&gt;reverse();\n    }\n\n    public function deal(): ?Card\n    {\n        if (0 === $this-&gt;cards-&gt;count()) {\n            return null;\n        }\n\n        return $this-&gt;cards-&gt;pop();\n    }\n\n    public function remainingCards(): int\n    {\n        return $this-&gt;cards-&gt;count();\n    }\n}\n<\/pre>\n<p>\u4eca\u5929\u5173\u4e8e\u300a\u4e00\u526f\u7eb8\u724c\u300b\u7684\u5185\u5bb9\u4ecb\u7ecd\u5c31\u5230\u6b64\u7ed3\u675f\uff0c\u5982\u679c\u6709\u4ec0\u4e48\u7591\u95ee\u6216\u8005\u5efa\u8bae\uff0c\u53ef\u4ee5\u5728\u7c73\u4e91\u516c\u4f17\u53f7\u4e0b\u591a\u591a\u56de\u590d\u4ea4\u6d41\uff1b\u6587\u4e2d\u82e5\u6709\u4e0d\u6b63\u4e4b\u5904\uff0c\u4e5f\u5e0c\u671b\u56de\u590d\u7559\u8a00\u4ee5\u544a\u77e5\uff01<\/p>\n<p> \u7248\u672c\u58f0\u660e \u672c\u6587\u8f6c\u8f7d\u4e8e\uff1adev.to \u5982\u6709\u4fb5\u72af\uff0c\u8bf7\u8054\u7cfb \u5220\u9664<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u526f\u7eb8\u724c \u6536\u85cf \u672c\u7bc7\u6587\u7ae0\u7ed9\u5927\u5bb6\u5206\u4eab\u300a\u4e00\u526f\u7eb8\u724c\u300b\uff0c\u8986\u76d6\u4e86\u6587\u7ae0\u7684\u5e38\u89c1\u57fa\u7840\u77e5\u8bc6\uff0c\u5176\u5b9e\u4e00\u4e2a\u8bed\u8a00\u7684\u5168\u90e8\u77e5\u8bc6\u70b9\u4e00\u7bc7\u6587\u7ae0\u662f\u4e0d\u53ef\u80fd\u8bf4\u5b8c\u7684\uff0c\u4f46\u5e0c\u671b\u901a\u8fc7\u8fd9\u4e9b\u95ee\u9898\uff0c\u8ba9\u8bfb\u8005\u5bf9\u81ea\u5df1\u7684\u638c\u63e1\u7a0b\u5ea6\u6709\u4e00\u5b9a\u7684\u8ba4\u8bc6(B \u6570)\uff0c\u4ece\u800c\u5f25\u8865\u81ea\u5df1\u7684\u4e0d\u8db3\uff0c\u66f4\u597d\u7684\u638c\u63e1\u5b83\u3002 \u6211\u6700\u8fd1\u4e00\u76f4\u5728\u4e0e verbs \u548c livewire \u5408\u4f5c\uff0c\u5e76\u8ba4\u4e3a\u5c1d\u8bd5\u521b\u5efa\u4e00\u4e9b\u6211\u559c\u6b22\u73a9\u7684\u7eb8\u724c\u6e38\u620f\u662f\u4e00\u4e2a\u6709\u8da3\u7684\u5b9e\u9a8c\u3002 \u4e3a\u4e86\u4fc3\u8fdb\u8fd9\u4e00\u70b9\uff0c\u6211\u9700\u8981\u5b9a\u4e49\u4e00\u526f\u5361\u7247\uff0c\u6211\u53ef\u4ee5\u5728\u4e4b\u540e\u4ece\u4e8b\u7684\u4efb\u4f55\u9879\u76ee\u4e2d\u4f7f\u7528\u5b83\u3002 \u4e00\u526f\u724c\u9700\u8981\u5305\u542b card\u3001deck \u548c cardcollection \u7c7b\u3002\u4e00\u5f20\u724c\u5e94\u6709\u82b1\u8272\u548c\u6570\u503c\uff0c\u4e00\u526f\u724c\u5e94\u7531 52 \u5f20\u724c\u7ec4\u6210\u3002\u56e0\u4e3a\u82b1\u8272\u548c\u6570\u503c\u90fd\u662f\u4e3a\u4e00\u526f\u724c\u5b9a\u4e49\u7684\uff0c\u6240\u4ee5\u6211\u53ef\u4ee5\u4f7f\u7528\u679a\u4e3e\u6765\u8868\u793a\u724c\u7684\u5c5e\u6027\u3002 cardcollection \u7c7b\u5141\u8bb8\u6211\u4ee5 verbs \u72b6\u6001\u5b89\u5168\u5730\u5b58\u50a8\u5361\u7247\u96c6\u5408\u3002 &lt;?php \/\/ cards\/enums\/suit.php declare(strict_types=1); namespace cards\\enums; enum suit: string { case clubs = &#8216;clubs&#8217;; case diamonds = &#8216;diamonds&#8217;; case hearts = &#8216;hearts&#8217;; case spades = &#8216;spades&#8217;; } &lt;?php \/\/ cards\/enums\/value.php declare(strict_types=1); namespace cards\\enums; enum [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-49296","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/49296","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=49296"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/49296\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=49296"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=49296"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=49296"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}