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

luttje / filament-user-attributes / 6909724102

17 Nov 2023 10:28PM UTC coverage: 59.278% (+7.6%) from 51.704%
6909724102

push

github

luttje
fix basename not working for linux

1 of 2 new or added lines in 2 files covered. (50.0%)

103 existing lines in 8 files now uncovered.

837 of 1412 relevant lines covered (59.28%)

16.41 hits per line

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

88.24
/src/CodeGeneration/MethodInserter.php
1
<?php
2

3
namespace Luttje\FilamentUserAttributes\CodeGeneration;
4

5
use PhpParser\Node;
6
use PhpParser\NodeVisitorAbstract;
7

8
/**
9
 * @internal
10
 */
11
class MethodInserter extends NodeVisitorAbstract
12
{
13
    private $methodNameToAdd;
14

15
    private $methodBuilder;
16

17
    public function __construct(string $methodNameToAdd, ?\Closure $builder = null)
4✔
18
    {
19
        $this->methodNameToAdd = $methodNameToAdd;
4✔
20
        $this->methodBuilder = $builder;
4✔
21
    }
22

23
    public function enterNode(Node $node)
4✔
24
    {
25
        if (!($node instanceof Node\Stmt\Class_)) {
4✔
26
            return null;
4✔
27
        }
28

29
        $found = false;
4✔
30

31
        foreach ($node->stmts as $stmt) {
4✔
32
            if ($stmt instanceof Node\Stmt\ClassMethod) {
4✔
33
                if ($stmt->name->toString() === $this->methodNameToAdd) {
4✔
UNCOV
34
                    $found = true;
×
UNCOV
35
                    break;
×
36
                }
37
            }
38
        }
39

40
        if (!$found) {
4✔
41
            $builder = $this->methodBuilder;
4✔
42
            $node->stmts[] = new Node\Stmt\Nop();
4✔
43
            $node->stmts[] = $builder();
4✔
44
        }
45

46
        return null;
4✔
47
    }
48
}
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