Fix class and method names to use camel case
This commit is contained in:
@@ -3,6 +3,7 @@ namespace MailPoet\Config;
|
||||
|
||||
use MailPoet\Models\Subscriber;
|
||||
use MailPoet\Models\Newsletter;
|
||||
use MailPoet\Util\Helpers;
|
||||
|
||||
if(!defined('ABSPATH')) exit;
|
||||
|
||||
@@ -41,7 +42,8 @@ class Migrator {
|
||||
|
||||
$_this = $this;
|
||||
$migrate = function($model) use($_this) {
|
||||
dbDelta($_this->$model());
|
||||
$modelMethod = Helpers::underscoreToCamelCase($model);
|
||||
dbDelta($_this->$modelMethod());
|
||||
};
|
||||
|
||||
array_map($migrate, $this->models);
|
||||
@@ -86,7 +88,7 @@ class Migrator {
|
||||
return $this->sqlify(__FUNCTION__, $attributes);
|
||||
}
|
||||
|
||||
function custom_fields() {
|
||||
function customFields() {
|
||||
$attributes = array(
|
||||
'id mediumint(9) NOT NULL AUTO_INCREMENT,',
|
||||
'name varchar(90) NOT NULL,',
|
||||
@@ -100,7 +102,7 @@ class Migrator {
|
||||
return $this->sqlify(__FUNCTION__, $attributes);
|
||||
}
|
||||
|
||||
function sending_queues() {
|
||||
function sendingQueues() {
|
||||
$attributes = array(
|
||||
'id mediumint(9) NOT NULL AUTO_INCREMENT,',
|
||||
'newsletter_id mediumint(9) NOT NULL,',
|
||||
@@ -140,7 +142,7 @@ class Migrator {
|
||||
return $this->sqlify(__FUNCTION__, $attributes);
|
||||
}
|
||||
|
||||
function subscriber_segment() {
|
||||
function subscriberSegment() {
|
||||
$attributes = array(
|
||||
'id mediumint(9) NOT NULL AUTO_INCREMENT,',
|
||||
'subscriber_id mediumint(9) NOT NULL,',
|
||||
@@ -154,7 +156,7 @@ class Migrator {
|
||||
return $this->sqlify(__FUNCTION__, $attributes);
|
||||
}
|
||||
|
||||
function subscriber_custom_field() {
|
||||
function subscriberCustomField() {
|
||||
$attributes = array(
|
||||
'id mediumint(9) NOT NULL AUTO_INCREMENT,',
|
||||
'subscriber_id mediumint(9) NOT NULL,',
|
||||
@@ -188,7 +190,7 @@ class Migrator {
|
||||
return $this->sqlify(__FUNCTION__, $attributes);
|
||||
}
|
||||
|
||||
function newsletter_templates() {
|
||||
function newsletterTemplates() {
|
||||
$attributes = array(
|
||||
'id mediumint(9) NOT NULL AUTO_INCREMENT,',
|
||||
'name varchar(250) NOT NULL,',
|
||||
@@ -203,7 +205,7 @@ class Migrator {
|
||||
return $this->sqlify(__FUNCTION__, $attributes);
|
||||
}
|
||||
|
||||
function newsletter_option_fields() {
|
||||
function newsletterOptionFields() {
|
||||
$attributes = array(
|
||||
'id mediumint(9) NOT NULL AUTO_INCREMENT,',
|
||||
'name varchar(90) NOT NULL,',
|
||||
@@ -216,7 +218,7 @@ class Migrator {
|
||||
return $this->sqlify(__FUNCTION__, $attributes);
|
||||
}
|
||||
|
||||
function newsletter_option() {
|
||||
function newsletterOption() {
|
||||
$attributes = array(
|
||||
'id mediumint(9) NOT NULL AUTO_INCREMENT,',
|
||||
'newsletter_id mediumint(9) NOT NULL,',
|
||||
@@ -230,7 +232,7 @@ class Migrator {
|
||||
return $this->sqlify(__FUNCTION__, $attributes);
|
||||
}
|
||||
|
||||
function newsletter_segment() {
|
||||
function newsletterSegment() {
|
||||
$attributes = array(
|
||||
'id mediumint(9) NOT NULL AUTO_INCREMENT,',
|
||||
'newsletter_id mediumint(9) NOT NULL,',
|
||||
@@ -243,7 +245,7 @@ class Migrator {
|
||||
return $this->sqlify(__FUNCTION__, $attributes);
|
||||
}
|
||||
|
||||
function newsletter_links() {
|
||||
function newsletterLinks() {
|
||||
$attributes = array(
|
||||
'id mediumint(9) NOT NULL AUTO_INCREMENT,',
|
||||
'newsletter_id mediumint(9) NOT NULL,',
|
||||
@@ -257,7 +259,7 @@ class Migrator {
|
||||
return $this->sqlify(__FUNCTION__, $attributes);
|
||||
}
|
||||
|
||||
function newsletter_posts() {
|
||||
function newsletterPosts() {
|
||||
$attributes = array(
|
||||
'id mediumint(9) NOT NULL AUTO_INCREMENT,',
|
||||
'newsletter_id mediumint(9) NOT NULL,',
|
||||
@@ -284,7 +286,7 @@ class Migrator {
|
||||
return $this->sqlify(__FUNCTION__, $attributes);
|
||||
}
|
||||
|
||||
function statistics_newsletters() {
|
||||
function statisticsNewsletters() {
|
||||
$attributes = array(
|
||||
'id mediumint(9) NOT NULL AUTO_INCREMENT,',
|
||||
'newsletter_id mediumint(9) NOT NULL,',
|
||||
@@ -296,7 +298,7 @@ class Migrator {
|
||||
return $this->sqlify(__FUNCTION__, $attributes);
|
||||
}
|
||||
|
||||
function statistics_clicks() {
|
||||
function statisticsClicks() {
|
||||
$attributes = array(
|
||||
'id mediumint(9) NOT NULL AUTO_INCREMENT,',
|
||||
'newsletter_id mediumint(9) NOT NULL,',
|
||||
@@ -311,7 +313,7 @@ class Migrator {
|
||||
return $this->sqlify(__FUNCTION__, $attributes);
|
||||
}
|
||||
|
||||
function statistics_opens() {
|
||||
function statisticsOpens() {
|
||||
$attributes = array(
|
||||
'id mediumint(9) NOT NULL AUTO_INCREMENT,',
|
||||
'newsletter_id mediumint(9) NOT NULL,',
|
||||
@@ -323,7 +325,7 @@ class Migrator {
|
||||
return $this->sqlify(__FUNCTION__, $attributes);
|
||||
}
|
||||
|
||||
function statistics_unsubscribes() {
|
||||
function statisticsUnsubscribes() {
|
||||
$attributes = array(
|
||||
'id mediumint(9) NOT NULL AUTO_INCREMENT,',
|
||||
'newsletter_id mediumint(9) NOT NULL,',
|
||||
@@ -335,7 +337,7 @@ class Migrator {
|
||||
return $this->sqlify(__FUNCTION__, $attributes);
|
||||
}
|
||||
|
||||
function statistics_forms() {
|
||||
function statisticsForms() {
|
||||
$attributes = array(
|
||||
'id mediumint(9) NOT NULL AUTO_INCREMENT,',
|
||||
'form_id mediumint(9) NOT NULL,',
|
||||
@@ -348,7 +350,7 @@ class Migrator {
|
||||
}
|
||||
|
||||
private function sqlify($model, $attributes) {
|
||||
$table = $this->prefix . $model;
|
||||
$table = $this->prefix . Helpers::camelCaseToUnderscore($model);
|
||||
|
||||
$sql = array();
|
||||
$sql[] = "CREATE TABLE " . $table . " (";
|
||||
|
@@ -9,6 +9,7 @@ use \MailPoet\Models\Segment;
|
||||
use \MailPoet\Segments\WP;
|
||||
use \MailPoet\Models\Setting;
|
||||
use \MailPoet\Settings\Pages;
|
||||
use \MailPoet\Util\Helpers;
|
||||
|
||||
if(!defined('ABSPATH')) exit;
|
||||
|
||||
@@ -29,7 +30,8 @@ class Populator {
|
||||
$_this = $this;
|
||||
|
||||
$populate = function($model) use($_this, $wpdb) {
|
||||
$fields = $_this->$model();
|
||||
$modelMethod = Helpers::underscoreToCamelCase($model);
|
||||
$fields = $_this->$modelMethod();
|
||||
$table = $_this->prefix . $model;
|
||||
|
||||
array_map(function($field) use ($wpdb, $table) {
|
||||
@@ -126,7 +128,7 @@ class Populator {
|
||||
}
|
||||
}
|
||||
|
||||
function newsletter_option_fields() {
|
||||
private function newsletterOptionFields() {
|
||||
return array(
|
||||
array(
|
||||
'name' => 'isScheduled',
|
||||
@@ -184,7 +186,7 @@ class Populator {
|
||||
);
|
||||
}
|
||||
|
||||
private function newsletter_templates() {
|
||||
private function newsletterTemplates() {
|
||||
return array(
|
||||
(new FranksRoastHouseTemplate(Env::$assets_url))->get(),
|
||||
(new BlankTemplate(Env::$assets_url))->get(),
|
||||
@@ -194,7 +196,8 @@ class Populator {
|
||||
}
|
||||
|
||||
private function populate($model) {
|
||||
$rows = $this->$model();
|
||||
$modelMethod = Helpers::underscoreToCamelCase($model);
|
||||
$rows = $this->$modelMethod();
|
||||
$table = $this->prefix . $model;
|
||||
$_this = $this;
|
||||
|
||||
|
@@ -30,7 +30,7 @@ class Renderer {
|
||||
}
|
||||
|
||||
function setupTranslations() {
|
||||
$this->renderer->addExtension(new Twig\i18n(Env::$plugin_name));
|
||||
$this->renderer->addExtension(new Twig\I18n(Env::$plugin_name));
|
||||
}
|
||||
|
||||
function setupFunctions() {
|
||||
|
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
namespace MailPoet\Twig;
|
||||
|
||||
class i18n extends \Twig_Extension {
|
||||
class I18n extends \Twig_Extension {
|
||||
|
||||
private $_text_domain;
|
||||
|
@@ -13,7 +13,7 @@
|
||||
<!-- Final methods don't need final in classes marked as final -->
|
||||
<rule ref="Generic.CodeAnalysis.UnnecessaryFinalModifier"/>
|
||||
<!-- All parameters in function signature should be used within the function -->
|
||||
<rule ref="Generic.CodeAnalysis.UnusedFunctionParameter"/>
|
||||
<!--<rule ref="Generic.CodeAnalysis.UnusedFunctionParameter"/>-->
|
||||
<!-- Don't use methods that extend and only call the parent method -->
|
||||
<rule ref="Generic.CodeAnalysis.UselessOverridingMethod"/>
|
||||
|
||||
@@ -51,12 +51,8 @@
|
||||
<!-- Nesting level should be kept under 5, not more than 10 -->
|
||||
<rule ref="Generic.Metrics.NestingLevel"/>
|
||||
|
||||
<!-- Function names should use camelCaps -->
|
||||
<rule ref="Generic.NamingConventions.CamelCapsFunctionName">
|
||||
<properties>
|
||||
<property name="strict" value="false"/>
|
||||
</properties>
|
||||
</rule>
|
||||
<!-- Method names should use camelCaps -->
|
||||
<rule ref="PSR1.Methods.CamelCapsMethodName"/>
|
||||
<!-- Constants should be all uppercase with underscores separating words -->
|
||||
<rule ref="Generic.NamingConventions.UpperCaseConstantName"/>
|
||||
|
||||
@@ -68,7 +64,7 @@
|
||||
<!-- System keywords should always be lower case -->
|
||||
<rule ref="Generic.PHP.LowerCaseKeyword"/>
|
||||
<!-- Disallow silencing errors with @ -->
|
||||
<rule ref="Generic.PHP.NoSilencedErrors"/>
|
||||
<!--<rule ref="Generic.PHP.NoSilencedErrors"/>-->
|
||||
|
||||
<!-- Disallow indenting with tabs -->
|
||||
<rule ref="Generic.WhiteSpace.DisallowTabIndent"/>
|
||||
|
Reference in New Issue
Block a user