for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Iatstuti\SimpleMenu\Traits;
/**
* Trait to handle retrieving all or a specific option.
*
* @package Iatstuti\SimpleMenu
* @copyright 2016 IATSTUTI
* @author Michael Dyrynda <[email protected]>
*/
trait ObjectOptions
{
* Return this menu's options, or a single option as specified.
* @param null $key
* @return array
public function options($key = null)
if (! is_null($key) && array_key_exists($key, $this->options)) {
return $this->options[$key];
options
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
class MyClass { } $x = new MyClass(); $x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:
class MyClass { public $foo; } $x = new MyClass(); $x->foo = true;
}
return $this->options;
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: