Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Data Fields | Protected Member Functions | Protected Attributes
Zend_Validate_File_WordCount Class Reference
Inheritance diagram for Zend_Validate_File_WordCount:
Zend_Validate_File_Count Zend_Validate_Abstract Zend_Validate_Interface

Public Member Functions

 isValid ($value, $file=null)
 
- Public Member Functions inherited from Zend_Validate_File_Count
 __construct ($options)
 
 getMin ()
 
 setMin ($min)
 
 getMax ()
 
 setMax ($max)
 
 addFile ($file)
 
 isValid ($value, $file=null)
 
- Public Member Functions inherited from Zend_Validate_Abstract
 getMessages ()
 
 getMessageVariables ()
 
 getMessageTemplates ()
 
 setMessage ($messageString, $messageKey=null)
 
 setMessages (array $messages)
 
 __get ($property)
 
 getErrors ()
 
 setObscureValue ($flag)
 
 getObscureValue ()
 
 setTranslator ($translator=null)
 
 getTranslator ()
 
 hasTranslator ()
 
 setDisableTranslator ($flag)
 
 translatorIsDisabled ()
 
- Public Member Functions inherited from Zend_Validate_Interface
 isValid ($value)
 

Data Fields

const TOO_MUCH = 'fileWordCountTooMuch'
 
const TOO_LESS = 'fileWordCountTooLess'
 
const NOT_FOUND = 'fileWordCountNotFound'
 
- Data Fields inherited from Zend_Validate_File_Count
const TOO_MANY = 'fileCountTooMany'
 
const TOO_FEW = 'fileCountTooFew'
 

Protected Member Functions

 _throw ($file, $errorType)
 
- Protected Member Functions inherited from Zend_Validate_File_Count
 _throw ($file, $errorType)
 
- Protected Member Functions inherited from Zend_Validate_Abstract
 _createMessage ($messageKey, $value)
 
 _implodeRecursive (array $pieces)
 
 _error ($messageKey, $value=null)
 
 _setValue ($value)
 

Protected Attributes

 $_messageTemplates
 
- Protected Attributes inherited from Zend_Validate_File_Count
 $_messageTemplates
 
 $_messageVariables
 
 $_min
 
 $_max
 
 $_count
 
 $_files
 
- Protected Attributes inherited from Zend_Validate_Abstract
 $_value
 
 $_messageVariables = array()
 
 $_messageTemplates = array()
 
 $_messages = array()
 
 $_obscureValue = false
 
 $_errors = array()
 
 $_translator
 
 $_translatorDisabled = false
 

Additional Inherited Members

- Static Public Member Functions inherited from Zend_Validate_Abstract
static setDefaultTranslator ($translator=null)
 
static getDefaultTranslator ()
 
static hasDefaultTranslator ()
 
static getMessageLength ()
 
static setMessageLength ($length=-1)
 
- Static Protected Attributes inherited from Zend_Validate_Abstract
static $_defaultTranslator
 
static $_messageLength = -1
 

Detailed Description

Definition at line 35 of file WordCount.php.

Member Function Documentation

◆ _throw()

_throw (   $file,
  $errorType 
)
protected

Throws an error of the given type

Parameters
string$file
string$errorType
Returns
false

Definition at line 92 of file WordCount.php.

93  {
94  if ($file !== null) {
95  $this->_value = $file['name'];
96  }
97 
98  $this->_error($errorType);
99  return false;
100  }
_error($messageKey, $value=null)
Definition: Abstract.php:284

◆ isValid()

isValid (   $value,
  $file = null 
)

Defined by Zend_Validate_Interface

Returns true if and only if the counted words are at least min and not bigger than max (when max is not null).

Parameters
string$valueFilename to check for word count
array$fileFile data from Zend_File_Transfer
Returns
boolean

Definition at line 64 of file WordCount.php.

65  {
66  // Is file readable ?
67  #require_once 'Zend/Loader.php';
69  return $this->_throw($file, self::NOT_FOUND);
70  }
71 
73  $this->_count = str_word_count($content);
74  if (($this->_max !== null) && ($this->_count > $this->_max)) {
75  return $this->_throw($file, self::TOO_MUCH);
76  }
77 
78  if (($this->_min !== null) && ($this->_count < $this->_min)) {
79  return $this->_throw($file, self::TOO_LESS);
80  }
81 
82  return true;
83  }
_throw($file, $errorType)
Definition: WordCount.php:92
static isReadable($filename)
Definition: Loader.php:162
$value
Definition: gender.phtml:16

Field Documentation

◆ $_messageTemplates

$_messageTemplates
protected
Initial value:
= array(
self::TOO_MUCH => "Too much words, maximum '%max%' are allowed but '%count%' were counted",
self::TOO_LESS => "Too less words, minimum '%min%' are expected but '%count%' were counted",
self::NOT_FOUND => "File '%value%' is not readable or does not exist",
)

Definition at line 48 of file WordCount.php.

◆ NOT_FOUND

const NOT_FOUND = 'fileWordCountNotFound'

Definition at line 42 of file WordCount.php.

◆ TOO_LESS

const TOO_LESS = 'fileWordCountTooLess'

Definition at line 41 of file WordCount.php.

◆ TOO_MUCH

const TOO_MUCH = 'fileWordCountTooMuch'

#+ @const string Error constants

Definition at line 40 of file WordCount.php.


The documentation for this class was generated from the following file: