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

phpolar / model / 6328972008

27 Sep 2023 04:47PM UTC coverage: 91.815%. First build
6328972008

Pull #42

github

web-flow
Merge ea05db7cb into c9b7f1c25
Pull Request #42: build(deps-dev): bump phpmd/phpmd from 2.13.0 to 2.14.0

258 of 281 relevant lines covered (91.81%)

7.74 hits per line

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

100.0
/src/ColumnNameTrait.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace Phpolar\Model;
6

7
use Phpolar\Phpolar\Core\DefaultColumnName;
8
use ReflectionObject;
9
use ReflectionProperty;
10

11
/**
12
 * Provides support for configuring column names of records.
13
 */
14
trait ColumnNameTrait
15
{
16
    /**
17
     * Returns the configured column name.
18
     *
19
     * @api
20
     */
21
    public function getColumnName(string $name): string
22
    {
23
        return $this->getColumnAttr((new ReflectionObject($this))
6✔
24
            ->getProperty($name))
6✔
25
            ->getColumnName();
6✔
26
    }
27

28
    /**
29
     * @internal
30
     */
31
    private function getColumnAttr(ReflectionProperty $prop): Column|DefaultColumnName
32
    {
33
        $labelAttributes = $prop->getAttributes(Column::class);
6✔
34
        if (count($labelAttributes) > 0) {
6✔
35
            return $labelAttributes[0]->newInstance()->withPropName($prop);
4✔
36
        }
37
        return new DefaultColumnName($prop->getName());
2✔
38
    }
39
}
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