[DomCrawler] tweaked public @api

This commit is contained in:
Fabien Potencier 2011-06-14 15:16:43 +02:00
parent dd23402e94
commit 54e054b2d1
4 changed files with 39 additions and 35 deletions

View File

@ -47,6 +47,8 @@ class ChoiceFormField extends FormField
* @param string $value The value of the field
*
* @throws \InvalidArgumentException When value type provided is not correct
*
* @api
*/
public function select($value)
{

View File

@ -68,6 +68,8 @@ abstract class FormField
* Sets the value of the field.
*
* @param string $value The value of the field
*
* @api
*/
public function setValue($value)
{

View File

@ -44,23 +44,6 @@ class Form extends Link implements \ArrayAccess
$this->initialize();
}
protected function setNode(\DOMNode $node)
{
$this->button = $node;
if ('button' == $node->nodeName || ('input' == $node->nodeName && in_array($node->getAttribute('type'), array('submit', 'button', 'image')))) {
do {
// use the ancestor form element
if (null === $node = $node->parentNode) {
throw new \LogicException('The selected node does not have a form ancestor.');
}
} while ('form' != $node->nodeName);
} else {
throw new \LogicException(sprintf('Unable to submit on a "%s" tag.', $node->nodeName));
}
$this->node = $node;
}
/**
* Gets the form node associated with this form.
*
@ -380,4 +363,21 @@ class Form extends Link implements \ArrayAccess
{
$this->remove($name);
}
protected function setNode(\DOMNode $node)
{
$this->button = $node;
if ('button' == $node->nodeName || ('input' == $node->nodeName && in_array($node->getAttribute('type'), array('submit', 'button', 'image')))) {
do {
// use the ancestor form element
if (null === $node = $node->parentNode) {
throw new \LogicException('The selected node does not have a form ancestor.');
}
} while ('form' != $node->nodeName);
} else {
throw new \LogicException(sprintf('Unable to submit on a "%s" tag.', $node->nodeName));
}
$this->node = $node;
}
}

View File

@ -46,15 +46,6 @@ class Link
$this->currentUri = $currentUri;
}
protected function setNode(\DOMNode $node)
{
if ('a' != $node->nodeName) {
throw new \LogicException(sprintf('Unable to click on a "%s" tag.', $node->nodeName));
}
$this->node = $node;
}
/**
* Gets the node associated with this link.
*
@ -65,6 +56,18 @@ class Link
return $this->node;
}
/**
* Gets the method associated with this link.
*
* @return string The method
*
* @api
*/
public function getMethod()
{
return $this->method;
}
/**
* Gets the URI associated with this link.
*
@ -105,15 +108,12 @@ class Link
return $this->node->getAttribute('href');
}
/**
* Gets the method associated with this link.
*
* @return string The method
*
* @api
*/
public function getMethod()
protected function setNode(\DOMNode $node)
{
return $this->method;
if ('a' != $node->nodeName) {
throw new \LogicException(sprintf('Unable to click on a "%s" tag.', $node->nodeName));
}
$this->node = $node;
}
}