PHP  
 PHP: Test and Code Coverage Analysis
downloads | QA | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
 

LCOV - code coverage report
Current view: top level - ext/intl/dateformat - dateformat.c (source / functions) Hit Total Coverage
Test: PHP Code Coverage Lines: 20 27 74.1 %
Date: 2014-12-13 Functions: 3 3 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :    +----------------------------------------------------------------------+
       3             :    | PHP Version 7                                                        |
       4             :    +----------------------------------------------------------------------+
       5             :    | This source file is subject to version 3.01 of the PHP license,      |
       6             :    | that is bundled with this package in the file LICENSE, and is        |
       7             :    | available through the world-wide-web at the following url:           |
       8             :    | http://www.php.net/license/3_01.txt                                  |
       9             :    | If you did not receive a copy of the PHP license and are unable to   |
      10             :    | obtain it through the world-wide-web, please send a note to          |
      11             :    | license@php.net so we can mail you a copy immediately.               |
      12             :    +----------------------------------------------------------------------+
      13             :    | Authors: Kirti Velankar <kirtig@yahoo-inc.com>                       |
      14             :    +----------------------------------------------------------------------+
      15             : */
      16             : #ifdef HAVE_CONFIG_H
      17             : #include "config.h"
      18             : #endif
      19             : 
      20             : #include <unicode/udat.h>
      21             : 
      22             : #include "php_intl.h"
      23             : #include "dateformat_class.h"
      24             : #include "dateformat.h"
      25             : 
      26             : /* {{{ dateformat_register_constants
      27             :  * Register constants common for the both (OO and procedural)
      28             :  * APIs.
      29             :  */
      30       20622 : void dateformat_register_constants( INIT_FUNC_ARGS )
      31             : {
      32       20622 :         if( IntlDateFormatter_ce_ptr == NULL) {
      33           0 :                 zend_error(E_ERROR, "DateFormat class not defined");
      34           0 :                 return;
      35             :         }
      36             : 
      37             :         #define DATEFORMATTER_EXPOSE_CONST(x) REGISTER_LONG_CONSTANT(#x, x, CONST_PERSISTENT | CONST_CS)
      38             :         #define DATEFORMATTER_EXPOSE_CLASS_CONST(x) zend_declare_class_constant_long( IntlDateFormatter_ce_ptr, ZEND_STRS( #x ) - 1, UDAT_##x TSRMLS_CC );
      39             :         #define DATEFORMATTER_EXPOSE_CUSTOM_CLASS_CONST(name, value) zend_declare_class_constant_long( IntlDateFormatter_ce_ptr, ZEND_STRS( name ) - 1, value TSRMLS_CC );
      40             : 
      41             :         #define DATEFORMATTER_EXPOSE_UCAL_CLASS_CONST(x) zend_declare_class_constant_long( IntlDateFormatter_ce_ptr, ZEND_STRS( #x ) - 1, UCAL_##x TSRMLS_CC );
      42             : 
      43             :         /* UDateFormatStyle constants */
      44       20622 :         DATEFORMATTER_EXPOSE_CLASS_CONST( FULL );
      45       20622 :         DATEFORMATTER_EXPOSE_CLASS_CONST( LONG );
      46       20622 :         DATEFORMATTER_EXPOSE_CLASS_CONST( MEDIUM );
      47       20622 :         DATEFORMATTER_EXPOSE_CLASS_CONST( SHORT );
      48       20622 :         DATEFORMATTER_EXPOSE_CLASS_CONST( NONE );
      49             : 
      50             : /*
      51             :         DATEFORMATTER_EXPOSE_CUSTOM_CLASS_CONST( "GREGORIAN", DATEF_GREGORIAN );
      52             :         DATEFORMATTER_EXPOSE_CUSTOM_CLASS_CONST( "CUSTOMARY", DATEF_CUSTOMARY );
      53             :         DATEFORMATTER_EXPOSE_CUSTOM_CLASS_CONST( "BUDDHIST", DATEF_BUDDHIST );
      54             :         DATEFORMATTER_EXPOSE_CUSTOM_CLASS_CONST( "JAPANESE_IMPERIAL", DATEF_JAPANESE_IMPERIAL );
      55             : */
      56             : 
      57       20622 :         DATEFORMATTER_EXPOSE_UCAL_CLASS_CONST( GREGORIAN );
      58       20622 :         DATEFORMATTER_EXPOSE_UCAL_CLASS_CONST( TRADITIONAL );
      59             : 
      60             :         #undef DATEFORMATTER_EXPOSE_UCAL_CLASS_CONST
      61             :         #undef DATEFORMATTER_EXPOSE_CUSTOM_CLASS_CONST
      62             :         #undef DATEFORMATTER_EXPOSE_CLASS_CONST
      63             :         #undef DATEFORMATTER_EXPOSE_CONST
      64             : }
      65             : /* }}} */
      66             : 
      67             : /* {{{ proto int IntlDateFormatter::getErrorCode()
      68             :  * Get formatter's last error code. }}} */
      69             : /* {{{ proto int datefmt_get_error_code( IntlDateFormatter $nf )
      70             :  * Get formatter's last error code.
      71             :  */
      72           1 : PHP_FUNCTION( datefmt_get_error_code )
      73             : {
      74           1 :         DATE_FORMAT_METHOD_INIT_VARS;
      75             : 
      76             :         /* Parse parameters. */
      77           1 :         if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O",
      78             :                 &object, IntlDateFormatter_ce_ptr ) == FAILURE )
      79             :         {
      80           1 :                 intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
      81             :                         "datefmt_get_error_code: unable to parse input params", 0 TSRMLS_CC );
      82           1 :                 RETURN_FALSE;
      83             :         }
      84             : 
      85           0 :         dfo = Z_INTL_DATEFORMATTER_P( object );
      86             : 
      87             :         /* Return formatter's last error code. */
      88           0 :         RETURN_LONG( INTL_DATA_ERROR_CODE(dfo) );
      89             : }
      90             : /* }}} */
      91             : 
      92             : /* {{{ proto string IntlDateFormatter::getErrorMessage( )
      93             :  * Get text description for formatter's last error code. }}} */
      94             : /* {{{ proto string datefmt_get_error_message( IntlDateFormatter $coll )
      95             :  * Get text description for formatter's last error code.
      96             :  */
      97           1 : PHP_FUNCTION( datefmt_get_error_message )
      98             : {
      99           1 :         zend_string *message = NULL;
     100           1 :         DATE_FORMAT_METHOD_INIT_VARS;
     101             : 
     102             :         /* Parse parameters. */
     103           1 :         if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O",
     104             :                 &object, IntlDateFormatter_ce_ptr ) == FAILURE )
     105             :         {
     106           1 :                 intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
     107             :                         "datefmt_get_error_message: unable to parse input params", 0 TSRMLS_CC );
     108             : 
     109           1 :                 RETURN_FALSE;
     110             :         }
     111             : 
     112           0 :         dfo = Z_INTL_DATEFORMATTER_P( object );
     113             : 
     114             :         /* Return last error message. */
     115           0 :         message = intl_error_get_message( INTL_DATA_ERROR_P(dfo) TSRMLS_CC );
     116           0 :         RETURN_STR( message);
     117             : }
     118             : /* }}} */

Generated by: LCOV version 1.10

Generated at Sat, 13 Dec 2014 06:16:14 +0000 (6 days ago)

Copyright © 2005-2014 The PHP Group
All rights reserved.