Skip to content
This repository was archived by the owner on Jan 13, 2025. It is now read-only.

Commit a330b45

Browse files
author
jaw-sh
committed
Added verification checking.
Files sent for verification checking using the ::check($file, "ext") call will be matched only against cases that are ->leadEXT. This reduces the number of case checks that need to be ran, allows specificity, and can be used to prioritize certain container formats that ffprobe can put the file in.
1 parent 303a20b commit a330b45

File tree

2 files changed

+22
-7
lines changed

2 files changed

+22
-7
lines changed

src/FileSleuth.php

100755100644
Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class FileSleuth
2525
/**
2626
* Instantiates the model.
2727
*
28-
* @param $file string Optional parameter to automatically run a check.
28+
* @param string $file Optional parameter to automatically run a check.
2929
* @return null|boolean
3030
*/
3131
public function __construct($file = null)
@@ -39,17 +39,23 @@ public function __construct($file = null)
3939
/**
4040
* Runs the file against all dectives.
4141
*
42-
* @param $file string Optional parameter to automatically run a check.
42+
* @param string $file Optional parameter to automatically run a check.
43+
* @param string|null $verify Extension to verify against. Checks all possible if unset.
4344
* @return null|boolean
4445
*/
45-
public function check($file)
46+
public function check($file, $verify = null)
4647
{
48+
if (is_string($verify))
49+
{
50+
$verify = "lead" . strtoupper($verify);
51+
}
52+
4753
$case = null;
4854

4955
foreach ($this->detectives as $detectiveClass)
5056
{
5157
$detective = new $detectiveClass();
52-
$case = $detective->check($file);
58+
$case = $detective->check($file, $verify);
5359

5460
if ($case)
5561
{

src/Traits/DetectiveTrait.php

100755100644
Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ protected function caseClosedOrFail()
5757
* Check the the file against our leads.
5858
*
5959
* @param mixed $file File to check.
60-
* @param string|null Mime type to verify against. Checks all possible if unset.
60+
* @param string|null $verify Extension to verify against. Checks all possible if unset.
6161
* @return boolean True if we solved the case, false if not.
6262
*/
6363
public function check($file, $verify = null)
@@ -66,9 +66,18 @@ public function check($file, $verify = null)
6666
{
6767
$leads = $this->leads();
6868

69-
foreach ($leads as $lead)
69+
if (!is_null($verify))
7070
{
71-
if (is_null($verify) || $lead === $verify)
71+
if (isset($leads[$verify]))
72+
{
73+
return $this->checkLead($leads[$verify]);
74+
}
75+
76+
return false;
77+
}
78+
else
79+
{
80+
foreach ($leads as $lead)
7281
{
7382
$results = $this->checkLead($lead);
7483

0 commit comments

Comments
 (0)