original_string: private function validateSubSpec()
      {
          if ('!' != $this->currentSubSpec['operator'] && '?' != $this->currentSubSpec['operator']) { // skip left subTerm on operators ! and ?
              if (false === ($this->currentSubSpec['leftSubTerm'] instanceof CK\MARCspec\ComparisonStringInterface)) {
                  $leftSubTermReference = new self(
                      $this->currentSubSpec['leftSubTerm'],
                      $this->record,
                      $this->cache
                  );
                  if (!$leftSubTerm = $leftSubTermReference->content) { // see 2.3.4 SubSpec validation
                      return $this->cache->validation($this->currentSubSpec, false);
                  }
              } else {
                  // is a CK\MARCspec\ComparisonStringInterface
                  $leftSubTerm[] = $this->currentSubSpec['leftSubTerm']['comparable'];
              }
          }
  
          if (false === ($this->currentSubSpec['rightSubTerm'] instanceof CK\MARCspec\ComparisonStringInterface)) {
              $rightSubTermReference = new self(
                  $this->currentSubSpec['rightSubTerm'],
                  $this->record,
                  $this->cache
              );
              $rightSubTerm = $rightSubTermReference->content; // content maybe an empty array
          } else {
              // is a CK\MARCspec\ComparisonStringInterface
              $rightSubTerm[] = $this->currentSubSpec['rightSubTerm']['comparable'];
          }
          $validation = false;
  
          switch ($this->currentSubSpec['operator']) {
          case '=':
              if (0 < count(array_intersect($leftSubTerm, $rightSubTerm))) {
                  $validation = true;
              }
              break;
  
          case '!=':
              if (0 < count(array_diff($leftSubTerm, $rightSubTerm))) {
                  $validation = true;
              }
              break;
  
          case '~':
              if (0 < count(
                  array_uintersect(
                      $leftSubTerm,
                      $rightSubTerm,
                      function ($v1, $v2) {
                          if (strpos($v1, $v2) !== false) {
                              return 0;
                          }
  
                          return -1;
                      }
                  )
              )
              ) {
                  $validation = true;
              }
              break;
  
          case '!~':
              if (0 < count(
                  array_uintersect(
                      $leftSubTerm,
                      $rightSubTerm,
                      function ($v1, $v2) {
                          if (strpos($v1, $v2) === false) {
                              return 0;
                          }
  
                          return -1;
                      }
                  )
              )
              ) {
                  $validation = true;
              }
              break;
  
          case '?':
              if ($rightSubTerm) {
                  $validation = true;
              }
              break;
  
          case '!':
              if (!$rightSubTerm) {
                  $validation = true;
              }
              break;
          }
  
          $this->cache->validation($this->currentSubSpec, $validation);
  
          return $validation;
      }
code: private function validateSubSpec()
      {
          if ('!' != $this->currentSubSpec['operator'] && '?' != $this->currentSubSpec['operator']) { // skip left subTerm on operators ! and ?
              if (false === ($this->currentSubSpec['leftSubTerm'] instanceof CK\MARCspec\ComparisonStringInterface)) {
                  $leftSubTermReference = new self(
                      $this->currentSubSpec['leftSubTerm'],
                      $this->record,
                      $this->cache
                  );
                  if (!$leftSubTerm = $leftSubTermReference->content) { // see 2.3.4 SubSpec validation
                      return $this->cache->validation($this->currentSubSpec, false);
                  }
              } else {
                  // is a CK\MARCspec\ComparisonStringInterface
                  $leftSubTerm[] = $this->currentSubSpec['leftSubTerm']['comparable'];
              }
          }
  
          if (false === ($this->currentSubSpec['rightSubTerm'] instanceof CK\MARCspec\ComparisonStringInterface)) {
              $rightSubTermReference = new self(
                  $this->currentSubSpec['rightSubTerm'],
                  $this->record,
                  $this->cache
              );
              $rightSubTerm = $rightSubTermReference->content; // content maybe an empty array
          } else {
              // is a CK\MARCspec\ComparisonStringInterface
              $rightSubTerm[] = $this->currentSubSpec['rightSubTerm']['comparable'];
          }
          $validation = false;
  
          switch ($this->currentSubSpec['operator']) {
          case '=':
              if (0 < count(array_intersect($leftSubTerm, $rightSubTerm))) {
                  $validation = true;
              }
              break;
  
          case '!=':
              if (0 < count(array_diff($leftSubTerm, $rightSubTerm))) {
                  $validation = true;
              }
              break;
  
          case '~':
              if (0 < count(
                  array_uintersect(
                      $leftSubTerm,
                      $rightSubTerm,
                      function ($v1, $v2) {
                          if (strpos($v1, $v2) !== false) {
                              return 0;
                          }
  
                          return -1;
                      }
                  )
              )
              ) {
                  $validation = true;
              }
              break;
  
          case '!~':
              if (0 < count(
                  array_uintersect(
                      $leftSubTerm,
                      $rightSubTerm,
                      function ($v1, $v2) {
                          if (strpos($v1, $v2) === false) {
                              return 0;
                          }
  
                          return -1;
                      }
                  )
              )
              ) {
                  $validation = true;
              }
              break;
  
          case '?':
              if ($rightSubTerm) {
                  $validation = true;
              }
              break;
  
          case '!':
              if (!$rightSubTerm) {
                  $validation = true;
              }
              break;
          }
  
          $this->cache->validation($this->currentSubSpec, $validation);
  
          return $validation;
      }
code_tokens: private function validateSubSpec ( ) { if ( '!' != $ this -> currentSubSpec [ 'operator' ] && '?' != $ this -> currentSubSpec [ 'operator' ] ) { // skip left subTerm on operators ! and ? if ( false === ( $ this -> currentSubSpec [ 'leftSubTerm' ] instanceof CK \ MARCspec \ ComparisonStringInterface ) ) { $ leftSubTermReference = new self ( $ this -> currentSubSpec [ 'leftSubTerm' ] , $ this -> record , $ this -> cache ) ; if ( ! $ leftSubTerm = $ leftSubTermReference -> content ) { // see 2.3.4 SubSpec validation return $ this -> cache -> validation ( $ this -> currentSubSpec , false ) ; } } else { // is a CK\MARCspec\ComparisonStringInterface $ leftSubTerm [ ] = $ this -> currentSubSpec [ 'leftSubTerm' ] [ 'comparable' ] ; } } if ( false === ( $ this -> currentSubSpec [ 'rightSubTerm' ] instanceof CK \ MARCspec \ ComparisonStringInterface ) ) { $ rightSubTermReference = new self ( $ this -> currentSubSpec [ 'rightSubTerm' ] , $ this -> record , $ this -> cache ) ; $ rightSubTerm = $ rightSubTermReference -> content ; // content maybe an empty array } else { // is a CK\MARCspec\ComparisonStringInterface $ rightSubTerm [ ] = $ this -> currentSubSpec [ 'rightSubTerm' ] [ 'comparable' ] ; } $ validation = false ; switch ( $ this -> currentSubSpec [ 'operator' ] ) { case '=' : if ( 0 < count ( array_intersect ( $ leftSubTerm , $ rightSubTerm ) ) ) { $ validation = true ; } break ; case '!=' : if ( 0 < count ( array_diff ( $ leftSubTerm , $ rightSubTerm ) ) ) { $ validation = true ; } break ; case '~' : if ( 0 < count ( array_uintersect ( $ leftSubTerm , $ rightSubTerm , function ( $ v1 , $ v2 ) { if ( strpos ( $ v1 , $ v2 ) !== false ) { return 0 ; } return - 1 ; } ) ) ) { $ validation = true ; } break ; case '!~' : if ( 0 < count ( array_uintersect ( $ leftSubTerm , $ rightSubTerm , function ( $ v1 , $ v2 ) { if ( strpos ( $ v1 , $ v2 ) === false ) { return 0 ; } return - 1 ; } ) ) ) { $ validation = true ; } break ; case '?' : if ( $ rightSubTerm ) { $ validation = true ; } break ; case '!' : if ( ! $ rightSubTerm ) { $ validation = true ; } break ; } $ this -> cache -> validation ( $ this -> currentSubSpec , $ validation ) ; return $ validation ; }
docstring: Validates a subSpec.
  
  @return bool True if subSpec is valid and false if not
docstring_tokens: Validates a subSpec .