GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 0268aa...3ec9bd )
by cao
05:24
created

Entity/Annotations/ValidateAnnotationHandler.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace PhpBoot\Entity\Annotations;
4
5
use PhpBoot\Annotation\AnnotationBlock;
6
use PhpBoot\Annotation\AnnotationTag;
7
use PhpBoot\Entity\EntityContainer;
8
use PhpBoot\Exceptions\AnnotationSyntaxException;
9
use PhpBoot\Utils\AnnotationParams;
10
use PhpBoot\Validator\Validator;
11
12
class ValidateAnnotationHandler
13
{
14
    /**
15
     * @param EntityContainer $container
16
     * @param AnnotationBlock|AnnotationTag $ann
17
     * @return void
18
     */
19 3
    public function __invoke(EntityContainer $container, $ann)
20
    {
21 3
        $params = new AnnotationParams($ann->description, 3);
22 3
        if($params->count()){
23
24 3
            $target = $ann->parent->name;
25 3
            $property = $container->getProperty($target);
26 3
            $property or \PhpBoot\abort($container->getClassName()." property $target not exist ");
27 3
            if($params->count()>1){
28 1
                $property->validation = [$params->getParam(0), $params->getParam(1)];
29 1 View Code Duplication
            }else{
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
30 2
                $property->validation = $params->getParam(0);
31 2
                if($property->validation){
32 2
                    $v = new Validator();
33 2
                    $v->rule($property->validation, $property->name);
34 2
                    if($v->hasRule('optional', $property->name)){
35
                        $property->isOptional = true;
36
                    }
37 2
                }
38
            }
39
40 3
        }else{
41
            \PhpBoot\abort(new AnnotationSyntaxException(
42
                "The annotation \"@{$ann->name} {$ann->description}\" of {$container->getClassName()}::{$ann->parent->name} require 1 param, 0 given"
43
            ));
44
        }
45
    }
46
}