Import Drupal\Component\Serialization\Yaml class
Use Yaml::encode to process read configuration