Skip to content

Commit

Permalink
updated ip handler interface, added default implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
Soban Mahmod committed Jul 7, 2022
1 parent 4288457 commit 6338fbe
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 6 deletions.
20 changes: 20 additions & 0 deletions src/iphandler/DefaultIPHandler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace ipinfo\ipinfolaravel\iphandler;

/**
* Default implementation of the IPHandlerInterface. Selects default ip from request.
*/
class DefaultIPHandler implements IPHandlerInterface
{

/**
* Selectes default IP address from request.
* @param \Illuminate\Http\Request $request
* @return string IP address.
*/
public function getIP($request)
{
return $request->ip();
}
}
13 changes: 7 additions & 6 deletions src/iphandler/IPHandlerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
*/
interface IPHandlerInterface
{

/**
* Get IP address.
* @return string IP address.
*/
public function getIP();

/**
* Get IP address.
* @param \Illuminate\Http\Request $request
* @return string IP address.
*/
public function getIP($request);
}

0 comments on commit 6338fbe

Please sign in to comment.