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/spoofchecker - spoofchecker_main.c (source / functions) Hit Total Coverage
Test: PHP Code Coverage Lines: 30 45 66.7 %
Date: 2014-07-21 Functions: 4 4 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :    +----------------------------------------------------------------------+
       3             :    | PHP Version 5                                                        |
       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: Scott MacVicar <scottmac@php.net>                           |
      14             :    +----------------------------------------------------------------------+
      15             :  */
      16             : 
      17             : #ifdef HAVE_CONFIG_H
      18             : #include "config.h"
      19             : #endif
      20             : 
      21             : #include "php_intl.h"
      22             : #include "spoofchecker_class.h"
      23             : 
      24             : /* {{{ proto bool Spoofchecker::isSuspicious( string text[, int &error_code ] )
      25             :  * Checks if a given text contains any suspicious characters
      26             :  */
      27           5 : PHP_METHOD(Spoofchecker, isSuspicious)
      28             : {
      29             :         int ret;
      30             :         char *text;
      31             :         int text_len;
      32           5 :         zval *error_code = NULL;
      33           5 :         SPOOFCHECKER_METHOD_INIT_VARS;
      34             :         
      35           5 :         if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|z", &text, &text_len, &error_code)) {
      36           0 :                 return;
      37             :         }
      38             :         
      39           5 :         SPOOFCHECKER_METHOD_FETCH_OBJECT;
      40             : 
      41           5 :         ret = uspoof_checkUTF8(co->uspoof, text, text_len, NULL, SPOOFCHECKER_ERROR_CODE_P(co));
      42             : 
      43           5 :         if (U_FAILURE(SPOOFCHECKER_ERROR_CODE(co))) {
      44           0 :                 php_error_docref(NULL TSRMLS_CC, E_WARNING, "(%d) %s", SPOOFCHECKER_ERROR_CODE(co), u_errorName(SPOOFCHECKER_ERROR_CODE(co)));
      45           0 :                 RETURN_TRUE;
      46             :         }
      47             :         
      48           5 :         if (error_code) {
      49           0 :                 zval_dtor(error_code);
      50           0 :                 ZVAL_LONG(error_code, ret);
      51             :         }
      52           5 :         RETVAL_BOOL(ret != 0);
      53             : }
      54             : /* }}} */
      55             : 
      56             : /* {{{ proto bool Spoofchecker::areConfusable( string str1, string str2[, int &error_code ] )
      57             :  * Checks if a given text contains any confusable characters
      58             :  */
      59           7 : PHP_METHOD(Spoofchecker, areConfusable)
      60             : {
      61             :         int ret;
      62             :         char *s1, *s2;
      63             :         int s1_len, s2_len;
      64           7 :         zval *error_code = NULL;
      65           7 :         SPOOFCHECKER_METHOD_INIT_VARS;
      66             :         
      67           7 :         if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|z", &s1, &s1_len,
      68             :                                                                                  &s2, &s2_len, &error_code)) {
      69           0 :                 return;
      70             :         }
      71             : 
      72           7 :         SPOOFCHECKER_METHOD_FETCH_OBJECT;
      73             : 
      74           7 :         ret = uspoof_areConfusableUTF8(co->uspoof, s1, s1_len, s2, s2_len, SPOOFCHECKER_ERROR_CODE_P(co));
      75             : 
      76           7 :         if (U_FAILURE(SPOOFCHECKER_ERROR_CODE(co))) {
      77           0 :                 php_error_docref(NULL TSRMLS_CC, E_WARNING, "(%d) %s", SPOOFCHECKER_ERROR_CODE(co), u_errorName(SPOOFCHECKER_ERROR_CODE(co)));
      78           0 :                 RETURN_TRUE;
      79             :         }
      80             :         
      81           7 :         if (error_code) {
      82           0 :                 zval_dtor(error_code);
      83           0 :                 ZVAL_LONG(error_code, ret);
      84             :         }
      85           7 :         RETVAL_BOOL(ret != 0);
      86             : }
      87             : /* }}} */
      88             : 
      89             : /* {{{ proto void Spoofchecker::setAllowedLocales( string locales )
      90             :  * Locales to use when running checks
      91             :  */
      92           2 : PHP_METHOD(Spoofchecker, setAllowedLocales)
      93             : {
      94             :         char *locales;
      95             :         int locales_len;
      96           2 :         SPOOFCHECKER_METHOD_INIT_VARS;
      97             :         
      98           2 :         if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &locales, &locales_len)) {
      99           0 :                 return;
     100             :         }
     101             : 
     102           2 :         SPOOFCHECKER_METHOD_FETCH_OBJECT;
     103             : 
     104           2 :         uspoof_setAllowedLocales(co->uspoof, locales, SPOOFCHECKER_ERROR_CODE_P(co));
     105             : 
     106           2 :         if (U_FAILURE(SPOOFCHECKER_ERROR_CODE(co))) {
     107           0 :                 php_error_docref(NULL TSRMLS_CC, E_WARNING, "(%d) %s", SPOOFCHECKER_ERROR_CODE(co), u_errorName(SPOOFCHECKER_ERROR_CODE(co)));
     108           0 :                 return;
     109             :         }
     110             : }
     111             : /* }}} */
     112             : 
     113             : /* {{{ proto void Spoofchecker::setChecks( int checks )
     114             :  * Set the checks to run
     115             :  */
     116           1 : PHP_METHOD(Spoofchecker, setChecks)
     117             : {
     118             :         long checks;
     119           1 :         SPOOFCHECKER_METHOD_INIT_VARS;
     120             :                 
     121           1 :         if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &checks)) {
     122           0 :                 return;
     123             :         }
     124             : 
     125           1 :         SPOOFCHECKER_METHOD_FETCH_OBJECT;
     126             : 
     127           1 :         uspoof_setChecks(co->uspoof, checks, SPOOFCHECKER_ERROR_CODE_P(co));
     128             : 
     129           1 :         if (U_FAILURE(SPOOFCHECKER_ERROR_CODE(co))) {
     130           0 :                 php_error_docref(NULL TSRMLS_CC, E_WARNING, "(%d) %s", SPOOFCHECKER_ERROR_CODE(co), u_errorName(SPOOFCHECKER_ERROR_CODE(co)));
     131             :         }
     132             : }
     133             : /* }}} */
     134             : 
     135             : /*
     136             :  * Local variables:
     137             :  * tab-width: 4
     138             :  * c-basic-offset: 4
     139             :  * End:
     140             :  * vim600: noet sw=4 ts=4 fdm=marker
     141             :  * vim<600: noet sw=4 ts=4
     142             :  */

Generated by: LCOV version 1.10

Generated at Tue, 22 Jul 2014 01:33:11 +0000 (3 days ago)

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