PluginProbe
VikBooking Hotel Booking Engine & PMS / 1.8.16
VikBooking Hotel Booking Engine & PMS v1.8.16
1.8.16 1.8.15 1.8.14 1.8.13 1.8.12 1.8.11 1.8.10 1.8.9 1.8.6 1.8.7 1.8.8 trunk 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.6.9 1.7.0 1.7.1 1.7.2 All 37 releases
← All changes | libraries/adapter/sms/status.php +172 -0 1.6.1 → 1.8.16 View file →
@@ -1,0 +1,172 @@
1 +<?php
2 +/**
3 + * @package VikWP - Libraries
4 + * @subpackage adapter.sms
5 + * @author E4J s.r.l.
6 + * @copyright Copyright (C) 2023 E4J s.r.l. All Rights Reserved.
7 + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
8 + * @link https://vikwp.com
9 + */
10 +
11 +// No direct access
12 +defined('ABSPATH') or die('No script kiddies please!');
13 +
14 +/**
15 + * This class is used to wrap the details of
16 + * a sms response.
17 + *
18 + * @since 10.1.30
19 + */
20 +class JSmsStatus
21 +{
22 + /**
23 + * The sms status.
24 + *
25 + * @var boolean
26 + */
27 + protected $status = false;
28 +
29 + /**
30 + * Property used to track what is happening
31 + * during the validation of the dispatch.
32 + *
33 + * @var string
34 + */
35 + protected $log = '';
36 +
37 + /**
38 + * Additional data.
39 + *
40 + * @var array
41 + */
42 + protected $data = array();
43 +
44 + /**
45 + * Magic method to access the property of the object.
46 + *
47 + * @param string $name The property name.
48 + *
49 + * @return mixed The property value.
50 + */
51 + public function __get($name)
52 + {
53 + if (isset($this->{$name}))
54 + {
55 + return $this->{$name};
56 + }
57 + else if (isset($this->data[$name]))
58 + {
59 + return $this->data[$name];
60 + }
61 +
62 + return null;
63 + }
64 +
65 + /**
66 + * Checks whether the notification was successful.
67 + *
68 + * @return boolean True on success, otherwise false.
69 + */
70 + public function isVerified()
71 + {
72 + return $this->status;
73 + }
74 +
75 + /**
76 + * Marks the notification status as verified or failed.
77 + *
78 + * @param boolean $status True if verified (default).
79 + *
80 + * @return self This object to support chaining.
81 + */
82 + public function verified($status = true)
83 + {
84 + $this->status = (bool) $status;
85 +
86 + return $this;
87 + }
88 +
89 + /**
90 + * Tracks the given log.
91 + *
92 + * @param mixed $log A string or a non-scalar value.
93 + * An array will be logged using print_r.
94 + *
95 + * @return self This object to support chaining.
96 + */
97 + public function setLog($log)
98 + {
99 + if (!is_scalar($log))
100 + {
101 + // use print_r for non scalar logs
102 + $log = print_r($log, true);
103 + }
104 +
105 + $this->log = $log;
106 +
107 + return $this;
108 + }
109 +
110 + /**
111 + * Appends the given log to the existing string.
112 + *
113 + * @param mixed $log A string or a non-scalar value.
114 + * An array will be logged using print_r.
115 + *
116 + * @return self This object to support chaining.
117 + *
118 + * @uses setLog()
119 + */
120 + public function appendLog($log, $separator = "\n")
121 + {
122 + // keep current log
123 + $current = $this->log;
124 +
125 + // set log using the proper method
126 + $this->setLog($log);
127 +
128 + // re-build the log by prepending the existing logs
129 + $this->log = $current . $separator . $this->log;
130 +
131 + return $this;
132 + }
133 +
134 + /**
135 + * Prepends the given log to the existing string.
136 + *
137 + * @param mixed $log A string or a non-scalar value.
138 + * An array will be logged using print_r.
139 + *
140 + * @return self This object to support chaining.
141 + *
142 + * @uses setLog()
143 + */
144 + public function prependLog($log, $separator = "\n")
145 + {
146 + // keep current log
147 + $current = $this->log;
148 +
149 + // set log using the proper method
150 + $this->setLog($log);
151 +
152 + // re-build the log by appending the existing logs
153 + $this->log .= $separator . $current;
154 +
155 + return $this;
156 + }
157 +
158 + /**
159 + * Registers an additional information.
160 + *
161 + * @param string $key The data key.
162 + * @param mixed $val The data value.
163 + *
164 + * @return self This object to support chaining.
165 + */
166 + public function setData($key, $val)
167 + {
168 + $this->data[$key] = $val;
169 +
170 + return $this;
171 + }
172 +}