Completed
Push — next_gen ( 4e4ec4 )
by Armando
02:53
created

WP_To_Diaspora   B

Complexity

Total Complexity 45

Size/Duplication

Total Lines 366
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 3

Importance

Changes 0
Metric Value
wmc 45
lcom 2
cbo 3
dl 0
loc 366
rs 8.8
c 0
b 0
f 0

How to fix   Complexity   

Complex Class

Complex classes like WP_To_Diaspora often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use WP_To_Diaspora, and based on these observations, apply Extract Interface, too.

1
<?php
2
/**
3
 * Plugin Name:       WP to diaspora*
4
 * Plugin URI:        https://github.com/DiasPHPora/wp-to-diaspora
5
 * Description:       Automatically shares WordPress posts on diaspora*
6
 * Version:           unreleased
7
 * Author:            Augusto Bennemann, Armando Lüscher
8
 * Author URI:        https://github.com/DiasPHPora
9
 * License:           GPLv2 or later
10
 * License URI:       https://www.gnu.org/licenses/gpl-2.0.html
11
 * Text Domain:       wp-to-diaspora
12
 * GitHub Plugin URI: DiasPHPora/wp-to-diaspora
13
 * GitHub Branch:     master
14
 *
15
 * Copyright 2014-2020 Augusto Bennemann (email: gutobenn at gmail.com)
16
 *
17
 * This program is free software; you can redistribute it and/or modify it under the terms of the GNU
18
 * General Public License as published by the Free Software Foundation; either version 2 of the License,
19
 * or (at your option) any later version.
20
 *
21
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
22
 * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
23
 *
24
 * You should have received a copy of the GNU General Public License along with this program; if not, write
25
 * to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26
 *
27
 * @package   WP_To_Diaspora
28
 * @version   unreleased
29
 * @author    Augusto Bennemann <[email protected]>
30
 * @copyright Copyright (c) 2017, Augusto Bennemann
31
 * @link      https://github.com/DiasPHPora/wp-to-diaspora
32
 * @license   https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
33
 */
34
35
// Exit if accessed directly.
36
defined( 'ABSPATH' ) || exit;
37
38
// Set the current version.
39
define( 'WP2D_VERSION', 'unreleased' );
40
define( 'WP2D_BASENAME', plugin_basename( __FILE__ ) );
41
42
require_once __DIR__ . '/vendor/autoload.php';
43
44
// Get the party started!
45
WP2D::instance();
46