Passed
Branch feature/2.1-geodispersion-dev (38d49e)
by Jonathan
04:17
created
src/Webtrees/Globals.php 1 patch
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -16,48 +16,48 @@
 block discarded – undo
16 16
  */
17 17
 class Globals {
18 18
     
19
-    /**
20
-     * Get global $WT_TREE variable.
21
-     * 
22
-     * @return \Fisharebest\Webtrees\Tree
23
-     */
24
-    public static function getTree() {
25
-        global $WT_TREE;
19
+	/**
20
+	 * Get global $WT_TREE variable.
21
+	 * 
22
+	 * @return \Fisharebest\Webtrees\Tree
23
+	 */
24
+	public static function getTree() {
25
+		global $WT_TREE;
26 26
         
27
-        return $WT_TREE;
28
-    }
27
+		return $WT_TREE;
28
+	}
29 29
     
30
-    /**
31
-     * Check whether the visitor is a bot.
32
-     * 
33
-     * @return boolean
34
-     */
35
-    public static function isSearchSpider() {
36
-        global $SEARCH_SPIDER;
30
+	/**
31
+	 * Check whether the visitor is a bot.
32
+	 * 
33
+	 * @return boolean
34
+	 */
35
+	public static function isSearchSpider() {
36
+		global $SEARCH_SPIDER;
37 37
         
38
-        return $SEARCH_SPIDER;
39
-    }
38
+		return $SEARCH_SPIDER;
39
+	}
40 40
     
41
-    /**
42
-     * Get the current controller.
43
-     * 
44
-     * @return \Fisharebest\Webtrees\BaseController
45
-     */
46
-    public static function getController() {
47
-        global $controller;
41
+	/**
42
+	 * Get the current controller.
43
+	 * 
44
+	 * @return \Fisharebest\Webtrees\BaseController
45
+	 */
46
+	public static function getController() {
47
+		global $controller;
48 48
         
49
-        return $controller;
50
-    }
49
+		return $controller;
50
+	}
51 51
     
52
-    /**
53
-     * Get the global facts
54
-     * 
55
-     * @return array
56
-     */
57
-    public static function getGlobalFacts() {
58
-        global $global_facts;
52
+	/**
53
+	 * Get the global facts
54
+	 * 
55
+	 * @return array
56
+	 */
57
+	public static function getGlobalFacts() {
58
+		global $global_facts;
59 59
         
60
-        return $global_facts;
61
-    }
60
+		return $global_facts;
61
+	}
62 62
     
63 63
 }
Please login to merge, or discard this patch.
src/Webtrees/Hook/HookProvider.php 1 patch
Indentation   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -43,11 +43,11 @@  discard block
 block discarded – undo
43 43
 	 */
44 44
 	public static function getInstance()
45 45
 	{
46
-	    if (null === static::$instance) {
47
-	        static::$instance = new static();
48
-	    }
46
+		if (null === static::$instance) {
47
+			static::$instance = new static();
48
+		}
49 49
 	
50
-	    return static::$instance;
50
+		return static::$instance;
51 51
 	}
52 52
 	
53 53
 	/**
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 	 * @see \MyArtJaub\Webtrees\Hook\HookProviderInterface::get()
56 56
 	 */
57 57
 	public function get($hook_function, $hook_context = null) {
58
-	    return new Hook($hook_function, $hook_context);
58
+		return new Hook($hook_function, $hook_context);
59 59
 	}
60 60
 	
61 61
 	/**
@@ -73,20 +73,20 @@  discard block
 block discarded – undo
73 73
 	public function getPossibleHooks() {
74 74
 		static $hooks=null;
75 75
 		if ($hooks === null) {
76
-		    $hooks = array();
76
+			$hooks = array();
77 77
 		    
78
-		    // Cannot use the same logic as the core Module loading,
79
-		    // as this forces a new include of the module.php file.
80
-		    // This causes issue when classes are defined in this file.
81
-		    // Cannot use Module::getActiveModules as well, as this is private.
82
-		    $module_names = Database::prepare(
83
-		        'SELECT module_name FROM `##module`'
84
-		    )->fetchOneColumn();
78
+			// Cannot use the same logic as the core Module loading,
79
+			// as this forces a new include of the module.php file.
80
+			// This causes issue when classes are defined in this file.
81
+			// Cannot use Module::getActiveModules as well, as this is private.
82
+			$module_names = Database::prepare(
83
+				'SELECT module_name FROM `##module`'
84
+			)->fetchOneColumn();
85 85
 		    
86
-		    foreach($module_names as $module_name) {
87
-		        $module = Module::getModuleByName($module_name);
86
+			foreach($module_names as $module_name) {
87
+				$module = Module::getModuleByName($module_name);
88 88
 		        
89
-		        if($module instanceof HookSubscriberInterface){
89
+				if($module instanceof HookSubscriberInterface){
90 90
 					$subscribedhooks = $module->getSubscribedHooks();
91 91
 					if(is_array($subscribedhooks)){
92 92
 						foreach($subscribedhooks as $key => $value){
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 							}
112 112
 						}
113 113
 					}
114
-		        }
114
+				}
115 115
 			}
116 116
 		}
117 117
 		return $hooks;
@@ -153,33 +153,33 @@  discard block
 block discarded – undo
153 153
 	 */
154 154
 	public function updateHooks() {
155 155
 	    
156
-	    if(Auth::isAdmin()){
157
-	        $ihooks = self::getInstalledHooks();
158
-	        $phooks = self::getPossibleHooks();
156
+		if(Auth::isAdmin()){
157
+			$ihooks = self::getInstalledHooks();
158
+			$phooks = self::getPossibleHooks();
159 159
 	        	
160
-	        // Insert hooks not existing yet in the DB
161
-	        if($phooks !== null){
162
-	            foreach($phooks as $phook => $priority){
163
-	                $array_hook = explode('#', $phook);
164
-	                if($ihooks === null || !array_key_exists($phook, $ihooks)){
165
-	                    $chook = new Hook($array_hook[1], $array_hook[2]);
166
-	                    $chook->subscribe($array_hook[0]);
167
-	                    $chook->setPriority($array_hook[0], $priority);
168
-	                }
169
-	            }
170
-	        }
160
+			// Insert hooks not existing yet in the DB
161
+			if($phooks !== null){
162
+				foreach($phooks as $phook => $priority){
163
+					$array_hook = explode('#', $phook);
164
+					if($ihooks === null || !array_key_exists($phook, $ihooks)){
165
+						$chook = new Hook($array_hook[1], $array_hook[2]);
166
+						$chook->subscribe($array_hook[0]);
167
+						$chook->setPriority($array_hook[0], $priority);
168
+					}
169
+				}
170
+			}
171 171
 	        	
172
-	        //Remove hooks not existing any more in the file system
173
-	        if($ihooks !== null){
174
-	            foreach(array_keys($ihooks) as $ihook){
175
-	                $array_hook = explode('#', $ihook);
176
-	                if($phooks === null || !array_key_exists($ihook, $phooks)){
177
-	                    $chook = new Hook($array_hook[1], $array_hook[2]);
178
-	                    $chook->remove($array_hook[0]);
179
-	                }
180
-	            }
181
-	        }
182
-	    }
172
+			//Remove hooks not existing any more in the file system
173
+			if($ihooks !== null){
174
+				foreach(array_keys($ihooks) as $ihook){
175
+					$array_hook = explode('#', $ihook);
176
+					if($phooks === null || !array_key_exists($ihook, $phooks)){
177
+						$chook = new Hook($array_hook[1], $array_hook[2]);
178
+						$chook->remove($array_hook[0]);
179
+					}
180
+				}
181
+			}
182
+		}
183 183
 	}
184 184
 	
185 185
 }
186 186
\ No newline at end of file
Please login to merge, or discard this patch.
src/Webtrees/Module/PatronymicLineage/Model/LineageRootNode.php 1 patch
Indentation   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -24,68 +24,68 @@
 block discarded – undo
24 24
 class LineageRootNode extends LineageNode
25 25
 {
26 26
     
27
-    /**
28
-     * @var Collection $places Places for the lineage node
29
-     */
30
-    private $places;
27
+	/**
28
+	 * @var Collection $places Places for the lineage node
29
+	 */
30
+	private $places;
31 31
    
32
-    /**
33
-     * @var int $nb_children Number of node childs
34
-     */
35
-    private $nb_children;
32
+	/**
33
+	 * @var int $nb_children Number of node childs
34
+	 */
35
+	private $nb_children;
36 36
   
37
-    /**
38
-     * Constructor for LineageRootNode
39
-     *
40
-     * @param Individual|null $node_indi
41
-     */
42
-    public function __construct(?Individual $node_indi = null)
43
-    {
44
-        parent::__construct($node_indi, $this);
45
-        $this->places = new Collection();
46
-        $this->nb_children = 0;
47
-    }
37
+	/**
38
+	 * Constructor for LineageRootNode
39
+	 *
40
+	 * @param Individual|null $node_indi
41
+	 */
42
+	public function __construct(?Individual $node_indi = null)
43
+	{
44
+		parent::__construct($node_indi, $this);
45
+		$this->places = new Collection();
46
+		$this->nb_children = 0;
47
+	}
48 48
    
49
-    /**
50
-     * Adds a place to the list of lineage's place
51
-     *
52
-     * @param Place $place
53
-     */
54
-    public function addPlace(Place $place): void
55
-    {
56
-        $place_name = $place->gedcomName();
57
-        if (mb_strlen($place_name) > 0) {
58
-            $this->places->put($place_name, $this->places->get($place_name, 0) + 1);
59
-        }
60
-    }
49
+	/**
50
+	 * Adds a place to the list of lineage's place
51
+	 *
52
+	 * @param Place $place
53
+	 */
54
+	public function addPlace(Place $place): void
55
+	{
56
+		$place_name = $place->gedcomName();
57
+		if (mb_strlen($place_name) > 0) {
58
+			$this->places->put($place_name, $this->places->get($place_name, 0) + 1);
59
+		}
60
+	}
61 61
     
62
-    /**
63
-     * Returns the number of child nodes.
64
-     * This number is more to be used as indication rather than an accurate one.
65
-     *
66
-     * @return int
67
-     */
68
-    public function numberChildNodes(): int
69
-    {
70
-        return $this->nb_children;
71
-    }
62
+	/**
63
+	 * Returns the number of child nodes.
64
+	 * This number is more to be used as indication rather than an accurate one.
65
+	 *
66
+	 * @return int
67
+	 */
68
+	public function numberChildNodes(): int
69
+	{
70
+		return $this->nb_children;
71
+	}
72 72
    
73
-    /**
74
-     * Increments the number of child nodes by one
75
-     *
76
-     */
77
-    public function incrementChildNodes(): void
78
-    {
79
-        $this->nb_children++;
80
-    }
73
+	/**
74
+	 * Increments the number of child nodes by one
75
+	 *
76
+	 */
77
+	public function incrementChildNodes(): void
78
+	{
79
+		$this->nb_children++;
80
+	}
81 81
    
82
-    /**
83
-     * Returns the list of place for the lineage
84
-     *
85
-     * @return Collection
86
-     */
87
-    public function places(): Collection
88
-    {
89
-        return $this->places;
90
-    }
82
+	/**
83
+	 * Returns the list of place for the lineage
84
+	 *
85
+	 * @return Collection
86
+	 */
87
+	public function places(): Collection
88
+	{
89
+		return $this->places;
90
+	}
91 91
 }
Please login to merge, or discard this patch.
src/Webtrees/Module/AdminTasks/Schema/Migration0.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -22,12 +22,12 @@
 block discarded – undo
22 22
 class Migration0 implements MigrationInterface
23 23
 {
24 24
     
25
-    /**
26
-     * {@inheritDoc}
27
-     * @see MigrationInterface::upgrade()
28
-     */
29
-    public function upgrade(): void
30
-    {
31
-        // These migrations have been merged into migration 1.
32
-    }
25
+	/**
26
+	 * {@inheritDoc}
27
+	 * @see MigrationInterface::upgrade()
28
+	 */
29
+	public function upgrade(): void
30
+	{
31
+		// These migrations have been merged into migration 1.
32
+	}
33 33
 }
Please login to merge, or discard this patch.
src/Webtrees/Module/AdminTasks/Contracts/ConfigurableTaskInterface.php 1 patch
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -22,20 +22,20 @@
 block discarded – undo
22 22
 interface ConfigurableTaskInterface
23 23
 {
24 24
     
25
-    /**
26
-     * Returns the HTML code to display the specific task configuration.
27
-     *
28
-     * @param ServerRequestInterface $request
29
-     * @return string HTML code
30
-     */
31
-    public function configView(ServerRequestInterface $request): string;
25
+	/**
26
+	 * Returns the HTML code to display the specific task configuration.
27
+	 *
28
+	 * @param ServerRequestInterface $request
29
+	 * @return string HTML code
30
+	 */
31
+	public function configView(ServerRequestInterface $request): string;
32 32
  
33
-    /**
34
-     * Update the specific configuration of the task.
35
-     *
36
-     * @param ServerRequestInterface $request
37
-     * @param TaskSchedule $task_schedule
38
-     * @return bool Result of the update
39
-     */
40
-    public function updateConfig(ServerRequestInterface $request, TaskSchedule $task_schedule): bool;
33
+	/**
34
+	 * Update the specific configuration of the task.
35
+	 *
36
+	 * @param ServerRequestInterface $request
37
+	 * @param TaskSchedule $task_schedule
38
+	 * @return bool Result of the update
39
+	 */
40
+	public function updateConfig(ServerRequestInterface $request, TaskSchedule $task_schedule): bool;
41 41
 }
Please login to merge, or discard this patch.
src/Webtrees/Module/AdminTasks/Contracts/TaskInterface.php 1 patch
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -19,25 +19,25 @@
 block discarded – undo
19 19
  */
20 20
 interface TaskInterface
21 21
 {
22
-    /**
23
-     * Display name of the task
24
-     *
25
-     * @return string
26
-     */
27
-    public function name(): string;
22
+	/**
23
+	 * Display name of the task
24
+	 *
25
+	 * @return string
26
+	 */
27
+	public function name(): string;
28 28
     
29
-    /**
30
-     * Return the default frequency for the execution of the task, in minutes.
31
-     *
32
-     * @return int Frequency for the execution of the task
33
-     */
34
-    public function defaultFrequency(): int;
29
+	/**
30
+	 * Return the default frequency for the execution of the task, in minutes.
31
+	 *
32
+	 * @return int Frequency for the execution of the task
33
+	 */
34
+	public function defaultFrequency(): int;
35 35
     
36
-    /**
37
-     * Run the task's actions, and return whether the execution has been successful.
38
-     *
39
-     * @param TaskSchedule $task_schedule
40
-     * @return bool Has the execution been a success
41
-     */
42
-    public function run(TaskSchedule $task_schedule): bool;
36
+	/**
37
+	 * Run the task's actions, and return whether the execution has been successful.
38
+	 *
39
+	 * @param TaskSchedule $task_schedule
40
+	 * @return bool Has the execution been a success
41
+	 */
42
+	public function run(TaskSchedule $task_schedule): bool;
43 43
 }
Please login to merge, or discard this patch.
src/Webtrees/Module/AdminTasks/Contracts/ModuleTasksProviderInterface.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -20,11 +20,11 @@
 block discarded – undo
20 20
 interface ModuleTasksProviderInterface
21 21
 {
22 22
     
23
-    /**
24
-     * List tasks provided by the module as an associative array.
25
-     * They keys are used as task IDs for storage and reference.
26
-     *
27
-     * @return array<string, string> List of tasks
28
-     */
29
-    public function listTasks(): array;
23
+	/**
24
+	 * List tasks provided by the module as an associative array.
25
+	 * They keys are used as task IDs for storage and reference.
26
+	 *
27
+	 * @return array<string, string> List of tasks
28
+	 */
29
+	public function listTasks(): array;
30 30
 }
Please login to merge, or discard this patch.
src/Webtrees/Module/PatronymicLineage/Model/LineageNode.php 1 patch
Indentation   +113 added lines, -113 removed lines patch added patch discarded remove patch
@@ -25,117 +25,117 @@
 block discarded – undo
25 25
 class LineageNode
26 26
 {
27 27
 
28
-    /**
29
-     * @var Collection $linked_fams Spouse families linked to the node
30
-     */
31
-    private $linked_fams;
32
-
33
-    /**
34
-     * @var ?Individual $node_indi Reference individual for the node
35
-     */
36
-    private $node_indi;
37
-
38
-    /**
39
-     * @var LineageRootNode $root_node Root node of the lineage
40
-     */
41
-    private $root_node;
42
-
43
-    /**
44
-     * @var ?string $alt_surname Linked surname, used to link to another lineage
45
-     */
46
-    private $alt_surname;
47
-
48
-    /**
49
-     * Constructor for Lineage node
50
-     *
51
-     * @param Individual $node_indi Main individual
52
-     * @param LineageRootNode $root_node Node of the lineage root
53
-     * @param null|string $alt_surname Follow-up surname
54
-     */
55
-    public function __construct(?Individual $node_indi = null, LineageRootNode $root_node, $alt_surname = null)
56
-    {
57
-        $this->node_indi = $node_indi;
58
-        $this->root_node = $root_node;
59
-        $this->alt_surname = $alt_surname;
60
-        $this->linked_fams = new Collection();
61
-    }
62
-
63
-    /**
64
-     * Add a spouse family to the node
65
-     *
66
-     * @param Family $fams
67
-     * @return stdClass
68
-     */
69
-    public function addFamily(Family $fams): object
70
-    {
71
-        if (!$this->linked_fams->has($fams->xref())) {
72
-            $this->linked_fams->put($fams->xref(), (object) [
73
-                'family'   =>  $fams,
74
-                'children' =>  new Collection()
75
-            ]);
76
-        }
77
-        return $this->linked_fams->get($fams->xref());
78
-    }
79
-
80
-    /**
81
-     * Add a child LineageNode to the node
82
-     *
83
-     * @param Family $fams
84
-     * @param LineageNode $child
85
-     */
86
-    public function addChild(Family $fams, LineageNode $child = null): void
87
-    {
88
-        $this->addFamily($fams)->children->push($child);
89
-        $this->root_node->incrementChildNodes();
90
-    }
91
-
92
-    /**
93
-     * Returns the node individual
94
-     *
95
-     * @return Individual|NULL
96
-     */
97
-    public function individual(): ?Individual
98
-    {
99
-        return $this->node_indi;
100
-    }
101
-
102
-    /**
103
-     * Returns the lineage root node individual
104
-     *
105
-     * @return LineageRootNode
106
-     */
107
-    public function rootNode(): LineageRootNode
108
-    {
109
-        return $this->root_node;
110
-    }
111
-
112
-    /**
113
-     * Returns the spouse families linked to the node
114
-     *
115
-     * @return Collection
116
-     */
117
-    public function families(): Collection
118
-    {
119
-        return $this->linked_fams;
120
-    }
121
-
122
-    /**
123
-     * Returns the follow-up surname
124
-     *
125
-     * @return string
126
-     */
127
-    public function followUpSurname(): string
128
-    {
129
-        return $this->alt_surname ?? '';
130
-    }
131
-
132
-    /**
133
-     * Indicates whether the node has a follow up surname
134
-     *
135
-     * @return boolean
136
-     */
137
-    public function hasFollowUpSurname(): bool
138
-    {
139
-        return mb_strlen($this->followUpSurname()) > 0 ;
140
-    }
28
+	/**
29
+	 * @var Collection $linked_fams Spouse families linked to the node
30
+	 */
31
+	private $linked_fams;
32
+
33
+	/**
34
+	 * @var ?Individual $node_indi Reference individual for the node
35
+	 */
36
+	private $node_indi;
37
+
38
+	/**
39
+	 * @var LineageRootNode $root_node Root node of the lineage
40
+	 */
41
+	private $root_node;
42
+
43
+	/**
44
+	 * @var ?string $alt_surname Linked surname, used to link to another lineage
45
+	 */
46
+	private $alt_surname;
47
+
48
+	/**
49
+	 * Constructor for Lineage node
50
+	 *
51
+	 * @param Individual $node_indi Main individual
52
+	 * @param LineageRootNode $root_node Node of the lineage root
53
+	 * @param null|string $alt_surname Follow-up surname
54
+	 */
55
+	public function __construct(?Individual $node_indi = null, LineageRootNode $root_node, $alt_surname = null)
56
+	{
57
+		$this->node_indi = $node_indi;
58
+		$this->root_node = $root_node;
59
+		$this->alt_surname = $alt_surname;
60
+		$this->linked_fams = new Collection();
61
+	}
62
+
63
+	/**
64
+	 * Add a spouse family to the node
65
+	 *
66
+	 * @param Family $fams
67
+	 * @return stdClass
68
+	 */
69
+	public function addFamily(Family $fams): object
70
+	{
71
+		if (!$this->linked_fams->has($fams->xref())) {
72
+			$this->linked_fams->put($fams->xref(), (object) [
73
+				'family'   =>  $fams,
74
+				'children' =>  new Collection()
75
+			]);
76
+		}
77
+		return $this->linked_fams->get($fams->xref());
78
+	}
79
+
80
+	/**
81
+	 * Add a child LineageNode to the node
82
+	 *
83
+	 * @param Family $fams
84
+	 * @param LineageNode $child
85
+	 */
86
+	public function addChild(Family $fams, LineageNode $child = null): void
87
+	{
88
+		$this->addFamily($fams)->children->push($child);
89
+		$this->root_node->incrementChildNodes();
90
+	}
91
+
92
+	/**
93
+	 * Returns the node individual
94
+	 *
95
+	 * @return Individual|NULL
96
+	 */
97
+	public function individual(): ?Individual
98
+	{
99
+		return $this->node_indi;
100
+	}
101
+
102
+	/**
103
+	 * Returns the lineage root node individual
104
+	 *
105
+	 * @return LineageRootNode
106
+	 */
107
+	public function rootNode(): LineageRootNode
108
+	{
109
+		return $this->root_node;
110
+	}
111
+
112
+	/**
113
+	 * Returns the spouse families linked to the node
114
+	 *
115
+	 * @return Collection
116
+	 */
117
+	public function families(): Collection
118
+	{
119
+		return $this->linked_fams;
120
+	}
121
+
122
+	/**
123
+	 * Returns the follow-up surname
124
+	 *
125
+	 * @return string
126
+	 */
127
+	public function followUpSurname(): string
128
+	{
129
+		return $this->alt_surname ?? '';
130
+	}
131
+
132
+	/**
133
+	 * Indicates whether the node has a follow up surname
134
+	 *
135
+	 * @return boolean
136
+	 */
137
+	public function hasFollowUpSurname(): bool
138
+	{
139
+		return mb_strlen($this->followUpSurname()) > 0 ;
140
+	}
141 141
 }
Please login to merge, or discard this patch.
src/Webtrees/Module/AdminTasks/Model/TaskSchedule.php 1 patch
Indentation   +286 added lines, -286 removed lines patch added patch discarded remove patch
@@ -25,290 +25,290 @@
 block discarded – undo
25 25
 class TaskSchedule
26 26
 {
27 27
 
28
-    /**
29
-     * Task Schedule ID
30
-     * @var int $id
31
-     */
32
-    private $id;
33
-
34
-    /**
35
-     * Task schedule status
36
-     * @var bool $enabled
37
-     */
38
-    private $enabled;
39
-
40
-    /**
41
-     * ID of the task attached to schedule
42
-     * @var string $task_id
43
-     */
44
-    private $task_id;
45
-
46
-    /**
47
-     * Last updated date
48
-     * @var Carbon $last_run
49
-     */
50
-    private $last_run;
51
-
52
-    /**
53
-     * Last run result
54
-     * @var bool $last_result
55
-     */
56
-    private $last_result;
57
-
58
-    /**
59
-     * Task run frequency
60
-     * @var CarbonInterval $frequency
61
-     */
62
-    private $frequency;
63
-
64
-    /**
65
-     * Task remaining runs
66
-     * @var int $nb_occurrences
67
-     */
68
-    private $nb_occurrences;
69
-
70
-    /**
71
-     * Current running status of the task
72
-     * @var bool $is_running
73
-     */
74
-    private $is_running;
75
-
76
-    /**
77
-     * Constructor for TaskSchedule
78
-     *
79
-     * @param int $id Schedule ID
80
-     * @param string $task_id Task ID
81
-     * @param bool $enabled Is the schedule enabled
82
-     * @param Carbon $last_run Last successful run date/time
83
-     * @param bool $last_result Result of the last run
84
-     * @param CarbonInterval $frequency Schedule frequency
85
-     * @param int $nb_occurrences Number of remaining occurrences to be run
86
-     * @param bool $is_running Is the task currently running
87
-     */
88
-    public function __construct(
89
-        int $id,
90
-        string $task_id,
91
-        bool $enabled,
92
-        Carbon $last_run,
93
-        bool $last_result,
94
-        CarbonInterval $frequency,
95
-        int $nb_occurrences,
96
-        bool $is_running
97
-    ) {
98
-        $this->id = $id;
99
-        $this->task_id = $task_id;
100
-        $this->enabled = $enabled;
101
-        $this->last_run = $last_run;
102
-        $this->last_result = $last_result;
103
-        $this->frequency = $frequency;
104
-        $this->nb_occurrences = $nb_occurrences;
105
-        $this->is_running = $is_running;
106
-    }
107
-
108
-    /**
109
-     * Get the schedule ID.
110
-     *
111
-     * @return int
112
-     */
113
-    public function id(): int
114
-    {
115
-        return $this->id;
116
-    }
117
-
118
-    /**
119
-     * Get the task ID.
120
-     *
121
-     * @return string
122
-     */
123
-    public function taskId(): string
124
-    {
125
-        return $this->task_id;
126
-    }
127
-
128
-    /**
129
-     * Returns whether the schedule is enabled
130
-     *
131
-     * @return bool
132
-     */
133
-    public function isEnabled(): bool
134
-    {
135
-        return $this->enabled;
136
-    }
137
-
138
-    /**
139
-     * Enable the schedule
140
-     *
141
-     * @return self
142
-     */
143
-    public function enable(): self
144
-    {
145
-        $this->enabled = true;
146
-        return $this;
147
-    }
148
-
149
-    /**
150
-     * Disable the schedule
151
-     *
152
-     * @return self
153
-     */
154
-    public function disable(): self
155
-    {
156
-        $this->enabled = false;
157
-        return $this;
158
-    }
159
-
160
-    /**
161
-     * Get the frequency of the schedule
162
-     *
163
-     * @return CarbonInterval
164
-     */
165
-    public function frequency(): CarbonInterval
166
-    {
167
-        return $this->frequency;
168
-    }
169
-
170
-    /**
171
-     * Set the frequency of the schedule
172
-     *
173
-     * @param CarbonInterval $frequency
174
-     * @return self
175
-     */
176
-    public function setFrequency(CarbonInterval $frequency): self
177
-    {
178
-        $this->frequency = $frequency;
179
-        return $this;
180
-    }
181
-
182
-    /**
183
-     * Get the date/time of the last successful run.
184
-     *
185
-     * @return Carbon
186
-     */
187
-    public function lastRunTime(): Carbon
188
-    {
189
-        return $this->last_run;
190
-    }
191
-
192
-    /**
193
-     * Set the last successful run date/time
194
-     *
195
-     * @param Carbon $last_run
196
-     * @return self
197
-     */
198
-    public function setLastRunTime(Carbon $last_run): self
199
-    {
200
-        $this->last_run = $last_run;
201
-        return $this;
202
-    }
203
-
204
-    /**
205
-     * Returns whether the last run was successful
206
-     *
207
-     * @return bool
208
-     */
209
-    public function wasLastRunSuccess(): bool
210
-    {
211
-        return $this->last_result;
212
-    }
213
-
214
-    /**
215
-     * Set the last run result
216
-     *
217
-     * @param bool $last_result
218
-     * @return self
219
-     */
220
-    public function setLastResult(bool $last_result): self
221
-    {
222
-        $this->last_result = $last_result;
223
-        return $this;
224
-    }
225
-
226
-    /**
227
-     * Get the number of remaining of occurrences of task runs.
228
-     * Returns 0 if the tasks must be run indefinitely.
229
-     *
230
-     * @return int
231
-     */
232
-    public function remainingOccurences(): int
233
-    {
234
-        return $this->nb_occurrences;
235
-    }
236
-
237
-    /**
238
-     * Decrements the number of remaining occurences by 1.
239
-     * The task will be disabled when the number reaches 0.
240
-     *
241
-     * @return self
242
-     */
243
-    public function decrementRemainingOccurences(): self
244
-    {
245
-        if ($this->nb_occurrences > 0) {
246
-            $this->nb_occurrences--;
247
-            if ($this->nb_occurrences == 0) {
248
-                $this->disable();
249
-            }
250
-        }
251
-        return $this;
252
-    }
253
-
254
-    /**
255
-     * Set the number of remaining occurences of task runs.
256
-     *
257
-     * @param int $nb_occurrences
258
-     * @return self
259
-     */
260
-    public function setRemainingOccurences(int $nb_occurrences): self
261
-    {
262
-        $this->nb_occurrences = $nb_occurrences;
263
-        return $this;
264
-    }
265
-
266
-    /**
267
-     * Returns whether the task is running
268
-     * @return bool
269
-     */
270
-    public function isRunning(): bool
271
-    {
272
-        return $this->is_running;
273
-    }
274
-
275
-    /**
276
-     * Informs the schedule that the task is going to run
277
-     *
278
-     * @return self
279
-     */
280
-    public function startRunning(): self
281
-    {
282
-        $this->is_running = true;
283
-        return $this;
284
-    }
285
-
286
-    /**
287
-     * Informs the schedule that the task has stopped running.
288
-     * @return self
289
-     */
290
-    public function stopRunning(): self
291
-    {
292
-        $this->is_running = false;
293
-        return $this;
294
-    }
295
-
296
-    /**
297
-     * Returns the schedule details as an associate array
298
-     *
299
-     * @return array
300
-     */
301
-    public function toArray(): array
302
-    {
303
-        return [
304
-            'id'            =>  $this->id,
305
-            'task_id'       =>  $this->task_id,
306
-            'enabled'       =>  $this->enabled,
307
-            'last_run'      =>  $this->last_run,
308
-            'last_result'   =>  $this->last_result,
309
-            'frequency'     =>  $this->frequency,
310
-            'nb_occurrences' =>  $this->nb_occurrences,
311
-            'is_running'    =>  $this->is_running
312
-        ];
313
-    }
28
+	/**
29
+	 * Task Schedule ID
30
+	 * @var int $id
31
+	 */
32
+	private $id;
33
+
34
+	/**
35
+	 * Task schedule status
36
+	 * @var bool $enabled
37
+	 */
38
+	private $enabled;
39
+
40
+	/**
41
+	 * ID of the task attached to schedule
42
+	 * @var string $task_id
43
+	 */
44
+	private $task_id;
45
+
46
+	/**
47
+	 * Last updated date
48
+	 * @var Carbon $last_run
49
+	 */
50
+	private $last_run;
51
+
52
+	/**
53
+	 * Last run result
54
+	 * @var bool $last_result
55
+	 */
56
+	private $last_result;
57
+
58
+	/**
59
+	 * Task run frequency
60
+	 * @var CarbonInterval $frequency
61
+	 */
62
+	private $frequency;
63
+
64
+	/**
65
+	 * Task remaining runs
66
+	 * @var int $nb_occurrences
67
+	 */
68
+	private $nb_occurrences;
69
+
70
+	/**
71
+	 * Current running status of the task
72
+	 * @var bool $is_running
73
+	 */
74
+	private $is_running;
75
+
76
+	/**
77
+	 * Constructor for TaskSchedule
78
+	 *
79
+	 * @param int $id Schedule ID
80
+	 * @param string $task_id Task ID
81
+	 * @param bool $enabled Is the schedule enabled
82
+	 * @param Carbon $last_run Last successful run date/time
83
+	 * @param bool $last_result Result of the last run
84
+	 * @param CarbonInterval $frequency Schedule frequency
85
+	 * @param int $nb_occurrences Number of remaining occurrences to be run
86
+	 * @param bool $is_running Is the task currently running
87
+	 */
88
+	public function __construct(
89
+		int $id,
90
+		string $task_id,
91
+		bool $enabled,
92
+		Carbon $last_run,
93
+		bool $last_result,
94
+		CarbonInterval $frequency,
95
+		int $nb_occurrences,
96
+		bool $is_running
97
+	) {
98
+		$this->id = $id;
99
+		$this->task_id = $task_id;
100
+		$this->enabled = $enabled;
101
+		$this->last_run = $last_run;
102
+		$this->last_result = $last_result;
103
+		$this->frequency = $frequency;
104
+		$this->nb_occurrences = $nb_occurrences;
105
+		$this->is_running = $is_running;
106
+	}
107
+
108
+	/**
109
+	 * Get the schedule ID.
110
+	 *
111
+	 * @return int
112
+	 */
113
+	public function id(): int
114
+	{
115
+		return $this->id;
116
+	}
117
+
118
+	/**
119
+	 * Get the task ID.
120
+	 *
121
+	 * @return string
122
+	 */
123
+	public function taskId(): string
124
+	{
125
+		return $this->task_id;
126
+	}
127
+
128
+	/**
129
+	 * Returns whether the schedule is enabled
130
+	 *
131
+	 * @return bool
132
+	 */
133
+	public function isEnabled(): bool
134
+	{
135
+		return $this->enabled;
136
+	}
137
+
138
+	/**
139
+	 * Enable the schedule
140
+	 *
141
+	 * @return self
142
+	 */
143
+	public function enable(): self
144
+	{
145
+		$this->enabled = true;
146
+		return $this;
147
+	}
148
+
149
+	/**
150
+	 * Disable the schedule
151
+	 *
152
+	 * @return self
153
+	 */
154
+	public function disable(): self
155
+	{
156
+		$this->enabled = false;
157
+		return $this;
158
+	}
159
+
160
+	/**
161
+	 * Get the frequency of the schedule
162
+	 *
163
+	 * @return CarbonInterval
164
+	 */
165
+	public function frequency(): CarbonInterval
166
+	{
167
+		return $this->frequency;
168
+	}
169
+
170
+	/**
171
+	 * Set the frequency of the schedule
172
+	 *
173
+	 * @param CarbonInterval $frequency
174
+	 * @return self
175
+	 */
176
+	public function setFrequency(CarbonInterval $frequency): self
177
+	{
178
+		$this->frequency = $frequency;
179
+		return $this;
180
+	}
181
+
182
+	/**
183
+	 * Get the date/time of the last successful run.
184
+	 *
185
+	 * @return Carbon
186
+	 */
187
+	public function lastRunTime(): Carbon
188
+	{
189
+		return $this->last_run;
190
+	}
191
+
192
+	/**
193
+	 * Set the last successful run date/time
194
+	 *
195
+	 * @param Carbon $last_run
196
+	 * @return self
197
+	 */
198
+	public function setLastRunTime(Carbon $last_run): self
199
+	{
200
+		$this->last_run = $last_run;
201
+		return $this;
202
+	}
203
+
204
+	/**
205
+	 * Returns whether the last run was successful
206
+	 *
207
+	 * @return bool
208
+	 */
209
+	public function wasLastRunSuccess(): bool
210
+	{
211
+		return $this->last_result;
212
+	}
213
+
214
+	/**
215
+	 * Set the last run result
216
+	 *
217
+	 * @param bool $last_result
218
+	 * @return self
219
+	 */
220
+	public function setLastResult(bool $last_result): self
221
+	{
222
+		$this->last_result = $last_result;
223
+		return $this;
224
+	}
225
+
226
+	/**
227
+	 * Get the number of remaining of occurrences of task runs.
228
+	 * Returns 0 if the tasks must be run indefinitely.
229
+	 *
230
+	 * @return int
231
+	 */
232
+	public function remainingOccurences(): int
233
+	{
234
+		return $this->nb_occurrences;
235
+	}
236
+
237
+	/**
238
+	 * Decrements the number of remaining occurences by 1.
239
+	 * The task will be disabled when the number reaches 0.
240
+	 *
241
+	 * @return self
242
+	 */
243
+	public function decrementRemainingOccurences(): self
244
+	{
245
+		if ($this->nb_occurrences > 0) {
246
+			$this->nb_occurrences--;
247
+			if ($this->nb_occurrences == 0) {
248
+				$this->disable();
249
+			}
250
+		}
251
+		return $this;
252
+	}
253
+
254
+	/**
255
+	 * Set the number of remaining occurences of task runs.
256
+	 *
257
+	 * @param int $nb_occurrences
258
+	 * @return self
259
+	 */
260
+	public function setRemainingOccurences(int $nb_occurrences): self
261
+	{
262
+		$this->nb_occurrences = $nb_occurrences;
263
+		return $this;
264
+	}
265
+
266
+	/**
267
+	 * Returns whether the task is running
268
+	 * @return bool
269
+	 */
270
+	public function isRunning(): bool
271
+	{
272
+		return $this->is_running;
273
+	}
274
+
275
+	/**
276
+	 * Informs the schedule that the task is going to run
277
+	 *
278
+	 * @return self
279
+	 */
280
+	public function startRunning(): self
281
+	{
282
+		$this->is_running = true;
283
+		return $this;
284
+	}
285
+
286
+	/**
287
+	 * Informs the schedule that the task has stopped running.
288
+	 * @return self
289
+	 */
290
+	public function stopRunning(): self
291
+	{
292
+		$this->is_running = false;
293
+		return $this;
294
+	}
295
+
296
+	/**
297
+	 * Returns the schedule details as an associate array
298
+	 *
299
+	 * @return array
300
+	 */
301
+	public function toArray(): array
302
+	{
303
+		return [
304
+			'id'            =>  $this->id,
305
+			'task_id'       =>  $this->task_id,
306
+			'enabled'       =>  $this->enabled,
307
+			'last_run'      =>  $this->last_run,
308
+			'last_result'   =>  $this->last_result,
309
+			'frequency'     =>  $this->frequency,
310
+			'nb_occurrences' =>  $this->nb_occurrences,
311
+			'is_running'    =>  $this->is_running
312
+		];
313
+	}
314 314
 }
Please login to merge, or discard this patch.