Harmonize helper funcitons to snake_case

This commit is contained in:
Stefan Kalscheuer 2019-03-17 16:50:50 +01:00
parent 84ce89b127
commit 39dcce3eeb
2 changed files with 7 additions and 7 deletions

View File

@ -66,7 +66,7 @@ class StatifyBlacklist_Admin extends StatifyBlacklist {
$given_referer = $options['referer']['blacklist']; $given_referer = $options['referer']['blacklist'];
if ( self::MODE_NORMAL === $options['referer']['regexp'] ) { if ( self::MODE_NORMAL === $options['referer']['regexp'] ) {
// Sanitize URLs and remove empty inputs. // Sanitize URLs and remove empty inputs.
$sanitized_referer = self::sanitizeURLs( $given_referer ); $sanitized_referer = self::sanitize_urls( $given_referer );
} elseif ( self::MODE_REGEX === $options['referer']['regexp'] || self::MODE_REGEX_CI === $options['referer']['regexp'] ) { } elseif ( self::MODE_REGEX === $options['referer']['regexp'] || self::MODE_REGEX_CI === $options['referer']['regexp'] ) {
// TODO Check regular expressions. // TODO Check regular expressions.
$sanitized_referer = $given_referer; $sanitized_referer = $given_referer;
@ -85,7 +85,7 @@ class StatifyBlacklist_Admin extends StatifyBlacklist {
// Sanitize IPs and subnets and remove empty inputs. // Sanitize IPs and subnets and remove empty inputs.
$given_ip = $options['ip']['blacklist']; $given_ip = $options['ip']['blacklist'];
$sanitized_ip = self::sanitizeIPs( $given_ip ); $sanitized_ip = self::sanitize_ips( $given_ip );
// Abort on errors. // Abort on errors.
$errors = [ $errors = [
@ -234,7 +234,7 @@ class StatifyBlacklist_Admin extends StatifyBlacklist {
$referer_regexp = implode( '|', array_keys( self::$_options['referer']['blacklist'] ) ); $referer_regexp = implode( '|', array_keys( self::$_options['referer']['blacklist'] ) );
} else { } else {
// Sanitize URLs. // Sanitize URLs.
$referer = self::sanitizeURLs( self::$_options['referer']['blacklist'] ); $referer = self::sanitize_urls( self::$_options['referer']['blacklist'] );
// Build filter regexp. // Build filter regexp.
$referer_regexp = str_replace( '.', '\.', implode( '|', array_flip( $referer ) ) ); $referer_regexp = str_replace( '.', '\.', implode( '|', array_flip( $referer ) ) );
@ -294,7 +294,7 @@ class StatifyBlacklist_Admin extends StatifyBlacklist {
* *
* @return array sanitized array. * @return array sanitized array.
*/ */
private static function sanitizeURLs( $urls ) { private static function sanitize_urls( $urls ) {
return array_flip( return array_flip(
array_filter( array_filter(
array_map( array_map(
@ -316,7 +316,7 @@ class StatifyBlacklist_Admin extends StatifyBlacklist {
* *
* @return array sanitized array. * @return array sanitized array.
*/ */
private static function sanitizeIPs( $ips ) { private static function sanitize_ips( $ips ) {
return array_filter( return array_filter(
$ips, $ips,
function ( $ip ) { function ( $ip ) {

View File

@ -371,7 +371,7 @@ class StatifyBlacklist_Test extends PHPUnit\Framework\TestCase {
// IPv4 tests. // IPv4 tests.
$valid = array( '192.0.2.123', '192.0.2.123/32', '192.0.2.0/24', '192.0.2.128/25' ); $valid = array( '192.0.2.123', '192.0.2.123/32', '192.0.2.0/24', '192.0.2.128/25' );
$invalid = array( '12.34.56.789', '192.0.2.123/33', '192.0.2.123/-1' ); $invalid = array( '12.34.56.789', '192.0.2.123/33', '192.0.2.123/-1' );
$result = invoke_static( StatifyBlacklist_Admin::class, 'sanitizeIPs', array( array_merge( $valid, $invalid ) ) ); $result = invoke_static( StatifyBlacklist_Admin::class, 'sanitize_ips', array( array_merge( $valid, $invalid ) ) );
$this->assertNotFalse( $result ); $this->assertNotFalse( $result );
/* /*
* Unfortunately this is nencessary as long as we run PHP 5 tests, because "assertInternalType" is deprecated * Unfortunately this is nencessary as long as we run PHP 5 tests, because "assertInternalType" is deprecated
@ -398,7 +398,7 @@ class StatifyBlacklist_Test extends PHPUnit\Framework\TestCase {
'2001:db8:a0b:12f0::/129', '2001:db8:a0b:12f0::/129',
'1:2:3:4:5:6:7:8:9', '1:2:3:4:5:6:7:8:9',
); );
$result = invoke_static( StatifyBlacklist_Admin::class, 'sanitizeIPs', array( array_merge( $valid, $invalid ) ) ); $result = invoke_static( StatifyBlacklist_Admin::class, 'sanitize_ips', array( array_merge( $valid, $invalid ) ) );
$this->assertNotFalse( $result ); $this->assertNotFalse( $result );
if ( method_exists( $this, 'assertIsArray' ) ) { if ( method_exists( $this, 'assertIsArray' ) ) {
$this->assertIsArray( $result ); $this->assertIsArray( $result );