<?php

namespace Mine\SeekerBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * Gamer
 *
 * @ORM\Table(name="gamer")
 * @ORM\Entity(repositoryClass="Mine\SeekerBundle\Repository\GamerRepository")
 */
class Gamer
{
    /**
     * @var int
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;

    /**
     * @var string
     *
     * @ORM\Column(name="user_name", type="string", length=100, nullable=false)
     */
    private $userName;

    /**
     * @var string
     *
     * @ORM\Column(name="ip", type="string", length=20, nullable=true)
     */
    private $ip;

    /**
     * TODO
     * $ip='0.0.0.0';
     * $ip=$_SERVER['REMOTE_ADDR'];
     * $clientDetails = json_decode(file_get_contents("http://ipinfo.io/$ip/json"));
     * echo "You're logged in from: <b>" . $clientDetails->country . "</b>";
     *
     * function GetIP()
     * {
     * if ( getenv("HTTP_CLIENT_IP") ) {
     * $ip = getenv("HTTP_CLIENT_IP");
     * } elseif ( getenv("HTTP_X_FORWARDED_FOR") ) {
     * $ip = getenv("HTTP_X_FORWARDED_FOR");
     * if ( strstr($ip, ',') ) {
     * $tmp = explode(',', $ip);
     * $ip = trim($tmp[0]);
     * }
     * } else {
     * $ip = getenv("REMOTE_ADDR");
     * }
     * return $ip;
     * }
     */

    /**
     * @var string
     *
     * @ORM\Column(name="country", type="string", length=100, nullable=true)
     */
    private $country;

    /**
     * @var string
     * @see http://symfony.com/doc/current/components/http_foundation.html
     *
     * @ORM\Column(name="user_agent", type="string", length=255, nullable=true)
     */
    private $userAgent;

    /**
     * @var \DateTime
     *
     * @ORM\Column(name="conn_timestamp", type="datetime", nullable=false)
     */
    private $connTimestamp;


    /**
     * Get id
     *
     * @return int
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set userName
     *
     * @param string $userName
     *
     * @return Gamer
     */
    public function setUserName($userName)
    {
        $this->userName = $userName;

        return $this;
    }

    /**
     * Get userName
     *
     * @return string
     */
    public function getUserName()
    {
        return $this->userName;
    }

    /**
     * Set ip
     *
     * @param string $ip
     *
     * @return Gamer
     */
    public function setIp($ip)
    {
        $this->ip = $ip;

        return $this;
    }

    /**
     * Get ip
     *
     * @return string
     */
    public function getIp()
    {
        return $this->ip;
    }

    /**
     * Set country
     *
     * @param string $country
     *
     * @return Gamer
     */
    public function setCountry($country)
    {
        $this->country = $country;

        return $this;
    }

    /**
     * Get country
     *
     * @return string
     */
    public function getCountry()
    {
        return $this->country;
    }

    /**
     * Set userAgent
     *
     * @param string $userAgent
     *
     * @return Gamer
     */
    public function setUserAgent($userAgent)
    {
        $this->userAgent = $userAgent;

        return $this;
    }

    /**
     * Get userAgent
     *
     * @return string
     */
    public function getUserAgent()
    {
        return $this->userAgent;
    }

    /**
     * Set connTimestamp
     *
     * @param \DateTime $connTimestamp
     *
     * @return Gamer
     */
    public function setConnTimestamp($connTimestamp)
    {
        $this->connTimestamp = $connTimestamp;

        return $this;
    }

    /**
     * Get connTimestamp
     *
     * @return \DateTime
     */
    public function getConnTimestamp()
    {
        return $this->connTimestamp;
    }
}
