1<?php 2/** 3 * Zend Framework (http://framework.zend.com/) 4 * 5 * @link http://github.com/zendframework/zf2 for the canonical source repository 6 * @copyright Copyright (c) 2005-2016 Zend Technologies USA Inc. (http://www.zend.com) 7 * @license http://framework.zend.com/license/new-bsd New BSD License 8 */ 9 10namespace Zend\Db\Sql\Predicate; 11 12use Zend\Db\Sql\AbstractExpression; 13 14class IsNull extends AbstractExpression implements PredicateInterface 15{ 16 /** 17 * @var string 18 */ 19 protected $specification = '%1$s IS NULL'; 20 21 /** 22 * @var 23 */ 24 protected $identifier; 25 26 /** 27 * Constructor 28 * 29 * @param string $identifier 30 */ 31 public function __construct($identifier = null) 32 { 33 if ($identifier) { 34 $this->setIdentifier($identifier); 35 } 36 } 37 38 /** 39 * Set identifier for comparison 40 * 41 * @param string $identifier 42 * @return self Provides a fluent interface 43 */ 44 public function setIdentifier($identifier) 45 { 46 $this->identifier = $identifier; 47 return $this; 48 } 49 50 /** 51 * Get identifier of comparison 52 * 53 * @return null|string 54 */ 55 public function getIdentifier() 56 { 57 return $this->identifier; 58 } 59 60 /** 61 * Set specification string to use in forming SQL predicate 62 * 63 * @param string $specification 64 * @return self Provides a fluent interface 65 */ 66 public function setSpecification($specification) 67 { 68 $this->specification = $specification; 69 return $this; 70 } 71 72 /** 73 * Get specification string to use in forming SQL predicate 74 * 75 * @return string 76 */ 77 public function getSpecification() 78 { 79 return $this->specification; 80 } 81 82 /** 83 * Get parts for where statement 84 * 85 * @return array 86 */ 87 public function getExpressionData() 88 { 89 $identifier = $this->normalizeArgument($this->identifier, self::TYPE_IDENTIFIER); 90 return [[ 91 $this->getSpecification(), 92 [$identifier[0]], 93 [$identifier[1]], 94 ]]; 95 } 96} 97