@param CharactersAndStaffParser $parser

@return AnimeCharactersAndStaff
@throws \RuntimeException
@throws \InvalidArgumentException
162297
public static function fromParser(CharactersAndStaffParser $parser): self
    {
        $instance = new self();
        $instance->characters = $parser->getCharacters();
        $instance->staff = $parser->getStaff();

        return $instance;
    }
293765
public static function fromParser(PublishedMangaParser $parser): PublishedManga
    {
        $instance = new self();
        $instance->position = $parser->getPosition();
        $instance->mangaMeta = $parser->getMangaMeta();

        return $instance;
    }
307235
public function setParser(ParserInterface $parser)
    {
        $this->parsed = false;
        $this->parser = $parser;
        return $this;
    }
162900
public function getDocJSON(Parser $parser) {
    $myClass = get_called_class();
    $rClass = new \ReflectionClass($myClass);

    $this->configureMiddlewares($this->middlewares);

    $doc = array();
    $doc['name'] = $this->documentationName;
    $doc['description'] = $parser->parse(ReflectionHelper::getDocText($rClass->getDocComment()));

    // Adding documentation for custom controller actions
    $rMethods = $rClass->getMethods(\ReflectionMethod::IS_PUBLIC);
    foreach ($rMethods as $rMethod) {
      // If there is a '@endpoint ignore' property, the function is not served as an endpoint
      if (in_array('ignore', ReflectionHelper::getDocDirective($rMethod->getDocComment(), 'endpoint'))) {
        continue;
      }

      $methodDoc = array();

      $methodDoc['InternalMethodName'] = $rMethod->name;
      if (strpos($rMethod->name, 'get', 0) === 0) {
        $methodDoc['MethodName'] = substr($rMethod->name, 3);
        $methodDoc['HTTPMethod'] = 'GET';
      }
      elseif (strpos($rMethod->name, 'put', 0) === 0) {
        $methodDoc['MethodName'] = substr($rMethod->name, 3);
        $methodDoc['HTTPMethod'] = 'PUT';
      }
      elseif (strpos($rMethod->name, 'post', 0) === 0) {
        $methodDoc['MethodName'] = substr($rMethod->name, 4);
        $methodDoc['HTTPMethod'] = 'POST';
      }
      elseif (strpos($rMethod->name, 'delete', 0) === 0) {
        $methodDoc['MethodName'] = substr($rMethod->name, 6);
        $methodDoc['HTTPMethod'] = 'DELETE';
      }
      else {
        continue;
      }
      $action = strtolower($methodDoc['MethodName']);
      $methodDoc['URI'] = "/{$this->base}" . (empty($action) ? '' : "/{$action}");
      $methodDoc['Synopsis'] = $parser->parse(ReflectionHelper::getDocText($rMethod->getDocComment()));
      $methodDoc['parameters'] = $this->getDocParameters($rMethod);

      if (empty($methodDoc['MethodName'])) {
        $methodDoc['MethodName'] = ucwords($this->base);
      }

      // Allow controller middlewares to modify the documentation for this method
      if (!empty($this->middlewares)) {
        $middleware = reset($this->middlewares);
        $middleware->documentMethod($rClass, $rMethod, $methodDoc);
      }

      if (!empty($methodDoc)) {
        $doc['methods'][] = $methodDoc;
      }
    }

    foreach(ReflectionHelper::getDocDirective($rClass->getDocComment(), 'docs-attach-model') as $includeModelClass) {
      /**
       * @var $model \MABI\Model
       */
      $model = call_user_func($includeModelClass . '::init', $this->getApp());
      $doc['models'][] = $model->getDocOutput($parser);
    }

    return $doc;
  }
534192
public static function fromParser(MangaGenreParser $parser): self
    {
        $instance = new self();
        $instance->itemCount = $parser->getCount();
        $instance->manga = $parser->getGenreManga();
        $instance->malUrl = new MalUrl(
            $parser->getName(),
            $parser->getUrl()
        );

        return $instance;
    }
290062
public static function fromParser(MangaRecentlyUpdatedByUsersListParser $parser): self
    {
        $instance = new self();

        $instance->username = $parser->getUsername();
        $instance->url = $parser->getUrl();
        $instance->imageUrl = $parser->getImageUrl();
        $instance->score = $parser->getScore();
        $instance->status = $parser->getStatus();
        $instance->volumesRead = $parser->getVolumesRead();
        $instance->volumesTotal = $parser->getVolumesTotal();
        $instance->chaptersRead = $parser->getChaptersRead();
        $instance->chaptersTotal = $parser->getChaptersTotal();
        $instance->date = $parser->getDate();

        return $instance;
    }
151912
public static function fromParser(VoiceActingRoleParser $parser): VoiceActingRole
    {
        $instance = new self();
        $instance->role = $parser->getRole();
        $instance->animeMeta = $parser->getAnimeMeta();
        $instance->characterMeta = $parser->getCharacterMeta();

        return $instance;
    }
480774
public function getDocJSON(Parser $parser) {
    $doc = parent::getDocJSON($parser);

    $rClass = new \ReflectionClass(get_called_class());

    foreach($doc['methods'] as $k => $methodDoc) {
      if($methodDoc['InternalMethodName'] == 'get') {
        $doc['methods'][$k]['MethodName'] = 'Get Full Collection';
      }
      elseif($methodDoc['InternalMethodName'] == 'post') {
        $doc['methods'][$k]['MethodName'] = 'Add to Collection';
      }
      elseif($methodDoc['InternalMethodName'] == 'put') {
        $doc['methods'][$k]['MethodName'] = 'Replace Full Collection';
      }
      elseif($methodDoc['InternalMethodName'] == 'delete') {
        $doc['methods'][$k]['MethodName'] = 'Delete Full Collection';
      }
    }

    $methodDoc = $this->getRestMethodDocJSON($parser, 'Get Resource',
      'GET', "/{$this->base}/:id", $rClass, '_restGetResource');
    if (!empty($methodDoc)) {
      $doc['methods'][] = $methodDoc;
    }
    $methodDoc = $this->getRestMethodDocJSON($parser, 'Update Resource',
      'PUT', "/{$this->base}/:id", $rClass, '_restPutResource');
    if (!empty($methodDoc)) {
      $doc['methods'][] = $methodDoc;
    }
    $methodDoc = $this->getRestMethodDocJSON($parser, 'Delete Resource',
      'DELETE', "/{$this->base}/:id", $rClass, '_restDeleteResource');
    if (!empty($methodDoc)) {
      $doc['methods'][] = $methodDoc;
    }

    // Add documentation for custom rest actions
    $rMethods = $rClass->getMethods(\ReflectionMethod::IS_PUBLIC);
    foreach ($rMethods as $rMethod) {
      $docComment = $rMethod->getDocComment();
      // If there is a '@endpoint ignore' property, the function is not served as an endpoint
      if (in_array('ignore', ReflectionHelper::getDocDirective($docComment, 'endpoint'))) {
        continue;
      }

      $methodDoc = array();

      $methodDoc['InternalMethodName'] = $rMethod->name;
      if (strpos($rMethod->name, 'restGet', 0) === 0) {
        $methodDoc['MethodName'] = substr($rMethod->name, 7);
        $methodDoc['HTTPMethod'] = 'GET';
      }
      elseif (strpos($rMethod->name, 'restPut', 0) === 0) {
        $methodDoc['MethodName'] = substr($rMethod->name, 7);
        $methodDoc['HTTPMethod'] = 'PUT';
      }
      elseif (strpos($rMethod->name, 'restPost', 0) === 0) {
        $methodDoc['MethodName'] = substr($rMethod->name, 8);
        $methodDoc['HTTPMethod'] = 'POST';
      }
      elseif (strpos($rMethod->name, 'restDelete', 0) === 0) {
        $methodDoc['MethodName'] = substr($rMethod->name, 10);
        $methodDoc['HTTPMethod'] = 'DELETE';
      }
      else {
        continue;
      }
      $action = strtolower($methodDoc['MethodName']);
      $methodDoc['URI'] = "/{$this->base}/:id/{$action}";
      $methodDoc['Synopsis'] = $parser->parse(ReflectionHelper::getDocText($docComment));
      $methodDoc['parameters'][] = array(
        'Name' => 'id',
        'Required' => 'Y',
        'Type' => 'string',
        'Location' => 'url',
        'Description' => 'The id of the resource'
      );
      $methodDoc['parameters'] = array_merge($methodDoc['parameters'], $this->getDocParameters($rMethod));

      // Allow controller middlewares to modify the documentation for this method
      if (!empty($this->middlewares)) {
        $middleware = reset($this->middlewares);
        $middleware->documentMethod($rClass, $rMethod, $methodDoc);
      }

      if (!empty($methodDoc)) {
        $doc['methods'][] = $methodDoc;
      }
    }

    return $doc;
  }
906601
public static function fromParser(ScheduleParser $parser): self
    {
        $instance = new self();
        $instance->monday = $parser->getShedule('monday');
        $instance->tuesday = $parser->getShedule('tuesday');
        $instance->wednesday = $parser->getShedule('wednesday');
        $instance->thursday = $parser->getShedule('thursday');
        $instance->friday = $parser->getShedule('friday');
        $instance->saturday = $parser->getShedule('saturday');
        $instance->sunday = $parser->getShedule('sunday');
        $instance->other = $parser->getShedule('other');
        $instance->unknown = $parser->getShedule('unknown');

        return $instance;
    }
1202449
public static function fromParser(TopListItemParser $parser): self
    {
        $instance = new self();
        $instance->rank = $parser->getRank();
        $instance->malId = $parser->getMalUrl()->getMalId();
        $instance->title = $parser->getMalUrl()->getTitle();
        $instance->url = $parser->getMalUrl()->getUrl();
        $instance->nameKanji = $parser->getKanjiName();
        $instance->favorites = $parser->getPeopleFavorites();
        $instance->imageUrl = $parser->getImage();
        $instance->birthday = $parser->getBirthday();

        return $instance;
    }
1269721
public function charXML($parser, $data) {
		if(array_key_exists($this->xml_depth, $this->xmlobj)) {
			$this->xmlobj[$this->xml_depth]->data .= $data;
		}
	}
490042
public static function fromParser(CharacterListItemParser $parser): self
    {
        $instance = new self();
        $instance->voiceActors = $parser->getVoiceActors();
        $instance->malId = $parser->getMalId();
        $instance->url = $parser->getCharacterUrl();
        $instance->name = $parser->getName();
        $instance->role = $parser->getRole();
        $instance->imageUrl = $parser->getImage();

        return $instance;
    }
49851
public static function fromParser(StaffListItemParser $parser): self
    {
        $instance = new self();
        $instance->positions = $parser->getPositions();
        $instance->malId = $parser->getMalId();
        $instance->url = $parser->getUrl();
        $instance->name = $parser->getName();
        $instance->imageUrl = $parser->getImage();

        return $instance;
    }
333646
public static function fromParser(UserListParser $parser): self
    {
        $instance = new self();
        $instance->profiles = $parser->getResults();

        return $instance;
    }
228567
public static function fromParser(EpisodesParser $parser): self
    {
        $instance = new self();
        $instance->episodes = $parser->getEpisodes();
        $instance->episodesLastPage = $parser->getEpisodesLastPage();

        return $instance;
    }
64285
public static function fromParser(SeasonalParser $parser): self
    {
        $instance = new self();
        $instance->seasonName = $parser->getSeasonName();
        $instance->seasonYear = $parser->getSeasonYear();
        $instance->anime = $parser->getSeasonalAnime();

        return $instance;
    }
63250
public static function parseSeasonalAnime(Parser\Common\AnimeCardParser $parser): SeasonalAnime
    {
        $instance = new self();
        parent::setProperties($parser, $instance);
        $instance->continuing = $parser->isContinuing();

        return $instance;
    }