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

znframework / fullpack-edition / 3808625564

pending completion
3808625564

push

github

ozanuykun
Allowed Dynamic Property

24 of 24 new or added lines in 2 files covered. (100.0%)

22 existing lines in 6 files now uncovered.

10406 of 10449 relevant lines covered (99.59%)

17.5 hits per line

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

23.81
/Internal/package-authentication/SendEmail.php
1
<?php namespace ZN\Authentication;
2
/**
3
 * ZN PHP Web Framework
4
 * 
5
 * "Simplicity is the ultimate sophistication." ~ Da Vinci
6
 * 
7
 * @package ZN
8
 * @license MIT [http://opensource.org/licenses/MIT]
9
 * @author  Ozan UYKUN [ozan@znframework.com]
10
 */
11

12
use ZN\IS;
13
use ZN\Singleton;
14

15
class SendEmail extends UserExtends
16
{
17
    /**
18
     * Keeps email class
19
     * 
20
     * @var object
21
     */
22
    protected $emailClass;
23

24
    /**
25
     * Magic construct
26
     * 
27
     * @param void
28
     * 
29
     * @return void
30
     */
31
    public function __construct()
32
    {
33
        parent::__construct();
1✔
34

35
        $this->emailClass = Singleton::class('ZN\Email\Sender');
1✔
36
    }
1✔
37
    
38
    /**
39
     * Attachment
40
     * 
41
     * @param string $file
42
     * @param string $disposition = NULL
43
     * @param string $newName     = NULL
44
     * @param mixed  $mime        = NULL
45
     */
46
    public function attachment(string $file, string $disposition = NULL, string $newName = NULL, $mime = NULL)
47
    {
48
        $this->emailClass->attachment($file, $disposition, $newName, $mime);
1✔
49
    }
1✔
50

51
    /**
52
     * Send
53
     * 
54
     * @param string $subject
55
     * @param string $body
56
     * @param int    $count = 35
57
     * 
58
     * @return void
59
     */
60
    public function send(string $subject, string $body, int $count = 35)
61
        {
UNCOV
62
        if( empty($this->usernameColumn) )
×
63
        {
64
            return false; // @codeCoverageIgnore
65
        }
66
         
67
                $users     = array_chunk($this->getUserDataResult(), $count);
×
UNCOV
68
                $sendCount = count($users);
×
69

UNCOV
70
        $this->emailClass->sender($this->senderMail, $this->senderName);
×
71

72
                for( $i = 0; $i < $sendCount; $i++ )
×
73
                {
UNCOV
74
                        foreach( $users[$i] as $user )
×
75
                        {
UNCOV
76
                $username = $user->{$this->usernameColumn};
×
77

UNCOV
78
                $email = IS::email($username)
×
UNCOV
79
                       ? $username
×
UNCOV
80
                       : ($user->{$this->emailColumn} ?? '');
×
81

UNCOV
82
                if( IS::email($email) )
×
83
                {
UNCOV
84
                    $this->emailClass->bcc($email, $username);
×
85
                }
86
                        }
87

UNCOV
88
            $this->emailClass->send($subject, $body);
×
89
                }
90
    }
×
91
    
92
    /**
93
     * Protected get user data result
94
     */
95
    protected function getUserDataResult()
96
    {
UNCOV
97
        if( ! empty($this->bannedColumn) )
×
98
        {
99
                $this->dbClass->where($this->bannedColumn, 0); // @codeCoverageIgnore
100
        }
101
        
UNCOV
102
        return $this->dbClass->get($this->tableName)->result();  
×
103
    }
104
}
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