‪TYPO3CMS  ‪main
Method.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
21 
26 class ‪Method
27 {
31  private ‪$name;
32 
36  private ‪$definition;
37 
41  private ‪$className;
42 
46  private ‪$parameters = [];
47 
48  public function ‪__construct(string ‪$name, array ‪$definition, string ‪$className)
49  {
50  $this->name = ‪$name;
51  $this->className = ‪$className;
52 
53  $defaults = [
54  'params' => [],
55  'public' => false,
56  'protected' => false,
57  'private' => false,
58  ];
59 
60  foreach ($defaults as $key => $defaultValue) {
61  if (!isset(‪$definition[$key])) {
62  ‪$definition[$key] = $defaultValue;
63  }
64  }
65 
66  $this->definition = ‪$definition;
67 
68  foreach ($this->definition['params'] as $parameterName => $parameterDefinition) {
69  $this->parameters[$parameterName] = new ‪MethodParameter($parameterName, $parameterDefinition);
70  }
71  }
72 
73  public function ‪getName(): string
74  {
75  return ‪$this->name;
76  }
77 
81  public function ‪getParameters(): array
82  {
83  return ‪$this->parameters;
84  }
85 
89  public function ‪getParameter(string $parameterName): ‪MethodParameter
90  {
91  if (!isset($this->parameters[$parameterName])) {
92  throw NoSuchMethodParameterException::createForParameterName(
93  $this->className,
94  $this->name,
95  $parameterName
96  );
97  }
98 
99  return $this->parameters[$parameterName];
100  }
101 
102  public function ‪isPublic(): bool
103  {
104  return $this->definition['public'];
105  }
106 
107  public function ‪isProtected(): bool
108  {
109  return $this->definition['protected'];
110  }
111 
112  public function ‪isPrivate(): bool
113  {
114  return $this->definition['private'];
115  }
116 }
‪TYPO3\CMS\Extbase\Reflection\ClassSchema\Method\isPublic
‪isPublic()
Definition: Method.php:98
‪TYPO3\CMS\Extbase\Reflection\ClassSchema\Exception\NoSuchMethodParameterException
Definition: NoSuchMethodParameterException.php:24
‪TYPO3\CMS\Extbase\Reflection\ClassSchema\Method\isPrivate
‪isPrivate()
Definition: Method.php:108
‪TYPO3\CMS\Extbase\Reflection\ClassSchema\Method\$parameters
‪array $parameters
Definition: Method.php:42
‪TYPO3\CMS\Extbase\Reflection\ClassSchema\Method\getParameter
‪getParameter(string $parameterName)
Definition: Method.php:85
‪TYPO3\CMS\Extbase\Reflection\ClassSchema\Method\$definition
‪array $definition
Definition: Method.php:34
‪TYPO3\CMS\Extbase\Reflection\ClassSchema\Method\getName
‪getName()
Definition: Method.php:69
‪TYPO3\CMS\Extbase\Reflection\ClassSchema\Method\isProtected
‪isProtected()
Definition: Method.php:103
‪TYPO3\CMS\Extbase\Reflection\ClassSchema\MethodParameter
Definition: MethodParameter.php:25
‪TYPO3\CMS\Extbase\Reflection\ClassSchema
‪TYPO3\CMS\Extbase\Reflection\ClassSchema\Method\getParameters
‪array MethodParameter[] getParameters()
Definition: Method.php:77
‪TYPO3\CMS\Extbase\Reflection\ClassSchema\Method\$name
‪string $name
Definition: Method.php:30
‪TYPO3\CMS\Extbase\Reflection\ClassSchema\Method\__construct
‪__construct(string $name, array $definition, string $className)
Definition: Method.php:44
‪TYPO3\CMS\Extbase\Reflection\ClassSchema\Method
Definition: Method.php:27
‪TYPO3\CMS\Extbase\Reflection\ClassSchema\Method\$className
‪string $className
Definition: Method.php:38