Core  3.2
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
Class.AccountList.php
Go to the documentation of this file.
1 <?php
2 /*
3  * @author Anakeen
4  * @package FDL
5 */
6 /**
7  * Account list class
8  *
9  * @author Anakeen
10  * @version $Id: $
11  * @package FDL
12  */
13 /**
14  */
15 class AccountList implements Iterator, Countable
16 {
17  /**
18  * @var null|SearchAccount
19  */
20  private $accountsData = null;
21  /**
22  * @var null|Account
23  */
24  private $currentAccount = null;
25  private $currentIndex = 0;
26 
27  private $init = false;
28  public $length = 0;
29 
30  public function __construct(Array $data)
31  {
32  $this->accountsData = $data;
33  $this->length = count($this->accountsData);
34  $this->initSearch();
35  }
36  /**
37  * get number of returned documents
38  * can be upper of real length due to callback map
39  * @return int
40  */
41  public function count()
42  {
43  return $this->length;
44  }
45  private function initSearch()
46  {
47 
48  $this->currentIndex = 0;
49  $this->currentAccount = new Account();
50  }
51 
52  private function getCurrentAccount()
53  {
54  if (empty($this->accountsData[$this->currentIndex])) return null;
55  $this->currentAccount->affect($this->accountsData[$this->currentIndex]);
56  return $this->currentAccount;
57  }
58 
59  public function rewind()
60  {
61  $this->initSearch();
62  }
63  /**
64  * @return void
65  */
66  public function next()
67  {
68  $this->currentIndex++;
69  }
70 
71  public function key()
72  {
73  return $this->currentAccount->id;
74  }
75  /**
76  * @return \Account|null
77  */
78  public function current()
79  {
80  return $this->getCurrentAccount();
81  }
82  /**
83  * @return bool
84  */
85  public function valid()
86  {
87  return (!empty($this->accountsData[$this->currentIndex]));
88  }
89 }
90 ?>
__construct(Array $data)
$data
← centre documentaire © anakeen