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

conedevelopment / root / 15084089635

17 May 2025 10:00AM UTC coverage: 77.93% (+0.04%) from 77.891%
15084089635

push

github

web-flow
Modernize back-end.yml (#240)

3291 of 4223 relevant lines covered (77.93%)

36.04 hits per line

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

88.24
/src/Fields/Option.php
1
<?php
2

3
namespace Cone\Root\Fields;
4

5
use Cone\Root\Traits\HasAttributes;
6
use Cone\Root\Traits\Makeable;
7
use Illuminate\Contracts\Support\Arrayable;
8
use Illuminate\Support\Traits\Conditionable;
9
use JsonSerializable;
10

11
use function Illuminate\Support\enum_value;
12

13
class Option implements Arrayable, JsonSerializable
14
{
15
    use Conditionable;
16
    use HasAttributes;
17
    use Makeable;
18

19
    /**
20
     * The option label.
21
     */
22
    protected string $label;
23

24
    /**
25
     * Create a new option instance.
26
     */
27
    public function __construct(mixed $value, string $label)
11✔
28
    {
29
        $this->label = $label;
11✔
30
        $this->setAttribute('value', enum_value($value));
11✔
31
        $this->selected(false);
11✔
32
    }
33

34
    /**
35
     * Set the "disabled" HTML attribute.
36
     */
37
    public function disabled(bool $value = true): static
×
38
    {
39
        return $this->setAttribute('disabled', $value);
×
40
    }
41

42
    /**
43
     * Set the "selected" HTML attribute.
44
     */
45
    public function selected(bool $value = true): static
11✔
46
    {
47
        return $this->setAttribute('selected', $value);
11✔
48
    }
49

50
    /**
51
     * Convert the element to a JSON serializable format.
52
     */
53
    public function jsonSerialize(): array
2✔
54
    {
55
        return $this->toArray();
2✔
56
    }
57

58
    /**
59
     * Get the array representation of the object.
60
     */
61
    public function toArray(): array
11✔
62
    {
63
        return [
11✔
64
            'attrs' => $this->newAttributeBag(),
11✔
65
            'label' => $this->label,
11✔
66
            'selected' => $this->getAttribute('selected'),
11✔
67
            'value' => $this->getAttribute('value'),
11✔
68
        ];
11✔
69
    }
70
}
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