Completed
Push — feature/issue-47 ( cdce8d...8413b2 )
by Mikaël
24:42
created

Generator::setOptionSuffix()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1
Metric Value
dl 0
loc 5
ccs 3
cts 3
cp 1
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
crap 1
1
<?php
2
3
namespace WsdlToPhp\PackageGenerator\Generator;
4
5
use WsdlToPhp\PackageGenerator\Model\Schema;
6
use WsdlToPhp\PackageGenerator\Model\Wsdl;
7
use WsdlToPhp\PackageGenerator\Model\AbstractModel;
8
use WsdlToPhp\PackageGenerator\Model\EmptyModel;
9
use WsdlToPhp\PackageGenerator\Model\Struct;
10
use WsdlToPhp\PackageGenerator\Model\Service;
11
use WsdlToPhp\PackageGenerator\Model\Method;
12
use WsdlToPhp\PackageGenerator\Container\Model\Service as ServiceContainer;
13
use WsdlToPhp\PackageGenerator\Container\Model\Struct as StructContainer;
14
use WsdlToPhp\PackageGenerator\ConfigurationReader\GeneratorOptions;
15
use WsdlToPhp\PackageGenerator\DomHandler\Wsdl\Wsdl as WsdlDocument;
16
17
class Generator
18
{
19
    /**
20
     * Wsdl
21
     * @var Wsdl
22
     */
23
    private $wsdl;
24
    /**
25
     * @var GeneratorOptions
26
     */
27
    private $options;
28
    /**
29
     * Used parsers
30
     * @var GeneratorParsers
31
     */
32
    private $parsers;
33
    /**
34
     * Used files
35
     * @var GeneratorFiles
36
     */
37
    private $files;
38
    /**
39
     * Used containers
40
     * @var GeneratorContainers
41
     */
42
    private $containers;
43
    /**
44
     * Used SoapClient
45
     * @var GeneratorSoapClient
46
     */
47
    private $soapClient;
48
    /**
49
     * Constructor
50
     * @param GeneratorOptions $options
51
     */
52 448
    public function __construct(GeneratorOptions $options)
53
    {
54 336
        $this
55 448
            ->setOptions($options)
56 448
            ->initialize();
57 440
    }
58
    /**
59
     * @return Generator
60
     */
61 448
    protected function initialize()
62
    {
63 336
        return $this
64 448
            ->initContainers()
65 448
            ->initParsers()
66 448
            ->initFiles()
67 448
            ->initSoapClient()
68 444
            ->initWsdl();
69 15
    }
70
    /**
71
     * @throws \InvalidArgumentException
72
     * @return Generator
73
     */
74 448
    protected function initSoapClient()
75
    {
76 448
        if (!isset($this->soapClient)) {
77 448
            $this->soapClient = new GeneratorSoapClient($this);
78 333
        }
79 444
        return $this;
80
    }
81
    /**
82
     * @return Generator
83
     */
84 448
    protected function initContainers()
85
    {
86 448
        if (!isset($this->containers)) {
87 448
            $this->containers = new GeneratorContainers($this);
88 336
        }
89 448
        return $this;
90
    }
91
    /**
92
     * @return Generator
93
     */
94 448
    protected function initParsers()
95
    {
96 448
        if (!isset($this->parsers)) {
97 448
            $this->parsers = new GeneratorParsers($this);
98 336
        }
99 448
        return $this;
100
    }
101
    /**
102
     * @return GeneratorParsers
103
     */
104 144
    public function getParsers()
105
    {
106 144
        return $this->parsers;
107
    }
108
    /**
109
     * @return Generator
110
     */
111 448
    protected function initFiles()
112
    {
113 448
        if (!isset($this->files)) {
114 448
            $this->files = new GeneratorFiles($this);
115 336
        }
116 448
        return $this;
117
    }
118
    /**
119
     * @return GeneratorFiles
120
     */
121 44
    public function getFiles()
122
    {
123 44
        return $this->files;
124
    }
125
    /**
126
     * @throws \InvalidArgumentException
127
     * @return Generator
128
     */
129 24
    protected function initDirectory()
130
    {
131 24
        Utils::createDirectory($this->getOptions()->getDestination());
132 24
        if (!is_writable($this->getOptionDestination())) {
133 4
            throw new \InvalidArgumentException(sprintf('Unable to use dir "%s" as dir does not exists, its creation has been impossible or it\'s not writable', $this->getOptionDestination()), __LINE__);
134
        }
135 20
        return $this;
136
    }
137
    /**
138
     * @return Generator
139
     */
140 448
    protected function initWsdl()
141
    {
142 448
        $this->setWsdl(new Wsdl($this, $this->getOptionOrigin(), $this->getUrlContent($this->getOptionOrigin())));
143 444
        return $this;
144
    }
145
    /**
146
     * @return Generator
147
     */
148 32
    protected function doSanityChecks()
149
    {
150 32
        $destination = $this->getOptionDestination();
151 32
        if (empty($destination)) {
152 4
            throw new \InvalidArgumentException('Package\'s destination must be defined', __LINE__);
153
        }
154 28
        $composerName = $this->getOptionComposerName();
155 28
        if ($this->getOptionStandalone() && empty($composerName)) {
156 4
            throw new \InvalidArgumentException('Package\'s composer name must be defined', __LINE__);
157
        }
158 24
        return $this;
159
    }
160
    /**
161
     * @return Generator
162
     */
163 20
    protected function doParse()
164
    {
165 20
        $this->parsers->doParse();
166 20
        return $this;
167
    }
168
    /**
169
     * @return Generator
170
     */
171 20
    protected function doGenerate()
172
    {
173 20
        $this->files->doGenerate();
174 20
        return $this;
175
    }
176
    /**
177
     * Generates all classes based on options
178
     * @return Generator
179
     */
180 32
    public function generatePackage()
181
    {
182 24
        return $this
183 32
            ->doSanityChecks()
184 24
            ->initDirectory()
185 20
            ->doParse()
186 20
            ->doGenerate();
187
    }
188
    /**
189
     * Gets the struct by its name
190
     * @uses Generator::getStructs()
191
     * @param string $structName the original struct name
192
     * @return Struct|null
193
     */
194 320
    public function getStruct($structName)
195
    {
196 320
        return $this->getStructs()->getStructByName($structName);
197
    }
198
    /**
199
     * Gets a service by its name
200
     * @param string $serviceName the service name
201
     * @return Service|null
202
     */
203 284
    public function getService($serviceName)
204
    {
205 284
        return $this->getServices()->getServiceByName($serviceName);
206
    }
207
    /**
208
     * Returns the method
209
     * @uses Generator::getServiceName()
210
     * @uses Generator::getService()
211
     * @uses Service::getMethod()
212
     * @param string $methodName the original function name
213
     * @return Method|null
214
     */
215 280
    public function getServiceMethod($methodName)
216
    {
217 280
        return $this->getService($this->getServiceName($methodName)) instanceof Service ? $this->getService($this->getServiceName($methodName))->getMethod($methodName) : null;
218
    }
219
    /**
220
     * @return ServiceContainer
221
     */
222 408
    public function getServices()
223
    {
224 408
        return $this->containers->getServices();
225
    }
226
    /**
227
     * @return StructContainer
228
     */
229 388
    public function getStructs()
230
    {
231 388
        return $this->containers->getStructs();
232
    }
233
    /**
234
     * Sets the optionCategory value
235
     * @return string
236
     */
237 228
    public function getOptionCategory()
238
    {
239 228
        return $this->options->getCategory();
240
    }
241
    /**
242
     * Sets the optionCategory value
243
     * @param string $category
244
     * @return Generator
245
     */
246 224
    public function setOptionCategory($category)
247
    {
248 224
        $this->options->setCategory($category);
249 224
        return $this;
250
    }
251
    /**
252
     * Sets the optionGatherMethods value
253
     * @return string
254
     */
255 416
    public function getOptionGatherMethods()
256
    {
257 416
        return $this->options->getGatherMethods();
258
    }
259
    /**
260
     * Sets the optionGatherMethods value
261
     * @param string $gatherMethods
262
     * @return Generator
263
     */
264 224
    public function setOptionGatherMethods($gatherMethods)
265
    {
266 224
        $this->options->setGatherMethods($gatherMethods);
267 224
        return $this;
268
    }
269
    /**
270
     * Gets the optionGenericConstantsNames value
271
     * @return bool
272
     */
273 56
    public function getOptionGenericConstantsNames()
274
    {
275 56
        return $this->options->getGenericConstantsName();
276
    }
277
    /**
278
     * Sets the optionGenericConstantsNames value
279
     * @param bool $genericConstantsNames
280
     * @return Generator
281
     */
282 8
    public function setOptionGenericConstantsNames($genericConstantsNames)
283
    {
284 8
        $this->options->setGenericConstantsName($genericConstantsNames);
285 8
        return $this;
286
    }
287
    /**
288
     * Gets the optionGenerateTutorialFile value
289
     * @return bool
290
     */
291 28
    public function getOptionGenerateTutorialFile()
292
    {
293 28
        return $this->options->getGenerateTutorialFile();
294
    }
295
    /**
296
     * Sets the optionGenerateTutorialFile value
297
     * @param bool $generateTutorialFile
298
     * @return Generator
299
     */
300 4
    public function setOptionGenerateTutorialFile($generateTutorialFile)
301
    {
302 4
        $this->options->setGenerateTutorialFile($generateTutorialFile);
303 4
        return $this;
304
    }
305
    /**
306
     * Gets the optionNamespacePrefix value
307
     * @return string
308
     */
309 204
    public function getOptionNamespacePrefix()
310
    {
311 204
        return $this->options->getNamespace();
312
    }
313
    /**
314
     * Sets the optionGenerateTutorialFile value
315
     * @param string $namespace
316
     * @return Generator
317
     */
318 12
    public function setOptionNamespacePrefix($namespace)
319
    {
320 12
        $this->options->setNamespace($namespace);
321 12
        return $this;
322
    }
323
    /**
324
     * Gets the optionAddComments value
325
     * @return array
326
     */
327 164
    public function getOptionAddComments()
328
    {
329 164
        return $this->options->getAddComments();
330
    }
331
    /**
332
     * Sets the optionAddComments value
333
     * @param array $addComments
334
     * @return Generator
335
     */
336 224
    public function setOptionAddComments($addComments)
337
    {
338 224
        $this->options->setAddComments($addComments);
339 224
        return $this;
340
    }
341
    /**
342
     * Gets the optionStandalone value
343
     * @return bool
344
     */
345 60
    public function getOptionStandalone()
346
    {
347 60
        return $this->options->getStandalone();
348
    }
349
    /**
350
     * Sets the optionStandalone value
351
     * @param bool $standalone
352
     * @return Generator
353
     */
354 8
    public function setOptionStandalone($standalone)
355
    {
356 8
        $this->options->setStandalone($standalone);
357 8
        return $this;
358
    }
359
    /**
360
     * Gets the optionStructClass value
361
     * @return string
362
     */
363 64
    public function getOptionStructClass()
364
    {
365 64
        return $this->options->getStructClass();
366
    }
367
    /**
368
     * Sets the optionStructClass value
369
     * @param string $structClass
370
     * @return Generator
371
     */
372 12
    public function setOptionStructClass($structClass)
373
    {
374 12
        $this->options->setStructClass($structClass);
375 12
        return $this;
376
    }
377
    /**
378
     * Gets the optionStructArrayClass value
379
     * @return string
380
     */
381 36
    public function getOptionStructArrayClass()
382
    {
383 36
        return $this->options->getStructArrayClass();
384
    }
385
    /**
386
     * Sets the optionStructArrayClass value
387
     * @param string $structArrayClass
388
     * @return Generator
389
     */
390 4
    public function setOptionStructArrayClass($structArrayClass)
391
    {
392 4
        $this->options->setStructArrayClass($structArrayClass);
393 4
        return $this;
394
    }
395
    /**
396
     * Gets the optionSoapClientClass value
397
     * @return string
398
     */
399 80
    public function getOptionSoapClientClass()
400
    {
401 80
        return $this->options->getSoapClientClass();
402
    }
403
    /**
404
     * Sets the optionSoapClientClass value
405
     * @param string $soapClientClass
406
     * @return Generator
407
     */
408 4
    public function setOptionSoapClientClass($soapClientClass)
409
    {
410 4
        $this->options->setSoapClientClass($soapClientClass);
411 4
        return $this;
412
    }
413
    /**
414
     * Gets the package name prefix
415
     * @param bool $ucFirst ucfirst package name prefix or not
416
     * @return string
417
     */
418 472
    public function getOptionPrefix($ucFirst = true)
419
    {
420 472
        return $ucFirst ? ucfirst($this->getOptions()->getPrefix()) : $this->getOptions()->getPrefix();
421
    }
422
    /**
423
     * Sets the package name prefix
424
     * @param string $optionPrefix
425
     * @return Generator
426
     */
427 244
    public function setOptionPrefix($optionPrefix)
428
    {
429 244
        $this->options->setPrefix($optionPrefix);
430 244
        return $this;
431
    }
432
    /**
433
     * Gets the package name suffix
434
     * @param bool $ucFirst ucfirst package name suffix or not
435
     * @return string
436
     */
437 460
    public function getOptionSuffix($ucFirst = true)
438
    {
439 460
        return $ucFirst ? ucfirst($this->getOptions()->getSuffix()) : $this->getOptions()->getSuffix();
440
    }
441
    /**
442
     * Sets the package name suffix
443
     * @param string $optionSuffix
444
     * @return Generator
445
     */
446 28
    public function setOptionSuffix($optionSuffix)
447
    {
448 28
        $this->options->setSuffix($optionSuffix);
449 28
        return $this;
450
    }
451
    /**
452
     * Gets the optionBasicLogin value
453
     * @return string
454
     */
455 464
    public function getOptionBasicLogin()
456
    {
457 464
        return $this->options->getBasicLogin();
458
    }
459
    /**
460
     * Sets the optionBasicLogin value
461
     * @param string $optionBasicLogin
462
     * @return Generator
463
     */
464 4
    public function setOptionBasicLogin($optionBasicLogin)
465
    {
466 4
        $this->options->setBasicLogin($optionBasicLogin);
467 4
        return $this;
468
    }
469
    /**
470
     * Gets the optionBasicPassword value
471
     * @return string
472
     */
473 464
    public function getOptionBasicPassword()
474
    {
475 464
        return $this->options->getBasicPassword();
476
    }
477
    /**
478
     * Sets the optionBasicPassword value
479
     * @param string $optionBasicPassword
480
     * @return Generator
481
     */
482 4
    public function setOptionBasicPassword($optionBasicPassword)
483
    {
484 4
        $this->options->setBasicPassword($optionBasicPassword);
485 4
        return $this;
486
    }
487
    /**
488
     * Gets the optionProxyHost value
489
     * @return string
490
     */
491 464
    public function getOptionProxyHost()
492
    {
493 464
        return $this->options->getProxyHost();
494
    }
495
    /**
496
     * Sets the optionProxyHost value
497
     * @param string $optionProxyHost
498
     * @return Generator
499
     */
500 4
    public function setOptionProxyHost($optionProxyHost)
501
    {
502 4
        $this->options->setProxyHost($optionProxyHost);
503 4
        return $this;
504
    }
505
    /**
506
     * Gets the optionProxyPort value
507
     * @return string
508
     */
509 464
    public function getOptionProxyPort()
510
    {
511 464
        return $this->options->getProxyPort();
512
    }
513
    /**
514
     * Sets the optionProxyPort value
515
     * @param string $optionProxyPort
516
     * @return Generator
517
     */
518 4
    public function setOptionProxyPort($optionProxyPort)
519
    {
520 4
        $this->options->setProxyPort($optionProxyPort);
521 4
        return $this;
522
    }
523
    /**
524
     * Gets the optionProxyLogin value
525
     * @return string
526
     */
527 464
    public function getOptionProxyLogin()
528
    {
529 464
        return $this->options->getProxyLogin();
530
    }
531
    /**
532
     * Sets the optionProxyLogin value
533
     * @param string $optionProxyLogin
534
     * @return Generator
535
     */
536 4
    public function setOptionProxyLogin($optionProxyLogin)
537
    {
538 4
        $this->options->setProxyLogin($optionProxyLogin);
539 4
        return $this;
540
    }
541
    /**
542
     * Gets the optionProxyPassword value
543
     * @return string
544
     */
545 464
    public function getOptionProxyPassword()
546
    {
547 464
        return $this->options->getProxyPassword();
548
    }
549
    /**
550
     * Sets the optionProxyPassword value
551
     * @param string $optionProxyPassword
552
     * @return Generator
553
     */
554 4
    public function setOptionProxyPassword($optionProxyPassword)
555
    {
556 4
        $this->options->setProxyPassword($optionProxyPassword);
557 4
        return $this;
558
    }
559
    /**
560
     * Gets the optionOrigin value
561
     * @return string
562
     */
563 460
    public function getOptionOrigin()
564
    {
565 460
        return $this->options->getOrigin();
566
    }
567
    /**
568
     * Sets the optionOrigin value
569
     * @param string $optionOrigin
570
     * @return Generator
571
     */
572 4
    public function setOptionOrigin($optionOrigin)
573
    {
574 4
        $this->options->setOrigin($optionOrigin);
575 4
        $this->initWsdl();
576 4
        return $this;
577
    }
578
    /**
579
     * Gets the optionDestination value
580
     * @return string
581
     */
582 244
    public function getOptionDestination()
583
    {
584 244
        $destination = $this->options->getDestination();
585 244
        if (!empty($destination)) {
586 240
            $destination = realpath($this->options->getDestination()) . DIRECTORY_SEPARATOR;
587 180
        }
588 244
        return $destination;
589
    }
590
    /**
591
     * Sets the optionDestination value
592
     * @param string $optionDestination
593
     * @return Generator
594
     */
595 12
    public function setOptionDestination($optionDestination)
596
    {
597 12
        if (!empty($optionDestination)) {
598 8
            $this->options->setDestination(realpath($optionDestination) . DIRECTORY_SEPARATOR);
599 6
        } else {
600 4
            throw new \InvalidArgumentException('Package\'s destination can\'t be empty', __LINE__);
601
        }
602 8
        return $this;
603
    }
604
    /**
605
     * Gets the optionSoapOptions value
606
     * @return string
607
     */
608 456
    public function getOptionSoapOptions()
609
    {
610 456
        return $this->options->getSoapOptions();
611
    }
612
    /**
613
     * Sets the optionSoapOptions value
614
     * @param array $optionSoapOptions
615
     * @return Generator
616
     */
617 4
    public function setOptionSoapOptions($optionSoapOptions)
618
    {
619 4
        $this->options->setSoapOptions($optionSoapOptions);
620 4
        if ($this->getSoapClient() instanceof GeneratorSoapClient) {
621 4
            $this->getSoapClient()->initSoapClient();
622 3
        }
623 4
        return $this;
624
    }
625
    /**
626
     * Gets the optionComposerName value
627
     * @return string
628
     */
629 36
    public function getOptionComposerName()
630
    {
631 36
        return $this->options->getComposerName();
632
    }
633
    /**
634
     * Sets the optionComposerName value
635
     * @param string $optionComposerName
636
     * @return Generator
637
     */
638 16
    public function setOptionComposerName($optionComposerName)
639
    {
640 16
        if (!empty($optionComposerName)) {
641 12
            $this->options->setComposerName($optionComposerName);
642 9
        } else {
643 4
            throw new \InvalidArgumentException('Package\'s composer name can\'t be empty', __LINE__);
644
        }
645 12
        return $this;
646
    }
647
    /**
648
     * Gets the optionStructsFolder value
649
     * @return string
650
     */
651 212
    public function getOptionStructsFolder()
652
    {
653 212
        return $this->options->getStructsFolder();
654
    }
655
    /**
656
     * Sets the optionStructsFolder value
657
     * @param string $optionStructsFolder
658
     * @return Generator
659
     */
660 4
    public function setOptionStructsFolder($optionStructsFolder)
661
    {
662 4
        $this->options->setStructsFolder($optionStructsFolder);
663 4
        return $this;
664
    }
665
    /**
666
     * Gets the optionArraysFolder value
667
     * @return string
668
     */
669 48
    public function getOptionArraysFolder()
670
    {
671 48
        return $this->options->getArraysFolder();
672
    }
673
    /**
674
     * Sets the optionArraysFolder value
675
     * @param string $optionArraysFolder
676
     * @return Generator
677
     */
678 4
    public function setOptionArraysFolder($optionArraysFolder)
679
    {
680 4
        $this->options->setArraysFolder($optionArraysFolder);
681 4
        return $this;
682
    }
683
    /**
684
     * Gets the optionEnumsFolder value
685
     * @return string
686
     */
687 80
    public function getOptionEnumsFolder()
688
    {
689 80
        return $this->options->getEnumsFolder();
690
    }
691
    /**
692
     * Sets the optionEnumsFolder value
693
     * @param string $optionEnumsFolder
694
     * @return Generator
695
     */
696 4
    public function setOptionEnumsFolder($optionEnumsFolder)
697
    {
698 4
        $this->options->setEnumsFolder($optionEnumsFolder);
699 4
        return $this;
700
    }
701
    /**
702
     * Gets the optionServicesFolder value
703
     * @return string
704
     */
705 452
    public function getOptionServicesFolder()
706
    {
707 452
        return $this->options->getServicesFolder();
708
    }
709
    /**
710
     * Sets the optionServicesFolder value
711
     * @param string $optionServicesFolder
712
     * @return Generator
713
     */
714 4
    public function setOptionServicesFolder($optionServicesFolder)
715
    {
716 4
        $this->options->setServicesFolder($optionServicesFolder);
717 4
        return $this;
718
    }
719
    /**
720
     * Gets the WSDL
721
     * @return Wsdl|null
722
     */
723 396
    public function getWsdl()
724
    {
725 396
        return $this->wsdl;
726
    }
727
    /**
728
     * Sets the WSDLs
729
     * @param Wsdl $wsdl
730
     * @return Generator
731
     */
732 444
    protected function setWsdl(Wsdl $wsdl)
733
    {
734 444
        $this->wsdl = $wsdl;
735 444
        return $this;
736
    }
737
    /**
738
     * Adds Wsdl location
739
     * @param Wsdl $wsdl
740
     * @param string $schemaLocation
741
     * @return Generator
742
     */
743 144
    public function addSchemaToWsdl(Wsdl $wsdl, $schemaLocation)
744
    {
745 144
        if (!empty($schemaLocation) && $wsdl->getContent() instanceof WsdlDocument && $wsdl->getContent()->getExternalSchema($schemaLocation) === null) {
746 140
            $wsdl->getContent()->addExternalSchema(new Schema($wsdl->getGenerator(), $schemaLocation, $this->getUrlContent($schemaLocation)));
747 105
        }
748 144
        return $this;
749
    }
750
    /**
751
     * Gets gather name class
752
     * @param AbstractModel $model the model for which we generate the folder
753
     * @return string
754
     */
755 392
    private function getGather(AbstractModel $model)
756
    {
757 392
        return Utils::getPart($this->getOptionGatherMethods(), $model->getCleanName());
758
    }
759
    /**
760
     * Returns the service name associated to the method/operation name in order to gather them in one service class
761
     * @uses Generator::getGather()
762
     * @param string $methodName original operation/method name
763
     * @return string
764
     */
765 408
    public function getServiceName($methodName)
766
    {
767 408
        return ucfirst($this->getOptionGatherMethods() === GeneratorOptions::VALUE_NONE ? Service::DEFAULT_SERVICE_CLASS_NAME : $this->getGather(new EmptyModel($this, $methodName)));
768
    }
769
    /**
770
     * @param GeneratorOptions $options
771
     * @return Generator
772
     */
773 448
    protected function setOptions(GeneratorOptions $options = null)
774
    {
775 448
        $this->options = $options;
776 448
        return $this;
777
    }
778
    /**
779
     * @return GeneratorOptions
780
     */
781 484
    public function getOptions()
782
    {
783 484
        return $this->options;
784
    }
785
    /**
786
     * @return GeneratorSoapClient
787
     */
788 428
    public function getSoapClient()
789
    {
790 428
        return $this->soapClient;
791
    }
792
    /**
793
     * @param string $url
794
     * @return string
795
     */
796 452
    public function getUrlContent($url)
797
    {
798 452
        if (strpos($url, '://') !== false) {
799 8
            return Utils::getContentFromUrl($url, $this->getOptionBasicLogin(), $this->getOptionBasicPassword(), $this->getOptionProxyHost(), $this->getOptionProxyPort(), $this->getOptionProxyLogin(), $this->getOptionProxyPassword(), $this->getSoapClient()->getSoapClientStreamContextOptions());
800 444
        } elseif (is_file($url)) {
801 440
            return file_get_contents($url);
802
        }
803 4
        return null;
804
    }
805
}
806