MongoId::__construct PHP Method

__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.
    public function __construct($id = null)
    {
        $this->createObjectID($id);
    }

Usage Example

Beispiel #1
0
 /**
  * @param string $id
  */
 public function __construct($id = null)
 {
     if ($id !== null && strlen($id) < 20 && ctype_alnum($id)) {
         $id = gmp_strval(gmp_init(strrev($id), 62), 16);
         if (strlen($id) > 24) {
             $id = 'FFFFFFFFFFFFFFFFFFFFFFFF';
         } elseif (strlen($id) < 24) {
             $id = str_pad($id, 24, '0', STR_PAD_LEFT);
         }
     }
     @parent::__construct($id);
 }
All Usage Examples Of MongoId::__construct