Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
/**
3
 * This file contains the class XML_Query2XML_Data_Condition_NonEmpty.
4
 *
5
 * PHP version 5
6
 *
7
 * @category  XML
8
 * @package   XML_Query2XML
9
 * @author    Lukas Feiler <lukas.feiler@lukasfeiler.com>
10
 * @copyright 2009 Lukas Feiler
11
 * @license   http://www.gnu.org/copyleft/lesser.html  LGPL Version 2.1
12
 * @version   CVS: $Id: NonEmpty.php 276636 2009-03-01 12:58:57Z lukasfeiler $
13
 * @link      http://pear.php.net/package/XML_Query2XML
14
 * @access    private
15
 */
16
 
17
/**
18
 * XML_Query2XML_Data_Condition_NonEmpty extends
19
 * XML_Query2XML_Data_Condition.
20
 */
21
require_once 'XML/Query2XML/Data/Condition.php';
22
 
23
/**
24
 * Data Condition Class implementing a condition based on whether the
25
 * value returned by a pre-processor is an object or a non-empty string.
26
 *
27
 * XML_Query2XML_Data_Condition_NonEmpty requires a pre-processor to be used.
28
 *
29
 * usage:
30
 * <code>
31
 * $commandObject = new XML_Query2XML_Data_Condition_NonEmpty(
32
 *   new XML_Query2XML_Data_Source_ColumnValue('name')  //pre-processor
33
 * );
34
 * </code>
35
 *
36
 * @category  XML
37
 * @package   XML_Query2XML
38
 * @author    Lukas Feiler <lukas.feiler@lukasfeiler.com>
39
 * @copyright 2009 Lukas Feiler
40
 * @license   http://www.gnu.org/copyleft/lesser.html  LGPL Version 2.1
41
 * @version   Release: 1.7.2
42
 * @link      http://pear.php.net/package/XML_Query2XML
43
 * @access    private
44
 * @since     Release 1.7.1RC1
45
 */
46
class XML_Query2XML_Data_Condition_NonEmpty extends XML_Query2XML_Data_Condition
47
{
48
    /**
49
     * Create a new instance of this class.
50
     *
51
     * @param mixed  $preProcessor The pre-processor to be used. An instance of
52
     *                             XML_Query2XML_Data or null.
53
     * @param string $configPath   The configuration path within the $options
54
     *                             array.
55
     *
56
     * @return XML_Query2XML_Data_Condition_NonEmpty
57
     */
58
    public function create($preProcessor, $configPath)
59
    {
60
        $condition = new XML_Query2XML_Data_Condition_NonEmpty($preProcessor);
61
        $condition->setConfigPath($configPath);
62
        return $condition;
63
    }
64
 
65
    /**
66
     * As this class implements XML_Query2XML_Data_Condition, XML_Query2XML
67
     * will call this method to determin whether the condition is fulfilled.
68
     *
69
     * @param mixed $value The value previously returned by $this->execute().
70
     *
71
     * @return boolean Whether the condition is fulfilled.
72
     */
73
    public function evaluateCondition($value)
74
    {
75
        return is_object($value) ||
76
            !(is_null($value) || (is_string($value) && strlen($value) == 0));
77
    }
78
}
79
?>