• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

nepada / file-upload-control / 9327437708

pending completion
9327437708

Pull #156

github

web-flow
Merge 92839108e into 46a12c798
Pull Request #156: Update mockery/mockery requirement from 1.6.11 to 1.6.12

Source File
Press 'n' to go to next uncovered line, 'b' for previous

91.3
/src/FileUploadControl/Validation/FakeUploadControl.php
1
<?php
2
declare(strict_types = 1);
3

4
namespace Nepada\FileUploadControl\Validation;
5

6
use Nepada\FileUploadControl\FileUploadControl;
7
use Nette\Forms\Controls\UploadControl;
8
use Nette\Forms\Form;
9
use Nette\Http\FileUpload;
10

11
/**
12
 * @internal
13
 */
14
final class FakeUploadControl extends UploadControl
15
{
16

17
    private FileUploadControl $fileUploadControl;
18

19
    private ?FileUpload $newFileUpload = null;
20

21
    public function __construct(FileUploadControl $fileUploadControl)
1✔
22
    {
23
        parent::__construct();
1✔
24
        $this->fileUploadControl = $fileUploadControl;
1✔
25
        $fileUploadControl->monitor(Form::class, function (Form $form): void {
1✔
26
            $this->setParent(null, $this->fileUploadControl->getName());
1✔
27
            $this->control->name = $this->fileUploadControl->getComponent('upload')->getHtmlName();
1✔
28
        });
1✔
29
    }
1✔
30

31
    public function setNewFileUpload(FileUpload $fileUpload): void
1✔
32
    {
33
        $this->newFileUpload = $fileUpload;
1✔
34
    }
1✔
35

36
    public function getFileUploadControl(): FileUploadControl
37
    {
38
        return $this->fileUploadControl;
×
39
    }
40

41
    public function getCaption(): \Stringable|string|null
42
    {
43
        return $this->fileUploadControl->getCaption();
×
44
    }
45

46
    /**
47
     * @return FileUpload[]
48
     */
49
    public function getValue(): array
50
    {
51
        $fileUploads = $this->fileUploadControl->getValue();
1✔
52
        if ($this->newFileUpload !== null) {
1✔
53
            $fileUploads[] = $this->newFileUpload;
1✔
54
        }
55
        return $fileUploads;
1✔
56
    }
57

58
    public function isFilled(): bool
59
    {
60
        return count($this->getValue()) > 0;
1✔
61
    }
62

63
    public function getForm(bool $throw = true): ?Form
1✔
64
    {
65
        return $this->fileUploadControl->getForm($throw);
1✔
66
    }
67

68
    /**
69
     * @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint
70
     * @param \Stringable|string $message
71
     */
72
    public function addError($message, bool $translate = true): void
1✔
73
    {
74
        $this->fileUploadControl->addError($message, $translate);
1✔
75
    }
1✔
76

77
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc