Skip to content
Snippets Groups Projects
Select Git revision
  • b2b9facfb5b6b8fb5008f0e985d306f48f5e99f7
  • master default protected
  • feat/npm-publish
  • feat/demo-deploy
  • change-demo-deploy
  • remove-smoke
  • feat/acceptance-tests
  • feature/deploy-composer.json
  • feature/mysql-bin-logs
  • skip-codecept-for-libs
  • include-composer-json
  • exclude-wp-assets
  • update_codecept_image
  • fix/silenced-copy
  • remove-free-translations
  • codeception-with-optional-step
  • improve-parallelization
  • linter-exit
  • change-images
  • fix/linter
  • globally-raise-mem-limit
  • no-symlink2
22 results

codeception.yml

Blame
  • ChainValidator.php 874 B
    <?php
    
    namespace WPDesk\Forms\Validator;
    
    use WPDesk\Forms\Validator;
    
    class ChainValidator implements Validator {
    
    	/** @var Validator[] */
    	private $validators;
    
    	/** @var array */
    	private $messages;
    
    	public function __construct() {
    		$this->validators = [];
    		$this->messages   = [];
    	}
    
    	/**
    	 * @param Validator $validator
    	 *
    	 * @return $this
    	 */
    	public function attach( Validator $validator ): self {
    		$this->validators[] = $validator;
    
    		return $this;
    	}
    
    	public function is_valid( $value ): bool {
    		$result   = true;
    		$messages = [ [] ];
    		foreach ( $this->validators as $validator ) {
    			if ( ! $validator->is_valid( $value ) ) {
    				$result     = false;
    				$messages[] = $validator->get_messages();
    			}
    		}
    		$this->messages = array_merge( ...$messages );
    
    		return $result;
    	}
    
    	public function get_messages(): array {
    		return $this->messages;
    	}
    
    }