1- <?php namespace IXP \Console \Commands \MailingList ;
1+ <?php
2+
3+ namespace IXP \Console \Commands \MailingList ;
24
35/*
4- * Copyright (C) 2009 - 2019 Internet Neutral Exchange Association Company Limited By Guarantee.
6+ * Copyright (C) 2009 - 2021 Internet Neutral Exchange Association Company Limited By Guarantee.
57 * All Rights Reserved.
68 *
79 * This file is part of IXP Manager.
3133 * @author Barry O'Donovan <[email protected] > 3234 * @category MailingList
3335 * @package IXP\Console\Commands
34- * @copyright Copyright (C) 2009 - 2019 Internet Neutral Exchange Association Company Limited By Guarantee
36+ * @copyright Copyright (C) 2009 - 2021 Internet Neutral Exchange Association Company Limited By Guarantee
3537 * @license http://www.gnu.org/licenses/gpl-2.0.html GNU GPL V2.0
3638 */
37- class Init extends MailingList {
38-
39+ class Init extends MailingList
40+ {
3941 /**
4042 * The name and signature of the console command.
4143 *
@@ -66,17 +68,19 @@ class Init extends MailingList {
6668 * but set those without a setting to on / off as appropriate.
6769 *
6870 * @return mixed
71+ *
72+ * @throws
6973 */
70- public function handle (): int {
71-
74+ public function handle (): int
75+ {
7276 if ( !config ( 'mailinglists.enabled ' ) ) {
7377 die ( "Mailing list functionality is disabled. See: http://docs.ixpmanager.org/features/mailing-lists/ \n" );
7478 }
7579
7680 $ ml = new ML ( $ this ->argument ('list ' ) );
7781
7882 $ stdin = fopen ( "php://stdin " ,"r " );
79- $ addresses = new Set ;
83+ $ addresses = collect () ;
8084
8185 while ( $ address = strtolower ( trim ( fgets ( $ stdin ) ) ) ) {
8286 if ( !$ addresses ->contains ( $ address ) ) {
@@ -90,9 +94,9 @@ public function handle(): int {
9094
9195 $ result = $ ml ->init ( $ addresses );
9296
93- if ( $ this ->isVerbosityVerbose () || $ this ->option ('format ' ) == 'json ' ) {
94- if ( $ this ->option ( 'format ' ) == 'json ' ) {
95- echo json_encode ( $ result );
97+ if ( $ this ->isVerbosityVerbose () || $ this ->option ('format ' ) === 'json ' ) {
98+ if ( $ this ->option ( 'format ' ) === 'json ' ) {
99+ echo json_encode ( $ result, JSON_THROW_ON_ERROR );
96100 } else {
97101 foreach ( $ result as $ k => $ v ) {
98102 foreach ( $ v as $ e ) {
@@ -105,5 +109,4 @@ public function handle(): int {
105109 echo "\n" ;
106110 return 0 ;
107111 }
108-
109- }
112+ }
0 commit comments