Skip to content

Commit

Permalink
Document getFields() and clean up getPostParameters().
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Gauthier committed Jan 11, 2009
1 parent 19deefd commit 693a0ec
Showing 1 changed file with 24 additions and 12 deletions.
36 changes: 24 additions & 12 deletions Services/Akismet2/Comment.php
Expand Up @@ -277,13 +277,6 @@ public function __toString()
*/
public function getPostParameters()
{
foreach (self::$_requiredFields as $field) {
if (!array_key_exists($field, $this->_fields)) {
throw new Services_Akismet2_InvalidCommentException('Comment ' .
'is missing required field: "' . $field . '".', 0, $this);
}
}

$values = array();

foreach ($this->_fields as $key => $value) {
Expand All @@ -297,6 +290,14 @@ public function getPostParameters()
}
}

// make sure all required fields are set
foreach (self::$_requiredFields as $field) {
if (!array_key_exists($field, $values)) {
throw new Services_Akismet2_InvalidCommentException('Comment ' .
'is missing required field: "' . $field . '".', 0, $this);
}
}

return $values;
}

Expand All @@ -323,11 +324,6 @@ public function setField($name, $value)
}

// }}}

public function getFields() {
return $this->_fields;
}

// {{{ setFields()

/**
Expand All @@ -353,6 +349,22 @@ public function setFields(array $fields)
return $this;
}

// }}}
// {{{ getFields()

/**
* Gets the fields that are set for this comment
*
* Note: This method does not include extra server-related fields that are
* included in {@link Services_Akismet2_Comment::getPostParameters()}.
*
* @return array an array containing the fields set for this comment.
*/
public function getFields()
{
return $this->_fields;
}

// }}}
// {{{ setType()

Expand Down

0 comments on commit 693a0ec

Please sign in to comment.