Completed
Push — master ( 3b65eb...dc665d )
by Nicolaas
11:00 queued 02:51
created

api/EcommerceCountry_VisitorCountryProvider.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
/**
4
 * this is a very basic class with as its sole purpose providing
5
 * the country of the customer.
6
 * By default we are using the GEOIP class
7
 * but you can switch it to your own system by changing
8
 * the classname in the ecommerce.yml config file.
9
 */
10
class EcommerceCountry_VisitorCountryProvider extends Object implements EcommerceGEOipProvider
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
11
{
12
    /**
13
     * @return string (Country Code - e.g. NZ, AU, or AF)
14
     */
15
    public function getCountry()
16
    {
17
        if (class_exists('Geoip')) {
18
            return Geoip::visitor_country();
19
        } else {
20
            return Config::inst()->get('EcommerceCountry', 'default_country_code');
21
        }
22
    }
23
24
    /**
25
     * returns string of IP address.
26
     */
27
    public function getIP()
28
    {
29
        return Controller::curr()->getRequest()->getIP();
30
    }
31
}
32