Sha256: 87866ca4b041980e42a9edcbd4bd5675f66f2fe614226d7b4702f41c77d7c952
Contents?: true
Size: 673 Bytes
Versions: 29
Compression:
Stored size: 673 Bytes
Contents
<?php class Robot { protected $name = null; protected $alphabet = ''; public function __construct() { $this->alphabet = array_flip(str_split('ABCDEFGHIJKLMNOPQRSTUVWXYZ')); } public function getName() { if (is_null($this->name)) { $this->name = sprintf('%s%s', $this->getPrefix(), $this->getSuffix()); } return $this->name; } protected function getPrefix() { return implode('', array_rand($this->alphabet, 2)); } protected function getSuffix() { return strval(rand(100, 999)); } public function reset() { $this->name = null; } }
Version data entries
29 entries across 29 versions & 1 rubygems