diff --git a/src/File/Path/Filename/DefaultTrait.php b/src/File/Path/Filename/DefaultTrait.php index 96828727..91ebfc51 100644 --- a/src/File/Path/Filename/DefaultTrait.php +++ b/src/File/Path/Filename/DefaultTrait.php @@ -20,12 +20,6 @@ public function filename(): string { $processor = Hash::get($this->settings, 'nameCallback', null); if (is_callable($processor)) { - $processor = Closure::fromCallable($processor); - $numberOfParameters = (new ReflectionFunction($processor))->getNumberOfParameters(); - if ($numberOfParameters == 2) { - return $processor($this->data, $this->settings); - } - return $processor($this->table, $this->entity, $this->data, $this->field, $this->settings); } diff --git a/tests/TestCase/File/Path/Filename/DefaultTraitTest.php b/tests/TestCase/File/Path/Filename/DefaultTraitTest.php index 11071f1e..32d55d8c 100644 --- a/tests/TestCase/File/Path/Filename/DefaultTraitTest.php +++ b/tests/TestCase/File/Path/Filename/DefaultTraitTest.php @@ -22,15 +22,6 @@ public function testFilename() $mock->data = new UploadedFile(fopen('php://temp', 'wb+'), 150, UPLOAD_ERR_OK, 'filename'); $this->assertEquals('filename', $mock->filename()); - $mock = $this->getMockForTrait('Josegonzalez\Upload\File\Path\Filename\DefaultTrait'); - $mock->settings = [ - 'nameCallback' => function ($data, $settings) { - return $data->getClientFilename(); - }, - ]; - $mock->data = new UploadedFile(fopen('php://temp', 'wb+'), 150, UPLOAD_ERR_OK, 'filename'); - $this->assertEquals('filename', $mock->filename()); - $mock = $this->getMockForTrait('Josegonzalez\Upload\File\Path\Filename\DefaultTrait'); $mock->entity = $this->getMockBuilder('Cake\ORM\Entity')->getMock(); $mock->table = $this->getMockBuilder('Cake\ORM\Table')->getMock();