@@ -8,6 +8,30 @@ class PetNameGenerator
88 private static array $ adjectives = ["able " , "above " , "absolute " , "accepted " , "accurate " , "ace " , "active " , "actual " , "adapted " , "adapting " , "adequate " , "adjusted " , "advanced " , "alert " , "alive " , "allowed " , "allowing " , "amazed " , "amazing " , "ample " , "amused " , "amusing " , "apparent " , "apt " , "arriving " , "artistic " , "assured " , "assuring " , "awaited " , "awake " , "aware " , "balanced " , "becoming " , "beloved " , "better " , "big " , "blessed " , "bold " , "boss " , "brave " , "brief " , "bright " , "bursting " , "busy " , "calm " , "capable " , "capital " , "careful " , "caring " , "casual " , "causal " , "central " , "certain " , "champion " , "charmed " , "charming " , "cheerful " , "chief " , "choice " , "civil " , "classic " , "clean " , "clear " , "clever " , "climbing " , "close " , "closing " , "coherent " , "comic " , "communal " , "complete " , "composed " , "concise " , "concrete " , "content " , "cool " , "correct " , "cosmic " , "crack " , "creative " , "credible " , "crisp " , "crucial " , "cuddly " , "cunning " , "curious " , "current " , "cute " , "daring " , "darling " , "dashing " , "dear " , "decent " , "deciding " , "deep " , "definite " , "delicate " , "desired " , "destined " , "devoted " , "direct " , "discrete " , "distinct " , "diverse " , "divine " , "dominant " , "driven " , "driving " , "dynamic " , "eager " , "easy " , "electric " , "elegant " , "emerging " , "eminent " , "enabled " , "enabling " , "endless " , "engaged " , "engaging " , "enhanced " , "enjoyed " , "enormous " , "enough " , "epic " , "equal " , "equipped " , "eternal " , "ethical " , "evident " , "evolved " , "evolving " , "exact " , "excited " , "exciting " , "exotic " , "expert " , "factual " , "fair " , "faithful " , "famous " , "fancy " , "fast " , "feasible " , "fine " , "finer " , "firm " , "first " , "fit " , "fitting " , "fleet " , "flexible " , "flowing " , "fluent " , "flying " , "fond " , "frank " , "free " , "fresh " , "full " , "fun " , "funny " , "game " , "generous " , "gentle " , "genuine " , "giving " , "glad " , "glorious " , "glowing " , "golden " , "good " , "gorgeous " , "grand " , "grateful " , "great " , "growing " , "grown " , "guided " , "guiding " , "handy " , "happy " , "hardy " , "harmless " , "healthy " , "helped " , "helpful " , "helping " , "heroic " , "hip " , "holy " , "honest " , "hopeful " , "hot " , "huge " , "humane " , "humble " , "humorous " , "ideal " , "immense " , "immortal " , "immune " , "improved " , "in " , "included " , "infinite " , "informed " , "innocent " , "inspired " , "integral " , "intense " , "intent " , "internal " , "intimate " , "inviting " , "joint " , "just " , "keen " , "key " , "kind " , "knowing " , "known " , "large " , "lasting " , "leading " , "learning " , "legal " , "legible " , "lenient " , "liberal " , "light " , "liked " , "literate " , "live " , "living " , "logical " , "loved " , "loving " , "loyal " , "lucky " , "magical " , "magnetic " , "main " , "major " , "many " , "massive " , "master " , "mature " , "maximum " , "measured " , "meet " , "merry " , "mighty " , "mint " , "model " , "modern " , "modest " , "moral " , "more " , "moved " , "moving " , "musical " , "mutual " , "national " , "native " , "natural " , "nearby " , "neat " , "needed " , "neutral " , "new " , "next " , "nice " , "noble " , "normal " , "notable " , "noted " , "novel " , "obliging " , "on " , "one " , "open " , "optimal " , "optimum " , "organic " , "oriented " , "outgoing " , "patient " , "peaceful " , "perfect " , "pet " , "picked " , "pleasant " , "pleased " , "pleasing " , "poetic " , "polished " , "polite " , "popular " , "positive " , "possible " , "powerful " , "precious " , "precise " , "premium " , "prepared " , "present " , "pretty " , "primary " , "prime " , "pro " , "probable " , "profound " , "promoted " , "prompt " , "proper " , "proud " , "proven " , "pumped " , "pure " , "quality " , "quick " , "quiet " , "rapid " , "rare " , "rational " , "ready " , "real " , "refined " , "regular " , "related " , "relative " , "relaxed " , "relaxing " , "relevant " , "relieved " , "renewed " , "renewing " , "resolved " , "rested " , "rich " , "right " , "robust " , "romantic " , "ruling " , "sacred " , "safe " , "saved " , "saving " , "secure " , "select " , "selected " , "sensible " , "set " , "settled " , "settling " , "sharing " , "sharp " , "shining " , "simple " , "sincere " , "singular " , "skilled " , "smart " , "smashing " , "smiling " , "smooth " , "social " , "solid " , "sought " , "sound " , "special " , "splendid " , "square " , "stable " , "star " , "steady " , "sterling " , "still " , "stirred " , "stirring " , "striking " , "strong " , "stunning " , "subtle " , "suitable " , "suited " , "summary " , "sunny " , "super " , "superb " , "supreme " , "sure " , "sweeping " , "sweet " , "talented " , "teaching " , "tender " , "thankful " , "thorough " , "tidy " , "tight " , "together " , "tolerant " , "top " , "topical " , "tops " , "touched " , "touching " , "tough " , "true " , "trusted " , "trusting " , "trusty " , "ultimate " , "unbiased " , "uncommon " , "unified " , "unique " , "united " , "up " , "upright " , "upward " , "usable " , "useful " , "valid " , "valued " , "vast " , "verified " , "viable " , "vital " , "vocal " , "wanted " , "warm " , "wealthy " , "welcome " , "welcomed " , "well " , "whole " , "willing " , "winning " , "wired " , "wise " , "witty " , "wondrous " , "workable " , "working " , "worthy " ];
99 private static array $ animals = ["ox " , "ant " , "ape " , "asp " , "bat " , "bee " , "boa " , "bug " , "cat " , "cod " , "cow " , "cub " , "doe " , "dog " , "eel " , "eft " , "elf " , "elk " , "emu " , "ewe " , "fly " , "fox " , "gar " , "gnu " , "hen " , "hog " , "imp " , "jay " , "kid " , "kit " , "koi " , "lab " , "man " , "owl " , "pig " , "pug " , "pup " , "ram " , "rat " , "ray " , "yak " , "bass " , "bear " , "bird " , "boar " , "buck " , "bull " , "calf " , "chow " , "clam " , "colt " , "crab " , "crow " , "dane " , "deer " , "dodo " , "dory " , "dove " , "drum " , "duck " , "fawn " , "fish " , "flea " , "foal " , "fowl " , "frog " , "gnat " , "goat " , "grub " , "gull " , "hare " , "hawk " , "ibex " , "joey " , "kite " , "kiwi " , "lamb " , "lark " , "lion " , "loon " , "lynx " , "mako " , "mink " , "mite " , "mole " , "moth " , "mule " , "mutt " , "newt " , "orca " , "oryx " , "pika " , "pony " , "puma " , "seal " , "shad " , "slug " , "sole " , "stag " , "stud " , "swan " , "tahr " , "teal " , "tick " , "toad " , "tuna " , "wasp " , "wolf " , "worm " , "wren " , "yeti " , "adder " , "akita " , "alien " , "aphid " , "bison " , "boxer " , "bream " , "bunny " , "burro " , "camel " , "chimp " , "civet " , "cobra " , "coral " , "corgi " , "crane " , "dingo " , "drake " , "eagle " , "egret " , "filly " , "finch " , "gator " , "gecko " , "ghost " , "ghoul " , "goose " , "guppy " , "heron " , "hippo " , "horse " , "hound " , "husky " , "hyena " , "koala " , "krill " , "leech " , "lemur " , "liger " , "llama " , "louse " , "macaw " , "midge " , "molly " , "moose " , "moray " , "mouse " , "panda " , "perch " , "prawn " , "quail " , "racer " , "raven " , "rhino " , "robin " , "satyr " , "shark " , "sheep " , "shrew " , "skink " , "skunk " , "sloth " , "snail " , "snake " , "snipe " , "squid " , "stork " , "swift " , "swine " , "tapir " , "tetra " , "tiger " , "troll " , "trout " , "viper " , "wahoo " , "whale " , "zebra " , "alpaca " , "amoeba " , "baboon " , "badger " , "beagle " , "bedbug " , "beetle " , "bengal " , "bobcat " , "caiman " , "cattle " , "cicada " , "collie " , "condor " , "cougar " , "coyote " , "dassie " , "donkey " , "dragon " , "earwig " , "falcon " , "feline " , "ferret " , "gannet " , "gibbon " , "glider " , "goblin " , "gopher " , "grouse " , "guinea " , "hermit " , "hornet " , "iguana " , "impala " , "insect " , "jackal " , "jaguar " , "jennet " , "kitten " , "kodiak " , "lizard " , "locust " , "maggot " , "magpie " , "mammal " , "mantis " , "marlin " , "marmot " , "marten " , "martin " , "mayfly " , "minnow " , "monkey " , "mullet " , "muskox " , "ocelot " , "oriole " , "osprey " , "oyster " , "parrot " , "pigeon " , "piglet " , "poodle " , "possum " , "python " , "quagga " , "rabbit " , "raptor " , "rodent " , "roughy " , "salmon " , "sawfly " , "serval " , "shiner " , "shrimp " , "spider " , "sponge " , "tarpon " , "thrush " , "tomcat " , "toucan " , "turkey " , "turtle " , "urchin " , "vervet " , "walrus " , "weasel " , "weevil " , "wombat " , "anchovy " , "anemone " , "bluejay " , "buffalo " , "bulldog " , "buzzard " , "caribou " , "catfish " , "chamois " , "cheetah " , "chicken " , "chigger " , "cowbird " , "crappie " , "crawdad " , "cricket " , "dogfish " , "dolphin " , "firefly " , "garfish " , "gazelle " , "gelding " , "giraffe " , "gobbler " , "gorilla " , "goshawk " , "grackle " , "griffon " , "grizzly " , "grouper " , "gryphon " , "haddock " , "hagfish " , "halibut " , "hamster " , "herring " , "jackass " , "javelin " , "jawfish " , "jaybird " , "katydid " , "ladybug " , "lamprey " , "lemming " , "leopard " , "lioness " , "lobster " , "macaque " , "mallard " , "mammoth " , "manatee " , "mastiff " , "meerkat " , "mollusk " , "monarch " , "mongrel " , "monitor " , "monster " , "mudfish " , "muskrat " , "mustang " , "narwhal " , "oarfish " , "octopus " , "opossum " , "ostrich " , "panther " , "peacock " , "pegasus " , "pelican " , "penguin " , "phoenix " , "piranha " , "polecat " , "primate " , "quetzal " , "raccoon " , "rattler " , "redbird " , "redfish " , "reptile " , "rooster " , "sawfish " , "sculpin " , "seagull " , "skylark " , "snapper " , "spaniel " , "sparrow " , "sunbeam " , "sunbird " , "sunfish " , "tadpole " , "termite " , "terrier " , "unicorn " , "vulture " , "wallaby " , "walleye " , "warthog " , "whippet " , "wildcat " , "aardvark " , "airedale " , "albacore " , "anteater " , "antelope " , "arachnid " , "barnacle " , "basilisk " , "blowfish " , "bluebird " , "bluegill " , "bonefish " , "bullfrog " , "cardinal " , "chipmunk " , "cockatoo " , "crawfish " , "crayfish " , "dinosaur " , "doberman " , "duckling " , "elephant " , "escargot " , "flamingo " , "flounder " , "foxhound " , "glowworm " , "goldfish " , "grubworm " , "hedgehog " , "honeybee " , "hookworm " , "humpback " , "kangaroo " , "killdeer " , "kingfish " , "labrador " , "lacewing " , "ladybird " , "lionfish " , "longhorn " , "mackerel " , "malamute " , "marmoset " , "mastodon " , "moccasin " , "mongoose " , "monkfish " , "mosquito " , "pangolin " , "parakeet " , "pheasant " , "pipefish " , "platypus " , "polliwog " , "porpoise " , "reindeer " , "ringtail " , "sailfish " , "scorpion " , "seahorse " , "seasnail " , "sheepdog " , "shepherd " , "silkworm " , "squirrel " , "stallion " , "starfish " , "starling " , "stingray " , "stinkbug " , "sturgeon " , "terrapin " , "titmouse " , "tortoise " , "treefrog " , "werewolf " , "woodcock " ];
1010
11+ /**
12+ * Get a random animal name
13+ */
14+ private static function animal (): string
15+ {
16+ return self ::$ animals [array_rand (self ::$ animals )];
17+ }
18+
19+ /**
20+ * Get a random adjective name
21+ */
22+ private static function adjective (): string
23+ {
24+ return self ::$ adjectives [array_rand (self ::$ adjectives )];
25+ }
26+
27+ /**
28+ * Get a random adverb name
29+ */
30+ private static function adverb (): string
31+ {
32+ return self ::$ adverbs [array_rand (self ::$ adverbs )];
33+ }
34+
1135 /**
1236 * Generates a random pet name.
1337 *
@@ -17,18 +41,21 @@ class PetNameGenerator
1741 */
1842 public static function generate (int $ wordCount = 1 , string $ separator = '- ' ): string
1943 {
44+ if ($ wordCount <= 1 ) {
45+ return self ::animal ();
46+ } elseif ($ wordCount === 2 ) {
47+ return self ::adjective () . $ separator . self ::animal ();
48+ }
49+
2050 $ words = [];
2151
22- for ($ i = 0 ; $ i < $ wordCount ; $ i ++) {
23- if ($ i % 3 === 0 ) {
24- $ words [] = self ::$ adverbs [array_rand (self ::$ adverbs )];
25- } elseif ($ i % 3 === 1 ) {
26- $ words [] = self ::$ adjectives [array_rand (self ::$ adjectives )];
27- } else {
28- $ words [] = self ::$ animals [array_rand (self ::$ animals )];
29- }
52+ for ($ i = 0 ; $ i < $ wordCount - 2 ; $ i ++) {
53+ $ words [] = self ::adverb ();
3054 }
3155
56+ $ words [] = self ::adjective ();
57+ $ words [] = self ::animal ();
58+
3259 return implode ($ separator , $ words );
3360 }
3461}
0 commit comments