Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions
NameFinder Class Reference

Public Member Functions

 getFieldNameFromGetterName ($getterName)
 
 getFieldDescriptionFromGetterDescription ($shortDescription)
 
 getGetterMethodName (ClassReflection $class, $camelCaseProperty)
 
 getSetterMethodName (ClassReflection $class, $camelCaseProperty)
 
 findAccessorMethodName (ClassReflection $class, $camelCaseProperty, $accessorName, $boolAccessorName)
 
 hasMethod (ClassReflection $class, $methodName)
 

Detailed Description

Definition at line 11 of file NameFinder.php.

Member Function Documentation

◆ findAccessorMethodName()

findAccessorMethodName ( ClassReflection  $class,
  $camelCaseProperty,
  $accessorName,
  $boolAccessorName 
)

Find the accessor method name for a property from the given class

Parameters
ClassReflection$class
string$camelCaseProperty
string$accessorName
bool$boolAccessorName
Returns
string processed method name
Exceptions

Definition at line 87 of file NameFinder.php.

92  {
93  if ($this->hasMethod($class, $accessorName)) {
94  $methodName = $accessorName;
95  return $methodName;
96  } elseif ($this->hasMethod($class, $boolAccessorName)) {
97  $methodName = $boolAccessorName;
98  return $methodName;
99  } else {
100  throw new \LogicException(
101  sprintf(
102  'Property "%s" does not have accessor method "%s" in class "%s".',
103  $camelCaseProperty,
104  $accessorName,
105  $class->getName()
106  )
107  );
108  }
109  }
elseif(isset( $params[ 'redirect_parent']))
Definition: iframe.phtml:17
$_option $_optionId $class
Definition: date.phtml:13
hasMethod(ClassReflection $class, $methodName)
Definition: NameFinder.php:120

◆ getFieldDescriptionFromGetterDescription()

getFieldDescriptionFromGetterDescription (   $shortDescription)

Convert Data Object getter short description into field description.

Parameters
string$shortDescription
Returns
string

Definition at line 42 of file NameFinder.php.

43  {
44  return ucfirst(substr(strstr($shortDescription, " "), 1));
45  }

◆ getFieldNameFromGetterName()

getFieldNameFromGetterName (   $getterName)

Convert Data Object getter name into field name.

Parameters
string$getterName
Returns
string

Remove 'get' prefix and make the first letter lower case

Remove 'is' prefix and make the first letter lower case

Remove 'has' prefix and make the first letter lower case

Definition at line 19 of file NameFinder.php.

20  {
21  if ((strpos($getterName, 'get') === 0)) {
23  $fieldName = substr($getterName, strlen('get'));
24  } elseif ((strpos($getterName, 'is') === 0)) {
26  $fieldName = substr($getterName, strlen('is'));
27  } elseif ((strpos($getterName, 'has') === 0)) {
29  $fieldName = substr($getterName, strlen('has'));
30  } else {
31  $fieldName = $getterName;
32  }
33  return lcfirst($fieldName);
34  }
elseif(isset( $params[ 'redirect_parent']))
Definition: iframe.phtml:17

◆ getGetterMethodName()

getGetterMethodName ( ClassReflection  $class,
  $camelCaseProperty 
)

Find the getter method name for a property from the given class

Parameters
ClassReflection$class
string$camelCaseProperty
Returns
string processed method name
Exceptions

Definition at line 55 of file NameFinder.php.

56  {
57  $getterName = 'get' . $camelCaseProperty;
58  $boolGetterName = 'is' . $camelCaseProperty;
59  return $this->findAccessorMethodName($class, $camelCaseProperty, $getterName, $boolGetterName);
60  }
findAccessorMethodName(ClassReflection $class, $camelCaseProperty, $accessorName, $boolAccessorName)
Definition: NameFinder.php:87
$_option $_optionId $class
Definition: date.phtml:13

◆ getSetterMethodName()

getSetterMethodName ( ClassReflection  $class,
  $camelCaseProperty 
)

Find the setter method name for a property from the given class

Parameters
ClassReflection$class
string$camelCaseProperty
Returns
string processed method name
Exceptions

Definition at line 70 of file NameFinder.php.

71  {
72  $setterName = 'set' . $camelCaseProperty;
73  $boolSetterName = 'setIs' . $camelCaseProperty;
74  return $this->findAccessorMethodName($class, $camelCaseProperty, $setterName, $boolSetterName);
75  }
findAccessorMethodName(ClassReflection $class, $camelCaseProperty, $accessorName, $boolAccessorName)
Definition: NameFinder.php:87
$_option $_optionId $class
Definition: date.phtml:13

◆ hasMethod()

hasMethod ( ClassReflection  $class,
  $methodName 
)

Checks if method is defined

Case sensitivity of the method is taken into account.

Parameters
ClassReflection$class
string$methodName
Returns
bool

Definition at line 120 of file NameFinder.php.

121  {
122  return $class->hasMethod($methodName) && ($class->getMethod($methodName)->getName() == $methodName);
123  }
$_option $_optionId $class
Definition: date.phtml:13

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