- rand: documentation ( source)
<?php
/** Object responsible for echoing debug data **/
class EchoLogger
{
public function addDebug($data) { echo $data; }
}
/** Object responsible for emailing debug data **/
class EmailLogger
{
public function addDebug($data) { /** Mail your data **/ }
}
class HttpClientService implements \SplSubject
{
private $observers = array();
public function getServiceStatus()
{
// -- SNIP --
$rand = rand(0, 10);
$status = ($rand >= 5) ? 'success' : 'error';
// -- Snip --
return $status;
}
}