fathomminds/php-rest-models

View on GitHub

Showing 21 of 21 total issues

RestObject has 24 functions (exceeds 20 allowed). Consider refactoring.
Open

abstract class RestObject implements IRestObject
{
    private $updateMode = false;
    private $replaceMode = false;

Severity: Minor
Found in src/Objects/RestObject.php - About 2 hrs to fix

    SchemaValidator has 21 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class SchemaValidator
    {
        protected $fields = [];
        protected $allowExtraneous = false;
        protected $requiredSchemaClass = null;
    Severity: Minor
    Found in src/Schema/SchemaValidator.php - About 2 hrs to fix

      Method parseWhere has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function parseWhere($conditions, $logical)
          {
              $subGroup = [];
              foreach ($conditions as $key => $condition) {
                  switch (strtoupper($key)) {
      Severity: Minor
      Found in src/Database/MongoDB/Finder.php - About 1 hr to fix

        Method castArray has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function castArray($array, $itemDetails)
            {
                $itemType = $this->getArrayItemType($itemDetails);
                if ($itemType === self::TYPE_OTHER) {
                    return $array;
        Severity: Minor
        Found in src/Database/MongoDB/MongoIdCast.php - About 1 hr to fix

          Method patch has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function patch($resourceId, $newResource)
              {
                  try {
                      if (isset($newResource->{$this->primaryKey})) {
                          unset($newResource->{$this->primaryKey});
          Severity: Minor
          Found in src/Database/MongoDB/Resource.php - About 1 hr to fix

            Method castSchema has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private function castSchema($object, $schema)
                {
                    $properties = get_object_vars($object);
                    foreach ($properties as $propertyName => $propertyValue) {
                        $propertyType = $this->getPropertyType($propertyName, $schema);
            Severity: Minor
            Found in src/Database/MongoDB/MongoIdCast.php - About 1 hr to fix

              Function parseWhere has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  protected function parseWhere($conditions, $logical)
                  {
                      $subGroup = [];
                      foreach ($conditions as $key => $condition) {
                          switch (strtoupper($key)) {
              Severity: Minor
              Found in src/Database/MongoDB/Finder.php - About 55 mins to fix

              Cognitive Complexity

              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

              A method's cognitive complexity is based on a few simple rules:

              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
              • Code is considered more complex for each "break in the linear flow of the code"
              • Code is considered more complex when "flow breaking structures are nested"

              Further reading

              Method __construct has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  public function __construct($resourceName, $schemaClass, $primaryKey, Client $client = null, $databaseName = null)
              Severity: Minor
              Found in src/Database/MongoDB/Resource.php - About 35 mins to fix

                Method put has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    public function put($resourceName, $schema, $primaryKey, $resourceId, $newResource);
                Severity: Minor
                Found in src/Contracts/IDatabase.php - About 35 mins to fix

                  Method put has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      public function put($resourceName, $schema, $primaryKey, $resourceId, $newResource)
                  Severity: Minor
                  Found in src/Database/MongoDB/Database.php - About 35 mins to fix

                    Method patch has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                        public function patch($resourceName, $schema, $primaryKey, $resourceId, $newResource)
                    Severity: Minor
                    Found in src/Database/MongoDB/Database.php - About 35 mins to fix

                      Method patch has 5 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                          public function patch($resourceName, $schema, $primaryKey, $resourceId, $newResource);
                      Severity: Minor
                      Found in src/Contracts/IDatabase.php - About 35 mins to fix

                        Function validateCircularDependency has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                        Open

                            private function validateCircularDependency($schemaName, $schemaDefinition, $schemaChain = [])
                            {
                                $schemaChain[] = $schemaName;
                                foreach ($schemaDefinition as $field => $fieldDetails)
                                {
                        Severity: Minor
                        Found in src/Schema/SchemaValidator.php - About 35 mins to fix

                        Cognitive Complexity

                        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                        A method's cognitive complexity is based on a few simple rules:

                        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                        • Code is considered more complex for each "break in the linear flow of the code"
                        • Code is considered more complex when "flow breaking structures are nested"

                        Further reading

                        Function removeExtraneous has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                        Open

                            public function removeExtraneous()
                            {
                                $schema = $this->schema();
                                foreach (get_object_vars($this) as $name => $value) {
                                    if (!array_key_exists($name, $schema)) {
                        Severity: Minor
                        Found in src/Schema.php - About 35 mins to fix

                        Cognitive Complexity

                        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                        A method's cognitive complexity is based on a few simple rules:

                        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                        • Code is considered more complex for each "break in the linear flow of the code"
                        • Code is considered more complex when "flow breaking structures are nested"

                        Further reading

                        Function validate has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                        Open

                            public function validate($value)
                            {
                                $details = [];
                                $this->validateType($value);
                                if ($value !== null) {
                        Severity: Minor
                        Found in src/Schema/TypeValidators/ArrayValidator.php - About 35 mins to fix

                        Cognitive Complexity

                        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                        A method's cognitive complexity is based on a few simple rules:

                        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                        • Code is considered more complex for each "break in the linear flow of the code"
                        • Code is considered more complex when "flow breaking structures are nested"

                        Further reading

                        Avoid too many return statements within this method.
                        Open

                                return $res;
                        Severity: Major
                        Found in src/Database/MongoDB/BSONSerialize.php - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                      return $this->bsonArraySerialize($res);
                          Severity: Major
                          Found in src/Database/MongoDB/BSONSerialize.php - About 30 mins to fix

                            Function castArray has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                            Open

                                private function castArray($array, $itemDetails)
                                {
                                    $itemType = $this->getArrayItemType($itemDetails);
                                    if ($itemType === self::TYPE_OTHER) {
                                        return $array;
                            Severity: Minor
                            Found in src/Database/MongoDB/MongoIdCast.php - About 25 mins to fix

                            Cognitive Complexity

                            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                            A method's cognitive complexity is based on a few simple rules:

                            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                            • Code is considered more complex for each "break in the linear flow of the code"
                            • Code is considered more complex when "flow breaking structures are nested"

                            Further reading

                            Function validateItems has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                            Open

                                private function validateItems($value)
                                {
                                    $errors = [];
                                    $this->itemValidator->updateMode($this->updateMode());
                                    $this->itemValidator->replaceMode($this->replaceMode());
                            Severity: Minor
                            Found in src/Schema/TypeValidators/ArrayValidator.php - About 25 mins to fix

                            Cognitive Complexity

                            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                            A method's cognitive complexity is based on a few simple rules:

                            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                            • Code is considered more complex for each "break in the linear flow of the code"
                            • Code is considered more complex when "flow breaking structures are nested"

                            Further reading

                            Function validateFieldTypes has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                            Open

                                private function validateFieldTypes($resource)
                                {
                                    $validatorFactory = new ValidatorFactory;
                                    $errors = [];
                                    foreach ($resource->schema() as $fieldName => $rules) {
                            Severity: Minor
                            Found in src/Schema/SchemaValidator.php - About 25 mins to fix

                            Cognitive Complexity

                            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                            A method's cognitive complexity is based on a few simple rules:

                            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                            • Code is considered more complex for each "break in the linear flow of the code"
                            • Code is considered more complex when "flow breaking structures are nested"

                            Further reading

                            Severity
                            Category
                            Status
                            Source
                            Language