-
-
Save glenjamin/9c3265dc5e6e865f6785 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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