技術情報
- 2020年12月14日
- 技術情報
Changing github theme to dark mode
According the the recent updates from github, there is some improvements in daily experience like UI appearances, pull requests, discussions & dependency review. There are also other updates as well such as Continuous delivery support and other updates.
But today, I would like to talk about the appearance setting and how to enable the dark mode for your github.
First thing first, go to your profile setting.

Then you will see the new appearance setting as follow.

after click the appearance setting, you will see the available setting to play with.

Number 1 is a theme setting to change your github to Light & Dark mode. There is also Emoji option in number 2 which can change your emoji skin tone color as well.
As a final step, I selected my theme to dark and here it is.

Enjoy Dark theme.
By Yuuma
yuuma at 2020年12月14日 11:00:38
- 2020年12月11日
- 技術情報
[Laravel] Eloquentとページネーション(4)
自力でページネーションの実装をおこなうには、大変工数がかかりますが、Laravelフレームワークが用意しているページネーションを使用することで工数が大幅に軽減されます。
今回はLaravelフレームワークのページネーションのカスタマイズ方法を紹介したいと思います。
本記事は前回の「[Laravel] Eloquentとページネーション(3)」の続きになります。
nishida at 2020年12月11日 10:00:03
- 2020年12月07日
- 技術情報
Polymorphism in PHP
Polymorphism sounds difficult in terms of its vocabulary but it’s not that complex. Today I will write some explanations along with simple code examples. There are two types of polymorphism called dynamic polymorphism and static polymorphism.
Let’s take a look at the dynamic polymorphism first. It can be achieved using interface.
<?php
interface Country
{
public function talk();
}
class Myanmar implements Country
{
public function talk()
{
return "Mingalarpr";
}
}
class Japan implements Country
{
public function talk()
{
return "ko ni chi wa";
}
}
?>
There is an interface called Country and two of the concrete classes called Myanmar and Japan implemented it. The type of two concrete classes, Myanmar & Japan are same as they are the country but the function called talk inside their classes will be different depending on the country.
$myanmar = new Myanmar();
$japan = new Japan();
echo $myanmar->talk(); //output - Mingalarpr
echo $japan->talk(); //output - ko ni chi wa
As I said earlier before their talk function is different. That is called dynamic polymorphism. Concrete classes are sharing the same interface as they are common in type but different in functionalities.
There is one more polymorphism called static polymorphism. This can be achieved using method overloading. We will use __call magic method as we are writing in PHP.
<?php
class Talk
{
function __call($name,$arg){
switch(count($arg)){
case 1 : return $arg[0];
case 2 : return $arg[0] . '&' .$arg[1];
}
}
}
$talk = new Talk();
echo $talk->lang("Myanmar"); //output - Myanmar
echo $talk->lang("Myanmar","Japan"); //output Myanmar & Japan
There are different return depending on the method arguments. The class talk can be adaptable depending on the function arguments which is called static polymorphism.
You can see the magic method __call reference here.
https://www.php.net/manual/en/language.oop5.overloading.php#object.call
Thanks for reading. By Yuuma.
yuuma at 2020年12月07日 11:00:11
- 2020年11月30日
- 技術情報
Dependency Injection in PHP
Dependency injection is the process by which one object provides the dependencies of another object. Dependency injection is a software design approach that avoids hard-coded dependencies and allows you to change dependencies at runtime and compile time.
Lets take a look along with the examples. Lets say we have a Food class that will supply dependency to Dinner Class.
<?php
class Food
{
protected $food;
public function __construct($food)
{
$this->food = $food;
}
public function get()
{
return $this->food;
}
}
After that, lets create a dinner class without dependency injection first.
<?php
class Dinner
{
public function eat()
{
$food = new Food("Chicken soup");
return $food->get();
}
}
$dinner = new Dinner();
echo $dinner->eat(); //output - Chicken soup
In the above style of Dinner class, we have hardcoded food class that is bad in coupling and not well dependency injected. Lets fix our dinner class using dependency injection.
<?php
class Dinner
{
protected $dinner;
//receiving the dependency object food.
public function __construct(Food $food)
{
$this->dinner = $food;
}
public function eat()
{
return $this->dinner->get();
}
}
$food = new Food("Chicken soup");
//supplying the food object.
$dinner = new Dinner($food);
echo $dinner->eat(); //output - Chicken soup
Now, we have added a constructor to be injected the necessary food dependency object. The code is now loosely coupled and not hardcoded in dinner class anymore.
By Yuuma.
yuuma at 2020年11月30日 11:00:23
- 2020年11月27日
- 技術情報
[Laravel] Eloquentとページネーション(3)
自力でページネーションの実装をおこなうには、大変工数がかかりますが、Laravelフレームワークが用意しているページネーションを使用することで工数が大幅に軽減できます。
今回はLaravelフレームワークのページネーションの実装方法を紹介したいと思います。本記事は前回の「[Laravel] Eloquentとページネーション(2)」の続きになります。
nishida at 2020年11月27日 10:00:32