for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* @author Oleg Krivtsov <[email protected]>
* @date 10 October 2016
* @copyright (c) 2016, Web Marketing ROI
*/
namespace WebMarketingROI\OptimizelyPHP\Resource\v2;
* An Optimizely campaign metric.
class Metric
{
* The kind of a Metric
* @var string
private $kind;
* The unique identifier for the Metric
* @var integer
private $id;
* Constructor.
public function __construct($options = array())
foreach ($options as $name=>$value) {
switch ($name) {
case 'kind': $this->setKind($value); break;
According to the PSR-2, the body of a case statement must start on the line immediately following the case statement.
switch ($expr) { case "A": doSomething(); //right break; case "B": doSomethingElse(); //wrong break;
}
To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.
As per the PSR-2 coding standard, the break (or other terminating) statement must be on a line of its own.
break
switch ($expr) { case "A": doSomething(); break; //wrong case "B": doSomething(); break; //right case "C:": doSomething(); return true; //right }
case 'id': $this->setId($value); break;
default:
throw new \Exception('Unknown option: ' . $name);
* Returns this object as array.
public function toArray()
$options = array(
'kind' => $this->getKind(),
'id' => $this->getId(),
);
// Remove options with empty values
$cleanedOptions = array();
if ($value!==null)
$cleanedOptions[$name] = $value;
return $cleanedOptions;
public function getKind()
return $this->kind;
public function setKind($kind)
$this->kind = $kind;
public function getId()
return $this->id;
public function setId($id)
$this->id = $id;
According to the PSR-2, the body of a case statement must start on the line immediately following the case statement.
}
To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.