1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace WeDevBr\Bankly\Inputs; |
4
|
|
|
|
5
|
|
|
use WeDevBr\Bankly\Support\Contracts\DocumentInterface; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* DocumentAnalysis class |
9
|
|
|
* |
10
|
|
|
* PHP version 7.4|8.0 |
11
|
|
|
* |
12
|
|
|
* @author WeDev Brasil Team <[email protected]> |
13
|
|
|
* @author Rafael Teixeira <[email protected]> |
14
|
|
|
* @copyright 2020 We Dev Tecnologia Ltda |
15
|
|
|
* @link https://github.com/wedevBr/bankly-laravel |
16
|
|
|
*/ |
17
|
|
|
class DocumentAnalysis implements DocumentInterface |
18
|
|
|
{ |
19
|
|
|
/** @var string */ |
20
|
|
|
protected $documentSide; |
21
|
|
|
|
22
|
|
|
/** @var string */ |
23
|
|
|
protected $documentType; |
24
|
|
|
|
25
|
|
|
/** @var string */ |
26
|
|
|
protected $filePath; |
27
|
|
|
|
28
|
|
|
/** @var string */ |
29
|
|
|
protected $fieldName; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @param string $documentSide |
33
|
|
|
* @return DocumentAnalysis |
34
|
|
|
*/ |
35
|
|
|
public function setDocumentSide(string $documentSide): DocumentAnalysis |
36
|
|
|
{ |
37
|
|
|
$this->documentSide = $documentSide; |
38
|
|
|
return $this; |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @param string $documentType |
43
|
|
|
* @return DocumentAnalysis |
44
|
|
|
*/ |
45
|
|
|
public function setDocumentType(string $documentType): DocumentAnalysis |
46
|
|
|
{ |
47
|
|
|
$this->documentType = $documentType; |
48
|
|
|
return $this; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @param string $path |
53
|
|
|
* @return DocumentAnalysis |
54
|
|
|
*/ |
55
|
|
|
public function setFilePath(string $path): DocumentAnalysis |
56
|
|
|
{ |
57
|
|
|
$this->filePath = $path; |
58
|
|
|
return $this; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* @param string $name |
63
|
|
|
* @return DocumentAnalysis |
64
|
|
|
*/ |
65
|
|
|
public function setFieldName(string $name): DocumentAnalysis |
66
|
|
|
{ |
67
|
|
|
$this->fieldName = $name; |
68
|
|
|
return $this; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* @return string |
73
|
|
|
*/ |
74
|
|
|
public function getDocumentSide(): string |
75
|
|
|
{ |
76
|
|
|
return $this->documentSide; |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* @return string |
81
|
|
|
*/ |
82
|
|
|
public function getDocumentType(): string |
83
|
|
|
{ |
84
|
|
|
return $this->documentType; |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* @return string |
89
|
|
|
*/ |
90
|
|
|
public function getFileName(): string |
91
|
|
|
{ |
92
|
|
|
return basename($this->filePath); |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* @return mixed |
97
|
|
|
*/ |
98
|
|
|
public function getFileContents() |
99
|
|
|
{ |
100
|
|
|
return file_get_contents($this->filePath); |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* @return string |
105
|
|
|
*/ |
106
|
|
|
public function getFieldName(): string |
107
|
|
|
{ |
108
|
|
|
return $this->fieldName; |
109
|
|
|
} |
110
|
|
|
} |
111
|
|
|
|