Skip to content

Commit b9535df

Browse files
ildyriad7415
andauthored
Support tool paths in factory (#73)
--------- Co-authored-by: Martin Stone <[email protected]>
1 parent 8a44f53 commit b9535df

18 files changed

+53
-25
lines changed

lib/PHPExif/Adapter/AbstractAdapter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ abstract class AbstractAdapter implements AdapterInterface
3030
*
3131
* @param array $options Optional array of data to initialize the object with
3232
*/
33-
public function __construct(array $options = array())
33+
public function __construct(array $options = [])
3434
{
3535
if (count($options) > 0) {
3636
$this->setOptions($options);
@@ -43,7 +43,7 @@ public function __construct(array $options = array())
4343
* @param \PHPExif\Contracts\MapperInterface $mapper
4444
* @return \PHPExif\Contracts\AdapterInterface
4545
*/
46-
public function setMapper(MapperInterface $mapper): AdapterInterface
46+
final public function setMapper(MapperInterface $mapper): AdapterInterface
4747
{
4848
$this->mapper = $mapper;
4949

lib/PHPExif/Adapter/Exiftool.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,22 @@ class Exiftool extends AbstractAdapter
3232
*/
3333
protected string $toolPath = '';
3434
protected bool $numeric = true;
35-
protected array $encoding = array();
35+
protected array $encoding = [];
3636
protected string $mapperClass = MapperExiftool::class;
3737

38+
/**
39+
* Set up Exiftool adapter
40+
*
41+
* @param array $options option to be passed to the parent
42+
* @param string $path optional path to the tool
43+
* @return self
44+
*/
45+
public function __construct(array $options = [], string $path = '')
46+
{
47+
parent::__construct($options);
48+
$this->toolPath = $path;
49+
}
50+
3851
/**
3952
* Setter for the exiftool binary path
4053
*

lib/PHPExif/Adapter/FFprobe.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,19 @@ class FFprobe extends AbstractAdapter
4242
protected string $mapperClass = MapperFFprobe::class;
4343

4444

45+
/**
46+
* Set up FFprobe adapter
47+
*
48+
* @param array $options option to be passed to the parent
49+
* @param string $path optional path to the tool
50+
* @return self
51+
*/
52+
public function __construct(array $options = [], string $path = '')
53+
{
54+
parent::__construct($options);
55+
$this->toolPath = $path;
56+
}
57+
4558
/**
4659
* Setter for the exiftool binary path
4760
*

lib/PHPExif/Adapter/ImageMagick.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ class ImageMagick extends AbstractAdapter
5252
public function getExifFromFile(string $file): Exif
5353
{
5454
/* Create the object */
55+
/** @disregard P1009 */
5556
$im = new Imagick($file);
5657

5758
/* Get the EXIF information */

lib/PHPExif/Adapter/Native.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class Native extends AbstractAdapter
4141
*
4242
* @var array
4343
*/
44-
protected array $requiredSections = array();
44+
protected array $requiredSections = [];
4545

4646
/**
4747
* Include the thumbnail in the EXIF data?
@@ -200,7 +200,7 @@ public function getExifFromFile(string $file): Exif
200200

201201
// exif_read_data failed to read exif data (i.e. not a jpg/tiff)
202202
if (false === $data) {
203-
$data = array();
203+
$data = [];
204204
$data['FileSize'] = filesize($file);
205205
$data['FileName'] = basename($file);
206206
$data['MimeType'] = $mimeType;
@@ -248,7 +248,7 @@ public function getExifFromFile(string $file): Exif
248248
public function getIptcData(string $file): array
249249
{
250250
getimagesize($file, $info);
251-
$arrData = array();
251+
$arrData = [];
252252
if (isset($info['APP13'])) {
253253
try {
254254
$iptc = iptcparse($info['APP13']);

lib/PHPExif/Exif.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,19 +62,19 @@ class Exif
6262
/**
6363
* The mapped EXIF data
6464
*/
65-
protected array $data = array();
65+
protected array $data = [];
6666

6767
/**
6868
* The raw EXIF data
6969
*/
70-
protected array $rawData = array();
70+
protected array $rawData = [];
7171

7272
/**
7373
* Class constructor
7474
*
7575
* @param array $data
7676
*/
77-
public function __construct(array $data = array())
77+
public function __construct(array $data = [])
7878
{
7979
$this->setData($data);
8080
}

lib/PHPExif/Mapper/Exiftool.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ public function setNumeric(bool $numeric): Exiftool
202202
*/
203203
public function mapRawData(array $data): array
204204
{
205-
$mappedData = array();
205+
$mappedData = [];
206206

207207
foreach ($data as $field => $value) {
208208
if (!array_key_exists($field, $this->map)) {

lib/PHPExif/Mapper/FFprobe.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ class FFprobe extends AbstractMapper
9090
*/
9191
public function mapRawData(array $data): array
9292
{
93-
$mappedData = array();
93+
$mappedData = [];
9494

9595
foreach ($data as $field => $value) {
9696
if ($this->isSection($field) && is_array($value)) {

lib/PHPExif/Mapper/ImageMagick.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ class ImageMagick extends AbstractMapper
123123
*/
124124
public function mapRawData(array $data): array
125125
{
126-
$mappedData = array();
126+
$mappedData = [];
127127

128128
foreach ($data as $field => $value) {
129129
if (!array_key_exists($field, $this->map)) {

lib/PHPExif/Mapper/Native.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ class Native extends AbstractMapper
147147
*/
148148
public function mapRawData(array $data): array
149149
{
150-
$mappedData = array();
150+
$mappedData = [];
151151

152152
foreach ($data as $field => $value) {
153153
if ($this->isSection($field) && is_array($value)) {

0 commit comments

Comments
 (0)