PHP Classes

File: docs/ForeachMgr.md

Recommend this page to a friend!
  Classes of Kjell-Inge Gustafsson   PcGen   docs/ForeachMgr.md   Download  
File: docs/ForeachMgr.md
Role: Example script
Content type: text/markdown
Description: 1.1.45
Class: PcGen
Generate PHP code from parameters
Author: By
Last change: 1.1.47
Date: 3 years ago
Size: 2,417 bytes
 

Contents

Class file image Download

[comment]: # (This file is part of PcGen, PHP Code Generation support package. Copyright 2020 Kjell-Inge Gustafsson, kigkonsult, All rights reserved, licence GPL 3.0)

ForeachMgr

The `ForeachMgr` manages control structure foreach

  • Accepts variable, classProperty and class function as array_expression
  • No reference iterValues
  • The foreach logic body is set using ForeachMgr::setBody()
ForeachMgr Methods

Inherited [Common methods]


* ```iterator``` _string_|_EntityMgr_|_FcnInvokeMgr_
* ```key``` _string_
* ```iterValue``` _string_  default 'value'
* Return _static_
* Throws _InvalidArgumentException_

---

  • Return _array_, result code rows (null-bytes removed) no trailing eol
  • Throws _RuntimeException_

* Return _array_, result code rows (null-bytes removed) no trailing eol
* Throws _RuntimeException_

---

  • Return _string_|_EntityMgr_|_FcnInvokeMgr_

* Return _bool_ true if set, false not


  • 
    
  • Return _static_
  • Throws _InvalidArgumentException_


* Return _string_


  • Return _bool_ true if set, false not

* ```key``` _string_
* Return _static_
* Throws _InvalidArgumentException_

---

  • Return _string_

* ```iterValue``` _string_
* Return _static_
* Throws _InvalidArgumentException_

---

#### Example

<?php

$code = FcnFrameMgr::init()

->setName( 'someFunction' )
->addArgument( 'iterator', FcnFrameMgr::ARRAY ) 
->setBody(
    ForeachMgr::factory( 'iterator' )
        ->setBody(
            ' // this is the foreach body'
        )
        ->toArray()
)
->toString();

Result :

public function someFunction( array $iterator )
{
    foreach( $iterator as $value ) {
        // this is the foreach body
    } // end foreach
}

---

<small>Return to [README] - [Summary]</small>

[ClassMgr]:ClassMgr.md
[Common methods]:CommonMethods.md
[DocBlockMgr]:DocBlockMgr.md
[README]:../README.md
[Summary]:Summary.md