| Conditions | 4 |
| Paths | 3 |
| Total Lines | 19 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 20 |
| Changes | 0 | ||
| 1 | <?php |
||
| 21 | function renderHtml() |
||
| 22 | { |
||
| 23 | $this->document->setTitle('Switch intranet'); |
||
| 24 | |||
| 25 | if ($this->query('id') and $this->getKernel()->user->hasIntranetAccess($this->query('id'))) { |
||
|
|
|||
| 26 | // @todo make sure a new user is stored in Auth, otherwise |
||
| 27 | // the access to the modules are not correctly maintained. |
||
| 28 | // Right now I just clear permisions when getting the new user |
||
| 29 | // which probably is the most clever solution. |
||
| 30 | if ($this->getKernel()->user->setActiveIntranetId(intval($this->query('id')))) { |
||
| 31 | return new k_SeeOther($this->url('../')); |
||
| 32 | } else { |
||
| 33 | throw new Exception('Could not change intranet'); |
||
| 34 | } |
||
| 35 | } |
||
| 36 | |||
| 37 | $smarty = $this->template->create(dirname(__FILE__) . '/templates/switchintranet'); |
||
| 38 | return $smarty->render($this); |
||
| 39 | } |
||
| 40 | |||
| 57 |
PHP has two types of connecting operators (logical operators, and boolean operators):
and&&or||The difference between these is the order in which they are executed. In most cases, you would want to use a boolean operator like
&&, or||.Let’s take a look at a few examples:
Logical Operators are used for Control-Flow
One case where you explicitly want to use logical operators is for control-flow such as this:
Since
dieintroduces problems of its own, f.e. it makes our code hardly testable, and prevents any kind of more sophisticated error handling; you probably do not want to use this in real-world code. Unfortunately, logical operators cannot be combined withthrowat this point:These limitations lead to logical operators rarely being of use in current PHP code.