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

diego-ninja / granite / 16608963009

29 Jul 2025 10:37PM UTC coverage: 50.423%. First build
16608963009

Pull #5

github

web-flow
Merge 43d8840d7 into 6a6caca51
Pull Request #5: code: adds phpstan level max, pint with per and github actions

321 of 632 new or added lines in 77 files covered. (50.79%)

1132 of 2245 relevant lines covered (50.42%)

9.88 hits per line

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

0.0
/src/Validation/Attributes/When.php
1
<?php
2

3
namespace Ninja\Granite\Validation\Attributes;
4

5
use Attribute;
6
use Ninja\Granite\Validation\Rules;
7
use Ninja\Granite\Validation\ValidationRule;
8

9
/**
10
 * Attribute for conditional validation.
11
 */
12
#[Attribute(Attribute::TARGET_PROPERTY)]
13
class When
14
{
15
    /**
16
     * @var callable Condition callback
17
     */
18
    private $condition;
19

20
    /**
21
     * @var ValidationRule Rule to apply if condition is true
22
     */
23
    private ValidationRule $rule;
24

25
    /**
26
     * @var string|null Custom error message
27
     */
28
    private ?string $message;
29

30
    public function __construct(callable $condition, ValidationRule $rule, ?string $message = null)
×
31
    {
32
        $this->condition = $condition;
×
33
        $this->rule = $rule;
×
34
        $this->message = $message;
×
35
    }
36

37
    public function asRule(): Rules\When
×
38
    {
39
        $rule = new Rules\When($this->condition, $this->rule);
×
40

NEW
41
        if (null !== $this->message) {
×
42
            $rule->withMessage($this->message);
×
43
        }
44

45
        return $rule;
×
46
    }
47
}
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

© 2026 Coveralls, Inc