initial
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace MightyPork\Utils;
|
||||
|
||||
use MightyPork\Exceptions\NotExistException;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
* Improved collection with object access to fields
|
||||
*/
|
||||
class ObjCollection extends Collection
|
||||
{
|
||||
public function __get($name)
|
||||
{
|
||||
if (isset($this[$name])) return $this[$name];
|
||||
|
||||
throw new NotExistException("No '$name' in collection.");
|
||||
}
|
||||
|
||||
public function __isset($name)
|
||||
{
|
||||
return isset($this[$name]);
|
||||
}
|
||||
|
||||
public function __set($name, $value)
|
||||
{
|
||||
$this[$name] = $value;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user