Skip to content

Commit

Permalink
Allow null options in Phly_Couch_Document constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
emjliano committed Nov 7, 2011
1 parent f9bc5f5 commit 0f81066
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions Phly_Couch/library/Phly/Couch/Document.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,19 @@ class Phly_Couch_Document

public function __construct($options = null)
{
if (is_string($options)) {
if ('{' == substr($options, 0, 1)) {
$this->loadJson($options);
if (null !== $options){
if (is_string($options)) {
if ('{' == substr($options, 0, 1)) {
$this->loadJson($options);
} else {
$this->setId($options);
}
} elseif (is_array($options)) {
$this->loadArray($options);
} else {
$this->setId($options);
require_once 'Phly/Couch/Exception.php';
throw new Phly_Couch_Exception('Invalid options provided to ' . __CLASS__ . 'constructor');
}
} elseif (is_array($options)) {
$this->loadArray($options);
} else {
require_once 'Phly/Couch/Exception.php';
throw new Phly_Couch_Exception('Invalid options provided to ' . __CLASS__ . 'constructor');
}
}

Expand Down

0 comments on commit 0f81066

Please sign in to comment.