* Licensed under the Apache License v2.0 * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. If you do not know how many parameters we pass to the constructor, we can do it this way. We do not need to interfere in the same class each time when we add another parameter. Suppose that we have a car that does not know how many people will travel and we want to pass to the constructor, each time a different number of people. Are we about contained in the class rules say that it is a new design pattern Special Arguments. Please send your feedback by email <ber34#o2.pl> Jeżeli nie wiemy ile parametrów będziemy przekazywali do konstruktora możemy zrobić to w ten sposób. Nie musimy ingerować w samą klasę za każdym razem kiedy dopisujemy kolejny parametr. Zakładamy że mamy samochód w którym nie wiemy ile osób będzie podróżować, a chcemy przekazać do konstruktora, za każdym razem inną ilość osób. Czy możemy o zawartych w klasie regułach‚ach powiedzieć, że jest to nowy wzorzec projektowy Special Arguments. Prześlijcie wasze opinie na email <ber34#o2.pl> co o tym sądzicie. */
class special_arguments{
public $person = array();
public function __construct(){
if($arg = func_num_args()>0){
$this->person = func_get_args();
} }
public function car(){
return $this->person;
} }
$adam = "1 person";
$ginter = "2 person";
$bodzio = "3 person";
$endriu = "4 person";
$bandzo = "5 person";
$test = new special_arguments($adam, $ginter, $bodzio, $endriu, $bandzo);
$a = $test->car(); foreach($a as $person){ echo $person.""; }

* Licensed under the Apache License v2.0 * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. If you do not know how many parameters we pass to the constructor, we can do it this way. We do not need to interfere in the same class each time when we add another parameter. Suppose that we have a car that does not know how many people will travel and we want to pass to the constructor, each time a different number of people. Are we about contained in the class rules say that it is a new design pattern Special Arguments. Please send your feedback by email <ber34#o2.pl>
class special_arguments{
public $person = array();
public function __construct(){
if($arg = func_num_args()>0){
$this->person = func_get_args();
} }
public function person1(){
return $this->person["a"];
}
public function person2(){
return $this->person["b"];
}
public function person3(){
return $this->person["c"];
}
public function person4(){
return $this->person["d"];
}
public function person5(){
return $this->person["e"];
} }
## Wywołanie w pliku ##
$adam = "1 person";
$ginter = "2 person";
$bodzio = "3 person";
$endriu = "4 person";
$bandzo = "5 person";
## Special Arguments ##
## Możemy dowolnie zmieniać na te metody które chcemy ##
$test = new special_arguments(array("a"=>$adam, "b"=>$ginter, "c"=>$bodzio, "d"=>$endriu, "e"=>$bandzo));
## albo ##
$test = new special_arguments(array( "b"=>$ginter, "d"=>$endriu, "e"=>$bandzo));
## albo ##
$test = new special_arguments(array("a"=>$adam, "e"=>$bandzo)); foreach($test->person[0] as $person){ echo $person."";
}

* Licensed under the Apache License v2.0 * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. If you do not know how many parameters we pass to the constructor, we can do it this way. We do not need to interfere in the same class each time when we add another parameter. Suppose that we have a car that does not know how many people will travel and we want to pass to the constructor, each time a different number of people. Are we about contained in the class rules say that it is a new design pattern Special Arguments. Please send your feedback by email <ber34#o2.pl> */
abstract class person1{
public static function person11(){
return "person 1";
} }
abstract class person2{
public static function person22(){
return "person 2";
} }
abstract class person3{
public static function person33(){
return "person 3";
} }
abstract class person4{
public static function person44(){
return "person 4";
} }
abstract class person5{
public static function person55(){
return "person 5";
} }
class special_arguments{
public $person = array();
public function __construct(){
if($arg = func_num_args()>0){
$this->person = func_get_args();
} }
public function person1(){
return $this->person["a"];
}
public function person2(){
return $this->person["b"];
}
public function person3(){
return $this->person["c"];
}
public function person4(){
return $this->person["d"];
}
public function person5(){
return $this->person["e"];
} }
## Special Arguments ##
## Możemy dowolnie zmieniać na te klasy które chcemy ##
$test = new special_arguments(array("a"=>person1::person11(), "b"=>person2::person22(), "c"=>person3::person33(), "d"=>person4::person44(), "e"=>person5::person55()));
## albo ##
$test = new special_arguments(array( "b"=>person2::person22(), "d"=>person4::person44(), "e"=>person5::person55()));
## albo ##
$test = new special_arguments(array("a"=>person1::person11(), "e"=>person5::person55()));
foreach($test->person[0] as $person){
echo $person."
";
}

<?php /* * @version Special Arguments class * @autor Adam Berger$ * Copyright 2015 Special Arguments * <ber34#o2.pl--> * Licensed under the Apache License v2.0 * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. If you do not know how many parameters we pass to the constructor, we can do it this way. We do not need to interfere in the same class each time when we add another parameter. Suppose that we have a car that does not know how many people will travel and we want to pass to the constructor, each time a different number of people. Are we about contained in the class rules say that it is a new design pattern Special Arguments. Please send your feedback by email <ber34#o2.pl> */
class person11{
public function person11(){
return "person 1";
}
public function person12(){
return "person 1 i 2";
} }
class person22{
public function person22(){
return "person 2";
} }
class person33{
public function person33(){
return "person 3";
} }
class person44{
public function person44(){
return "person 4";
} }
class person55{
public function person55(){
return "person 5";
} }
class special_arguments{
public $person = array();
public function __construct(){
if($arg = func_num_args()>0){
$this->person = func_get_args();
} }
public function person1(){
return $this->person[0]["a"];
} public function person2(){
return $this->person[0]["b"];
}
public function person3(){
return $this->person[0]["c"];
}
public function person4(){
return $this->person[0]["d"];
}
public function person5(){
return $this->person[0]["e"];
} }
## Special Arguments ##
## Możemy dowolnie zmieniać na te klasy które chcemy ##
//$test = new special_arguments(array("a"=>new person11(), "b"=>new person22(), "c"=>new person33(), "d"=>new person44(), "e"=>new person55()));
## albo ##
//$test = new special_arguments(array( "b"=>new person22(), "d"=>new person44(), "e"=>new person55()));
## albo ##
$test = new special_arguments(array("a"=>new person11(), "e"=>new person55()));
echo $test->person1()->person11();
echo "
";
echo $test->person1()->person12();
echo "
";
echo $test->person5()->person55();