isotopsweden/wp-cargo

View on GitHub
src/pusher/abstract-pusher.php

Summary

Maintainability
A
0 mins
Test Coverage

The class Abstract_Pusher is not named in CamelCase.
Open

abstract class Abstract_Pusher implements Pusher_Interface {

    /**
     * Cargo instance.
     *
Severity: Minor
Found in src/pusher/abstract-pusher.php by phpmd

CamelCaseClassName

Since: 0.2

It is considered best practice to use the CamelCase notation to name classes.

Example

class class_name {
}

Source

Expected 0 spaces between argument "$cargo" and closing bracket; 1 found
Open

    public function __construct( Cargo $cargo ) {

Expected 0 spaces between argument "$data" and closing bracket; 1 found
Open

    protected function to_json( $data ) {

Expected 0 spaces between opening bracket and argument "$data"; 1 found
Open

    protected function to_json( $data ) {

Expected 0 spaces between argument "$error" and closing bracket; 1 found
Open

    protected function save( $data, $error = '' ) {

Method name "Abstract_Pusher::to_json" is not in camel caps format
Open

    protected function to_json( $data ) {

Expected 0 spaces before closing bracket; 1 found
Open

        if ( $data instanceof Content_Interface ) {

Opening brace of a class must be on the line after the definition
Open

abstract class Abstract_Pusher implements Pusher_Interface {

Expected 0 spaces between opening bracket and type hint "Cargo"; 1 found
Open

    public function __construct( Cargo $cargo ) {

Expected 0 spaces between opening bracket and argument "$data"; 1 found
Open

    protected function save( $data, $error = '' ) {

Expected 0 spaces before closing bracket; 1 found
Open

        if ( empty( $data ) ) {

Spaces must be used to indent lines; tabs are not allowed
Open

     * @var \Isotop\Cargo\Cargo

Spaces must be used to indent lines; tabs are not allowed
Open

        $data = is_string( $data ) ? $data : wp_json_encode( $data );

Spaces must be used to indent lines; tabs are not allowed
Open

        $data  = $this->to_json( $data );

Spaces must be used to indent lines; tabs are not allowed
Open

    protected $cargo;

Spaces must be used to indent lines; tabs are not allowed
Open

    }

Spaces must be used to indent lines; tabs are not allowed
Open

     * Save data.

Spaces must be used to indent lines; tabs are not allowed
Open

            return;

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param \Isotop\Cargo\Cargo $cargo

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

        $this->cargo = $cargo;

Spaces must be used to indent lines; tabs are not allowed
Open

            return $data->to_json() ?: '';

Spaces must be used to indent lines; tabs are not allowed
Open

    }

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

        if ( $data instanceof Content_Interface ) {

Spaces must be used to indent lines; tabs are not allowed
Open

     */

Spaces must be used to indent lines; tabs are not allowed
Open

        }

Spaces must be used to indent lines; tabs are not allowed
Open

     * Cargo instance.

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

        }

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param mixed $data

Spaces must be used to indent lines; tabs are not allowed
Open

    }

Spaces must be used to indent lines; tabs are not allowed
Open

     * Convert data to JSON or empty string.

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param mixed $error

Spaces must be used to indent lines; tabs are not allowed
Open

    protected function save( $data, $error = '' ) {

Spaces must be used to indent lines; tabs are not allowed
Open

    /**

Spaces must be used to indent lines; tabs are not allowed
Open

     * @return string

Spaces must be used to indent lines; tabs are not allowed
Open

        if ( empty( $data ) ) {

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

        $error = $this->to_json( $error );

Spaces must be used to indent lines; tabs are not allowed
Open

     */

Spaces must be used to indent lines; tabs are not allowed
Open

    protected function to_json( $data ) {

Spaces must be used to indent lines; tabs are not allowed
Open

        $data = is_string( $data ) ? $data : '';

Spaces must be used to indent lines; tabs are not allowed
Open

        return $data;

Spaces must be used to indent lines; tabs are not allowed
Open

        $this->cargo->make( 'database' )->save( $data, $error );

Spaces must be used to indent lines; tabs are not allowed
Open

     */

Spaces must be used to indent lines; tabs are not allowed
Open

     * Pusher Constructor.

Spaces must be used to indent lines; tabs are not allowed
Open

     */

Spaces must be used to indent lines; tabs are not allowed
Open

    public function __construct( Cargo $cargo ) {

Spaces must be used to indent lines; tabs are not allowed
Open

    /**

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param  mixed $data

Spaces must be used to indent lines; tabs are not allowed
Open

    /**

Spaces must be used to indent lines; tabs are not allowed
Open

    /**

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Expected 0 spaces before closing bracket; 1 found
Open

        $data = is_string( $data ) ? $data : wp_json_encode( $data );

Space after opening parenthesis of function call prohibited
Open

        $data  = $this->to_json( $data );

Expected 0 spaces after opening bracket; 1 found
Open

        if ( empty( $data ) ) {

Expected 0 spaces before closing bracket; 1 found
Open

        $this->cargo->make( 'database' )->save( $data, $error );

Class name "Abstract_Pusher" is not in camel caps format
Open

abstract class Abstract_Pusher implements Pusher_Interface {

Space after opening parenthesis of function call prohibited
Open

        $data = is_string( $data ) ? $data : '';

Opening brace should be on a new line
Open

    public function __construct( Cargo $cargo ) {

Expected 0 spaces before closing bracket; 1 found
Open

        $data = is_string( $data ) ? $data : wp_json_encode( $data );

Expected 0 spaces after opening bracket; 1 found
Open

        if ( $data instanceof Content_Interface ) {

Space after opening parenthesis of function call prohibited
Open

        $data = is_string( $data ) ? $data : wp_json_encode( $data );

Space after opening parenthesis of function call prohibited
Open

        $error = $this->to_json( $error );

Space after opening parenthesis of function call prohibited
Open

        $this->cargo->make( 'database' )->save( $data, $error );

Space after opening parenthesis of function call prohibited
Open

        $data = is_string( $data ) ? $data : wp_json_encode( $data );

Expected 0 spaces before closing bracket; 1 found
Open

        $error = $this->to_json( $error );

Space after opening parenthesis of function call prohibited
Open

        if ( empty( $data ) ) {

Expected 0 spaces before closing bracket; 1 found
Open

        $data = is_string( $data ) ? $data : '';

Expected 0 spaces before closing bracket; 1 found
Open

        $data  = $this->to_json( $data );

Expected 0 spaces before closing bracket; 1 found
Open

        if ( empty( $data ) ) {

Opening brace should be on a new line
Open

    protected function save( $data, $error = '' ) {

Opening brace should be on a new line
Open

    protected function to_json( $data ) {

Expected 0 spaces before closing bracket; 1 found
Open

        $this->cargo->make( 'database' )->save( $data, $error );

Space after opening parenthesis of function call prohibited
Open

        $this->cargo->make( 'database' )->save( $data, $error );

The method to_json is not named in camelCase.
Open

    protected function to_json( $data ) {
        if ( $data instanceof Content_Interface ) {
            return $data->to_json() ?: '';
        }

Severity: Minor
Found in src/pusher/abstract-pusher.php by phpmd

CamelCaseMethodName

Since: 0.2

It is considered best practice to use the camelCase notation to name methods.

Example

class ClassName {
    public function get_name() {
    }
}

Source

There are no issues that match your filters.

Category
Status