what is sugar?

On Monday, 11 April 2016, S.A.N <ua.san.a...@gmail.com> wrote:

> Maybe even more sugar? :)
>
> <?php
>
> class SugarCache
> {
>  // Methode getValueFromDB() called, if its value null
>  public $value ??= $this->getValueFromDB();
>
>  // Methode getValueFromDB() called, if $value not transmitted or null
> value
>  public function __construct($value ??= $this->getValueFromDB())
>  {
>   //...
>  }
>
>  public function getFromCache()
>  {
>   // Methode getValueFromDB() called, once upon init static $value
>   static $value ??= $this->getValueFromDB();
>
>   return $value;
>  }
> }
>

Reply via email to