PHP Classes
elePHPant
Icontem

A real usecase

Recommend this page to a friend!

      PHP Classes blog  >  PHP 7 Anonymous Class...  >  All threads  >  A real usecase  >  (Un) Subscribe thread alerts  
Subject:A real usecase
Summary:One time used value objects
Messages:1
Author:iltar van der berg
Date:2015-10-15 09:36:41
Update:2015-10-15 18:56:18
 

 


  1. A real usecase   Reply   Report abuse  
iltar van der berg - 2015-10-15 18:56:18
One of the usecases where this is useful is a result object to avoid multiple return types.
<?php
interface PingResultInterface
{
public function isSuccessful();
}
?>

Given we have 2 implementations, one would be a ping that is executed before creating the object (value object) and one that's lazy (proxy), they could be made runtime based on certain things:
pastebin.com/LPGaHRCF