<commit_before><?xml version="1.0" encoding="UTF-8"?>
<!-- Reviewed: no -->
<sect1 id="zend.captcha.operation">
    <title>Captcha Operation</title>

    <para>
        All <acronym>CAPTCHA</acronym> adapter implement
        <classname>Zend_Captcha_Adapter</classname>, which looks like the following:
    </para>

    <programlisting language="php"><![CDATA[
interface Zend_Captcha_Adapter extends Zend_Validate_Interface
{
    public function generate();

    public function render(Zend_View $view, $element = null);

    public function setName($name);

    public function getName();

    public function getDecorator();

    // Additionally, to satisfy Zend_Validate_Interface:
    public function isValid($value);

    public function getMessages();

    public function getErrors();
}
]]></programlisting>

    <para>
        The name setter and getter are used to specify and retrieve the
        <acronym>CAPTCHA</acronym> identifier. <methodname>getDecorator()</methodname> can be used
        to specify a <classname>Zend_Form</classname> decorator either by name or returning an
        actual decorator object. The most interesting methods are
        <methodname>generate()</methodname> and <methodname>render()</methodname>.
        <methodname>generate()</methodname> is used to create the <acronym>CAPTCHA</acronym>
        token. This process typically will store the token in the session so that you may compare
        against it in subsequent requests. <methodname>render()</methodname> is used to render the
        information that represents the <acronym>CAPTCHA</acronym>, be it an image, a figlet, a
        logic problem, or some other <acronym>CAPTCHA</acronym>.
    </para>

    <para>
        A typical use case might look like the following:
    </para>

        <programlisting language="php"><![CDATA[
// Creating a Zend_View instance
$view = new Zend_View();

// Originating request:
$captcha = new Zend_Captcha_Figlet(array(
    'name' => 'foo',
    'wordLen' => 6,
    'timeout' => 300,
));

$id = $captcha->generate();
echo $captcha->render($view);

// On subsequent request:
// Assume captcha setup as before, and $value is the submitted value:
if ($captcha->isValid($_POST['foo'], $_POST)) {
    // Validated!
}
]]></programlisting>
</sect1>
<!--
vim:se ts=4 sw=4 et:
--><commit_msg>docs improvements, see  	 ZF-5418<commit_after><?xml version="1.0" encoding="UTF-8"?>
<!-- Reviewed: no -->
<sect1 id="zend.captcha.operation">
    <title>Captcha Operation</title>

    <para>
        All <acronym>CAPTCHA</acronym> adapter implement
        <classname>Zend_Captcha_Adapter</classname>, which looks like the following:
    </para>

    <programlisting language="php"><![CDATA[
interface Zend_Captcha_Adapter extends Zend_Validate_Interface
{
    public function generate();

    public function render(Zend_View $view, $element = null);

    public function setName($name);

    public function getName();

    public function getDecorator();

    // Additionally, to satisfy Zend_Validate_Interface:
    public function isValid($value);

    public function getMessages();

    public function getErrors();
}
]]></programlisting>

    <para>
        The name setter and getter are used to specify and retrieve the
        <acronym>CAPTCHA</acronym> identifier. <methodname>getDecorator()</methodname> can be used
        to specify a <classname>Zend_Form</classname> decorator either by name or returning an
        actual decorator object. The most interesting methods are
        <methodname>generate()</methodname> and <methodname>render()</methodname>.
        <methodname>generate()</methodname> is used to create the <acronym>CAPTCHA</acronym>
        token. This process typically will store the token in the session so that you may compare
        against it in subsequent requests. <methodname>render()</methodname> is used to render the
        information that represents the <acronym>CAPTCHA</acronym>, be it an image, a figlet, a
        logic problem, or some other <acronym>CAPTCHA</acronym>.
    </para>

    <para>
        A typical use case might look like the following:
    </para>

        <programlisting language="php"><![CDATA[
// Creating a Zend_View instance
$view = new Zend_View();

// Originating request:
$captcha = new Zend_Captcha_Figlet(array(
    'name' => 'foo',
    'wordLen' => 6,
    'timeout' => 300,
));

$id = $captcha->generate();
echo "<form method=\"post\" action=\"\">";
echo $captcha->render($view);
echo "</form>";

// On subsequent request:
// Assume captcha setup as before, the value of $_POST['foo']
// would be key/value array: id => captcha ID, input => captcha value
if ($captcha->isValid($_POST['foo'], $_POST)) {
    // Validated!
}
]]></programlisting>
</sect1>
<!--
vim:se ts=4 sw=4 et:
-->
{'fraction_non_alphanumeric': 0.12800167049488412, 'fraction_numerical': 0.005429108373355606, 'mean_word_length': 3.6731707317073172, 'pattern_counts': {'":': 0, '<': 91, '<?xml version=': 2, '>': 105, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2495804', 'n_tokens_mistral': 1460, 'n_tokens_neox': 1376, 'n_words': 441}