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

heimrichhannot / contao-utils-bundle / 8432729857

26 Mar 2024 08:10AM UTC coverage: 73.003% (+0.2%) from 72.82%
8432729857

push

github

web-flow
Merge pull request #82 from heimrichhannot/feature/static-utils

Add static utilities

42 of 47 new or added lines in 5 files covered. (89.36%)

795 of 1089 relevant lines covered (73.0%)

3.51 hits per line

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

0.0
/src/StaticUtil/StaticClassUtil.php
1
<?php
2

3
namespace HeimrichHannot\UtilsBundle\StaticUtil;
4

5
class StaticClassUtil extends AbstractStaticUtil
6
{
7
    /**
8
     * Check if a class or any of its parents implements a trait.
9
     *
10
     * @param object|class-string $class The class to check.
11
     * @param class-string $trait The trait to check for.
12
     * @return bool True if the class or any of its parents implements the trait, false otherwise.
13
     */
14
    public static function hasTrait(object|string $class, string $trait): bool
15
    {
16
        do {
NEW
17
            if (in_array($trait, class_uses($class))) {
×
NEW
18
                return true;
×
19
            }
NEW
20
        } while ($class = get_parent_class($class));
×
21

NEW
22
        return false;
×
23
    }
24
}
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