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/collator - collator_create.c (source / functions) Hit Total Coverage
Test: PHP Code Coverage Lines: 17 25 68.0 %
Date: 2014-10-30 Functions: 2 3 66.7 %
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: Vadim Savchuk <vsavchuk@productengine.com>                  |
      14             :    |          Dmitry Lakhtyuk <dlakhtyuk@productengine.com>               |
      15             :    +----------------------------------------------------------------------+
      16             :  */
      17             : 
      18             : #ifdef HAVE_CONFIG_H
      19             : #include "config.h"
      20             : #endif
      21             : 
      22             : #include "php_intl.h"
      23             : #include "collator_class.h"
      24             : #include "collator_create.h"
      25             : #include "intl_data.h"
      26             : 
      27             : /* {{{ */
      28          71 : static void collator_ctor(INTERNAL_FUNCTION_PARAMETERS)
      29             : {
      30             :         const char*      locale;
      31          71 :         size_t              locale_len = 0;
      32             :         zval*            object;
      33             :         Collator_object* co;
      34             : 
      35          71 :         intl_error_reset( NULL TSRMLS_CC );
      36          71 :         object = return_value;
      37             :         /* Parse parameters. */
      38          71 :         if( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "s",
      39             :                 &locale, &locale_len ) == FAILURE )
      40             :         {
      41           1 :                 intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
      42             :                         "collator_create: unable to parse input params", 0 TSRMLS_CC );
      43             :                 zval_dtor(return_value);
      44           1 :                 RETURN_NULL();
      45             :         }
      46             : 
      47          72 :         INTL_CHECK_LOCALE_LEN_OBJ(locale_len, return_value);
      48          68 :         COLLATOR_METHOD_FETCH_OBJECT;
      49             : 
      50          68 :         if(locale_len == 0) {
      51           2 :                 locale = intl_locale_get_default(TSRMLS_C);
      52             :         }
      53             : 
      54             :         /* Open ICU collator. */
      55          68 :         co->ucoll = ucol_open( locale, COLLATOR_ERROR_CODE_P( co ) );
      56          68 :         INTL_CTOR_CHECK_STATUS(co, "collator_create: unable to open ICU collator");
      57             : }
      58             : /* }}} */ 
      59             : 
      60             : /* {{{ proto Collator collator_create( string $locale )
      61             :  * Create collator.
      62             :  */
      63          71 : PHP_FUNCTION( collator_create )
      64             : {
      65          71 :         object_init_ex( return_value, Collator_ce_ptr );
      66          71 :         collator_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU);
      67          71 : }
      68             : /* }}} */
      69             : 
      70             : /* {{{ proto Collator Collator::__construct( string $locale )
      71             :  * Collator object constructor.
      72             :  */
      73           0 : PHP_METHOD( Collator, __construct )
      74             : {
      75           0 :         zval orig_this = *getThis();
      76             : 
      77           0 :         return_value = getThis();
      78           0 :         collator_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU);
      79             : 
      80           0 :         if (Z_TYPE_P(return_value) == IS_OBJECT && Z_OBJ_P(return_value) == NULL) {
      81           0 :                 zend_object_store_ctor_failed(Z_OBJ(orig_this) TSRMLS_CC);
      82             :                 zval_dtor(&orig_this);
      83           0 :                 ZEND_CTOR_MAKE_NULL();
      84             :         }
      85           0 : }
      86             : /* }}} */
      87             : 
      88             : /*
      89             :  * Local variables:
      90             :  * tab-width: 4
      91             :  * c-basic-offset: 4
      92             :  * End:
      93             :  * vim600: noet sw=4 ts=4 fdm=marker
      94             :  * vim<600: noet sw=4 ts=4
      95             :  */

Generated by: LCOV version 1.10

Generated at Thu, 30 Oct 2014 07:41:31 +0000 (22 hours ago)

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