/
Entity.php
50 lines (42 loc) · 1.13 KB
/
Entity.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
namespace Razorpay\IFSC;
use Psr\Http\Message\ResponseInterface;
class Entity
{
protected $bankCode;
protected $bank;
protected $code;
protected $branch;
protected $address;
protected $contact;
protected $city;
protected $district;
protected $state;
public function __construct(ResponseInterface $response)
{
$data = json_decode($response->getBody(), true);
if ($data) {
$this->bank = $data['BANK'];
$this->branch = $data['BRANCH'];
$this->address = $data['ADDRESS'];
$this->contact = $data['CONTACT'];
$this->city = $data['CITY'];
$this->code = $this->ifsc = $data['IFSC'];
$this->district = $data['DISTRICT'];
$this->state = $data['STATE'];
$this->bankCode = $this->getBankCode();
}
}
public function getBankCode()
{
return substr($this->code, 0, 4);
}
public function getBankName()
{
return IFSC::getBankName($this->getBankCode());
}
public function __get ($name)
{
return $this->$name ?? null;
}
}