PluginProbe
MailerLite – WooCommerce integration / 3.1.25
MailerLite – WooCommerce integration v3.1.25
3.1.25 3.1.26 3.1.24 3.1.23 3.1.22 3.1.21 3.1.20 3.1.19 3.1.18 3.1.17 3.1.16 3.1.15 1.8.7 1.8.8 2.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 2.1.0 All 147 releases
woo-mailerlite / includes / common / WooMailerLiteCollection.php

WooMailerLiteCollection.php in MailerLite – WooCommerce integration 3.1.25, at includes/common/WooMailerLiteCollection.php

66 lines 1.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 class WooMailerLiteCollection
4 {
5 /**
6 * @var array $items
7 */
8 public $items = [];
9
10 public function __construct(array $items = [])
11 {
12 $this->items = $items;
13 }
14
15 /**
16 * Collect items
17 * @param array $items
18 * @return void
19 */
20 public function collect(?WooMailerLiteModel $items)
21 {
22 $this->items[] = $items;
23 }
24
25 /**
26 * Return array of items
27 * @return array
28 */
29 public function toArray()
30 {
31 $array = [];
32 foreach ($this->items as $model) {
33 $array[] = $model->attributes;
34 }
35 return $array;
36 }
37
38 /**
39 * Return count of items
40 * @return int
41 */
42 public function count()
43 {
44 return count(array_filter($this->items));
45 }
46
47 public function hasItems()
48 {
49 return $this->count() > 0;
50 }
51
52 public function first()
53 {
54 return $this->items[0];
55 }
56
57 public function last()
58 {
59 return $this->items[$this->count() - 1];
60 }
61
62 public function empty()
63 {
64 $this->items = [];
65 }
66 }