PHP Class MongoId

Inheritance: implements Serializable, implements Alcaeus\MongoDbAdapter\TypeInterface, implements JsonSerializable
显示文件 Open project: alcaeus/mongo-php-adapter Class Usage Examples

Public Methods

Method Description
__construct ( string $id = null ) Creates a new id
__get ( string $name ) : null | string
__isset ( string $name ) : boolean
__set ( string $name, mixed $value )
__set_state ( array $props ) : MongoId (PECL mongo >= 1.0.8) Create a dummy MongoId
__toString ( ) : string Returns a hexidecimal representation of this id
__unset ( string $name )
getHostname ( ) : string Gets the hostname being used for this machine's ids
getInc ( ) : integer Gets the incremented value to create this id
getPID ( ) : integer (PECL mongo >= 1.0.11) Gets the process ID
getTimestamp ( ) : integer (PECL mongo >= 1.0.1) Gets the number of seconds since the epoch that this id was created
isValid ( mixed $value ) : boolean Check if a value is a valid ObjectId
jsonSerialize ( ) : stdClass
serialize ( ) : string
toBSONType ( ) : MongoDB\BSON\ObjectID Converts this MongoId to the new BSON ObjectID type
unserialize ( string $serialized )

Private Methods

Method Description
createObjectID ( $id )

Method Details

__construct() public method

Creates a new id
public __construct ( string $id = null )
$id string [optional] A string to use as the id. Must be 24 hexidecimal characters. If an invalid string is passed to this constructor, the constructor will ignore it and create a new id value.

__get() public method

public __get ( string $name ) : null | string
$name string
return null | string

__isset() public method

public __isset ( string $name ) : boolean
$name string
return boolean

__set() public method

public __set ( string $name, mixed $value )
$name string
$value mixed

__set_state() public static method

(PECL mongo >= 1.0.8) Create a dummy MongoId
public static __set_state ( array $props ) : MongoId
$props array

Theoretically, an array of properties used to create the new id. However, as MongoId instances have no properties, this is not used.

return MongoId A new id with the value "000000000000000000000000".

__toString() public method

Returns a hexidecimal representation of this id
public __toString ( ) : string
return string

__unset() public method

public __unset ( string $name )
$name string

getHostname() public static method

Gets the hostname being used for this machine's ids
public static getHostname ( ) : string
return string

getInc() public method

Gets the incremented value to create this id
public getInc ( ) : integer
return integer Returns the incremented value used to create this MongoId.

getPID() public method

(PECL mongo >= 1.0.11) Gets the process ID
public getPID ( ) : integer
return integer Returns the PID of the MongoId.

getTimestamp() public method

(PECL mongo >= 1.0.1) Gets the number of seconds since the epoch that this id was created
public getTimestamp ( ) : integer
return integer

isValid() public static method

Check if a value is a valid ObjectId
public static isValid ( mixed $value ) : boolean
$value mixed The value to check for validity.
return boolean

jsonSerialize() public method

public jsonSerialize ( ) : stdClass
return stdClass

serialize() public method

public serialize ( ) : string
return string

toBSONType() public method

Converts this MongoId to the new BSON ObjectID type
public toBSONType ( ) : MongoDB\BSON\ObjectID
return MongoDB\BSON\ObjectID

unserialize() public method

public unserialize ( string $serialized )
$serialized string