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

conedevelopment / root / 13086943877

01 Feb 2025 08:35AM UTC coverage: 79.285% (+1.2%) from 78.037%
13086943877

push

github

web-flow
Merge pull request #234 from xHeaven/patch-1

Codebase health checkup

195 of 239 new or added lines in 45 files covered. (81.59%)

2 existing lines in 2 files now uncovered.

2572 of 3244 relevant lines covered (79.28%)

35.8 hits per line

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

90.91
/src/Traits/ResolvesVisibility.php
1
<?php
2

3
namespace Cone\Root\Traits;
4

5
use Closure;
6
use Illuminate\Support\Arr;
7

8
trait ResolvesVisibility
9
{
10
    /**
11
     * The visibility resolver callbacks.
12
     */
13
    protected array $visibilityResolvers = [];
14

15
    /**
16
     * Determine if the object is visible for the given request.
17
     */
18
    public function visible(string|array $context): bool
19
    {
20
        foreach ($this->visibilityResolvers as $callback) {
16✔
21
            if (! call_user_func_array($callback, [$context])) {
7✔
22
                return false;
7✔
23
            }
24
        }
25

26
        return true;
16✔
27
    }
28

29
    /**
30
     * Set a custom visibility resolver.
31
     */
32
    public function visibleOn(string|array|Closure $context): static
33
    {
34
        $this->visibilityResolvers[] = $context instanceof Closure
198✔
35
            ? $context
198✔
36
            : static fn (string|array $currentContext) => ! empty(array_intersect(Arr::wrap($currentContext), Arr::wrap($context)));
198✔
37

38
        return $this;
198✔
39
    }
40

41
    /**
42
     * Set a custom hidden resolver.
43
     */
44
    public function hiddenOn(string|array|Closure $context): static
45
    {
46
        return $this->visibleOn(static fn (array|string $currentContext): bool => $context instanceof Closure
198✔
NEW
47
            ? ! call_user_func_array($context, [$currentContext])
×
48
            : empty(array_intersect(Arr::wrap($currentContext), Arr::wrap($context))));
198✔
49
    }
50
}
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