Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Protocol.php
Go to the documentation of this file.
1 <?php
30 abstract class Zend_TimeSync_Protocol
31 {
37  protected $_socket;
38 
44  protected $_exceptions;
45 
51  protected $_timeserver;
52 
58  protected $_info = array();
59 
65  abstract protected function _prepare();
66 
72  abstract protected function _read();
73 
80  abstract protected function _write($data);
81 
88  abstract protected function _extract($data);
89 
96  protected function _connect()
97  {
98  $socket = @fsockopen($this->_timeserver, $this->_port, $errno, $errstr,
99  Zend_TimeSync::$options['timeout']);
100  if ($socket === false) {
101  throw new Zend_TimeSync_Exception('could not connect to ' .
102  "'$this->_timeserver' on port '$this->_port', reason: '$errstr'");
103  }
104 
105  $this->_socket = $socket;
106  }
107 
113  protected function _disconnect()
114  {
115  @fclose($this->_socket);
116  $this->_socket = null;
117  }
118 
124  public function getInfo()
125  {
126  if (empty($this->_info) === true) {
127  $this->_write($this->_prepare());
128  $timestamp = $this->_extract($this->_read());
129  }
130 
131  return $this->_info;
132  }
133 
140  public function getDate($locale = null)
141  {
142  $this->_write($this->_prepare());
143  $timestamp = $this->_extract($this->_read());
144 
145  $date = new Zend_Date($this, null, $locale);
146  return $date;
147  }
148 }
getDate($locale=null)
Definition: Protocol.php:140
fsockopen(&$errorNumber, &$errorMessage)
Definition: http_mock.php:37
static $options
Definition: TimeSync.php:72