Skip to content

Instantly share code, notes, and snippets.

@glenjamin
Created September 28, 2013 23:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save glenjamin/9c3265dc5e6e865f6785 to your computer and use it in GitHub Desktop.
Save glenjamin/9c3265dc5e6e865f6785 to your computer and use it in GitHub Desktop.
<?php
namespace Example\Single;
class AppleList
{
private $data = [];
private $sort = [];
public function __construct(array $data, array $sort)
{
$this->data = $data;
$this->sort = $sort;
}
public function items()
{
foreach ($this->sort as $key) {
yield new Apple($this->data[$key]);
}
}
public function length()
{
return count($this->data);
}
}
class Apple
{
private $id;
public function __construct(array $data) {
$this->id = $data['id'];
}
public function getId()
{
return $this->id;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment