Passed
Push — master ( fc114f...c229df )
by Andrea
12:57
created

Fifree2installCommand::execute()   B

Complexity

Conditions 4
Paths 4

Size

Total Lines 44
Code Lines 28

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 23
CRAP Score 4.1417

Importance

Changes 0
Metric Value
dl 0
loc 44
ccs 23
cts 29
cp 0.7931
rs 8.5806
c 0
b 0
f 0
cc 4
eloc 28
nc 4
nop 2
crap 4.1417
1
<?php
2
3
namespace Fi\CoreBundle\Command;
4
5
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
6
use Symfony\Component\Console\Input\InputArgument;
7
use Symfony\Component\Console\Input\InputInterface;
8
use Symfony\Component\Filesystem\Filesystem;
9
use Symfony\Component\Console\Output\OutputInterface;
10
use Symfony\Component\Console\Input\ArrayInput;
11
12
class Fifree2installCommand extends ContainerAwareCommand
13
{
14
15
    protected $fixtureFile;
16
17 4
    protected function configure()
18
    {
19 4
        $this
20 4
                ->setName('fifree2:install')
21 4
                ->setDescription('Installazione ambiente fifree')
22 4
                ->setHelp('Crea il database, un utente amministratore e i dati di default')
23 4
                ->addArgument('admin', InputArgument::REQUIRED, 'Username per amministratore')
24 4
                ->addArgument('adminpass', InputArgument::REQUIRED, 'Password per amministratore')
25 4
                ->addArgument('adminemail', InputArgument::REQUIRED, 'Email per amministratore')
26
        ;
27 4
    }
28
29 1
    protected function execute(InputInterface $input, OutputInterface $output)
30
    {
31 1
        $admin = $input->getArgument('admin');
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 13 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
32 1
        $adminpass = $input->getArgument('adminpass');
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 9 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
33 1
        $adminemail = $input->getArgument('adminemail');
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 8 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
34 1
        $this->fixtureFile = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'fixtures.yml';
35
36 1
        if (!$admin) {
37
            echo "Inserire il nome utente dell'amministratore";
38
39
            return 1;
40
        }
41 1
        if (!$adminpass) {
42
            echo "Inserire la password per dell'amministratore";
43
44
            return 1;
45
        }
46 1
        if (!$adminemail) {
47
            echo "Inserire la mail dell'amministratore";
48
49
            return 1;
50
        }
51
52 1
        $commanddb = $this->getApplication()->find('fifree2:createdatabase');
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 3 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
53 1
        $argumentsdb = array('command' => 'fifree2:createdatabase');
54 1
        $inputc = new ArrayInput($argumentsdb);
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 6 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
55 1
        $commanddb->run($inputc, $output);
56
57 1
        $this->generateDefaultData($admin, $adminemail);
58
59 1
        $commanddata = $this->getApplication()->find('fifree2:configuratorimport');
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 3 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
60
        $argumentsdata = array(
61 1
            'command' => 'fifree2:configuratorimport',
62 1
            array("--truncatetables" => true)
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal --truncatetables does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
63 1
        );
64 1
        $inputd = new ArrayInput($argumentsdata);
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 8 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
65 1
        $commanddata->run($inputd, $output);
66
67 1
        $fs = new Filesystem();
68 1
        $fs->remove($this->fixtureFile);
69
70 1
        $userManipulator = $this->getContainer()->get('fifree.fos_user.util.user_manipulator');
71
72 1
        $userManipulator->changePassword($admin, $adminpass);
73 1
    }
74
75
    /**
76
     * This will suppress UnusedLocalVariable
77
     * warnings in this method
78
     *
79
     * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
80
     */
81 1
    private function generateDefaultData($admin, $adminemail)
82
    {
83 1
        $todaydt = new \DateTime();
84 1
        $today = $todaydt->format("Y-m-d") . "T00:00:00+01:00";
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 3 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
Coding Style Comprehensibility introduced by
The string literal Y-m-d does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
Coding Style Comprehensibility introduced by
The string literal T00:00:00+01:00 does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
85
        
86
        $defaultData = <<<EOF
87
Fi\CoreBundle\Entity\Ruoli:
88
  -
89
    id: 1
90
    ruolo: 'Super Admin'
91
    paginainiziale: /adminpanel
92
    is_superadmin: true
93
    is_admin: true
94
    is_user: false
95
  -
96
    id: 2
97
    ruolo: Amministratore
98
    paginainiziale: /adminpanel
99
    is_superadmin: false
100
    is_admin: true
101
    is_user: false
102
  -
103
    id: 3
104
    ruolo: Utente
105
    paginainiziale: /ffprincipale
106
    is_superadmin: false
107
    is_admin: false
108
    is_user: true
109
Fi\CoreBundle\Entity\Operatori:
110
  -
111
    username: $admin
112 1
    usernameCanonical: $admin
113 1
    email: $adminemail
114 1
    emailCanonical: $adminemail
115
    enabled: true
116
    salt: null
117 1
    password: $admin
118
    lastLogin: null
119
    confirmationToken: null
120
    passwordRequestedAt: null
121
    roles:
122
      - ROLE_SUPER_ADMIN
123
    id: 1
124 1
    operatore: $admin
125
    ruoli_id: 1
126
Fi\CoreBundle\Entity\Permessi:
127
  -
128
    id: 1
129 1
    modulo: MenuApplicazione
130 1
    crud: crud
131
    operatori_id: null
132
    ruoli_id: 1
133
  -
134
    id: 2
135
    modulo: OpzioniTabella
136
    crud: crud
137
    operatori_id: null
138
    ruoli_id: 1
139
  -
140
    id: 3
141
    modulo: Tabelle
142
    crud: crud
143
    operatori_id: null
144
    ruoli_id: 1
145
  -
146
    id: 4
147
    modulo: Permessi
148
    crud: crud
149
    operatori_id: null
150
    ruoli_id: 1
151
  -
152
    id: 5
153
    modulo: Operatori
154
    crud: cru
155
    operatori_id: null
156
    ruoli_id: 1
157
  -
158
    id: 6
159
    modulo: Ruoli
160
    crud: crud
161
    operatori_id: null
162
    ruoli_id: 1
163
  -
164
    id: 7
165
    modulo: Ffprincipale
166
    crud: crud
167
    operatori_id: null
168
    ruoli_id: 1
169
  -
170
    id: 8
171
    modulo: Ffsecondaria
172
    crud: crud
173
    operatori_id: null
174
    ruoli_id: 1
175
Fi\CoreBundle\Entity\Tabelle:
176
  -
177
    id: 1
178
    nometabella: '*'
179
    nomecampo: null
180
    mostraindex: null
181
    ordineindex: null
182
    larghezzaindex: null
183
    etichettaindex: null
184
    mostrastampa: null
185
    ordinestampa: null
186
    larghezzastampa: null
187
    etichettastampa: null
188
    operatori_id: null
189
    registrastorico: null
190
  -
191
    id: 2
192
    nometabella: Ffsecondaria
193
    nomecampo: ffprincipale
194
    mostraindex: true
195
    ordineindex: null
196
    larghezzaindex: null
197
    etichettaindex: null
198
    mostrastampa: true
199
    ordinestampa: null
200
    larghezzastampa: null
201
    etichettastampa: null
202
    operatori_id: null
203
    registrastorico: true
204
  -
205
    id: 3
206
    nometabella: Ffsecondaria
207
    nomecampo: descsec
208
    mostraindex: true
209
    ordineindex: null
210
    larghezzaindex: null
211
    etichettaindex: null
212
    mostrastampa: true
213
    ordinestampa: null
214
    larghezzastampa: null
215
    etichettastampa: null
216
    operatori_id: null
217
    registrastorico: true
218
Fi\CoreBundle\Entity\OpzioniTabella:
219
  -
220
    id: 1
221
    tabelle_id: 1
222
    descrizione: null
223
    parametro: titolo
224
    valore: 'Elenco dati per %tabella%'
225
  -
226
    id: 2
227
    tabelle_id: 1
228
    descrizione: 'Altezza Griglia'
229
    parametro: altezzagriglia
230
    valore: '400'
231
  -
232
    id: 3
233
    tabelle_id: 1
234
    descrizione: 'Esegue filtri con invio in testata griglia'
235
    parametro: filterToolbar_searchOnEnter
236
    valore: true
237
  -
238
    id: 4
239
    tabelle_id: 1
240
    descrizione: 'Aggiunge filtri di default in testata griglia'
241
    parametro: filterToolbar_searchOperators
242
    valore: true
243
Fi\CoreBundle\Entity\Ffprincipale:
244
  -
245
    id: 1
246
    descrizione: 'Descrizione primo record'
247
  -
248
    id: 2
249
    descrizione: 'Descrizione secondo record'
250
Fi\CoreBundle\Entity\Ffsecondaria:
251
  -
252
    id: 1
253
    descsec: '1° secondaria legato al 1° record principale'
254
    ffprincipale_id: 1
255 1
    data: $today
256
    intero: 10
257
    importo: 12.34
258
    nota: 'Super Nota ffsecondaria'
259
    attivo: true
260
  -
261
    id: 2
262
    descsec: '2° secondaria legato al 1° record principale'
263
    ffprincipale_id: 1
264 1
    data: $today
265
    intero: 1
266
    importo: 1.23
267
    nota: 'Nota ffsecondaria'
268
    attivo: true
269
  -
270
    id: 3
271
    descsec: '3° secondaria legato al 1° record principale'
272
    ffprincipale_id: 1
273 1
    data: $today
274
    intero: 10
275
    importo: 11.34
276
    nota: 'Nota 3° ffsecondaria'
277
    attivo: false
278
  -
279
    id: 4
280
    descsec: '4° secondaria legato al 1° record principale'
281
    ffprincipale_id: 1
282 1
    data: $today
283
    intero: 101
284
    importo: 101.34
285
    nota: 'Nota 4° ffsecondaria'
286
    attivo: true
287
  -
288
    id: 5
289
    descsec: '5° secondaria legato al 1° record principale'
290
    ffprincipale_id: 1
291 1
    data: $today
292
    intero: 101
293
    importo: 101.34
294
    nota: 'Nota 4° ffsecondaria'
295
    attivo: true
296
  -
297
    id: 6
298
    descsec: '6° secondaria legato al 2° record principale'
299
    ffprincipale_id: 2
300 1
    data: $today
301
    intero: 10006
302
    importo: 10006.12
303
    nota: 'Nota altra ffsecondaria'
304
    attivo: true
305
  -
306
    id: 7
307
    descsec: '7° secondaria legato al 2° record principale'
308
    ffprincipale_id: 2
309 1
    data: $today
310
    intero: 10007
311
    importo: 10007.22
312
    nota: 'Nota altra 7 ffsecondaria'
313
    attivo: false
314
  -
315
    id: 8
316
    descsec: '9° secondaria legato al 2° "record principale"'
317
    ffprincipale_id: 2
318 1
    data: $today
319
    intero: 1000
320
    importo: 1000.12
321
    nota: 'Nota altra ffsecondaria'
322
    attivo: true
323
  -
324
    id: 9
325
    descsec: '10° secondaria legato al 2° record principale ed è l''ultimo record'
326
    ffprincipale_id: 2
327 1
    data: $today
328
    intero: 1100
329
    importo: 1100.99
330
    nota: 'Nota 10° altra ffsecondaria'
331
    attivo: false
332
Fi\CoreBundle\Entity\MenuApplicazione:
333
  -
334
    id: 1
335
    nome: Tabelle
336
    percorso: null
337
    padre: null
338
    ordine: 10
339
    attivo: true
340
    target: null
341
    tag: null
342
    notifiche: null
343
    autorizzazionerichiesta: null
344
    percorsonotifiche: null
345
  -
346
    id: 2
347
    nome: FFprincipale
348
    percorso: Ffprincipale
349
    padre: 1
350
    ordine: 10
351
    attivo: true
352
    target: null
353
    tag: null
354
    notifiche: null
355
    autorizzazionerichiesta: null
356
    percorsonotifiche: null
357
  -
358
    id: 3
359
    nome: FFsecondaria
360
    percorso: Ffsecondaria
361
    padre: 1
362
    ordine: 10
363
    attivo: true
364
    target: null
365
    tag: null
366
    notifiche: null
367
    autorizzazionerichiesta: null
368
    percorsonotifiche: null
369
  -
370
    id: 4
371
    nome: Amministrazione
372
    percorso: null
373
    padre: null
374
    ordine: 20
375
    attivo: true
376
    target: null
377
    tag: null
378
    notifiche: null
379
    autorizzazionerichiesta: null
380
    percorsonotifiche: null
381
  -
382
    id: 5
383
    nome: Operatori
384
    percorso: Operatori
385
    padre: 4
386
    ordine: 10
387
    attivo: true
388
    target: null
389
    tag: null
390
    notifiche: null
391
    autorizzazionerichiesta: null
392
    percorsonotifiche: null
393
  -
394
    id: 6
395
    nome: Ruoli
396
    percorso: Ruoli
397
    padre: 4
398
    ordine: 20
399
    attivo: true
400
    target: null
401
    tag: null
402
    notifiche: null
403
    autorizzazionerichiesta: null
404
    percorsonotifiche: null
405
  -
406
    id: 7
407
    nome: Permessi
408
    percorso: Permessi
409
    padre: 4
410
    ordine: 30
411
    attivo: true
412
    target: null
413
    tag: null
414
    notifiche: null
415
    autorizzazionerichiesta: null
416
    percorsonotifiche: null
417
  -
418
    id: 8
419
    nome: 'Gestione tabelle'
420
    percorso: null
421
    padre: 4
422
    ordine: 40
423
    attivo: true
424
    target: null
425
    tag: null
426
    notifiche: null
427
    autorizzazionerichiesta: null
428
    percorsonotifiche: null
429
  -
430
    id: 9
431
    nome: Tabelle
432
    percorso: Tabelle
433
    padre: 8
434
    ordine: 10
435
    attivo: true
436
    target: null
437
    tag: null
438
    notifiche: null
439
    autorizzazionerichiesta: null
440
    percorsonotifiche: null
441
  -
442
    id: 10
443
    nome: 'Opzioni tabella'
444
    percorso: OpzioniTabella
445
    padre: 8
446
    ordine: 20
447
    attivo: true
448
    target: null
449
    tag: null
450
    notifiche: null
451
    autorizzazionerichiesta: null
452
    percorsonotifiche: null
453
  -
454
    id: 11
455
    nome: 'Menu Applicazione'
456
    percorso: MenuApplicazione_container
457
    padre: 4
458
    ordine: 50
459
    attivo: true
460
    target: null
461
    tag: null
462
    notifiche: null
463
    autorizzazionerichiesta: null
464
    percorsonotifiche: null
465
  -
466
    id: 12
467
    nome: Utilità
468
    percorso: fi_pannello_amministrazione_homepage
469
    padre: 4
470
    ordine: 100
471
    attivo: true
472
    target: null
473
    tag: null
474
    notifiche: null
475
    autorizzazionerichiesta: null
476
    percorsonotifiche: null
477
  -
478
    id: 13
479
    nome: FiDemo
480
    percorso: fi_demo_index
481
    padre: 4
482
    ordine: 150
483
    attivo: false
484
    target: null
485
    tag: null
486
    notifiche: null
487
    autorizzazionerichiesta: null
488 1
    percorsonotifiche: null
489 1
EOF;
490 1
        $fs = new Filesystem();
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 10 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
491 1
        $fs->dumpFile($this->fixtureFile, $defaultData);
492 1
    }
493
}
494