Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
1.30% covered (danger)
1.30%
1 / 77
33.33% covered (danger)
33.33%
1 / 3
CRAP
0.00% covered (danger)
0.00%
0 / 1
Brands
1.30% covered (danger)
1.30%
1 / 77
33.33% covered (danger)
33.33%
1 / 3
86.88
0.00% covered (danger)
0.00%
0 / 1
 get_brand_name
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
 get_config
0.00% covered (danger)
0.00%
0 / 74
0.00% covered (danger)
0.00%
0 / 1
56
 is_brand_compatible
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2namespace NewfoldLabs\WP\Module\ECommerce\Data;
3
4use NewfoldLabs\WP\ModuleLoader\Container;
5/**
6 * Contains Brand information.
7 */
8final class Brands {
9
10    /**
11     * List of compatible brand plugin IDs for the next steps UI and store details.
12     *
13     * @var array<string>
14     */
15    private const COMPATIBLE_BRANDS = array( 'bluehost', 'web', 'crazy-domains', 'vodien' );
16
17    /**
18     * Retrieve and sanitize the brand name from the container.
19     *
20     * @param Container $container The container object that holds the plugin instance.
21     * @return string The sanitized brand name
22     * */
23    private static function get_brand_name( Container $container ) {
24        $brand_raw_value = $container->plugin()->brand;
25        return \sanitize_title( str_replace( '_', '-', $brand_raw_value ) );
26    }
27    /**
28     * Brand specific data
29     *
30     * @param Container $container The container object
31     * @return array
32     */
33    public static function get_config( Container $container ) {
34        $brand = self::get_brand_name( $container );
35        switch ( $brand ) {
36            case 'crazy-domains':
37                return array(
38                    'brand'            => 'crazy-domains',
39                    'name'             => 'CrazyDomains',
40                    'url'              => 'https://crazydomains.com',
41                    'hireExpertsInfo'  => 'admin.php?page=crazy-domains#/marketplace/services/blue-sky',
42                    'support'          => 'https://www.crazydomains.in/contact',
43                    'adminPage'        => 'admin.php?page=crazy-domains',
44                    'setup'            => array(
45                        'payment'  => array( 'PayPal' ),
46                        'shipping' => array( 'Shippo' ),
47                    ),
48                    'defaultContact'   => array(
49                        'woocommerce_default_country' => 'AU:NSW',
50                        'woocommerce_currency'        => 'AUD',
51                    ),
52                    'wondercartBuyNow' => '',
53                );
54
55            case 'bluehost-india':
56                return array(
57                    'brand'            => 'bluehost-india',
58                    'name'             => 'Bluehost',
59                    'url'              => 'https://bluehost.in',
60                    'hireExpertsInfo'  => 'https://www.bluehost.in/solutions/full-service',
61                    'support'          => 'https://helpchat.bluehost.in',
62                    'adminPage'        => 'admin.php?page=bluehost',
63                    'setup'            => array(
64                        'payment'  => array( 'PayPal', 'Razorpay', 'Stripe' ),
65                        'shipping' => array(),
66                    ),
67                    'defaultContact'   => array(
68                        'woocommerce_default_country' => 'IN:AP',
69                        'woocommerce_currency'        => 'INR',
70                    ),
71                    'wondercartBuyNow' => '',
72                );
73            case 'hostgator':
74            case 'hostgator-latam':
75                return array(
76                    'brand'            => 'hostgator',
77                    'name'             => 'hostgator',
78                    'url'              => 'https://hostgator.com',
79                    'hireExpertsInfo'  => 'admin.php?page=hostgator#/marketplace/services/blue-sky',
80                    'support'          => 'https://www.hostgator.com/contact',
81                    'adminPage'        => 'admin.php?page=hostgator',
82                    'setup'            => array(
83                        'payment'  => array( 'PayPal', 'Razorpay', 'Stripe' ),
84                        'shipping' => array(),
85                    ),
86                    'defaultContact'   => array(
87                        'woocommerce_default_country' => 'BR:AL',
88                        'woocommerce_currency'        => 'BRL',
89                    ),
90                    'wondercartBuyNow' => '',
91                );
92            case 'bluehost':
93            default:
94                return array(
95                    'brand'            => 'bluehost',
96                    'name'             => 'Bluehost',
97                    'url'              => 'https://bluehost.com',
98                    'hireExpertsInfo'  => 'admin.php?page=bluehost#/marketplace/services/blue-sky',
99                    'support'          => 'https://www.bluehost.com/contact',
100                    'adminPage'        => 'admin.php?page=bluehost',
101                    'setup'            => array(
102                        'payment'  => array( 'PayPal', 'Razorpay', 'Stripe' ),
103                        'shipping' => array( 'Shippo' ),
104                    ),
105                    'defaultContact'   => array(
106                        'woocommerce_default_country' => 'US:AZ',
107                        'woocommerce_currency'        => 'USD',
108                    ),
109                    'wondercartBuyNow' => 'https://my.bluehost.com/hosting/app?utm_source=wp-marketplace&utm_medium=brand-plugin&utm_campaign=wordpress-ad&utm_content=buynow#/marketplace/product',
110                );
111        }
112    }
113
114    /**
115     * Brand compatability
116     *
117     * @param string $plugin_id The plugin id
118     * @return boolean
119     */
120    public static function is_brand_compatible( $plugin_id ) {
121        return in_array( $plugin_id, self::COMPATIBLE_BRANDS, true );
122    }
123}