Skip to content

Commit 2ebce2e

Browse files
authored
update Updater.php and README.md
1 parent 3e24171 commit 2ebce2e

File tree

2 files changed

+22
-27
lines changed

2 files changed

+22
-27
lines changed

README.md

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -56,27 +56,19 @@ To initialize the Updater class and start the update process, follow these steps
5656
string $repository,
5757
string $token,
5858
string $version,
59-
string $admin,
60-
string $mailer,
61-
array $exclude = ['path' => [], 'filename' => []]
59+
string|null $admin,
60+
string|null $mailer,
61+
array|null $exclude = ['path' => [], 'filename' => []]
6262
);
6363
```
6464

6565
>- __$username__: Your GitHub username.
6666
>- __$repository__: The name of your GitHub repository.
6767
>- __$token__: The personal access token you generated earlier.
68-
>- __$version__: The current version number of your project.
69-
>- __$admin__: The email address of the admin who will receive an email in case of update failure.
70-
>- __$mailer__: The email address that the email will be sent from.
71-
>- __$exclude__: (Optional) An array of directories or files to exclude from the update.
72-
```
73-
// The $exclude array must have the format:
74-
$exclude =
75-
[
76-
'path' => [],
77-
'filename' => []
78-
]
79-
```
68+
>- __$version__: The generated GitHub personal access token for the repository.
69+
>- __$admin__: (Optional) The email address of the admin who will receive an email in case of update failure.
70+
>- __$mailer__: (Optional) The email address that the email will be sent from.
71+
>- __$exclude__: (Optional) An array of directories or files to exclude from the update. The array keys:<br>&ensp;'path' => an array of excluded paths<br>&ensp;'filename' => an array of excluded filenames
8072
8173
If a new release is available, the class will update your project automatically.
8274

src/Updater.php

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,20 @@ final class Updater
1919
private $log = [];
2020

2121
/**
22-
* Constructor for the class. Initializes the object properties and installs composer.
22+
* Constructs a new instance of the class and starts the update process for the provided version.
2323
*
24-
* @param string $username The username used for the API calls.
25-
* @param string $repository The repository used for the API calls.
26-
* @param string $token The API token used for authentication.
27-
* @param string $version The API version to use.
28-
* @param string $admin The email address of the administrator.
29-
* @param string $mailer The email address used for sending emails.
30-
* @param array $exclude An array of directories or files to exclude from the update.
31-
* The array must have the format ['path' => [], 'filename' => []]
32-
* @throws Some_Exception_Class If the update process fails.
24+
* @param string $username Your GitHub username.
25+
* @param string $repository The name of your GitHub repository.
26+
* @param string $token The generated GitHub personal access token for the repository.
27+
* @param string $version The current version number of your project.
28+
* @param string|null $admin (Optional) The email address of the admin who will receive an email in case of update failure.
29+
* @param string|null $mailer (Optional) The email address that the email will be sent from.
30+
* @param array|null $exclude (Optional) An array of directories or files to exclude from the update. The array keys:
31+
* 'path' => an array of excluded paths
32+
* 'filename' => an array of excluded filenames
3333
* @return void
3434
*/
35-
public function __construct(string $username, string $repository, string $token, string $version, string $admin, string $mailer, array $exclude = ['path' => [], 'filename' => []])
35+
public function __construct(string $username, string $repository, string $token, string $version, string|null $admin = '', string|null $mailer = '', array|null $exclude = ['path' => [], 'filename' => []])
3636
{
3737
$this->username = $username;
3838
$this->repository = $repository;
@@ -52,7 +52,10 @@ public function __construct(string $username, string $repository, string $token,
5252
$this->exclude = $exclude;
5353

5454
if (!$this->Update()) {
55-
$this->Mail();
55+
if($this->admin != '' && $this->mailer != '')
56+
{
57+
$this->Mail();
58+
}
5659
}
5760
$this->Log();
5861
if (class_exists('Composer\Autoload\ClassLoader')) {

0 commit comments

Comments
 (0)