Zend Framework  1.12
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
Zend_TimeSync Class Reference

Public Member Functions

 __construct ($target=null, $alias=null)
 Zend_TimeSync constructor.
 
 getIterator ()
 getIterator() - return an iteratable object for use in foreach and the like, this completes the IteratorAggregate interface
 
 addServer ($target, $alias=null)
 Add a timeserver or multiple timeservers.
 
 setServer ($alias)
 Marks a nameserver as current.
 
 getServer ($alias=null)
 Return a specified timeserver by alias If no alias is given it will return the current timeserver.
 
 getInfo ()
 Returns information sent/returned from the current timeserver.
 
 getDate ($locale=null)
 Query the timeserver list using the fallback mechanism.
 

Static Public Member Functions

static setOptions (array $options)
 Sets the value for the given options.
 
static getOptions ($key=null)
 Returns the value to the option.
 

Public Attributes

const DEFAULT_PROTOCOL = 'Ntp'
 Set the default timeserver protocol to "Ntp".
 

Static Public Attributes

static $options
 

Protected Member Functions

 _addServer ($target, $alias)
 Adds a timeserver object to the timeserver list.
 

Protected Attributes

 $_timeservers = array()
 
 $_current
 
 $_allowedSchemes
 

Constructor & Destructor Documentation

__construct (   $target = null,
  $alias = null 
)

Zend_TimeSync constructor.

Parameters
string | array$target- OPTIONAL single timeserver, or an array of timeservers.
string$alias- OPTIONAL an alias for this timeserver
Returns
object

Member Function Documentation

_addServer (   $target,
  $alias 
)
protected

Adds a timeserver object to the timeserver list.

Parameters
string | array$target- Single timeserver, or an array of timeservers.
string$alias- An alias for this timeserver
addServer (   $target,
  $alias = null 
)

Add a timeserver or multiple timeservers.

Server should be a single string representation of a timeserver, or a structured array listing multiple timeservers.

If you provide an array of timeservers in the $target variable, $alias will be ignored. you can enter these as the array key in the provided array, which should be structured as follows:

$example = array( 'server_a' => 'ntp://127.0.0.1', 'server_b' => 'ntp://127.0.0.1:123', 'server_c' => 'ntp://[2000:364:234::2.5]', 'server_d' => 'ntp://[2000:364:234::2.5]:123' );

If no port number has been suplied, the default matching port number will be used.

Supported protocols are:

  • ntp
  • sntp
Parameters
string | array$target- Single timeserver, or an array of timeservers.
string$alias- OPTIONAL an alias for this timeserver
Exceptions
Zend_TimeSync_Exception
getDate (   $locale = null)

Query the timeserver list using the fallback mechanism.

If there are multiple servers listed, this method will act as a facade and will try to return the date from the first server that returns a valid result.

Parameters
Zend_Locale$locale- OPTIONAL locale
Returns
object
Exceptions
Zend_TimeSync_Exception
getInfo ( )

Returns information sent/returned from the current timeserver.

Returns
array
getIterator ( )

getIterator() - return an iteratable object for use in foreach and the like, this completes the IteratorAggregate interface

Returns
ArrayObject
static getOptions (   $key = null)
static

Returns the value to the option.

Parameters
string$key- The option's identifier
Returns
mixed
Exceptions
Zend_TimeSync_Exception
getServer (   $alias = null)

Return a specified timeserver by alias If no alias is given it will return the current timeserver.

Parameters
string | integer$alias- The alias from the timeserver to return
Returns
object
Exceptions
Zend_TimeSync_Exception
static setOptions ( array  $options)
static

Sets the value for the given options.

This will replace any currently defined options.

Parameters
array$options- An array of options to be set
setServer (   $alias)

Marks a nameserver as current.

Parameters
string | integer$alias- The alias from the timeserver to set as current
Exceptions
Zend_TimeSync_Exception

Member Data Documentation

$_allowedSchemes
protected
Initial value:
= array(
'Ntp',
'Sntp'
)
$_current
protected
$_timeservers = array()
protected
$options
static
Initial value:
= array(
'timeout' => 1
)
const DEFAULT_PROTOCOL = 'Ntp'

Set the default timeserver protocol to "Ntp".

This will be called when no protocol is specified