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

nepada / file-upload-control / 7140035394

01 Dec 2023 04:06AM UTC coverage: 89.525%. Remained the same
7140035394

push

github

web-flow
Bump actions/github-script from 6 to 7 (#134)

641 of 716 relevant lines covered (89.53%)

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
    public function getCaption(): Html|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 Html|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