Skip to content

Instantly share code, notes, and snippets.

@glenjamin glenjamin/Single_AppleList.php Secret
Created Sep 28, 2013

Embed
What would you like to do?
<?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
You can’t perform that action at this time.