Skip to content

Instantly share code, notes, and snippets.

@muratcakmaksoftware
Created March 29, 2022 20:22
Show Gist options
  • Select an option

  • Save muratcakmaksoftware/9f08261568b52ffb4281d2de6707faae to your computer and use it in GitHub Desktop.

Select an option

Save muratcakmaksoftware/9f08261568b52ffb4281d2de6707faae to your computer and use it in GitHub Desktop.
Open Closed Prenciple
<?php
//Open Closed Principle
abstract class Wing
{
public abstract function flap();
}
class Car extends Wing
{
private $name;
private $weight;
function __construct($name)
{
$this->name = $name;
}
/**
* Değişime kapalı
*/
public function getName()
{
return $this->name;
}
public function getWeight()
{
return $this->weight;
}
public function setWeight($weight)
{
$this->weight = $weight;
}
/**
* Gelişime açık
*/
public function flap()
{
echo 'Car flapped its wings';
}
}
class Bird extends Wing
{
private $weight;
/**
* Değişime kapalı
*/
public function getWeight()
{
return $this->weight;
}
/**
* Gelişime açık
*/
public function flap()
{
echo 'Bird flapped its wings';
}
}
$car = new Car('Murat131');
echo $car->flap().'<br/>';
$bird = new Bird();
$bird->flap();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment