Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
4 / 4
CRAP
100.00% covered (success)
100.00%
1 / 1
AuditableModel
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
4 / 4
4
100.00% covered (success)
100.00%
1 / 1
 setAuditor
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getAuditor
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 hasAuditor
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 isAuditable
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2declare(strict_types=1);
3/**
4 * Pop PHP Framework (https://www.popphp.org/)
5 *
6 * @link       https://github.com/popphp/popphp-framework
7 * @author     Nick Sagona, III <nick@popphp.org>
8 * @copyright  Copyright (c) 2009-2026 Nick Sagona, III
9 * @license    https://www.popphp.org/license     New BSD License
10 */
11
12/**
13 * @namespace
14 */
15namespace Pop\Audit\Model;
16
17use Pop\Audit\Auditor;
18use Pop\Db\Model\AbstractDataModel;
19
20/**
21 * Abstract auditable model class
22 *
23 * @category   Pop
24 * @package    Pop\Audit
25 * @author     Nick Sagona, III <nick@popphp.org>
26 * @copyright  Copyright (c) 2009-2026 Nick Sagona, III
27 * @license    https://www.popphp.org/license     New BSD License
28 * @version    3.0.0
29 */
30abstract class AuditableModel extends AbstractDataModel implements AuditableInterface
31{
32
33    /**
34     * Auditor object
35     * @var ?Auditor
36     */
37    protected ?Auditor $auditor = null;
38
39    /**
40     * Set the auditor object
41     *
42     * @param  Auditor $auditor
43     * @return AuditableModel
44     */
45    public function setAuditor(Auditor $auditor): AuditableModel
46    {
47        $this->auditor = $auditor;
48        return $this;
49    }
50
51    /**
52     * Get the auditor object
53     *
54     * @return Auditor|null
55     */
56    public function getAuditor(): Auditor|null
57    {
58        return $this->auditor;
59    }
60
61    /**
62     * Determine if the model has auditor
63     *
64     * @return bool
65     */
66    public function hasAuditor(): bool
67    {
68        return ($this->auditor !== null);
69    }
70
71    /**
72     * Determine if the model is auditable (alias)
73     *
74     * @return bool
75     */
76    public function isAuditable(): bool
77    {
78        return $this->hasAuditor();
79    }
80
81}