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

nepada / file-upload-control / 4581408359

pending completion
4581408359

Pull #103

github

GitHub
Merge ed661242b into c8546f895
Pull Request #103: Update nepada/coding-standard requirement from 7.6.0 to 7.7.0

641 of 710 relevant lines covered (90.28%)

0.9 hits per line

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

90.91
/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
use Nette\Utils\Html;
11

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

18
    private FileUploadControl $fileUploadControl;
19

20
    private ?FileUpload $newFileUpload = null;
21

22
    public function __construct(FileUploadControl $fileUploadControl)
1✔
23
    {
24
        parent::__construct();
1✔
25
        $this->fileUploadControl = $fileUploadControl;
1✔
26
        $fileUploadControl->monitor(Form::class, function (Form $form): void {
1✔
27
            $this->setParent(null, $this->fileUploadControl->getName());
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
    /**
42
     * @return Html|string|null
43
     */
44
    public function getCaption()
45
    {
46
        return $this->fileUploadControl->getCaption();
×
47
    }
48

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

61
    public function isFilled(): bool
62
    {
63
        return count($this->getValue()) > 0;
1✔
64
    }
65

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

71
    /**
72
     * @param Html|string $message
73
     * @param bool $translate
74
     */
75
    public function addError($message, bool $translate = true): void
1✔
76
    {
77
        $this->fileUploadControl->addError($message, $translate);
1✔
78
    }
1✔
79

80
}
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