expressly/php-common

View on GitHub

Showing 14 of 370 total issues

Method testBuildingEntity has 101 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function testBuildingEntity()
    {
        $social = new Social();
        $social
            ->setField(Social::SOCIAL_FACEBOOK)
Severity: Major
Found in tests/Entity/CustomerEntityTest.php - About 4 hrs to fix

    Address has 23 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Address extends ArraySerializeable
    {
        const ADDRESS_BILLING = 'billing';
        const ADDRESS_SHIPPING = 'shipping';
        const ADDRESS_BOTH = 'both';
    Severity: Minor
    Found in src/Entity/Address.php - About 2 hrs to fix

      Method testBuildingEntity has 51 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function testBuildingEntity()
          {
              $orderWithCoupon = new Order();
              $orderWithCoupon
                  ->setId('ORDER-531')
      Severity: Major
      Found in tests/Entity/InvoiceEntityTest.php - About 2 hrs to fix

        Method testBuildingEntity has 40 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function testBuildingEntity()
            {
                $entity = new Address();
        
                $this->assertInstanceOf('Expressly\Entity\Address', $entity->setFirstName('Sam'));
        Severity: Minor
        Found in tests/Entity/AddressEntityTest.php - About 1 hr to fix

          Method testConstruction has 36 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function testConstruction()
              {
                  $invoice = $this->getMockBuilder('Expressly\Entity\Invoice')->getMock();
                  $invoice->method('hasOrders')->willReturn(true);
                  $invoice->method('toArray')->willReturn(array(
          Severity: Minor
          Found in tests/Presenter/BatchInvoicePresenterTest.php - About 1 hr to fix

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

                public function testToArray($presenter)
                {
                    $this->assertSame(
                        array(
                            'meta' => array(
            Severity: Minor
            Found in tests/Presenter/CustomerMigratePresenterTest.php - About 1 hr to fix

              Function addAddress has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function addAddress(Address $address, $primary = false, $type = null)
                  {
                      $addresses = $this->addresses;
                      $exists = function ($el) use ($addresses, $address) {
                          if ($el->toArray() == $address->toArray()) {
              Severity: Minor
              Found in src/Entity/Customer.php - About 45 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 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  public function __construct(Merchant $merchant, Customer $customer, $email, $reference, $locale = 'en', EventDetails $eventDetails = null)
              Severity: Minor
              Found in src/Presenter/CustomerMigratePresenter.php - About 45 mins to fix

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

                    public function getURI()
                    {
                        if (empty($this->parameters)) {
                            if (!empty($this->rules)) {
                                throw new InvalidURIException(reset($this->rules)->getMessage());
                Severity: Minor
                Found in src/Entity/ExternalRoute.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 process has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function process($key)
                    {
                        foreach ($this->routes as $route) {
                            if ($route instanceof RouteInterface) {
                                if (($result = $route::match(preg_replace('/.*(expressly\/.*)/i', '/${1}', $key))) && $this->authenticate($route::isAuthenticated())) {
                Severity: Minor
                Found in src/Resolver/RouteResolver.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 Logger::WARNING;
                Severity: Major
                Found in src/ServiceProvider/MonologServiceProvider.php - About 30 mins to fix

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

                      private function authenticate($restricted)
                      {
                          if ($restricted) {
                              if (!empty($_SERVER['HTTP_X_XLY_TOKEN']) &&
                                  empty($_SERVER['PHP_AUTH_USER']) &&
                  Severity: Minor
                  Found in src/Resolver/RouteResolver.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 importSearch has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function importSearch(&$config, $container)
                      {
                          foreach ($config as $key => $value) {
                              if ($key == 'imports') {
                                  foreach ($value as $resource) {
                  Severity: Minor
                  Found in src/ServiceProvider/YamlConfigServiceProvider.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 __construct has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function __construct(Container $container, $hosts, $routes)
                      {
                          $this->routes = new ArrayCollection();
                  
                          foreach ($routes as $key => $definition) {
                  Severity: Minor
                  Found in src/Provider/ExternalRouteProvider.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