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: 20 28 71.4 %
Date: 2015-06-27 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 int collator_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_constructor)
      29             : {
      30             :         const char*      locale;
      31          71 :         size_t           locale_len = 0;
      32             :         zval*            object;
      33             :         Collator_object* co;
      34          71 :         int zpp_flags = is_constructor ? ZEND_PARSE_PARAMS_THROW : 0;
      35             : 
      36          71 :         intl_error_reset( NULL );
      37          71 :         object = return_value;
      38             :         /* Parse parameters. */
      39          71 :         if( zend_parse_parameters_ex( zpp_flags, ZEND_NUM_ARGS(), "s",
      40             :                 &locale, &locale_len ) == FAILURE )
      41             :         {
      42           1 :                 intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
      43             :                         "collator_create: unable to parse input params", 0 );
      44           1 :                 return FAILURE;
      45             :         }
      46             : 
      47          70 :         INTL_CHECK_LOCALE_LEN_OR_FAILURE(locale_len);
      48          68 :         COLLATOR_METHOD_FETCH_OBJECT;
      49             : 
      50          68 :         if(locale_len == 0) {
      51           2 :                 locale = intl_locale_get_default();
      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          68 :         return SUCCESS;
      58             : }
      59             : /* }}} */
      60             : 
      61             : /* {{{ proto Collator collator_create( string $locale )
      62             :  * Create collator.
      63             :  */
      64          71 : PHP_FUNCTION( collator_create )
      65             : {
      66          71 :         object_init_ex( return_value, Collator_ce_ptr );
      67          71 :         if (collator_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0) == FAILURE) {
      68           3 :                 zval_ptr_dtor(return_value);
      69           3 :                 RETURN_NULL();
      70             :         }
      71             : }
      72             : /* }}} */
      73             : 
      74             : /* {{{ proto Collator Collator::__construct( string $locale )
      75             :  * Collator object constructor.
      76             :  */
      77           0 : PHP_METHOD( Collator, __construct )
      78             : {
      79             :         zend_error_handling error_handling;
      80             : 
      81           0 :         zend_replace_error_handling(EH_THROW, IntlException_ce_ptr, &error_handling);
      82           0 :         return_value = getThis();
      83           0 :         if (collator_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1) == FAILURE) {
      84           0 :                 if (!EG(exception)) {
      85           0 :                         zend_throw_exception(IntlException_ce_ptr, "Constructor failed", 0);
      86             :                 }
      87             :         }
      88           0 :         zend_restore_error_handling(&error_handling);
      89           0 : }
      90             : /* }}} */
      91             : 
      92             : /*
      93             :  * Local variables:
      94             :  * tab-width: 4
      95             :  * c-basic-offset: 4
      96             :  * End:
      97             :  * vim600: noet sw=4 ts=4 fdm=marker
      98             :  * vim<600: noet sw=4 ts=4
      99             :  */

Generated by: LCOV version 1.10

Generated at Sat, 27 Jun 2015 09:41:10 +0000 (6 days ago)

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